Package org.stringtemplate.v4

Examples of org.stringtemplate.v4.ST.render()


    int lp = templates.indexOf('(');
    String name = templates.substring(0, lp);
    STGroup group = new STGroupString(templates);
    ST st = group.getInstanceOf(name);
    st.add(actionName, action);
    String grammar = st.render();
    ErrorQueue equeue = new ErrorQueue();
    Grammar g = new Grammar(grammar, equeue);
    if ( g.ast!=null && !g.ast.hasErrors ) {
      SemanticPipeline sem = new SemanticPipeline(g);
      sem.process();
View Full Code Here


      if ( g.isLexer() ) factory = new LexerATNFactory((LexerGrammar)g);
      g.atn = factory.createATN();

      CodeGenerator gen = new CodeGenerator(g);
      ST outputFileST = gen.generateParser();
      String output = outputFileST.render();
      //System.out.println(output);
      String b = "#" + actionName + "#";
      int start = output.indexOf(b);
      String e = "#end-" + actionName + "#";
      int end = output.indexOf(e);
View Full Code Here

      "    }\n" +
      "}"
      );

    outputFileST.add("lexerName", lexerName);
    writeFile(tmpdir, "Test.java", outputFileST.render());
  }

  public void writeRecognizerAndCompile(String parserName, String lexerName,
                      String parserStartRuleName,
                      boolean debug,
View Full Code Here

    ST grammarST = new ST(grammarTemplate);
    grammarST.add("args", "int expr");
    grammarST.add("retvals", "int expr");
    grammarST.add("locals", "int expr");
    grammarST.add("body", "expr=expr");
    testErrors(new String[] { grammarST.render(), expected }, false);
  }
}
View Full Code Here

        }
        if ( g.isCombined() ) {
            // add autogenerated lexer; e.g., TLexer.java TLexer.h TLexer.tokens

            String suffix = Grammar.getGrammarTypeToFileNameSuffix(ANTLRParser.LEXER);
            String lexer = g.name + suffix + extST.render();
            files.add(getOutputFile(lexer));
            String lexerTokens = g.name + suffix + CodeGenerator.VOCAB_FILE_EXTENSION;
            files.add(getOutputFile(lexerTokens));

            // TLexer.h
View Full Code Here

     * @param message The message to send to Maven.
     */
    @Override
    public void error(ANTLRMessage message) {
        ST msgST = tool.errMgr.getMessageTemplate(message);
        String outputMsg = msgST.render();
        if (tool.errMgr.formatWantsSingleLineMessage()) {
            outputMsg = outputMsg.replace('\n', ' ');
        }

        log.error(outputMsg);
View Full Code Here

     * @param message
     */
    @Override
    public void warning(ANTLRMessage message) {
        ST msgST = tool.errMgr.getMessageTemplate(message);
        String outputMsg = msgST.render();
        if (tool.errMgr.formatWantsSingleLineMessage()) {
            outputMsg = outputMsg.replace('\n', ' ');
        }

        log.warn(outputMsg);
View Full Code Here

  }

  public String getListLabel(String label) {
    ST st = getTemplates().getInstanceOf("ListLabelName");
    st.add("label", label);
    return st.render();
  }

  public String getRuleFunctionContextStructName(Rule r) {
    if ( r.g.isLexer() ) {
      return getTemplates().getInstanceOf("LexerRuleContext").render();
View Full Code Here

    if ( tokenName.startsWith("'") ) {
      return "s"+ttype;
    }
    String text = getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
    st.add("tokenName", text);
    return st.render();
  }

  // x=(A|B)
  public String getImplicitSetLabel(String id) {
    ST st = getTemplates().getInstanceOf("ImplicitSetLabel");
View Full Code Here

  // x=(A|B)
  public String getImplicitSetLabel(String id) {
    ST st = getTemplates().getInstanceOf("ImplicitSetLabel");
    st.add("id", id);
    return st.render();
  }

  public String getImplicitRuleLabel(String ruleName) {
    ST st = getTemplates().getInstanceOf("ImplicitRuleLabel");
    st.add("ruleName", ruleName);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.