ANTLR4 Grammar for different fileds #4179
Unanswered
techpranav
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Below are my sample statements for which I am writing grammar.
`item_select: KW_SELECT_ (field_name)+ ;
field_name: sub_field (DOT sub_field)*;
sub_field: any_string (any_string)? ;
any_string: ANY_STRING | keyword;
=========================
lexer rules
ANY_STRING:
DOUBLE_QUOTED_STRING
| BACKTICK_QUOTED_STRING
| SINGLE_QUOTED_STRING
| SQUARE_BRACKET_ENCLOSED_STRING
| SINGLE_WORD
;
SQUARE_BRACKET_ENCLOSED_STRING : '[' ~']'* ']' ;
SINGLE_QUOTED_STRING : SINGLE_QUOTE (EscapeSequence | ~['\])* SINGLE_QUOTE ;
BACKTICK_QUOTED_STRING : BACKTICK (EscapeSequence | ~[`\])* BACKTICK ;
BACKTICK : '`' ;
DOUBLE_QUOTED_STRING : DOUBLE_QUOTE (EscapeSequence | ~["\])* DOUBLE_QUOTE ;
BACKSLASH : '\' ;
SINGLE_WORD: [A-Za-z0-9:.!@#$%^&*_=+\/-]+;
`
Below statements are parsed successfully with given grammar rules but, I am expecting "property[Symboli].*" this as a single field.
But, in parser tree - its parsed as different fields.
It shows 3 different fields.
select property.*; select property[].*; select property.name; select property[Symboli].*; select property[Symboli].name; select property[Symboli].property[]; select property[Symboli].property[].*; select property[Symboli].property.* name type; select property[Symboli].property.* name type columns; select property[Symboli].property.* name type columns[].*; select property[Symboli].property.* name type columns[].name; select property[Symboli].property.* name type columns[].property; select property[Symboli].property.* name type columns[Test].property; select property[Symboli].property.* name type columns[*].*; select property[Symboli].property.* name type columns[*].*; select "property[Symboli].property.*" name type columns[*].*; select 'property[Symboli].property.*' name type columns[*].*; select 'property[Symboli].property.*' name 'type' 'columns[*].*'; select 'property[Symboli].property.*' name 'type' 'columns[Test column].*'; select 'property[Symboli].property.*' name 'type' columns[Test column].*; select *;
Beta Was this translation helpful? Give feedback.
All reactions