Reputation: 179
In javacc, how to check weather the input file is successfully passed the grammar or not? As an example, say I want to print "Filed parsed successfully" if the whole file is successfully parsed by the parser, and if not I want to print "File parsing faild!"
I'm pretty newbie to javacc. So please help
Upvotes: 0
Views: 95
Reputation: 16241
try {
parser.start() ;
System.out.println("File parsed successfully.") ;
} catch( ParseException ex ) {
// Syntax error
System.out.println( ex.getMessage() ) ; }
} catch( TokenManagerError ex ) {
// Lexical error
System.out.println( ex.getMessage() ) ; }
} catch( Throwable ex ) {
// Some other error
System.out.println( ex.getMessage() ) ; }
Upvotes: 1