From 51313c4773f0af62121b2192ff0cca9560b7ab44 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 17 Jan 2021 19:42:11 -0800 Subject: Adding more language grammars --- grammars/lua.bp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 grammars/lua.bp (limited to 'grammars/lua.bp') diff --git a/grammars/lua.bp b/grammars/lua.bp new file mode 100644 index 0000000..7ffdc73 --- /dev/null +++ b/grammars/lua.bp @@ -0,0 +1,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=*`= `[ ..(`]eqs`]) % \n / ..$) +string: `"..`" % (`\.) / `'..`' % (`\.) / `[ @eqs=*`= `[ .. (`]eqs`]) % \n +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")| .. (|"end"|) % (comment/string/block/\n) +function: function-def .. (|"end"|) % (comment/string/block/\n) -- cgit v1.2.3