MCPcopy Index your code
hub / github.com/antlr/codebuff / test1

Method test1

output/java8/1.4.12/STViz.java:456–485  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

454 }
455
456 public static void test1() throws IOException
457 { // test rig
458 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";
459 String tmpdir = System.getProperty("java.io.tmpdir");
460 writeFile(tmpdir, "t.stg", templates);
461 STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
462 ST st = group.getInstanceOf("method");
463 st.impl.dump();
464 st.add("type", "float");
465 st.add("name", "foo");
466 st.add("locals", 3);
467 st.add("args", new String[] {"x",
468 "y",
469 "z"});
470 ST s1 = group.getInstanceOf("assign");
471 ST paren = group.getInstanceOf("paren");
472 paren.add("x", "x");
473 s1.add("a", paren);
474 s1.add("b", "y");
475 ST s2 = group.getInstanceOf("assign");
476 s2.add("a", "y");
477 s2.add("b", "z");
478 ST s3 = group.getInstanceOf("return");
479 s3.add("x", "3.14159");
480 st.add("stats", s1);
481 st.add("stats", s2);
482 st.add("stats", s3);
483 STViz viz = st.inspect();
484 System.out.println(st.render()); // should not mess up ST event lists
485 }
486
487 public static void test2() throws IOException
488 { // test rig

Callers 1

mainMethod · 0.95

Calls 7

writeFileMethod · 0.95
addMethod · 0.95
inspectMethod · 0.95
renderMethod · 0.95
getPropertyMethod · 0.65
getInstanceOfMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected