cenotelie / hime

Apache License 2.0
27 stars 4 forks source link

Compiler fails to report error on the use of terminals that cannot be produced by the lexer #19

Closed woutersl closed 10 years ago

woutersl commented 10 years ago

Original report by Laurent Wouters (Bitbucket: 557058:675792b6-d731-4823-9f7d-c6dfcb2df2b5, ).


When a terminal is always superceded by one with a higher priority, but is still used in a syntactic rule, the grammar is ill-formed because the terminal will never be produced by the lexer. However, the compiler fails to report this error.

woutersl commented 10 years ago

Original comment by Laurent Wouters (Bitbucket: 557058:675792b6-d731-4823-9f7d-c6dfcb2df2b5, ).


Verified on grammar:

grammar Test
{
    options
    {
        Axiom = "block";
        Separator = "SEPARATOR";
    }
    terminals
    {
        INTEGER -> [1-9] [0-9]* | '0' ;
        IDENTIFIER -> [_a-zA-Z] [_a-zA-Z0-9]* ;
        ASSIGN -> ':=' ;
        WHITE_SPACE -> U+0020 | U+0009 | U+000B | U+000C ;
        SEPARATOR   -> WHITE_SPACE+;
    }
    rules
    {
        block -> statement1 | statement2 ;
        statement1  -> IDENTIFIER ASSIGN INTEGER ;
        statement2  -> IDENTIFIER ':='   INTEGER ;
    }
}
woutersl commented 10 years ago

Original comment by Laurent Wouters (Bitbucket: 557058:675792b6-d731-4823-9f7d-c6dfcb2df2b5, ).


[fix] Fixed issue #19 by adding some additional diagnostics

woutersl commented 10 years ago

Original comment by Laurent Wouters (Bitbucket: 557058:675792b6-d731-4823-9f7d-c6dfcb2df2b5, ).


[fix] Fixed issue #19 by adding some additional diagnostics