java - Determining whether string complies with ANTLR4 grammar -


How can I test a string against my grammar to see if it is valid (i.e., an error Is not found, and there is no error) recovery is necessary)?

I also tried, but I still get the message

Line 1: 2 token recognition error: 'x' / p> < P> On the console so I have a way to ensure that the results of all errors are exceptions, or there is a way to validate the input that does not rely on exceptions.

Edit: what you are seeing is a laser error, the parser is not the error of your laser Due to the failure to match an input letter by adding the following as the last rule, you must update Lexer unenforceable to make sure. This will give the parser (reporting, recovery, etc.) to handle wrong characters.

  ERR_CHAR:. ;   

In addition to this, you need to perform the general steps below that apply to configuring parser for simple string recognition.


You two things to work properly for this:

First of all, disable the default error reporting mechanism.

  parser.removeErrorListeners ();   

Second, disable the default error recovery mechanism.

  parser.setErrorStrategy (new bullserver ());   

If you do not match the string, you will not get any more reporting.

If you are not using the output from a pars operation, you may want to improve the efficiency of the recognition process by disabling the creation of a purse tree.

  parser.setBuildParseTree (wrong);    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -