Java Code Examples for org.stringtemplate.v4.ST#inspect()

The following examples show how to use org.stringtemplate.v4.ST#inspect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static void test4() throws IOException {
      String templates =
	"main(t) ::= <<\n" +
	"hi: <t>\n" +
	">>\n" +
	"foo(x,y={hi}) ::= \"<bar(x,y)>\"\n" +
	"bar(x,y) ::= << <y> >>\n" +
	"ignore(m) ::= \"<m>\"\n";

      STGroup group = new STGroupString(templates);
      ST st = group.getInstanceOf("main");
ST foo = group.getInstanceOf("foo");
st.add("t", foo);
ST ignore = group.getInstanceOf("ignore");
ignore.add("m", foo); // embed foo twice!
      st.inspect();
st.render();
  }
 
Example 2
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test3() throws IOException
{
    String templates = "main() ::= <<\n"+"Foo: <{bar};format=\"lower\">\n"+">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    st.inspect();
}
 
Example 3
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test2() throws IOException
{ // test rig
    String templates = "t1(q1=\"Some\\nText\") ::= <<\n"+
                       "<q1>\n" +">>\n"+"\n"+"t2(p1) ::= <<\n"+
                       "<p1>\n"+
                       ">>\n"+
                       "\n"+
                       "main() ::= <<\n" +"START-<t1()>-END\n"+"\n"+"START-<t2(p1=\"Some\\nText\")>-END\n"+">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    STViz viz = st.inspect();
}
 
Example 4
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test3() throws IOException
{
    String templates = "main() ::= <<\n"+"Foo: <{bar};format=\"lower\">\n"+">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    st.inspect();
}
 
Example 5
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test1() throws IOException
{ // test rig
    String templates = "method(type,name,locals,args,stats) ::= <<\n"+"public <type> <name>(<args:{a| int <a>}; separator=\", \">) {\n"+"    <if(locals)>int locals[<locals>];<endif>\n"+"    <stats;separator=\"\\n\">\n"+"}\n"+">>\n"+"assign(a,b) ::= \"<a> = <b>;\"\n"+"return(x) ::= <<return <x>;>>\n"+"paren(x) ::= \"(<x>)\"\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("method");
    st.impl.dump();
    st.add("type", "float");
    st.add("name", "foo");
    st.add("locals", 3);
    st.add("args", new String[] {"x",
                                 "y",
                                 "z"});
    ST s1 = group.getInstanceOf("assign");
    ST paren = group.getInstanceOf("paren");
    paren.add("x", "x");
    s1.add("a", paren);
    s1.add("b", "y");
    ST s2 = group.getInstanceOf("assign");
    s2.add("a", "y");
    s2.add("b", "z");
    ST s3 = group.getInstanceOf("return");
    s3.add("x", "3.14159");
    st.add("stats", s1);
    st.add("stats", s2);
    st.add("stats", s3);
    STViz viz = st.inspect();
    System.out.println(st.render()); // should not mess up ST event lists
}
 
Example 6
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test1() throws IOException
{ // test rig
    String templates = "method(type,name,locals,args,stats) ::= <<\n"+"public <type> <name>(<args:{a| int <a>}; separator=\", \">) {\n"+"    <if(locals)>int locals[<locals>];<endif>\n"+"    <stats;separator=\"\\n\">\n"+"}\n"+">>\n"+"assign(a,b) ::= \"<a> = <b>;\"\n"+"return(x) ::= <<return <x>;>>\n"+"paren(x) ::= \"(<x>)\"\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("method");
    st.impl.dump();
    st.add("type", "float");
    st.add("name", "foo");
    st.add("locals", 3);
    st.add("args", new String[] {"x",
                                 "y",
                                 "z"});
    ST s1 = group.getInstanceOf("assign");
    ST paren = group.getInstanceOf("paren");
    paren.add("x", "x");
    s1.add("a", paren);
    s1.add("b", "y");
    ST s2 = group.getInstanceOf("assign");
    s2.add("a", "y");
    s2.add("b", "z");
    ST s3 = group.getInstanceOf("return");
    s3.add("x", "3.14159");
    st.add("stats", s1);
    st.add("stats", s2);
    st.add("stats", s3);
    STViz viz = st.inspect();
    System.out.println(st.render()); // should not mess up ST event lists
}
 
Example 7
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test4() throws IOException
{
    String templates = "main(t) ::= <<\n"+"hi: <t>\n"+">>\n"+"foo(x,y={hi}) ::= \"<bar(x,y)>\"\n"+"bar(x,y) ::= << <y> >>\n"+"ignore(m) ::= \"<m>\"\n";
    STGroup group = new STGroupString(templates);
    ST st = group.getInstanceOf("main");
    ST foo = group.getInstanceOf("foo");
    st.add("t", foo);
    ST ignore = group.getInstanceOf("ignore");
    ignore.add("m", foo); // embed foo twice!
    st.inspect();
    st.render();
}
 
Example 8
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test3() throws IOException
{
    String templates = "main() ::= <<\n"+
                       "Foo: <{bar};format=\"lower\">\n" +">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    st.inspect();
}
 
Example 9
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test2() throws IOException
{ // test rig
    String templates = "t1(q1=\"Some\\nText\") ::= <<\n"+"<q1>\n"+">>\n"+"\n"+"t2(p1) ::= <<\n"+"<p1>\n"+">>\n"+"\n"+"main() ::= <<\n"+"START-<t1()>-END\n"+"\n"+"START-<t2(p1=\"Some\\nText\")>-END\n"+">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    STViz viz = st.inspect();
}
 
Example 10
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test1() throws IOException
{ // test rig
    String templates = "method(type,name,locals,args,stats) ::= <<\n"+"public <type> <name>(<args:{a| int <a>}; separator=\", \">) {\n"+"    <if(locals)>int locals[<locals>];<endif>\n"+"    <stats;separator=\"\\n\">\n"+"}\n"+">>\n"+"assign(a,b) ::= \"<a> = <b>;\"\n"+"return(x) ::= <<return <x>;>>\n"+"paren(x) ::= \"(<x>)\"\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("method");
    st.impl.dump();
    st.add("type", "float");
    st.add("name", "foo");
    st.add("locals", 3);
    st.add("args", new String[] {"x",
                                 "y",
                                 "z"});
    ST s1 = group.getInstanceOf("assign");
    ST paren = group.getInstanceOf("paren");
    paren.add("x", "x");
    s1.add("a", paren);
    s1.add("b", "y");
    ST s2 = group.getInstanceOf("assign");
    s2.add("a", "y");
    s2.add("b", "z");
    ST s3 = group.getInstanceOf("return");
    s3.add("x", "3.14159");
    st.add("stats", s1);
    st.add("stats", s2);
    st.add("stats", s3);
    STViz viz = st.inspect();
    System.out.println(st.render()); // should not mess up ST event lists
}
 
Example 11
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test2() throws IOException
{ // test rig
    String templates = "t1(q1=\"Some\\nText\") ::= <<\n"+"<q1>\n"+">>\n"+"\n"+"t2(p1) ::= <<\n"+
                       "<p1>\n"+
                       ">>\n"+
                       "\n" +"main() ::= <<\n"+"START-<t1()>-END\n"+"\n"+"START-<t2(p1=\"Some\\nText\")>-END\n"+">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    STViz viz = st.inspect();
}
 
Example 12
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test4() throws IOException
{
    String templates = "main(t) ::= <<\n"+"hi: <t>\n"+">>\n"+"foo(x,y={hi}) ::= \"<bar(x,y)>\"\n" +
                       "bar(x,y) ::= << <y> >>\n" +"ignore(m) ::= \"<m>\"\n";
    STGroup group = new STGroupString(templates);
    ST st = group.getInstanceOf("main");
    ST foo = group.getInstanceOf("foo");
    st.add("t", foo);
    ST ignore = group.getInstanceOf("ignore");
    ignore.add("m", foo); // embed foo twice!
    st.inspect();
    st.render();
}
 
Example 13
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test2() throws IOException
{ // test rig
    String templates = "t1(q1=\"Some\\nText\") ::= <<\n"+"<q1>\n"+">>\n"+"\n"+"t2(p1) ::= <<\n"+"<p1>\n"+">>\n"+"\n"+"main() ::= <<\n"+"START-<t1()>-END\n"+"\n"+"START-<t2(p1=\"Some\\nText\")>-END\n"+">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    STViz viz = st.inspect();
}
 
Example 14
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test1() throws IOException
{ // test rig
    String templates = "method(type,name,locals,args,stats) ::= <<\n"+"public <type> <name>(<args:{a| int <a>}; separator=\", \">) {\n"+"    <if(locals)>int locals[<locals>];<endif>\n"+"    <stats;separator=\"\\n\">\n"+"}\n"+">>\n"+"assign(a,b) ::= \"<a> = <b>;\"\n"+"return(x) ::= <<return <x>;>>\n"+"paren(x) ::= \"(<x>)\"\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("method");
    st.impl.dump();
    st.add("type", "float");
    st.add("name", "foo");
    st.add("locals", 3);
    st.add("args", new String[] {"x",
                                 "y",
                                 "z"});
    ST s1 = group.getInstanceOf("assign");
    ST paren = group.getInstanceOf("paren");
    paren.add("x", "x");
    s1.add("a", paren);
    s1.add("b", "y");
    ST s2 = group.getInstanceOf("assign");
    s2.add("a", "y");
    s2.add("b", "z");
    ST s3 = group.getInstanceOf("return");
    s3.add("x", "3.14159");
    st.add("stats", s1);
    st.add("stats", s2);
    st.add("stats", s3);
    STViz viz = st.inspect();
    System.out.println(st.render()); // should not mess up ST event lists
}
 
Example 15
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test3() throws IOException
{
    String templates = "main() ::= <<\n"+"Foo: <{bar};format=\"lower\">\n"+">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    st.inspect();
}
 
Example 16
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test2() throws IOException
{ // test rig
    String templates = "t1(q1=\"Some\\nText\") ::= <<\n"+"<q1>\n"+">>\n"+"\n"+"t2(p1) ::= <<\n"+"<p1>\n"+">>\n"+"\n"+"main() ::= <<\n"+"START-<t1()>-END\n"+"\n"+"START-<t2(p1=\"Some\\nText\")>-END\n"+">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    STViz viz = st.inspect();
}
 
Example 17
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test1() throws IOException
{ // test rig
    String templates = "method(type,name,locals,args,stats) ::= <<\n"+"public <type> <name>(<args:{a| int <a>}; separator=\", \">) {\n"+"    <if(locals)>int locals[<locals>];<endif>\n"+"    <stats;separator=\"\\n\">\n"+"}\n"+">>\n"+"assign(a,b) ::= \"<a> = <b>;\"\n"+"return(x) ::= <<return <x>;>>\n"+"paren(x) ::= \"(<x>)\"\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("method");
    st.impl.dump();
    st.add("type", "float");
    st.add("name", "foo");
    st.add("locals", 3);
    st.add("args", new String[] {"x",
                                 "y",
                                 "z"});
    ST s1 = group.getInstanceOf("assign");
    ST paren = group.getInstanceOf("paren");
    paren.add("x", "x");
    s1.add("a", paren);
    s1.add("b", "y");
    ST s2 = group.getInstanceOf("assign");
    s2.add("a", "y");
    s2.add("b", "z");
    ST s3 = group.getInstanceOf("return");
    s3.add("x", "3.14159");
    st.add("stats", s1);
    st.add("stats", s2);
    st.add("stats", s3);
    STViz viz = st.inspect();
    System.out.println(st.render()); // should not mess up ST event lists
}
 
Example 18
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test1() throws IOException
{ // test rig
    String templates = "method(type,name,locals,args,stats) ::= <<\n"+"public <type> <name>(<args:{a| int <a>}; separator=\", \">) {\n"+"    <if(locals)>int locals[<locals>];<endif>\n"+"    <stats;separator=\"\\n\">\n"+"}\n"+">>\n"+"assign(a,b) ::= \"<a> = <b>;\"\n"+"return(x) ::= <<return <x>;>>\n"+"paren(x) ::= \"(<x>)\"\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("method");
    st.impl.dump();
    st.add("type", "float");
    st.add("name", "foo");
    st.add("locals", 3);
    st.add("args", new String[] {"x",
                                 "y",
                                 "z"});
    ST s1 = group.getInstanceOf("assign");
    ST paren = group.getInstanceOf("paren");
    paren.add("x", "x");
    s1.add("a", paren);
    s1.add("b", "y");
    ST s2 = group.getInstanceOf("assign");
    s2.add("a", "y");
    s2.add("b", "z");
    ST s3 = group.getInstanceOf("return");
    s3.add("x", "3.14159");
    st.add("stats", s1);
    st.add("stats", s2);
    st.add("stats", s3);
    STViz viz = st.inspect();
    System.out.println(st.render()); // should not mess up ST event lists
}
 
Example 19
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test3() throws IOException
{
    String templates = "main() ::= <<\n"+"Foo: <{bar};format=\"lower\">\n"+">>\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    st.inspect();
}
 
Example 20
Source File: STViz.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void test1() throws IOException
{ // test rig
    String templates = "method(type,name,locals,args,stats) ::= <<\n"+"public <type> <name>(<args:{a| int <a>}; separator=\", \">) {\n"+"    <if(locals)>int locals[<locals>];<endif>\n"+"    <stats;separator=\"\\n\">\n"+"}\n"+">>\n"+"assign(a,b) ::= \"<a> = <b>;\"\n"+"return(x) ::= <<return <x>;>>\n"+"paren(x) ::= \"(<x>)\"\n";
    String tmpdir = System.getProperty("java.io.tmpdir");
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("method");
    st.impl.dump();
    st.add("type", "float");
    st.add("name", "foo");
    st.add("locals", 3);
    st.add("args", new String[] {"x",
                                 "y",
                                 "z"});
    ST s1 = group.getInstanceOf("assign");
    ST paren = group.getInstanceOf("paren");
    paren.add("x", "x");
    s1.add("a", paren);
    s1.add("b", "y");
    ST s2 = group.getInstanceOf("assign");
    s2.add("a", "y");
    s2.add("b", "z");
    ST s3 = group.getInstanceOf("return");
    s3.add("x", "3.14159");
    st.add("stats", s1);
    st.add("stats", s2);
    st.add("stats", s3);
    STViz viz = st.inspect();
    System.out.println(st.render()); // should not mess up ST event lists
}