From d62ea1df24dd1d313c41a2feedc79dba4b3890c7 Mon Sep 17 00:00:00 2001 From: Henri DF Date: Wed, 24 Feb 2016 15:47:19 -0800 Subject: [PATCH] Support for comments in rules files --- userspace/digwatch/lua/compiler.lua | 4 +++- userspace/digwatch/lua/smoke.sh | 2 ++ userspace/digwatch/lua/test.lua | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/userspace/digwatch/lua/compiler.lua b/userspace/digwatch/lua/compiler.lua index f804cba3..043660fd 100644 --- a/userspace/digwatch/lua/compiler.lua +++ b/userspace/digwatch/lua/compiler.lua @@ -177,9 +177,11 @@ end local G = { V"Start", -- Entry rule - Start = V"Skip" * (V"MacroDef" / macro + V"Rule" / rule)^-1 * -1 + report_error(); + Start = V"Skip" * (V"Comment" + V"MacroDef" / macro + V"Rule" / rule)^-1 * -1 + report_error(); -- Grammar + Comment = P"#" * P(1)^0; + Rule = V"Filter" / filter * ((V"Skip" * V"Pipe" * V"Skip" * (P(1)^0 / outputformat) )^-1 ); Filter = V"OrExpression"; diff --git a/userspace/digwatch/lua/smoke.sh b/userspace/digwatch/lua/smoke.sh index 216b8097..d4db4885 100755 --- a/userspace/digwatch/lua/smoke.sh +++ b/userspace/digwatch/lua/smoke.sh @@ -27,6 +27,8 @@ function bad good " " good " a" good "a and b" +good "#a and b; a and b" +good "#a and b; # ; ; a and b" good "(a)" good "(a and b)" good "(a.a exists and b)" diff --git a/userspace/digwatch/lua/test.lua b/userspace/digwatch/lua/test.lua index 03a716c9..b36a699d 100644 --- a/userspace/digwatch/lua/test.lua +++ b/userspace/digwatch/lua/test.lua @@ -21,7 +21,7 @@ for str in string.gmatch(arg[1], "([^;]+)") do doit(str) end -if not (ast) then +if (ast and ast.type) then compiler.parser.print_ast(ast) end