require "treetop/runtime" require "logstash/compiler/lscl.rb" grammar LogStashCompilerLSCLGrammar rule config (cs plugin_section)* cs end rule comment (whitespace? "#" [^\r\n]* "\r"? "\n")+ end rule cs (comment / whitespace)* end rule whitespace [ \t\r\n]+ end rule plugin_section plugin_type cs "{" cs (branch_or_plugin cs)* "}" end rule branch_or_plugin branch / plugin end rule plugin_type ("input" / "filter" / "output") end rule plugins (plugin (cs plugin)*)? end rule plugin name cs "{" cs attributes:( attribute (whitespace cs attribute)*)? cs "}" end rule name ( ([A-Za-z0-9_-]+ ) / string ) end rule attribute name cs "=>" cs value end rule value plugin / bareword / string / number / array / hash end rule array_value bareword / string / number / array / hash end rule bareword [A-Za-z_] [A-Za-z0-9_]+ end rule double_quoted_string ( '"' ( '\"' / !'"' . )* '"' ) end rule single_quoted_string ( "'" ( "\\'" / !"'" . )* "'" ) end rule string double_quoted_string / single_quoted_string end rule regexp ( '/' ( '\/' / !'/' . )* '/' ) end rule number "-"? [0-9]+ ("." [0-9]*)? end rule array "[" cs ( value (cs "," cs value)* )? cs "]" end rule hash "{" cs hashentries? cs "}" end rule hashentries hashentry (whitespace hashentry)* end rule hashentry name:(number / bareword / string) cs "=>" cs value end # Conditions rule branch if (cs else_if)* (cs else)? end rule if "if" cs condition cs "{" cs (branch_or_plugin cs)* "}" end rule else_if "else" cs "if" cs condition cs "{" cs ( branch_or_plugin cs)* "}" end rule else "else" cs "{" cs (branch_or_plugin cs)* "}" end rule condition expression (cs boolean_operator cs expression)* end rule expression ( ("(" cs condition cs ")") / negative_expression / in_expression / not_in_expression / compare_expression / regexp_expression / rvalue ) end rule negative_expression ( ("!" cs "(" cs condition cs ")") / ("!" cs selector) ) end rule in_expression rvalue cs in_operator cs rvalue end rule not_in_expression rvalue cs not_in_operator cs rvalue end rule in_operator "in" end rule not_in_operator "not " cs "in" end rule rvalue string / number / selector / array / method_call / regexp end rule method_call method cs "(" cs ( rvalue ( cs "," cs rvalue )* )? cs ")" end rule method bareword end rule compare_expression rvalue cs compare_operator cs rvalue end rule compare_operator ("==" / "!=" / "<=" / ">=" / "<" / ">") end rule regexp_expression rvalue cs regexp_operator cs (string / regexp) end rule regexp_operator ("=~" / "!~") end rule boolean_operator ("and" / "or" / "xor" / "nand") end rule selector selector_element+ end rule selector_element "[" [^\]\[,]+ "]" end end