]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/go.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / go.js
1 /*! `go` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Go
7 Author: Stephan Kountso aka StepLg <steplg@gmail.com>
8 Contributors: Evgeny Stepanischev <imbolk@gmail.com>
9 Description: Google go language (golang). For info about language
10 Website: http://golang.org/
11 Category: common, system
12 */
13
14 function go(hljs) {
15 const LITERALS = [
16 "true",
17 "false",
18 "iota",
19 "nil"
20 ];
21 const BUILT_INS = [
22 "append",
23 "cap",
24 "close",
25 "complex",
26 "copy",
27 "imag",
28 "len",
29 "make",
30 "new",
31 "panic",
32 "print",
33 "println",
34 "real",
35 "recover",
36 "delete"
37 ];
38 const TYPES = [
39 "bool",
40 "byte",
41 "complex64",
42 "complex128",
43 "error",
44 "float32",
45 "float64",
46 "int8",
47 "int16",
48 "int32",
49 "int64",
50 "string",
51 "uint8",
52 "uint16",
53 "uint32",
54 "uint64",
55 "int",
56 "uint",
57 "uintptr",
58 "rune"
59 ];
60 const KWS = [
61 "break",
62 "case",
63 "chan",
64 "const",
65 "continue",
66 "default",
67 "defer",
68 "else",
69 "fallthrough",
70 "for",
71 "func",
72 "go",
73 "goto",
74 "if",
75 "import",
76 "interface",
77 "map",
78 "package",
79 "range",
80 "return",
81 "select",
82 "struct",
83 "switch",
84 "type",
85 "var",
86 ];
87 const KEYWORDS = {
88 keyword: KWS,
89 type: TYPES,
90 literal: LITERALS,
91 built_in: BUILT_INS
92 };
93 return {
94 name: 'Go',
95 aliases: [ 'golang' ],
96 keywords: KEYWORDS,
97 illegal: '</',
98 contains: [
99 hljs.C_LINE_COMMENT_MODE,
100 hljs.C_BLOCK_COMMENT_MODE,
101 {
102 className: 'string',
103 variants: [
104 hljs.QUOTE_STRING_MODE,
105 hljs.APOS_STRING_MODE,
106 {
107 begin: '`',
108 end: '`'
109 }
110 ]
111 },
112 {
113 className: 'number',
114 variants: [
115 {
116 match: /-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/, // hex without a present digit before . (making a digit afterwards required)
117 relevance: 0
118 },
119 {
120 match: /-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/, // hex with a present digit before . (making a digit afterwards optional)
121 relevance: 0
122 },
123 {
124 match: /-?\b0[oO](_?[0-7])*i?/, // leading 0o octal
125 relevance: 0
126 },
127 {
128 match: /-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/, // decimal without a present digit before . (making a digit afterwards required)
129 relevance: 0
130 },
131 {
132 match: /-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/, // decimal with a present digit before . (making a digit afterwards optional)
133 relevance: 0
134 }
135 ]
136 },
137 { begin: /:=/ // relevance booster
138 },
139 {
140 className: 'function',
141 beginKeywords: 'func',
142 end: '\\s*(\\{|$)',
143 excludeEnd: true,
144 contains: [
145 hljs.TITLE_MODE,
146 {
147 className: 'params',
148 begin: /\(/,
149 end: /\)/,
150 endsParent: true,
151 keywords: KEYWORDS,
152 illegal: /["']/
153 }
154 ]
155 }
156 ]
157 };
158 }
159
160 return go;
161
162 })();
163 ;
164 export default hljsGrammar;