public static boolean targetExists(String language) { String targetName = "org.antlr.v4.codegen.target."+language+"Target"; try { Class<? extends Target> c = Class.forName(targetName).asSubclass(Target.class); Constructor<? extends Target> ctor = c.getConstructor(CodeGenerator.class); CodeGenerator gen = new CodeGenerator(language); Target target = ctor.newInstance(gen); return target.templatesExist(); } catch (Exception e) { // ignore errors; we're detecting presence only } return false; }
public static boolean targetExists(String language) { String targetName = "org.antlr.v4.codegen."+language+"Target"; try { Class<? extends Target> c = Class.forName(targetName).asSubclass(Target.class); Constructor<? extends Target> ctor = c.getConstructor(CodeGenerator.class); CodeGenerator gen = new CodeGenerator(language); Target target = ctor.newInstance(gen); return target.templatesExist(); } catch (Exception e) { // ignore errors; we're detecting presence only } return false; }
public BuildDependencyGenerator(Tool tool, Grammar g) { this.tool = tool; this.g = g; String language = g.getOptionString("language"); generator = new CodeGenerator(tool, g, language); }
public BuildDependencyGenerator(Tool tool, Grammar g) { this.tool = tool; this.g = g; String language = g.getOptionString("language"); generator = new CodeGenerator(tool, g, language); }
public BuildDependencyGenerator(Tool tool, Grammar g) { this.tool = tool; this.g = g; String language = g.getOptionString("language"); generator = new CodeGenerator(tool, g, language); }
public BuildDependencyGenerator(Tool tool, Grammar g) { this.tool = tool; this.g = g; String language = g.getOptionString("language"); generator = new CodeGenerator(tool, g, language); }
public static boolean targetExists(String language) { String targetName = "org.antlr.v4.codegen.target."+language+"Target"; try { Class<? extends Target> c = Class.forName(targetName).asSubclass(Target.class); Constructor<? extends Target> ctor = c.getConstructor(CodeGenerator.class); CodeGenerator gen = new CodeGenerator(language); Target target = ctor.newInstance(gen); return target.templatesExist(); } catch (Exception e) { // ignore errors; we're detecting presence only } return false; }
public BuildDependencyGenerator(Tool tool, Grammar g) { this.tool = tool; this.g = g; String language = g.getOptionString("language"); generator = new CodeGenerator(tool, g, language); }
public static boolean targetExists(String language) { String targetName = "org.antlr.v4.codegen.target."+language+"Target"; try { Class<? extends Target> c = Class.forName(targetName).asSubclass(Target.class); Constructor<? extends Target> ctor = c.getConstructor(CodeGenerator.class); CodeGenerator gen = new CodeGenerator(language); Target target = ctor.newInstance(gen); return target.templatesExist(); } catch (Exception e) { // ignore errors; we're detecting presence only } return false; }
public LexerATNFactory(LexerGrammar g) { super(g); // 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.getTemplates(); }
public LexerATNFactory(LexerGrammar g) { super(g); // 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.getTemplates(); }
public LexerATNFactory(LexerGrammar g) { super(g); // 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.getTemplates(); }
public LexerATNFactory(LexerGrammar g) { super(g); // 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.getTemplates(); }
public void loadPrecRuleTemplates() { String templateGroupFile = "org/antlr/v4/tool/templates/LeftRecursiveRules.stg"; recRuleTemplates = new STGroupFile(templateGroupFile); if ( !recRuleTemplates.isDefined("recRule") ) { tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules"); } // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); STGroup templates = gen.getTemplates(); if (templates == null) { // this class will still operate using Java templates templates = new CodeGenerator(tool, null, "Java").getTemplates(); assert templates != null; } codegenTemplates = templates; }
public LexerATNFactory(LexerGrammar g) { super(g); // use codegen to get correct language templates for lexer commands String language = g.getOptionString("language"); CodeGenerator gen = new CodeGenerator(g.tool, null, language); Target target = gen.getTarget(); codegenTemplates = target != null ? target.getTemplates() : null; }
public void loadPrecRuleTemplates() { String templateGroupFile = "org/antlr/v4/tool/templates/LeftRecursiveRules.stg"; recRuleTemplates = new STGroupFile(templateGroupFile); if ( !recRuleTemplates.isDefined("recRule") ) { tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules"); } // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); codegenTemplates = gen.getTemplates(); }
public void loadPrecRuleTemplates() { String templateGroupFile = "org/antlr/v4/tool/templates/LeftRecursiveRules.stg"; recRuleTemplates = new STGroupFile(templateGroupFile); if ( !recRuleTemplates.isDefined("recRule") ) { tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules"); } // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); codegenTemplates = gen.getTemplates(); }
public void loadPrecRuleTemplates() { String templateGroupFile = "org/antlr/v4/tool/templates/LeftRecursiveRules.stg"; recRuleTemplates = new STGroupFile(templateGroupFile); if ( !recRuleTemplates.isDefined("recRule") ) { tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules"); } // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); codegenTemplates = gen.getTemplates(); }
public void loadPrecRuleTemplates() { String templateGroupFile = "org/antlr/v4/tool/templates/LeftRecursiveRules.stg"; recRuleTemplates = new STGroupFile(templateGroupFile); if ( !recRuleTemplates.isDefined("recRule") ) { tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules"); } // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); codegenTemplates = gen.getTemplates(); }
@Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); String qualFileName = grammarFile.getPath(); boolean autogen = ConfigANTLRPerGrammar.getBooleanProp(project, qualFileName, ConfigANTLRPerGrammar.PROP_AUTO_GEN, false); // System.out.println("autogen is "+autogen+", force="+forceGeneration); if ( forceGeneration || (autogen && isGrammarStale()) ) { antlr(grammarFile); } else { ANTLRv4PluginController controller = ANTLRv4PluginController.getInstance(project); final PreviewState previewState = controller.getPreviewState(grammarFile); // is lexer file? gen .tokens file no matter what as tokens might have changed; // a parser that feeds off of that file will need to see the changes. if ( previewState.g==null && previewState.lg!=null) { Grammar g = previewState.lg; String language = g.getOptionString(ConfigANTLRPerGrammar.PROP_LANGUAGE); Tool tool = ParsingUtils.createANTLRToolForLoadingGrammars(); CodeGenerator gen = new CodeGenerator(tool, g, language); gen.writeVocabFile(); } } }