Hi All,
I am tyring to do SQL parsing using Pest Grammar Files.
I converted the below Teradata Antlr grammar file to rust and I get the left recursive error
section [204 to 229 ] of ANTLR code. from the above file having issue.
expr
: literal_value
| column_name
| unary_operator expr
| expr '||' expr
| expr ( '' | '/' | '%' ) expr
| expr ( '+' | '-' ) expr
| expr ( '<' | '<=' | '>' | '>=' ) expr
| expr ( '=' | '==' | '!=' | '<>' | K_IS | K_IS K_NOT | K_IN | K_LIKE ) expr
| expr K_AND expr
| expr K_OR expr
| function_name '(' ( K_DISTINCT? expr ( ',' expr ) | '' )? ')'
| '(' expr ')'
| K_CAST '(' expr K_AS type_name ')'
| expr K_NOT? K_LIKE expr ( K_ESCAPE expr )?
| expr ( K_IS K_NULL | K_IS K_NOT K_NULL | K_NOT K_NULL )
| expr K_IS K_NOT? expr
| expr K_NOT? K_BETWEEN expr K_AND expr
| expr K_NOT? K_IN ( OPEN_PAR ( select_expr
| expr ( ',' expr )
)?
CLOSE_PAR
| ( database_name '.' )? table_name )
/*| ( ( K_NOT )? K_EXISTS )? '(' select_stmt ')' */
| K_CASE expr? ( K_WHEN expr K_THEN expr )+ ( K_ELSE expr )? K_END
;
I think above scenario is similar to below code.
expr1 = {ASCII_DIGIT
|expr1~("+"|"-")~expr1
}
If I try to parse the statement 2+2+3 then grammar parser only 2 and not the rest. So how can we resolve this.
I am newbie to grammar parsing. Thanks for your help in advance.
Thanks,
Vignesh