* added check for v3 backward incompatibilities:

** (...)=> syntactic predicates
This commit is contained in:
Terence Parr 2012-11-18 14:10:28 -08:00
parent c5bf2ba0bd
commit 060343f027
3 changed files with 13 additions and 0 deletions

View File

@ -11,6 +11,7 @@ November 18, 2012
** tokens {A;B;} syntax
** tokens {A='C';} syntax
** {...}?=> gate semantic predicates
** (...)=> syntactic predicates
November 17, 2012

View File

@ -453,6 +453,17 @@ LT : '<' ;
GT : '>' ;
ASSIGN : '=' ;
QUESTION : '?' ;
SYNPRED : '=>'
{
Token t = new CommonToken(input, state.type, state.channel,
state.tokenStartCharIndex, getCharIndex()-1);
t.setLine(state.tokenStartLine);
t.setText(state.text);
t.setCharPositionInLine(state.tokenStartCharPositionInLine);
grammarError(ErrorType.V3_SYNPRED, t);
$channel=HIDDEN;
}
;
STAR : '*' ;
PLUS : '+' ;
PLUS_ASSIGN : '+=' ;

View File

@ -124,6 +124,7 @@ public enum ErrorType {
V3_TOKENS_SYNTAX(202, "'tokens {A; B;}' syntax is now 'tokens {A, B}' in ANTLR v4", ErrorSeverity.WARNING),
V3_ASSIGN_IN_TOKENS(203, "assignments in tokens{} are not supported in ANTLR v4; use lexical rule '<arg> : <arg2>;' instead", ErrorSeverity.ERROR_ONE_OFF),
V3_GATED_SEMPRED(204, "{...}?=> gate semantic predicates in v3 behave like normal predicates in ANTLR v4; use {...}? instead", ErrorSeverity.WARNING_ONE_OFF),
V3_SYNPRED(205, "(...)=> syntactic predicates are not needed or supported ANTLR v4; just delete them", ErrorSeverity.ERROR_ONE_OFF),
// Dependency sorting errors