From 371bcc83b2d8f71c157c42d7909812dbc304808b Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 23 Feb 2013 16:51:26 -0600 Subject: [PATCH] Use accessor methods for CodeGenerator.templates and CodeGenerator.target --- .../analysis/LeftRecursiveRuleAnalyzer.java | 2 +- .../antlr/v4/automata/LexerATNFactory.java | 2 +- .../antlr/v4/codegen/ActionTranslator.java | 4 +- .../org/antlr/v4/codegen/CodeGenPipeline.java | 4 +- .../org/antlr/v4/codegen/CodeGenerator.java | 44 +++++++++++-------- .../v4/codegen/OutputModelController.java | 6 +-- .../org/antlr/v4/codegen/ParserFactory.java | 14 +++--- tool/src/org/antlr/v4/codegen/Target.java | 20 ++++----- .../org/antlr/v4/codegen/model/Choice.java | 2 +- .../antlr/v4/codegen/model/InvokeRule.java | 6 +-- .../antlr/v4/codegen/model/LL1PlusBlock.java | 6 +-- .../antlr/v4/codegen/model/LL1StarBlock.java | 4 +- .../model/LeftRecursiveRuleFunction.java | 2 +- .../src/org/antlr/v4/codegen/model/Lexer.java | 4 +- .../antlr/v4/codegen/model/MatchToken.java | 2 +- .../org/antlr/v4/codegen/model/Parser.java | 4 +- .../antlr/v4/codegen/model/RuleFunction.java | 2 +- .../org/antlr/v4/codegen/model/SemPred.java | 4 +- .../antlr/v4/codegen/model/SerializedATN.java | 2 +- .../org/antlr/v4/codegen/model/StarBlock.java | 2 +- .../antlr/v4/codegen/model/TestSetInline.java | 2 +- .../model/decl/AltLabelStructDecl.java | 2 +- .../v4/codegen/model/decl/StructDecl.java | 2 +- .../v4/tool/BuildDependencyGenerator.java | 6 +-- 24 files changed, 78 insertions(+), 70 deletions(-) diff --git a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java index 4aca84d16..9f6b5f226 100644 --- a/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java +++ b/tool/src/org/antlr/v4/analysis/LeftRecursiveRuleAnalyzer.java @@ -106,7 +106,7 @@ public class LeftRecursiveRuleAnalyzer extends LeftRecursiveRuleWalker { // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); - codegenTemplates = gen.templates; + codegenTemplates = gen.getTemplates(); } @Override diff --git a/tool/src/org/antlr/v4/automata/LexerATNFactory.java b/tool/src/org/antlr/v4/automata/LexerATNFactory.java index 5fb4fed8a..8b0fdff58 100644 --- a/tool/src/org/antlr/v4/automata/LexerATNFactory.java +++ b/tool/src/org/antlr/v4/automata/LexerATNFactory.java @@ -66,7 +66,7 @@ public class LexerATNFactory extends ParserATNFactory { // use codegen to get correct language templates for lexer commands String language = g.getOptionString("language"); CodeGenerator gen = new CodeGenerator(g.tool, null, language); - codegenTemplates = gen.templates; + codegenTemplates = gen.getTemplates(); } @Override diff --git a/tool/src/org/antlr/v4/codegen/ActionTranslator.java b/tool/src/org/antlr/v4/codegen/ActionTranslator.java index 95c8d0b5f..4e374607c 100644 --- a/tool/src/org/antlr/v4/codegen/ActionTranslator.java +++ b/tool/src/org/antlr/v4/codegen/ActionTranslator.java @@ -316,12 +316,12 @@ public class ActionTranslator implements ActionSplitterListener { public String getTokenLabel(String x) { if ( node.resolver.resolvesToLabel(x, node) ) return x; - return factory.getGenerator().target.getImplicitTokenLabel(x); + return factory.getGenerator().getTarget().getImplicitTokenLabel(x); } public String getRuleLabel(String x) { if ( node.resolver.resolvesToLabel(x, node) ) return x; - return factory.getGenerator().target.getImplicitRuleLabel(x); + return factory.getGenerator().getTarget().getImplicitRuleLabel(x); } } diff --git a/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java b/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java index 3082d1d25..d54e7fb9a 100644 --- a/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java +++ b/tool/src/org/antlr/v4/codegen/CodeGenPipeline.java @@ -56,14 +56,14 @@ public class CodeGenPipeline { idTypes.add(ANTLRParser.TOKEN_REF); List idNodes = g.ast.getNodesWithType(idTypes); for (GrammarAST idNode : idNodes) { - if ( gen.target.grammarSymbolCausesIssueInGeneratedCode(idNode) ) { + if ( gen.getTarget().grammarSymbolCausesIssueInGeneratedCode(idNode) ) { g.tool.errMgr.grammarError(ErrorType.USE_OF_BAD_WORD, g.fileName, idNode.getToken(), idNode.getText()); } } - if ( gen.templates==null ) return; + if ( gen.getTemplates()==null ) return; if ( g.isLexer() ) { ST lexer = gen.generateLexer(); diff --git a/tool/src/org/antlr/v4/codegen/CodeGenerator.java b/tool/src/org/antlr/v4/codegen/CodeGenerator.java index d9ea20c7f..1fa33874c 100644 --- a/tool/src/org/antlr/v4/codegen/CodeGenerator.java +++ b/tool/src/org/antlr/v4/codegen/CodeGenerator.java @@ -67,8 +67,8 @@ public class CodeGenerator { @NotNull public final Tool tool; - public Target target; - public STGroup templates; + private Target target; + private STGroup templates; public int lineWidth = 72; @@ -83,6 +83,14 @@ public class CodeGenerator { loadTemplates(language); } + public Target getTarget() { + return target; + } + + public STGroup getTemplates() { + return templates; + } + void loadLanguageTarget(String language) { String targetName = "org.antlr.v4.codegen."+language+"Target"; try { @@ -161,7 +169,7 @@ public class CodeGenerator { } private ST walk(OutputModelObject outputModel) { - OutputModelWalker walker = new OutputModelWalker(tool, templates); + OutputModelWalker walker = new OutputModelWalker(tool, getTemplates()); return walker.walk(outputModel); } @@ -205,33 +213,33 @@ public class CodeGenerator { } public void writeRecognizer(ST outputFileST) { - target.genFile(g, outputFileST, getRecognizerFileName()); + getTarget().genFile(g, outputFileST, getRecognizerFileName()); } public void writeListener(ST outputFileST) { - target.genFile(g,outputFileST, getListenerFileName()); + getTarget().genFile(g,outputFileST, getListenerFileName()); } public void writeBaseListener(ST outputFileST) { - target.genFile(g,outputFileST, getBaseListenerFileName()); + getTarget().genFile(g,outputFileST, getBaseListenerFileName()); } public void writeVisitor(ST outputFileST) { - target.genFile(g,outputFileST, getVisitorFileName()); + getTarget().genFile(g,outputFileST, getVisitorFileName()); } public void writeBaseVisitor(ST outputFileST) { - target.genFile(g,outputFileST, getBaseVisitorFileName()); + getTarget().genFile(g,outputFileST, getBaseVisitorFileName()); } public void writeHeaderFile() { String fileName = getHeaderFileName(); if ( fileName==null ) return; - if ( templates.isDefined("headerFile") ) { - ST extST = templates.getInstanceOf("headerFileExtension"); + if ( getTemplates().isDefined("headerFile") ) { + ST extST = getTemplates().getInstanceOf("headerFileExtension"); ST headerFileST = null; // TODO: don't hide this header file generation here! - target.genRecognizerHeaderFile(g,headerFileST,extST.render(lineWidth)); + getTarget().genRecognizerHeaderFile(g,headerFileST,extST.render(lineWidth)); } } @@ -241,7 +249,7 @@ public class CodeGenerator { ST tokenVocabSerialization = getTokenVocabOutput(); String fileName = getVocabFileName(); if ( fileName!=null ) { - target.genFile(g, tokenVocabSerialization, fileName); + getTarget().genFile(g, tokenVocabSerialization, fileName); } } @@ -266,7 +274,7 @@ public class CodeGenerator { * just use T.java as output regardless of type. */ public String getRecognizerFileName() { - ST extST = templates.getInstanceOf("codeFileExtension"); + ST extST = getTemplates().getInstanceOf("codeFileExtension"); String recognizerName = g.getRecognizerName(); return recognizerName+extST.render(); } @@ -276,7 +284,7 @@ public class CodeGenerator { */ public String getListenerFileName() { assert g.name != null; - ST extST = templates.getInstanceOf("codeFileExtension"); + ST extST = getTemplates().getInstanceOf("codeFileExtension"); String listenerName = g.name + "Listener"; return listenerName+extST.render(); } @@ -286,7 +294,7 @@ public class CodeGenerator { */ public String getVisitorFileName() { assert g.name != null; - ST extST = templates.getInstanceOf("codeFileExtension"); + ST extST = getTemplates().getInstanceOf("codeFileExtension"); String listenerName = g.name + "Visitor"; return listenerName+extST.render(); } @@ -296,7 +304,7 @@ public class CodeGenerator { */ public String getBaseListenerFileName() { assert g.name != null; - ST extST = templates.getInstanceOf("codeFileExtension"); + ST extST = getTemplates().getInstanceOf("codeFileExtension"); String listenerName = g.name + "BaseListener"; return listenerName+extST.render(); } @@ -306,7 +314,7 @@ public class CodeGenerator { */ public String getBaseVisitorFileName() { assert g.name != null; - ST extST = templates.getInstanceOf("codeFileExtension"); + ST extST = getTemplates().getInstanceOf("codeFileExtension"); String listenerName = g.name + "BaseVisitor"; return listenerName+extST.render(); } @@ -319,7 +327,7 @@ public class CodeGenerator { } public String getHeaderFileName() { - ST extST = templates.getInstanceOf("headerFileExtension"); + ST extST = getTemplates().getInstanceOf("headerFileExtension"); if ( extST==null ) return null; String recognizerName = g.getRecognizerName(); return recognizerName+extST.render(); diff --git a/tool/src/org/antlr/v4/codegen/OutputModelController.java b/tool/src/org/antlr/v4/codegen/OutputModelController.java index f26998ccd..d1274abd2 100644 --- a/tool/src/org/antlr/v4/codegen/OutputModelController.java +++ b/tool/src/org/antlr/v4/codegen/OutputModelController.java @@ -213,7 +213,7 @@ public class OutputModelController { // now inject code to start alts CodeGenerator gen = delegate.getGenerator(); - STGroup codegenTemplates = gen.templates; + STGroup codegenTemplates = gen.getTemplates(); // pick out alt(s) for primaries CodeBlockForOuterMostAlt outerAlt = (CodeBlockForOuterMostAlt)function.code.get(0); @@ -300,7 +300,7 @@ public class OutputModelController { e.printStackTrace(System.err); } - function.ctxType = gen.target.getRuleFunctionContextStructName(function); + function.ctxType = gen.getTarget().getRuleFunctionContextStructName(function); function.postamble = rulePostamble(function, r); } @@ -312,7 +312,7 @@ public class OutputModelController { CodeGenerator gen = delegate.getGenerator(); Grammar g = delegate.getGrammar(); - String ctxType = gen.target.getRuleFunctionContextStructName(r); + String ctxType = gen.getTarget().getRuleFunctionContextStructName(r); RuleActionFunction raf = lexer.actionFuncs.get(r); if ( raf==null ) { raf = new RuleActionFunction(delegate, r, ctxType); diff --git a/tool/src/org/antlr/v4/codegen/ParserFactory.java b/tool/src/org/antlr/v4/codegen/ParserFactory.java index 79b153d92..cdbb1edd4 100644 --- a/tool/src/org/antlr/v4/codegen/ParserFactory.java +++ b/tool/src/org/antlr/v4/codegen/ParserFactory.java @@ -171,7 +171,7 @@ public class ParserFactory extends DefaultOutputModelFactory { } public TokenListDecl getTokenListLabelDecl(String label) { - return new TokenListDecl(this, gen.target.getListLabel(label)); + return new TokenListDecl(this, gen.getTarget().getListLabel(label)); } @Override @@ -230,7 +230,7 @@ public class ParserFactory extends DefaultOutputModelFactory { c.label = d; getCurrentRuleFunction().addContextDecl(labelAST.getAltLabel(), d); if ( labelAST.parent.getType() == ANTLRParser.PLUS_ASSIGN ) { - String listLabel = gen.target.getListLabel(label); + String listLabel = gen.getTarget().getListLabel(label); TokenListDecl l = new TokenListDecl(this, listLabel); getCurrentRuleFunction().addContextDecl(labelAST.getAltLabel(), l); } @@ -331,20 +331,20 @@ public class ParserFactory extends DefaultOutputModelFactory { Decl d; if ( ast.getType()==ANTLRParser.SET || ast.getType()==ANTLRParser.WILDCARD ) { String implLabel = - gen.target.getImplicitSetLabel(String.valueOf(ast.token.getTokenIndex())); + gen.getTarget().getImplicitSetLabel(String.valueOf(ast.token.getTokenIndex())); d = getTokenLabelDecl(implLabel); ((TokenDecl)d).isImplicit = true; } else if ( ast.getType()==ANTLRParser.RULE_REF ) { // a rule reference? Rule r = g.getRule(ast.getText()); - String implLabel = gen.target.getImplicitRuleLabel(ast.getText()); + String implLabel = gen.getTarget().getImplicitRuleLabel(ast.getText()); String ctxName = - gen.target.getRuleFunctionContextStructName(r); + gen.getTarget().getRuleFunctionContextStructName(r); d = new RuleContextDecl(this, implLabel, ctxName); ((RuleContextDecl)d).isImplicit = true; } else { - String implLabel = gen.target.getImplicitTokenLabel(ast.getText()); + String implLabel = gen.getTarget().getImplicitTokenLabel(ast.getText()); d = getTokenLabelDecl(implLabel); ((TokenDecl)d).isImplicit = true; } @@ -356,7 +356,7 @@ public class ParserFactory extends DefaultOutputModelFactory { public AddToLabelList getAddToListOpIfListLabelPresent(LabeledOp op, GrammarAST label) { AddToLabelList labelOp = null; if ( label!=null && label.parent.getType()==ANTLRParser.PLUS_ASSIGN ) { - String listLabel = gen.target.getListLabel(label.getText()); + String listLabel = gen.getTarget().getListLabel(label.getText()); labelOp = new AddToLabelList(this, listLabel, op.getLabels().get(0)); } return labelOp; diff --git a/tool/src/org/antlr/v4/codegen/Target.java b/tool/src/org/antlr/v4/codegen/Target.java index 619e49b80..718f46f46 100644 --- a/tool/src/org/antlr/v4/codegen/Target.java +++ b/tool/src/org/antlr/v4/codegen/Target.java @@ -350,20 +350,20 @@ public class Target { } public String getListLabel(String label) { - ST st = gen.templates.getInstanceOf("ListLabelName"); + ST st = gen.getTemplates().getInstanceOf("ListLabelName"); st.add("label", label); return st.render(); } public String getRuleFunctionContextStructName(Rule r) { if ( r.g.isLexer() ) { - return gen.templates.getInstanceOf("LexerRuleContext").render(); + return gen.getTemplates().getInstanceOf("LexerRuleContext").render(); } - return Utils.capitalize(r.name)+gen.templates.getInstanceOf("RuleContextNameSuffix").render(); + return Utils.capitalize(r.name)+gen.getTemplates().getInstanceOf("RuleContextNameSuffix").render(); } public String getAltLabelContextStructName(String label) { - return Utils.capitalize(label)+gen.templates.getInstanceOf("RuleContextNameSuffix").render(); + return Utils.capitalize(label)+gen.getTemplates().getInstanceOf("RuleContextNameSuffix").render(); } /** If we know which actual function, we can provide the actual ctx type. @@ -374,15 +374,15 @@ public class Target { public String getRuleFunctionContextStructName(RuleFunction function) { Rule r = function.rule; if ( r.g.isLexer() ) { - return gen.templates.getInstanceOf("LexerRuleContext").render(); + return gen.getTemplates().getInstanceOf("LexerRuleContext").render(); } - return Utils.capitalize(r.name)+gen.templates.getInstanceOf("RuleContextNameSuffix").render(); + return Utils.capitalize(r.name)+gen.getTemplates().getInstanceOf("RuleContextNameSuffix").render(); } // should be same for all refs to same token like ctx.ID within single rule function // for literals like 'while', we gen _s public String getImplicitTokenLabel(String tokenName) { - ST st = gen.templates.getInstanceOf("ImplicitTokenLabel"); + ST st = gen.getTemplates().getInstanceOf("ImplicitTokenLabel"); int ttype = gen.g.getTokenType(tokenName); if ( tokenName.startsWith("'") ) { return "s"+ttype; @@ -394,19 +394,19 @@ public class Target { // x=(A|B) public String getImplicitSetLabel(String id) { - ST st = gen.templates.getInstanceOf("ImplicitSetLabel"); + ST st = gen.getTemplates().getInstanceOf("ImplicitSetLabel"); st.add("id", id); return st.render(); } public String getImplicitRuleLabel(String ruleName) { - ST st = gen.templates.getInstanceOf("ImplicitRuleLabel"); + ST st = gen.getTemplates().getInstanceOf("ImplicitRuleLabel"); st.add("ruleName", ruleName); return st.render(); } public String getElementListName(String name) { - ST st = gen.templates.getInstanceOf("ElementListName"); + ST st = gen.getTemplates().getInstanceOf("ElementListName"); st.add("elemName", getElementName(name)); return st.render(); } diff --git a/tool/src/org/antlr/v4/codegen/model/Choice.java b/tool/src/org/antlr/v4/codegen/model/Choice.java index 561e36f66..aaa1174a3 100644 --- a/tool/src/org/antlr/v4/codegen/model/Choice.java +++ b/tool/src/org/antlr/v4/codegen/model/Choice.java @@ -73,7 +73,7 @@ public abstract class Choice extends RuleElement { List altLook = new ArrayList(); for (int a=1; a decls = new ArrayList(); if ( t.getType()==RULE_REF ) { Rule rref = factory.getGrammar().getRule(t.getText()); - String ctxName = factory.getGenerator().target + String ctxName = factory.getGenerator().getTarget() .getRuleFunctionContextStructName(rref); if ( needList ) { decls.add( new ContextRuleListGetterDecl(factory, refLabelName, ctxName) ); diff --git a/tool/src/org/antlr/v4/codegen/model/SemPred.java b/tool/src/org/antlr/v4/codegen/model/SemPred.java index b57cc6bd3..cecfb6f29 100644 --- a/tool/src/org/antlr/v4/codegen/model/SemPred.java +++ b/tool/src/org/antlr/v4/codegen/model/SemPred.java @@ -55,7 +55,7 @@ public class SemPred extends Action { if (predicate.startsWith("{") && predicate.endsWith("}?")) { predicate = predicate.substring(1, predicate.length() - 2); } - predicate = gen.target.getTargetStringLiteralFromString(predicate); + predicate = gen.getTarget().getTargetStringLiteralFromString(predicate); if ( failNode==null ) return; @@ -67,7 +67,7 @@ public class SemPred extends Action { failActionNode); } else { - msg = gen.target.getTargetStringLiteralFromANTLRStringLiteral(gen, + msg = gen.getTarget().getTargetStringLiteralFromANTLRStringLiteral(gen, failNode.getText(), true); } diff --git a/tool/src/org/antlr/v4/codegen/model/SerializedATN.java b/tool/src/org/antlr/v4/codegen/model/SerializedATN.java index 17a5e26fc..df7fe2320 100644 --- a/tool/src/org/antlr/v4/codegen/model/SerializedATN.java +++ b/tool/src/org/antlr/v4/codegen/model/SerializedATN.java @@ -46,7 +46,7 @@ public class SerializedATN extends OutputModelObject { IntegerList data = ATNSerializer.getSerialized(factory.getGrammar(), atn); serialized = new ArrayList(data.size()); for (int c : data.toArray()) { - String encoded = factory.getGenerator().target.encodeIntAsCharEscape(c == -1 ? Character.MAX_VALUE : c); + String encoded = factory.getGenerator().getTarget().encodeIntAsCharEscape(c == -1 ? Character.MAX_VALUE : c); serialized.add(encoded); } // System.out.println(ATNSerializer.getDecoded(factory.getGrammar(), atn)); diff --git a/tool/src/org/antlr/v4/codegen/model/StarBlock.java b/tool/src/org/antlr/v4/codegen/model/StarBlock.java index 50b6b3cfb..e61ef72e7 100644 --- a/tool/src/org/antlr/v4/codegen/model/StarBlock.java +++ b/tool/src/org/antlr/v4/codegen/model/StarBlock.java @@ -44,7 +44,7 @@ public class StarBlock extends Loop { List alts) { super(factory, blkOrEbnfRootAST, alts); - loopLabel = factory.getGenerator().target.getLoopLabel(blkOrEbnfRootAST); + loopLabel = factory.getGenerator().getTarget().getLoopLabel(blkOrEbnfRootAST); StarLoopEntryState star = (StarLoopEntryState)blkOrEbnfRootAST.atnState; loopBackStateNumber = star.loopBackState.stateNumber; decision = star.decision; diff --git a/tool/src/org/antlr/v4/codegen/model/TestSetInline.java b/tool/src/org/antlr/v4/codegen/model/TestSetInline.java index 32db5456b..4ea5c900c 100644 --- a/tool/src/org/antlr/v4/codegen/model/TestSetInline.java +++ b/tool/src/org/antlr/v4/codegen/model/TestSetInline.java @@ -67,7 +67,7 @@ public class TestSetInline extends SrcOp { bitsetList.add(current); } - current.ttypes.add(factory.getGenerator().target.getTokenTypeAsTargetLabel(factory.getGrammar(), ttype)); + current.ttypes.add(factory.getGenerator().getTarget().getTokenTypeAsTargetLabel(factory.getGrammar(), ttype)); } return bitsetList.toArray(new Bitset[bitsetList.size()]); diff --git a/tool/src/org/antlr/v4/codegen/model/decl/AltLabelStructDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/AltLabelStructDecl.java index a7e749a4f..5d49625d3 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/AltLabelStructDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/AltLabelStructDecl.java @@ -47,7 +47,7 @@ public class AltLabelStructDecl extends StructDecl { super(factory, r); this.altNum = altNum; this.name = // override name set in super to the label ctx - factory.getGenerator().target.getAltLabelContextStructName(label); + factory.getGenerator().getTarget().getAltLabelContextStructName(label); derivedFromName = label; } diff --git a/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java b/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java index 3be12bf72..7c43a5022 100644 --- a/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java +++ b/tool/src/org/antlr/v4/codegen/model/decl/StructDecl.java @@ -58,7 +58,7 @@ public class StructDecl extends Decl { @ModelElement public List extensionMembers; public StructDecl(OutputModelFactory factory, Rule r) { - super(factory, factory.getGenerator().target.getRuleFunctionContextStructName(r)); + super(factory, factory.getGenerator().getTarget().getRuleFunctionContextStructName(r)); addDispatchMethods(r); derivedFromName = r.name; provideCopyFrom = r.hasAltSpecificContexts(); diff --git a/tool/src/org/antlr/v4/tool/BuildDependencyGenerator.java b/tool/src/org/antlr/v4/tool/BuildDependencyGenerator.java index ef312bb65..54e4937a6 100644 --- a/tool/src/org/antlr/v4/tool/BuildDependencyGenerator.java +++ b/tool/src/org/antlr/v4/tool/BuildDependencyGenerator.java @@ -110,9 +110,9 @@ public class BuildDependencyGenerator { files.add(getOutputFile(generator.getVocabFileName())); // are we generating a .h file? ST headerExtST = null; - ST extST = generator.templates.getInstanceOf("codeFileExtension"); - if (generator.templates.isDefined("headerFile")) { - headerExtST = generator.templates.getInstanceOf("headerFileExtension"); + ST extST = generator.getTemplates().getInstanceOf("codeFileExtension"); + if (generator.getTemplates().isDefined("headerFile")) { + headerExtST = generator.getTemplates().getInstanceOf("headerFileExtension"); String suffix = Grammar.getGrammarTypeToFileNameSuffix(g.getType()); String fileName = g.name + suffix + headerExtST.render(); files.add(getOutputFile(fileName));