# PEG grammar for pattern matching and extracting module Fear::Extractor grammar Grammar rule matcher identified_matcher / anonymous_matcher end rule identified_matcher identifier space '@' space anonymous_matcher end rule anonymous_matcher array / literal / identifier / extractor / type end rule array '[' (non_empty_array / array_splat / empty_array) ']' end rule empty_array '' end rule non_empty_array array_head (array_tail / empty_array) end rule array_tail ',' (non_empty_array / array_splat) end rule array_splat space? (named_array_splat / anonymous_array_splat) space? end rule array_splat_identifier space? anonymous_array_splat space? end rule anonymous_array_splat '*' '_'? end rule named_array_splat '*' [a-z] [a-z0-9_]* end rule array_head space? anonymous_matcher space? end rule space [\s]+ end rule any '_' end rule variable_identifier [a-z_] [a-z0-9_]* end rule identifier typed_identifier / any / variable_identifier end rule typed_identifier (any / variable_identifier) ' : ' type end rule literal nil / true / false / number / string / symbol end rule number float / integer end rule integer ('+' / '-')? [0-9]+ end rule float ('+' / '-')? [0-9]+ '.' [0-9]+ end rule symbol ':' (string / any / variable_identifier) end rule string double_quoted_string / single_quoted_string end rule double_quoted_string '"' ([^"\\] / '\\' . )* '"' end rule single_quoted_string "'" ([^'\\] / '\\' . )* "'" end rule true 'true' end rule false 'false' end rule nil 'nil' end rule extractor type '(' non_empty_array? ')' end rule type constant ('::' constant)* end rule constant [A-Z] [a-zA-Z0-9_]* end end end