2021-01-17 20:05:19 -08:00
|
|
|
# Syntax definitions for some Go-specific patterns
|
|
|
|
#
|
|
|
|
# NOTE: this is *NOT* intended to be a complete definition of the language's
|
|
|
|
# syntax! Providing a full language grammar is overkill, because the intended
|
|
|
|
# use case is finding/replacing string patterns. This task does not require a
|
|
|
|
# full parse tree, and having one makes the task considerably more complicated.
|
|
|
|
# See the accompanying README.md for more info.
|
|
|
|
|
2021-01-20 15:46:21 -08:00
|
|
|
comment: "//" .. $ / "/*" ..%\n "*/"
|
2021-05-19 21:58:54 -07:00
|
|
|
string: `" ..%string-escape `"
|
2021-08-01 12:40:27 -07:00
|
|
|
keyword: ("break" / "default" / "func" / "interface" / "select" / "case" / "defer" / "go" /
|
2021-01-17 20:05:19 -08:00
|
|
|
"map" / "struct" / "chan" / "else" / "goto" / "package" / "switch" / "const" /
|
2021-08-01 12:40:27 -07:00
|
|
|
"fallthrough" / "if" / "range" / "type" / "continue" / "for" / "import" / "return" / "var")
|
2021-07-30 20:23:18 -07:00
|
|
|
function-def: |"func"| __ id __ parens __ [id / parens] >(__`{)
|
2021-01-17 20:05:19 -08:00
|
|
|
function: function-def __ braces
|
2021-07-30 20:23:18 -07:00
|
|
|
import: |"import"| __ (parens / string)
|