From 70e3e5de70bbcd46fe41e17ad161cc5362a62842 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sun, 9 Sep 2018 11:55:13 +0300 Subject: [PATCH] ElementFrequenciesVisitor: override stringRef(TerminalAST ref) for correct processing of arrays of string literals --- .../v4/codegen/model/ElementFrequenciesVisitor.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tool/src/org/antlr/v4/codegen/model/ElementFrequenciesVisitor.java b/tool/src/org/antlr/v4/codegen/model/ElementFrequenciesVisitor.java index ccd5c805f..ef1aae2d4 100644 --- a/tool/src/org/antlr/v4/codegen/model/ElementFrequenciesVisitor.java +++ b/tool/src/org/antlr/v4/codegen/model/ElementFrequenciesVisitor.java @@ -149,6 +149,16 @@ public class ElementFrequenciesVisitor extends GrammarTreeVisitor { minFrequencies.peek().add(ref.getText()); } + @Override + public void stringRef(TerminalAST ref) { + String tokenName = ref.g.getTokenName(ref.getText()); + + if (tokenName != null && !tokenName.startsWith("T__")) { + frequencies.peek().add(tokenName); + minFrequencies.peek().add(tokenName); + } + } + /* * Parser rules */