2021-01-17 20:13:34 -08:00
|
|
|
# Syntax definition for some Shell-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.
|
|
|
|
|
|
|
|
comment: `#..$
|
2021-05-19 21:58:54 -07:00
|
|
|
string: `" ..%(string-escape / subcommand / \n) `" / `' ..%\n `' / "<<" _ @delim=id _$ ..%\n (^delim$)
|
|
|
|
string-escape: `\ `",`
|
|
|
|
subcommand: `` ..%\n `` / "$" (parens/braces)
|
2021-08-01 12:40:27 -07:00
|
|
|
keyword: ("echo" / "read" / "set" / "unset" / "readonly" / "shift" / "export" / "if" / "fi" /
|
2021-01-17 20:13:34 -08:00
|
|
|
"else" / "while" / "do" / "done" / "for" / "until" / "case" / "esac" / "break" /
|
2021-08-01 12:40:27 -07:00
|
|
|
"continue" / "exit" / "return" / "trap" / "wait" / "eval" / "exec" / "ulimit" / "umask")
|
2021-01-17 20:13:34 -08:00
|
|
|
function-def: ^_ ["function"_] id _ `(_`) >(__`{)
|
|
|
|
function: function-def __ braces
|
|
|
|
var: `$ (id / braces)
|