diff --git a/userspace/digwatch/lua/compiler.lua b/userspace/digwatch/lua/compiler.lua index 1923a347..16df628f 100644 --- a/userspace/digwatch/lua/compiler.lua +++ b/userspace/digwatch/lua/compiler.lua @@ -166,7 +166,7 @@ end local G = { V"Start", -- Entry rule - Start = V"Skip" * (V"MacroDef" / macro + V"Filter" / filter) * -1 + report_error(); + Start = V"Skip" * (V"MacroDef" / macro + V"Filter" / filter)^-1 * -1 + report_error(); -- Grammar Filter = V"OrExpression"; @@ -466,6 +466,14 @@ function compiler.compile_line(line, state) error(error_msg) end + if (type(ast) == "number") then + -- hack: we get a number (# of matched chars) V"Skip" back if this line + -- only contained whitespace. (According to docs 'v"Skip" / 0' in Start + -- rule should not capture anything but it doesn't seem to work that + -- way...) + return {} + end + local macros = get_macros(ast.value, {}) for m, _ in pairs(macros) do if state.macros[m] == nil then diff --git a/userspace/digwatch/lua/parser-smoke.sh b/userspace/digwatch/lua/parser-smoke.sh index d6dc1833..e2fa1162 100755 --- a/userspace/digwatch/lua/parser-smoke.sh +++ b/userspace/digwatch/lua/parser-smoke.sh @@ -24,7 +24,8 @@ function bad } # Filters -good "a" +good " " +good " a" good "a and b" good "(a)" good "(a and b)"