# 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: `"..%string-escape `" / `' ..%string-escape `' / `[ @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: \b"function"\b[_id (*(`.id)[`:id])]_ parens block: function / if-block / while-block / for-block / repeat-block / do-block repeat-block: \b"repeat"\b ..%(comment/string/\n) (\b"until"\b) do-block: \b"do"\b ..%(comment/string/block/\n) (\b"end"\b) for-block: \b"for"\b ..%\n >(\b"do"\b) do-block while-block: \b"while"\b ..%\n >(\b"do"\b) do-block if-block: \b"if"\b ..%\n \b"then"\b ..%(comment/string/\n) (\b"end"\b) function: function-def ..%(comment/string/block/\n) (\b"end"\b)