Skip to content

Commit 8390816

Browse files
authored
Merge pull request #229 from Gompyn/patch-1
fix go grammar
2 parents 8afb425 + 4d375ce commit 8390816

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

syncode/parsers/grammars/go.lark

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ slice_type: "[" "]" element_type
165165
// It's possible to replace `type` with more restricted type_lit list and also pay attention to nil maps
166166
map_type: "map" "[" type_ "]" element_type
167167

168-
channel_type: ("'chan" | "chan" "<-" | "<-" "chan" ) element_type
168+
channel_type: ("chan" | "chan" "<-" | "<-" "chan" ) element_type
169169

170170
method_spec: NAME parameters result | NAME parameters
171171

@@ -214,7 +214,7 @@ HEX_LIT.2: /0x[\da-f]*/i
214214
OCTAL_LIT.2: /0o[0-7]*/i
215215
BINARY_LIT.2 : /0b[0-1]*/i
216216
FLOAT_LIT.2: /((\d+\.\d*|\.\d+)(e[-+]?\d+)?|\d+(e[-+]?\d+))/i
217-
CHAR_LIT: /'.'/i
217+
CHAR_LIT: /'/ (/[^'\\]/ | ESCAPED_VALUE) /'/
218218

219219
composite_lit: literal_type literal_value
220220

@@ -239,8 +239,10 @@ string_: RAW_STRING_LIT | INTERPRETED_STRING_LIT
239239
// RAW_STRING_LIT : '`' ~'`'* '`' -> mode(NLSEMI);
240240
// INTERPRETED_STRING_LIT : '"' (~["\\] | ESCAPED_VALUE)* '"' -> mode(NLSEMI);
241241

242-
RAW_STRING_LIT: /`.*?`/
243-
INTERPRETED_STRING_LIT: /".*?"/i
242+
RAW_STRING_LIT: /`.*?`/s
243+
INTERPRETED_STRING_LIT: /"/ (/[^"\\]/ | ESCAPED_VALUE)* /"/
244+
245+
ESCAPED_VALUE: /\\(u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|[abfnrtv\\'"]|[0-7]{3}|x[0-9a-fA-F]{2})/
244246

245247
embedded_field: "*"? (NAME "." NAME | NAME) type_args?
246248

@@ -259,7 +261,7 @@ arguments: "(" ( expression_list? "..."? ","?)? ")"
259261
eos: ";" | EOS // | {this.closingBracket()}?
260262

261263
NAME : /[a-zA-Z_]\w*/
262-
EOS: _NL | ";" | "/*' .*? '*/"
264+
EOS: _NL | ";" | /\/\*.*?\*\//s
263265

264266
COMMENT : /\/\/[^\n]*/
265267
_NL: ( /(\r?\n[\t ]*)+/ | COMMENT)+

0 commit comments

Comments
 (0)