Added modeNames to gen'd lexers

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9878]
This commit is contained in:
parrt 2012-01-21 15:10:46 -08:00
parent dc82edad02
commit 6013c4c97d
3 changed files with 24 additions and 13 deletions

View File

@ -1,5 +1,21 @@
ANTLR v4 Honey Badger early access
Jan 21, 2012
* Added modeNames to gen'd lexers
* added lexer commands
skip
more
popMode
mode(x)
pushMode(x)
type(x)
channel(x)
WS : (' '|'\n')+ -> skip ;
use commas to separate commands: "-> skip, mode(FOO)"
Jan 14, 2012
* labels on tokens in left-recursive rules caused codegen exception.

View File

@ -291,19 +291,8 @@ public abstract class Lexer extends Recognizer<Integer, LexerATNSimulator>
this.text = text;
}
public void reportError(RecognitionException e) {
/** TODO: not thought about recovery in lexer yet.
*
// if we've already reported an error and have not matched a token
// yet successfully, don't report any errors.
if ( errorRecovery ) {
//System.err.print("[SPURIOUS] ");
return;
}
errorRecovery = true;
*/
//displayRecognitionError(this.getTokenNames(), e);
public String[] getModeNames() {
return null;
}
/** Used to print out token names like ID during debugging and

View File

@ -603,6 +603,9 @@ public class <lexer.name> extends Lexer {
public static final int
<lexer.tokens:{k | <k>=<lexer.tokens.(k)>}; separator=", ", wrap, anchor>;
<rest(lexer.modes):{m| public static final int <m> = <i>;}; separator="\n">
public static String[] modeNames = {
<lexer.modes:{m| "<m>"}; separator=", ", wrap, anchor>
};
public static final String[] tokenNames = {
"\<INVALID>", "\<INVALID>", "\<INVALID>",
@ -627,6 +630,9 @@ public class <lexer.name> extends Lexer {
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String[] getModeNames() { return modeNames; }
@Override
public ATN getATN() { return _ATN; }