[antlr-interest] Advice on effective expr parsing

Ruslan Zasukhin sunshine at public.kherson.ua
Tue Aug 27 15:31:58 PDT 2002


Hi Guys,

Assume I have the following rules in grammar.
It is easy to note that rule row_expr has ambiguity between 1 and 2 branches
on LPAREN expr RPAREN

-----------------------------------------------------------------
expr
    :    primary( (PLUS | MINUS) primary)*
    ;

primary
    :    LPAREN expr RPAREN
    |    unsigned_value_specification
    |    column_reference
    |    set_function_specification
    |    subquery
    |    case_expression
    |    cast_specification
    ;

row_expr
    :    LPAREN row_list_element ( COMMA row_list_element )* RPAREN
    |    row_list_element
    ;

row_list_element
    :    expr
    |    "null"
    |    "default"
    ;
----------------------------------------------------------------------


Yes, using syntax predicate this can be handled as

row_expr
    :    (LPAREN row_list_element COMMA) =>
            LPAREN row_list_element ( COMMA row_list_element )* RPAREN
    |    row_list_element
    ;


But I afraid this is NOT effective way.
Because expr in general case can be VERY LONG and COMPLEX.

So I wonder does exists any "secret" "cool" trick to resolve this problem in
row_expr ?

What is the best way ?

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list
send a letter to valentina-on at lists.macserve.net
-------------------------------------------------------------


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list