This project is read-only.
1
Vote

Rule doesn't match

description

I develop a pascal-like language and one of my rule doesn't work.
terminals
    {
        INTEGER      -> [0-9]+
    }
rules
    {
        constant -> INTEGER ;
        subrange -> INTEGER '..' INTEGER ;

        case_statement -> 'CASE' expression 'OF' case_element_list ('ELSE' statement_list)? 'END_CASE';
        case_element_list -> case_element+;
        case_element -> case_list ':' statement_list;
        case_list -> case_list_element (',' case_list_element)* ;
        case_list_element -> constant
                           | subrange ;
so, when I trying to parse the following source with 'subrange' (i.e. where I expected the subrange rule matching) - then I get "Unexpected token ".." error".
CASE qwerty OF
    1: a:=3;
    6: b:=2;
    9,10,11: d := e;
    12..15: f := -g;
ELSE a:=0;
END_CASE;
After lexer I see the sequence [INTEGER] [..] [INTEGER] (for "12..15" part of the input string).
How I can write own rules for successful parse the above source?

comments