I have the Java source code for Parser and Lexer of ANTLR 3 in .java file and want to see the actual grammar behind with all rules and etc.
Is it even possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not by some automated tool (AFAIK). But the generated source file(s) contain the parser and lexer rules of the original grammar in its comments, so you can reverse engineer them yourself reasonable easy.
For example, take this dummy grammar:
If you generate a lexer and parser from it, the parser would look like this:
and the lexer like this:
As you can see, all the grammar rules are there inside comments in the .java source files.