mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-31 22:16:49 +00:00
compiler: don't fail on empty lines
This commit is contained in:
parent
7853260f38
commit
05362e2c68
@ -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
|
||||
|
@ -24,7 +24,8 @@ function bad
|
||||
}
|
||||
|
||||
# Filters
|
||||
good "a"
|
||||
good " "
|
||||
good " a"
|
||||
good "a and b"
|
||||
good "(a)"
|
||||
good "(a and b)"
|
||||
|
Loading…
Reference in New Issue
Block a user