blob: e8c9ba8b31cc7a3588e3358ca17f84b4011f0393 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# Syntax definitions for some Lua-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: "--" (`[ @eqs=*`= `[ ..%\n (`]eqs`]) / ..$)
string: `"..%(`\.) `" / `' ..%(`\.) `' / `[ @eqs=*`= `[ ..%\n (`]eqs`])
table: `{ ..%(table/string/comment/\n) `}
keyword: |(
"and" / "break" / "do" / "else" / "elseif" / "end" / "false" / "for" /
"function" / "goto" / "if" / "in" / "local" / "nil" / "not" / "or" /
"repeat" / "return" / "then" / "true" / "until" / "while"
)|
function-def: |"function"|[_id (*(`.id)[`:id])]_ parens
block: function / |("do"/"then")| ..%(comment/string/block/\n) (|"end"|)
function: function-def ..%(comment/string/block/\n) (|"end"|)
|