Examples of STGroupString


Examples of org.stringtemplate.v4.STGroupString

    setFileName(fileName);
    // ensure we have the composite set to something
    if ( composite.delegateGrammarTreeRoot==null ) {
      composite.setDelegationRoot(this);
    }
    STGroup lexerGrammarSTG = new STGroupString(lexerGrammarTemplate);
    lexerGrammarST = lexerGrammarSTG.getInstanceOf("grammar");
    target = CodeGenerator.loadLanguageTarget((String) getOption("language"));
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  public Grammar(Tool tool) {
    setTool(tool);
    builtFromString = true;
    composite = new CompositeGrammar(this);
    STGroup lexerGrammarSTG = new STGroupString(lexerGrammarTemplate);
    lexerGrammarST = lexerGrammarSTG.getInstanceOf("grammar");
    target = CodeGenerator.loadLanguageTarget((String)getOption("language"));
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  }

  public void testActions(String templates, String actionName, String action, String expected) throws org.antlr.runtime.RecognitionException {
    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 ) {
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

        "method(name) ::= <<"+newline+
        "$stat(name)$" +newline+
        ">>"+newline+
        "stat(name,value=\"99\") ::= \"x=$value$; // $name$\""+newline
        ;
    STGroup group = new STGroupString(templates);
    ST b = group.getInstanceOf("method");
    b.add("name", "foo");
    String expecting = "x=99; // foo";
    String result = b.render();
    assertEquals(expecting, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

      "\n" +
      "\n" +
      "]\n" +
      "\n" +
      "%>\n";
    STGroup g = new STGroupString(template);
    ST st = g.getInstanceOf("t");
    st.add("x", 99);
    String expected = "[  99]";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  @Test public void testWSNoNewlineTemplate() throws Exception {
    String template =
      "t(x) ::= <%\n" +
      "\n" +
      "%>\n";
    STGroup g = new STGroupString(template);
    ST st = g.getInstanceOf("t");
    st.add("x", 99);
    String expected = "";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  }

  @Test public void testEmptyNoNewlineTemplate() throws Exception {
    String template =
      "t(x) ::= <%%>\n";
    STGroup g = new STGroupString(template);
    ST st = g.getInstanceOf("t");
    st.add("x", 99);
    String expected = "";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

    String template =
      "t(x) ::= <%\n" +
      "  foo\n" +
      "  <x>\n" +
      "%>\n";
    STGroup g = new STGroupString(template);
    ST st = g.getInstanceOf("t");
    st.add("x", 99);
    String expected = "foo99";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

      "  <if(x)>\n" +
      "    foo\n" +
      "  <endif>\n" +
      "  <x>\n" +
      "%>\n";
    STGroup g = new STGroupString(template);
    ST st = g.getInstanceOf("t");
    st.add("x", 99);
    String expected = "foo99";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  @Test public void testKeepWS() throws Exception {
    String template =
      "t(x) ::= <%\n" +
      "  <x> <x> hi\n" +
      "%>\n";
    STGroup g = new STGroupString(template);
    ST st = g.getInstanceOf("t");
    st.add("x", 99);
    String expected = "99 99 hi";
    String result = st.render();
    assertEquals(expected, result);
  }
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.