v4: Fix NPE when creating Action elements within an extension

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9354]
This commit is contained in:
sharwell 2011-11-17 18:24:44 -08:00
parent 24b354e0a5
commit 08d47088b4
1 changed files with 6 additions and 1 deletions

View File

@ -35,6 +35,7 @@ import org.antlr.v4.codegen.model.actions.ActionChunk;
import org.antlr.v4.tool.ast.ActionAST; import org.antlr.v4.tool.ast.ActionAST;
import org.antlr.v4.tool.ast.GrammarAST; import org.antlr.v4.tool.ast.GrammarAST;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** */ /** */
@ -44,7 +45,11 @@ public class Action extends RuleElement {
public Action(OutputModelFactory factory, GrammarAST ast) { public Action(OutputModelFactory factory, GrammarAST ast) {
super(factory,ast); super(factory,ast);
RuleFunction rf = factory.getCurrentRuleFunction(); RuleFunction rf = factory.getCurrentRuleFunction();
if (ast != null) {
chunks = ActionTranslator.translateAction(factory, rf, ast.token, (ActionAST)ast); chunks = ActionTranslator.translateAction(factory, rf, ast.token, (ActionAST)ast);
} else {
chunks = new ArrayList<ActionChunk>();
}
//System.out.println("actions="+chunks); //System.out.println("actions="+chunks);
} }
} }