trying a refactoring to test if i can push back

This commit is contained in:
parrt 2016-11-07 10:55:48 -08:00
parent 1c3a5879e6
commit 51d38110be
2 changed files with 13 additions and 7 deletions

View File

@ -71,7 +71,9 @@ import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STGroup;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
/** This receives events from SourceGenTriggers.g and asks factory to do work.
@ -361,6 +363,15 @@ public class OutputModelController {
return ops;
}
public Map<String, Action> buildNamedActions(Grammar g) {
Map<String, Action> namedActions = new HashMap<String, Action>();
for (String name : g.namedActions.keySet()) {
ActionAST ast = g.namedActions.get(name);
namedActions.put(name, new Action(delegate, ast));
}
return namedActions;
}
public Grammar getGrammar() { return delegate.getGrammar(); }
public CodeGenerator getGenerator() { return delegate.getGenerator(); }

View File

@ -30,13 +30,12 @@
package org.antlr.v4.codegen.model;
import org.antlr.v4.codegen.OutputModelController;
import org.antlr.v4.codegen.OutputModelFactory;
import org.antlr.v4.codegen.model.chunk.ActionChunk;
import org.antlr.v4.codegen.model.chunk.ActionText;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.ast.ActionAST;
import java.util.HashMap;
import java.util.Map;
/** */
@ -52,11 +51,7 @@ public class ParserFile extends OutputFile {
public ParserFile(OutputModelFactory factory, String fileName) {
super(factory, fileName);
Grammar g = factory.getGrammar();
namedActions = new HashMap<String, Action>();
for (String name : g.namedActions.keySet()) {
ActionAST ast = g.namedActions.get(name);
namedActions.put(name, new Action(factory, ast));
}
namedActions = factory.getController().buildNamedActions(g);
genPackage = g.tool.genPackage;
// need the below members in the ST for Python, C++
genListener = g.tool.gen_listener;