mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-10 10:32:23 +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 = {
|
local G = {
|
||||||
V"Start", -- Entry rule
|
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
|
-- Grammar
|
||||||
Filter = V"OrExpression";
|
Filter = V"OrExpression";
|
||||||
@ -466,6 +466,14 @@ function compiler.compile_line(line, state)
|
|||||||
error(error_msg)
|
error(error_msg)
|
||||||
end
|
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, {})
|
local macros = get_macros(ast.value, {})
|
||||||
for m, _ in pairs(macros) do
|
for m, _ in pairs(macros) do
|
||||||
if state.macros[m] == nil then
|
if state.macros[m] == nil then
|
||||||
|
@ -24,7 +24,8 @@ function bad
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Filters
|
# Filters
|
||||||
good "a"
|
good " "
|
||||||
|
good " a"
|
||||||
good "a and b"
|
good "a and b"
|
||||||
good "(a)"
|
good "(a)"
|
||||||
good "(a and b)"
|
good "(a and b)"
|
||||||
|
Loading…
Reference in New Issue
Block a user