1 /* C++ interface test of Parser Exception Handling
7 * the program should respond with
9 * invalid conditional in 'if' statement
10 * found assignment to a
15 #include "PBlackBox.h"
16 typedef ANTLRCommonToken ANTLRToken;
20 ParserBlackBox<DLGLexer, PEHTest, ANTLRToken> p(stdin);
22 p.parser()->rule(&retsignal);
28 Uncommenting this will make ANTLR think you put these handlers at the
32 catch MismatchedToken : <<printf("dflt:MismatchedToken\n");>>
33 default : <<printf("dflt:dflt\n");>>
36 #token "[\ \t]+" <<skip();>>
37 #token "\n" <<skip(); newline();>>
39 #tokclass DIE { "@" "if" ID "else" }
46 stat: "if" t:expr THEN stat { "else" stat }
48 <<printf("found assignment to %s\n", $id->getText());>>
53 printf("invalid conditional in 'if' statement\n");
54 consumeUntilToken(THEN);
57 catch MismatchedToken :
59 catch NoSemViableAlt :
61 printf("stat:caught predefined signal\n");
62 consumeUntil(DIE_set);
65 expr: expr1 ("\+" expr1)*