From 6f35cf231ba92d415a1a9ef4c41b8e8f6e2f7df4 Mon Sep 17 00:00:00 2001 From: ericvergnaud Date: Sat, 4 Oct 2014 11:28:36 +0800 Subject: [PATCH] improve debuggability of generated recognizer --- .../v4/tool/templates/codegen/Java/Java.stg | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) 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 be780c3d8..502384e4f 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 @@ -266,7 +266,8 @@ public class extends { public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { switch (ruleIndex) { : return _sempred(()_localctx, predIndex);}; separator="\n"> +case : + return _sempred(()_localctx, predIndex);}; separator="\n"> } return true; } @@ -323,8 +324,10 @@ dumpActions(recog, argFuncs, actionFuncs, sempredFuncs) ::= << @Override public void action(RuleContext _localctx, int ruleIndex, int actionIndex) { switch (ruleIndex) { - : _action(()_localctx, actionIndex); break;}; separator="\n"> + : + _action(()_localctx, actionIndex); + break;}; separator="\n"> } } @@ -334,7 +337,8 @@ case : _action(()_localctx, actionIndex); break; public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { switch (ruleIndex) { : return _sempred(()_localctx, predIndex);}; separator="\n"> +case : + return _sempred(()_localctx, predIndex);}; separator="\n"> } return true; } @@ -356,7 +360,9 @@ RuleActionFunction(r, actions) ::= << private void _action( _localctx, int actionIndex) { switch (actionIndex) { : break;}; separator="\n"> +case : + + break;}; separator="\n"> } } >> @@ -368,7 +374,8 @@ RuleSempredFunction(r, actions) ::= << private boolean _sempred( _localctx, int predIndex) { switch (predIndex) { : return ;}; separator="\n"> +case : + return ;}; separator="\n"> } return true; } @@ -621,11 +628,13 @@ cases(ttypes) ::= << >> InvokeRule(r, argExprsChunks) ::= << -setState(); = }>(,); +setState(); + = }>(,); >> MatchToken(m) ::= << -setState(); = }>match(); +setState(); + = }>match(); >> MatchSet(m, expr, capture) ::= ""