Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing %whitespace directive definition should be an error ? #39

Open
mingodad opened this issue Jun 18, 2023 · 0 comments
Open

Missing %whitespace directive definition should be an error ? #39

mingodad opened this issue Jun 18, 2023 · 0 comments

Comments

@mingodad
Copy link
Contributor

While testing the https://meimporta.eu/lalr-playground/ I introduced a grammar for https://github.com/jplevyak/dparser but forgot to add a %whitespace directive but lalr didn't flagged that as an error.

Maybe this can fix it:

int GrammarParser::parse( const char* start, const char* finish, ErrorPolicy* error_policy, Grammar* grammar )
{
    LALR_ASSERT( start );
    LALR_ASSERT( finish );
    LALR_ASSERT( grammar );
    error_policy_ = error_policy;
    grammar_ = grammar;
    position_ = start;
    end_ = finish;
    line_ = 1;
    errors_ = 0;
    if ( !match_grammar() )
    {
        error( 1, LALR_ERROR_SYNTAX, "parsing grammar failed" );
    }
    if( grammar_->whitespace_tokens().empty() )
    {
        error( 1, PARSER_ERROR_UNDEFINED_SYMBOL, "no '%%whitespace' directive defined" );
    }
    return errors_;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant