github.com/phobos182/packer@v0.2.3-0.20130819023704-c84d2aeffc68/website/source/javascripts/lang-go.js (about) 1 // Copyright (C) 2010 Google Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 16 17 /** 18 * @fileoverview 19 * Registers a language handler for the Go language.. 20 * <p> 21 * Based on the lexical grammar at 22 * http://golang.org/doc/go_spec.html#Lexical_elements 23 * <p> 24 * Go uses a minimal style for highlighting so the below does not distinguish 25 * strings, keywords, literals, etc. by design. 26 * From a discussion with the Go designers: 27 * <pre> 28 * On Thursday, July 22, 2010, Mike Samuel <...> wrote: 29 * > On Thu, Jul 22, 2010, Rob 'Commander' Pike <...> wrote: 30 * >> Personally, I would vote for the subdued style godoc presents at http://golang.org 31 * >> 32 * >> Not as fancy as some like, but a case can be made it's the official style. 33 * >> If people want more colors, I wouldn't fight too hard, in the interest of 34 * >> encouragement through familiarity, but even then I would ask to shy away 35 * >> from technicolor starbursts. 36 * > 37 * > Like http://golang.org/pkg/go/scanner/ where comments are blue and all 38 * > other content is black? I can do that. 39 * </pre> 40 * 41 * @author mikesamuel@gmail.com 42 */ 43 44 PR['registerLangHandler']( 45 PR['createSimpleLexer']( 46 [ 47 // Whitespace is made up of spaces, tabs and newline characters. 48 [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 49 // Not escaped as a string. See note on minimalism above. 50 [PR['PR_PLAIN'], /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])+(?:\'|$)|`[^`]*(?:`|$))/, null, '"\''] 51 ], 52 [ 53 // Block comments are delimited by /* and */. 54 // Single-line comments begin with // and extend to the end of a line. 55 [PR['PR_COMMENT'], /^(?:\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/], 56 [PR['PR_PLAIN'], /^(?:[^\/\"\'`]|\/(?![\/\*]))+/i] 57 ]), 58 ['go']);