From 6013c4c97d2e986148bb1020350e7930c33d9399 Mon Sep 17 00:00:00 2001 From: parrt Date: Sat, 21 Jan 2012 15:10:46 -0800 Subject: [PATCH] Added modeNames to gen'd lexers [git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9878] --- CHANGES.txt | 16 ++++++++++++++++ runtime/Java/src/org/antlr/v4/runtime/Lexer.java | 15 ++------------- .../v4/tool/templates/codegen/Java/Java.stg | 6 ++++++ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8e8edc4bc..bd6938ab0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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. diff --git a/runtime/Java/src/org/antlr/v4/runtime/Lexer.java b/runtime/Java/src/org/antlr/v4/runtime/Lexer.java index 461a0ba96..4a05c51d9 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/Lexer.java +++ b/runtime/Java/src/org/antlr/v4/runtime/Lexer.java @@ -291,19 +291,8 @@ public abstract class Lexer extends Recognizer 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 diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg index 3171b2410..57f6464fd 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg @@ -603,6 +603,9 @@ public class extends Lexer { public static final int =}; separator=", ", wrap, anchor>; = ;}; separator="\n"> + public static String[] modeNames = { + "}; separator=", ", wrap, anchor> + }; public static final String[] tokenNames = { "\", "\", "\", @@ -627,6 +630,9 @@ public class extends Lexer { @Override public String[] getRuleNames() { return ruleNames; } + @Override + public String[] getModeNames() { return modeNames; } + @Override public ATN getATN() { return _ATN; }