code / bp

Lines4.3K C3.3K Markdown541 YAML273 make110 Shell77 Lua54
(16 lines)
1 # Syntax definitions for some Go-specific patterns
2 #
3 # NOTE: this is *NOT* intended to be a complete definition of the language's
4 # syntax! Providing a full language grammar is overkill, because the intended
5 # use case is finding/replacing string patterns. This task does not require a
6 # full parse tree, and having one makes the task considerably more complicated.
7 # See the accompanying README.md for more info.
9 comment: "//" .. $ / "/*" ..%\n "*/"
10 string: `" ..%string-escape `"
11 keyword: ("break" / "default" / "func" / "interface" / "select" / "case" / "defer" / "go" /
12 "map" / "struct" / "chan" / "else" / "goto" / "package" / "switch" / "const" /
13 "fallthrough" / "if" / "range" / "type" / "continue" / "for" / "import" / "return" / "var")
14 function-def: |"func"| __ id __ parens __ [id / parens] >(__`{)
15 function: function-def __ braces
16 import: |"import"| __ (parens / string)