aboutsummaryrefslogtreecommitdiff
path: root/grammars/lua.bp
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-17 19:42:11 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-17 19:42:11 -0800
commit51313c4773f0af62121b2192ff0cca9560b7ab44 (patch)
tree5873f54aafe2cd537e286a88b368ba0315d3e15d /grammars/lua.bp
parent23f9b7ade9eccc6aee2e6c2a6737630a9d0cc77d (diff)
Adding more language grammars
Diffstat (limited to 'grammars/lua.bp')
-rw-r--r--grammars/lua.bp19
1 files changed, 19 insertions, 0 deletions
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)