本文整理汇总了Java中org.antlr.stringtemplate.language.AngleBracketTemplateLexer类的典型用法代码示例。如果您正苦于以下问题:Java AngleBracketTemplateLexer类的具体用法?Java AngleBracketTemplateLexer怎么用?Java AngleBracketTemplateLexer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AngleBracketTemplateLexer类属于org.antlr.stringtemplate.language包,在下文中一共展示了AngleBracketTemplateLexer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TemplateTypeBuilder
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public TemplateTypeBuilder(TypeSpecification spec) {
CommonGroupLoader loader = new CommonGroupLoader("org/lemurproject/galago/tupleflow/templates", null);
StringTemplateGroup.registerGroupLoader(loader);
StringTemplateGroup.registerDefaultLexer(AngleBracketTemplateLexer.class);
this.template = StringTemplateGroup.loadGroup("GalagoType");
this.typeName = spec.getTypeName();
this.typePackage = spec.getPackageName();
this.typeFields = new ArrayList<Field>();
this.typeOrders = new ArrayList<OrderSpec>();
for (FieldSpecification fieldSpec : spec.getFields()) {
Field field = new Field(fieldSpec.getType(), fieldSpec.getName());
typeFields.add(field);
}
for (OrderSpecification orderSpec : spec.getOrders()) {
OrderSpec order = new OrderSpec(orderSpec, typeFields);
typeOrders.add(order);
}
}
示例2: testEscapedLessThanInAction
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testEscapedLessThanInAction() throws Exception {
Grammar g = new Grammar();
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
String action = "i<3; '<xmltag>'";
ActionTranslatorLexer translator = new ActionTranslatorLexer(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),0);
String expecting = action;
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, "<action>");
actionST.setAttribute("action", rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
}
示例3: Grammar
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testEscaped$InAction() throws Exception {
String action = "int \\$n; \"\\$in string\\$\"";
String expecting = "int $n; \"$in string$\"";
Grammar g = new Grammar(
"parser grammar t;\n"+
"@members {"+action+"}\n"+
"a[User u, int i]\n" +
" : {"+action+"}\n" +
" ;");
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer(); // forces load of templates
ActionTranslatorLexer translator =
new ActionTranslatorLexer(generator,
"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),0);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
}
示例4: testFullyQualifiedRefToCurrentRuleParameter
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testFullyQualifiedRefToCurrentRuleParameter() throws Exception {
String action = "$a.i;";
String expecting = "i;";
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Grammar g = new Grammar(
"grammar t;\n"+
"a[int i]: {"+action+"}\n" +
" ;\n");
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer(); // forces load of templates
ActionTranslatorLexer translator = new ActionTranslatorLexer(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),1);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
}
示例5: testFullyQualifiedRefToCurrentRuleRetVal
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testFullyQualifiedRefToCurrentRuleRetVal() throws Exception {
String action = "$a.i;";
String expecting = "retval.i;";
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Grammar g = new Grammar(
"grammar t;\n"+
"a returns [int i, int j]: {"+action+"}\n" +
" ;\n");
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer(); // forces load of templates
ActionTranslatorLexer translator = new ActionTranslatorLexer(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),1);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
}
示例6: testSetFullyQualifiedRefToCurrentRuleRetVal
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testSetFullyQualifiedRefToCurrentRuleRetVal() throws Exception {
String action = "$a.i = 1;";
String expecting = "retval.i = 1;";
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Grammar g = new Grammar(
"grammar t;\n"+
"a returns [int i, int j]: {"+action+"}\n" +
" ;\n");
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer(); // forces load of templates
ActionTranslatorLexer translator = new ActionTranslatorLexer(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),1);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
}
示例7: testTokenRefTreeProperty
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testTokenRefTreeProperty() throws Exception {
String action = "$ID.tree;";
String expecting = "ID1_tree;";
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Grammar g = new Grammar(
"grammar t;\n"+
"a : ID {"+action+"} ;" +
"ID : 'a';\n");
Tool antlr = newTool();
antlr.setOutputDirectory(null); // write to /dev/null
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer();
ActionTranslatorLexer translator = new ActionTranslatorLexer(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),1);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
}
示例8: TemplateTypeBuilder
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public TemplateTypeBuilder(TypeSpecification spec) {
CommonGroupLoader loader = new CommonGroupLoader("org/galagosearch/tupleflow/templates", null);
StringTemplateGroup.registerGroupLoader(loader);
StringTemplateGroup.registerDefaultLexer(AngleBracketTemplateLexer.class);
this.template = StringTemplateGroup.loadGroup("GalagoType");
this.typeName = spec.getTypeName();
this.typePackage = spec.getPackageName();
this.typeFields = new ArrayList<Field>();
this.typeOrders = new ArrayList<OrderSpec>();
for (FieldSpecification fieldSpec : spec.getFields()) {
Field field = new Field(fieldSpec.getType(), fieldSpec.getName());
typeFields.add(field);
}
for (OrderSpecification orderSpec : spec.getOrders()) {
OrderSpec order = new OrderSpec(orderSpec, typeFields);
typeOrders.add(order);
}
}
示例9: compile
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void compile() throws IOException{
String junitFileName;
if ( grammarInfo.getTreeGrammarName()!=null ) {
junitFileName = "Test"+grammarInfo.getTreeGrammarName();
}
else {
junitFileName = "Test"+grammarInfo.getGrammarName();
}
String lexerName = grammarInfo.getGrammarName()+"Lexer";
String parserName = grammarInfo.getGrammarName()+"Parser";
StringTemplateGroupLoader loader = new CommonGroupLoader("org/antlr/gunit", null);
StringTemplateGroup.registerGroupLoader(loader);
StringTemplateGroup.registerDefaultLexer(AngleBracketTemplateLexer.class);
StringBuffer buf = compileToBuffer(junitFileName, lexerName, parserName);
writeTestFile(".", junitFileName+".java", buf.toString());
}
示例10: testEscapedLessThanInAction
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testEscapedLessThanInAction() throws Exception {
Grammar g = new Grammar();
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
String action = "i<3; '<xmltag>'";
ActionTranslator translator = new ActionTranslator(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),0);
String expecting = action;
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, "<action>");
actionST.setAttribute("action", rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
}
示例11: Grammar
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testEscaped$InAction() throws Exception {
String action = "int \\$n; \"\\$in string\\$\"";
String expecting = "int $n; \"$in string$\"";
Grammar g = new Grammar(
"parser grammar t;\n"+
"@members {"+action+"}\n"+
"a[User u, int i]\n" +
" : {"+action+"}\n" +
" ;");
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer(); // forces load of templates
ActionTranslator translator =
new ActionTranslator(generator,
"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),0);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
}
示例12: testFullyQualifiedRefToCurrentRuleParameter
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testFullyQualifiedRefToCurrentRuleParameter() throws Exception {
String action = "$a.i;";
String expecting = "i;";
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Grammar g = new Grammar(
"grammar t;\n"+
"a[int i]: {"+action+"}\n" +
" ;\n");
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer(); // forces load of templates
ActionTranslator translator = new ActionTranslator(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),1);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
}
示例13: testFullyQualifiedRefToCurrentRuleRetVal
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testFullyQualifiedRefToCurrentRuleRetVal() throws Exception {
String action = "$a.i;";
String expecting = "retval.i;";
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Grammar g = new Grammar(
"grammar t;\n"+
"a returns [int i, int j]: {"+action+"}\n" +
" ;\n");
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer(); // forces load of templates
ActionTranslator translator = new ActionTranslator(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),1);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
}
示例14: testSetFullyQualifiedRefToCurrentRuleRetVal
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testSetFullyQualifiedRefToCurrentRuleRetVal() throws Exception {
String action = "$a.i = 1;";
String expecting = "retval.i = 1;";
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Grammar g = new Grammar(
"grammar t;\n"+
"a returns [int i, int j]: {"+action+"}\n" +
" ;\n");
Tool antlr = newTool();
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer(); // forces load of templates
ActionTranslator translator = new ActionTranslator(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),1);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
}
示例15: testTokenRefTreeProperty
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer; //导入依赖的package包/类
public void testTokenRefTreeProperty() throws Exception {
String action = "$ID.tree;";
String expecting = "ID1_tree;";
ErrorQueue equeue = new ErrorQueue();
ErrorManager.setErrorListener(equeue);
Grammar g = new Grammar(
"grammar t;\n"+
"a : ID {"+action+"} ;" +
"ID : 'a';\n");
Tool antlr = newTool();
antlr.setOutputDirectory(null); // write to /dev/null
CodeGenerator generator = new CodeGenerator(antlr, g, "Java");
g.setCodeGenerator(generator);
generator.genRecognizer();
ActionTranslator translator = new ActionTranslator(generator,"a",
new antlr.CommonToken(ANTLRParser.ACTION,action),1);
String rawTranslation =
translator.translate();
StringTemplateGroup templates =
new StringTemplateGroup(".", AngleBracketTemplateLexer.class);
StringTemplate actionST = new StringTemplate(templates, rawTranslation);
String found = actionST.toString();
assertEquals(expecting, found);
}