mirror of
https://github.com/cwbaker/lalr.git
synced 2026-09-26 16:33:18 +03:00
Test that parsers with missing lexical action handlers generate errors
This commit is contained in:
parent
d8948dd936
commit
77602f9052
1 changed files with 28 additions and 0 deletions
|
|
@ -1255,4 +1255,32 @@ SUITE( Parsers )
|
|||
CHECK( parser.accepted() );
|
||||
CHECK( parser.full() );
|
||||
}
|
||||
|
||||
TEST( MissingLexicalActionHandler )
|
||||
{
|
||||
const char* line_comment_grammar =
|
||||
"MissingLexicalActionHandler {\n"
|
||||
" %whitespace \"([ \\t\\r\\n]|\\/\\/:line_comment:)*\";\n"
|
||||
" unit: '1';\n"
|
||||
"}"
|
||||
;
|
||||
|
||||
GrammarCompiler compiler;
|
||||
compiler.compile( line_comment_grammar, line_comment_grammar + strlen(line_comment_grammar) );
|
||||
Parser<const char*> parser( compiler.parser_state_machine() );
|
||||
CHECK( !parser.valid() );
|
||||
|
||||
const char* input = "1";
|
||||
parser.parse( input, input + strlen(input) );
|
||||
CHECK( !parser.accepted() );
|
||||
CHECK( !parser.full() );
|
||||
|
||||
parser.lexer_action_handlers()
|
||||
( "line_comment", &line_comment<const char*> )
|
||||
;
|
||||
|
||||
parser.parse( input, input + strlen(input) );
|
||||
CHECK( parser.accepted() );
|
||||
CHECK( parser.full() );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue