this comes from antlr. here is what the antlr4 (xtext uses antlr 3) javadoc says
Indicates that the parser could not decide which of two or more paths to take based upon the remaining input. It tracks the starting token of the offending input and also knows where the parser was in the various paths when the error.
My validation code for this error:
public class MyDsl1SyntaxErrorMessageProvider extends
SyntaxErrorMessageProvider {
@Override
public SyntaxErrorMessage getSyntaxErrorMessage(IParserErrorContext context) {
if (context.getRecognitionException() != null
&& context.getRecognitionException().token != null) {
//for no viable alternative at input 'datatype' error if (context.getRecognitionException() instanceof NoViableAltException ){
return new SyntaxErrorMessage("?????you must enter string??????? ", null);
}
}
return super.getSyntaxErrorMessage(context);
}
Defined rule my grammar :
Model: (datatype += DataType)*
&(type += Type)*
DataType returns DataType:
'datatype' name=ID
;
Test1 DSL output :
datatype 3 // if I enter a integer value ,I receive "no viable alternative at input '3'" default error (I changed it own message)
datatype String
datatype int
Test2 DSL output: this In this scenario ,call datatype 6 but I do not an error hence I receive error only datatype 3 .I do not understand why ?
datatype 3 // if I enter a integer value ,I receive "no viable alternative at input '3'" default error (I changed it own message)
datatype 6 //I must receive same error ("you must enter string")this section but ı only receive error first line
guess you have to look into the IParserErrorContext to see where you are
as said before in the other topic: your question and needs are very specific so
you may have to digg yourself (e.g. using debugger)
to find a solution since it is not a general problem.