check if there is any errors in lexer and parser java antlr4

390 views
Skip to first unread message

yasser BELHIMER

unread,
Jun 22, 2020, 5:51:16 PM6/22/20
to antlr-discussion
i am writing a grammar using antlr4 and i need to check if there is any errors in the lexer and parser,but i can't find an example of java code doing this. here is my grammar and my java code .



Federico Tomassetti

unread,
Jun 23, 2020, 1:36:35 AM6/23/20
to antlr-di...@googlegroups.com
Hi Yasser,
To check programmatically for errors you may want to remove the default error handler from both the lexer and the parser and add your own. For example, you can add error handler that saves the errors into a list and then check if the list is empty

Cheers,
Federico

--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/antlr-discussion/d0982628-3db8-42dc-9835-2730f95aba1ao%40googlegroups.com.


--

yasser BELHIMER

unread,
Jun 23, 2020, 4:39:14 AM6/23/20
to antlr-discussion
yes i was looking for an example how to do it .but now i did it thanks .
Reply all
Reply to author
Forward
0 new messages