本文整理匯總了Java中org.antlr.runtime.tree.CommonTreeNodeStream類的典型用法代碼示例。如果您正苦於以下問題:Java CommonTreeNodeStream類的具體用法?Java CommonTreeNodeStream怎麽用?Java CommonTreeNodeStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CommonTreeNodeStream類屬於org.antlr.runtime.tree包,在下文中一共展示了CommonTreeNodeStream類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
public static List<ExecutionPlan> parse(String source) throws SiddhiParserException {
try {
SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer();
lexer.setCharStream(new ANTLRStringStream(source));
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);
SiddhiQLGrammarParser.executionPlan_return r = parser.executionPlan();
CommonTree t = (CommonTree) r.getTree();
CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
nodes.setTokenStream(tokens);
SiddhiQLGrammarWalker walker = new SiddhiQLGrammarWalker(nodes);
return walker.executionPlan();
} catch (Throwable e) {
throw new SiddhiParserException(e.getMessage(), e);
}
}
示例2: parseStreamDefinition
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
public static StreamDefinition parseStreamDefinition(String source) throws SiddhiParserException {
try {
SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer();
lexer.setCharStream(new ANTLRStringStream(source));
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);
SiddhiQLGrammarParser.definitionStreamFinal_return r = parser.definitionStreamFinal();
CommonTree t = (CommonTree) r.getTree();
CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
nodes.setTokenStream(tokens);
SiddhiQLGrammarWalker walker = new SiddhiQLGrammarWalker(nodes);
return walker.definitionStreamFinal();
} catch (Throwable e) {
throw new SiddhiParserException(e.getMessage(), e);
}
}
示例3: parseTableDefinition
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
public static TableDefinition parseTableDefinition(String source) throws SiddhiParserException {
try {
SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer();
lexer.setCharStream(new ANTLRStringStream(source));
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);
SiddhiQLGrammarParser.definitionTableFinal_return r = parser.definitionTableFinal();
CommonTree t = (CommonTree) r.getTree();
CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
nodes.setTokenStream(tokens);
SiddhiQLGrammarWalker walker = new SiddhiQLGrammarWalker(nodes);
return walker.definitionTableFinal();
} catch (Throwable e) {
throw new SiddhiParserException(e.getMessage(), e);
}
}
示例4: parsePartitionDefinition
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
public static PartitionDefinition parsePartitionDefinition(String source) throws SiddhiParserException {
try {
SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer();
lexer.setCharStream(new ANTLRStringStream(source));
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);
SiddhiQLGrammarParser.definitionPartitionFinal_return r = parser.definitionPartitionFinal();
CommonTree t = (CommonTree) r.getTree();
CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
nodes.setTokenStream(tokens);
SiddhiQLGrammarWalker walker = new SiddhiQLGrammarWalker(nodes);
return walker.definitionPartitionFinal();
} catch (Throwable e) {
throw new SiddhiParserException(e.getMessage(), e);
}
}
示例5: parseQuery
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
public static Query parseQuery(String source) throws SiddhiParserException {
try {
SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer();
lexer.setCharStream(new ANTLRStringStream(source));
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);
SiddhiQLGrammarParser.queryFinal_return r = parser.queryFinal();
CommonTree t = (CommonTree) r.getTree();
CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
nodes.setTokenStream(tokens);
SiddhiQLGrammarWalker walker = new SiddhiQLGrammarWalker(nodes);
return walker.queryFinal();
} catch (Throwable e) {
throw new SiddhiParserException(e.getMessage(), e);
}
}
示例6: runTestFor
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
private void runTestFor(String script) throws RecognitionException {
ReflexLexer lexer = new ReflexLexer();
lexer.setCharStream(new ANTLRStringStream(script));
CommonTokenStream tokens = new CommonTokenStream(lexer);
ReflexParser parser = new ReflexParser(tokens);
CommonTree tree = (CommonTree) parser.parse().getTree();
/*
* DOTTreeGenerator gen = new DOTTreeGenerator(); StringTemplate st =
* gen.toDOT(tree); System.out.println(st);
*/
CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
ReflexTreeWalker walker = new ReflexTreeWalker(nodes, parser.languageRegistry);
HttpLoginApi loginApi = new HttpLoginApi("http://localhost:8665/rapture", new SimpleCredentialsProvider("rapture", "rapture"));
loginApi.login();
HttpUserApi userApi = new HttpUserApi(loginApi);
ApiVersion version = userApi.getServerApiVersion();
System.out.println("version is " + version.getMajor() + ":" + version.getMinor());
walker.getReflexHandler().setApi(new ScriptClient(loginApi));
ReflexNode returned = walker.walk();
System.out.println(returned == null ? "null" : returned.evaluateWithoutScope(new ReflexPrintingDebugger()));
}
示例7: runSuspendTestFor
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
protected void runSuspendTestFor(String fileName) throws RecognitionException {
ReflexLexer lexer = new ReflexLexer();
lexer.setCharStream(new ANTLRStringStream(getResourceAsString(this, fileName)));
CommonTokenStream tokens = new CommonTokenStream(lexer);
ReflexParser parser = new ReflexParser(tokens);
CommonTree tree = (CommonTree) parser.parse().getTree();
/*
* DOTTreeGenerator gen = new DOTTreeGenerator(); StringTemplate st =
* gen.toDOT(tree); System.out.println(st);
*/
CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
ReflexTreeWalker walker = new ReflexTreeWalker(nodes, parser.languageRegistry);
ReflexNode returned = walker.walk();
ReflexValue value = returned.evaluateWithoutScope(new NullDebugger());
while (value.getValue() == ReflexValue.Internal.SUSPEND) {
System.out.println("Oooh it suspended...");
System.out.println("Resuming script");
value = returned.evaluateWithResume(new NullDebugger(), returned.getScope());
}
System.out.println(value);
}
示例8: runTestForWithApi
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
protected String runTestForWithApi(String fileName, ScriptingApi api, IReflexDataHandler dataHandler, Map<String, Object> injectedVars)
throws RecognitionException {
ReflexLexer lexer = new ReflexLexer();
lexer.setCharStream(new ANTLRStringStream(getResourceAsString(this, fileName)));
CommonTokenStream tokens = new CommonTokenStream(lexer);
ReflexParser parser = new ReflexParser(tokens);
CommonTree tree = (CommonTree) parser.parse().getTree();
CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
ReflexTreeWalker walker = new ReflexTreeWalker(nodes, parser.languageRegistry);
walker.getReflexHandler().setApi(api);
walker.getReflexHandler().setDataHandler(dataHandler);
if (injectedVars != null && !injectedVars.isEmpty()) {
for (Map.Entry<String, Object> kv : injectedVars.entrySet()) {
walker.currentScope.assign(kv.getKey(), kv.getValue() == null ? new ReflexNullValue() : new ReflexValue(kv.getValue()));
}
}
ReflexNode returned = walker.walk();
return returned.evaluateWithoutScope(new ReflexPrintingDebugger()).asString();
}
示例9: test1
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
@Test
public void test1() throws RecognitionException {
CharStream input = new ANTLRStringStream("version(1.1.0)\n" + "minVer(1.1.0)\n"
+ "[ The Admin API is used to manipulate and access the low level entities in Rapture. Typically the methods in this API\n"
+ "are only used during significant setup events in a Rapture environment.]\n" + "api(Admin) {\n"
+ " [This method restores a user that has been deleted]\n" + " @entitle=/admin/main\n"
+ " @public Boolean restoreUser(String userName);\n" + "}\n" + "[A return value from a native query]\n"
+ "type RaptureQueryResult(@package=rapture.common) {\n" + " List(JsonContent) rows;\n" + "}\n");
TLexer lexer = new TLexer(input);
TokenStream tokenInputStream = new CommonTokenStream(lexer);
TParser parser = new TParser(tokenInputStream);
hmxdef_return returnVal = parser.hmxdef();
System.out.println("Done " + returnVal.getTree().toStringTree());
TreeNodeStream treeInput = new CommonTreeNodeStream(returnVal.getTree());
TTree walker = new TTree(treeInput);
walker.setTemplateLib(TemplateRepo.getApiTemplates("Java"));
com.incapture.rapgen.TTree.hmxdef_return walkerResult = walker.hmxdef();
System.out.println("Done, result=" + walkerResult.toString());
}
示例10: test2
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
@Test
public void test2() throws RecognitionException {
CharStream input = new ANTLRStringStream("version(1.1.0)\n" + "minVer(1.1.0)\n"
+ "[ The Admin API is used to manipulate and access the low level entities in Rapture. Typically the methods in this API\n"
+ "are only used during significant setup events in a Rapture environment.]\n" + "api(Admin) {\n"
+ " [This method restores a user that has been deleted]\n" + " @entitle=/admin/main\n"
+ " @public Boolean restoreUser(String userName);\n" + "}\n" + "[A return value from a native query]\n"
+ "type RaptureQueryResult(@package=rapture.common) {\n" + " List(JsonContent) rows;\n" + "}\n");
TLexer lexer = new TLexer(input);
TokenStream tokenInputStream = new CommonTokenStream(lexer);
TParser parser = new TParser(tokenInputStream);
hmxdef_return returnVal = parser.hmxdef();
System.out.println("Done " + returnVal.getTree().toStringTree());
TreeNodeStream treeInput = new CommonTreeNodeStream(returnVal.getTree());
TTree walker = new TTree(treeInput);
walker.setTemplateLib(TemplateRepo.getApiTemplates("Java"));
apiGen_return walkerResult = walker.apiGen();
System.out.println("Done, result=" + walkerResult.toString());
}
示例11: test3
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
@Test
public void test3() throws RecognitionException {
CharStream input = new ANTLRStringStream("version(1.1.0)\n" + "minVer(1.1.0)\n"
+ "[ The Admin API is used to manipulate and access the low level entities in Rapture. Typically the methods in this API\n"
+ "are only used during significant setup events in a Rapture environment.]\n" + "api(Admin) {\n"
+ " [This method restores a user that has been deleted]\n" + " @entitle=/admin/main\n"
+ " @public Boolean restoreUser(String userName);\n" + "}\n" + "[A return value from a native query]\n"
+ "type RaptureQueryResult(@package=rapture.common) {\n" + " List(JsonContent) rows;\n" + "}\n");
TLexer lexer = new TLexer(input);
TokenStream tokenInputStream = new CommonTokenStream(lexer);
TParser parser = new TParser(tokenInputStream);
hmxdef_return returnVal = parser.hmxdef();
System.out.println("Done " + returnVal.getTree().toStringTree());
TreeNodeStream treeInput = new CommonTreeNodeStream(returnVal.getTree());
TTree walker = new TTree(treeInput);
walker.setTemplateLib(TemplateRepo.getSdkTemplates("Java"));
try {
walker.sdkGen();
fail("This should have failed, sdk name is required but not present in code");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("SDK Name"));
}
}
示例12: test4
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
@Test
public void test4() throws RecognitionException {
CharStream input = new ANTLRStringStream("sdk(alan)\n" + "version(0.0.1)\n" + "minVer(0.0.1)\n"
+ "[ The Admin API is used to manipulate and access the low level entities in Rapture. Typically the methods in this API\n"
+ "are only used during significant setup events in a Rapture environment.]\n" + "api(Admin) {\n"
+ " [This method restores a user that has been deleted]\n" + " @entitle=/admin/main\n"
+ " @public Boolean restoreUser(String userName);\n" + "}\n" + "[A return value from a native query]\n"
+ "type RaptureQueryResult(@package=rapture.common) {\n" + " List(JsonContent) rows;\n" + "}\n");
TLexer lexer = new TLexer(input);
TokenStream tokenInputStream = new CommonTokenStream(lexer);
TParser parser = new TParser(tokenInputStream);
hmxdef_return returnVal = parser.hmxdef();
System.out.println("Done " + returnVal.getTree().toStringTree());
TreeNodeStream treeInput = new CommonTreeNodeStream(returnVal.getTree());
TTree walker = new TTree(treeInput);
walker.setTemplateLib(TemplateRepo.getSdkTemplates("Java"));
walker.sdkGen();
}
示例13: test5
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
@Test
public void test5() throws RecognitionException {
CharStream input = new ANTLRStringStream("sdk(alan)\n" + "version(0.0.1)\n" + "minVer(0.0.1)\n"
+ "[ The Admin API is used to manipulate and access the low level entities in Rapture. Typically the methods in this API\n"
+ "are only used during significant setup events in a Rapture environment.]\n" + "api(Admin) {\n"
+ " [This method restores a user that has been deleted]\n" + " @entitle=/admin/main\n"
+ " @public Boolean restoreUser(String userName);\n" + "}\n" + "[A return value from a native query]\n"
+ "type RaptureQueryResult(@package=rapture.common) {\n" + " List(JsonContent) rows;\n" + "}\n");
TLexer lexer = new TLexer(input);
TokenStream tokenInputStream = new CommonTokenStream(lexer);
TParser parser = new TParser(tokenInputStream);
hmxdef_return returnVal = parser.hmxdef();
System.out.println("Done " + returnVal.getTree().toStringTree());
TreeNodeStream treeInput = new CommonTreeNodeStream(returnVal.getTree());
TTree walker = new TTree(treeInput);
walker.setTemplateLib(TemplateRepo.getApiTemplates("Java"));
try {
walker.apiGen();
fail("This should have failed, sdk name is not expected but found");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("SDK Name"));
}
}
示例14: test7
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
@Test
public void test7() throws RecognitionException {
CharStream input = new ANTLRStringStream("version(1.1.0)\n" + "minVer(1.1.0)\n"
+ "[ The Admin API is used to manipulate and access the low level entities in Rapture. Typically the methods in this API\n"
+ "are only used during significant setup events in a Rapture environment.]\n" + "api(Admin) {\n"
+ " [This method restores a user that has been deleted]\n" + " @entitle=/admin/main\n"
+ " @public Boolean restoreUser(String userName);\n" + "}\n" + "[A return value from a native query]\n"
+ "@Storable(storagePath : {\"sys\", name}, separator=\".\")\n" +
"type RepoConfig (@package=rapture.common.model) {\n" +
" String name = \"test\";\n" +
" String config;\n" +
"}\n" +
"");
TLexer lexer = new TLexer(input);
TokenStream tokenInputStream = new CommonTokenStream(lexer);
TParser parser = new TParser(tokenInputStream);
hmxdef_return returnVal = parser.hmxdef();
System.out.println("Done " + returnVal.getTree().toStringTree());
TreeNodeStream treeInput = new CommonTreeNodeStream(returnVal.getTree());
TTree walker = new TTree(treeInput);
walker.setTemplateLib(TemplateRepo.getApiTemplates("Java"));
apiGen_return walkerResult = walker.apiGen();
System.out.println("Done, result=" + walkerResult.toString());
}
示例15: testBean
import org.antlr.runtime.tree.CommonTreeNodeStream; //導入依賴的package包/類
@Test
public void testBean() throws RecognitionException {
CharStream input = new ANTLRStringStream("version(1.1.0)\n" + "minVer(1.1.0)\n"
+ "[ The Admin API is used to manipulate and access the low level entities in Rapture. Typically the methods in this API\n"
+ "are only used during significant setup events in a Rapture environment.]\n" + "api(Admin) {\n"
+ " [This method restores a user that has been deleted]\n" + " @entitle=/admin/main\n"
+ " @public Boolean restoreUser(String userName);\n" + "}\n" +
"[A Graph node]\n" +
"@Bean\n" +
"type Node(@package=rapture.common.dp) {\n" +
" String nodeId; //this is not a URI, just a String id\n" +
" List<XFer> xferValues;\n" +
"}\n" +
"");
TLexer lexer = new TLexer(input);
TokenStream tokenInputStream = new CommonTokenStream(lexer);
TParser parser = new TParser(tokenInputStream);
hmxdef_return returnVal = parser.hmxdef();
System.out.println("Done " + returnVal.getTree().toStringTree());
TreeNodeStream treeInput = new CommonTreeNodeStream(returnVal.getTree());
TTree walker = new TTree(treeInput);
walker.setTemplateLib(TemplateRepo.getApiTemplates("Java"));
apiGen_return walkerResult = walker.apiGen();
System.out.println("Done, result=" + walkerResult.toString());
}