本文整理汇总了Java中com.romanenco.cfrm.llparser.LLParser类的典型用法代码示例。如果您正苦于以下问题:Java LLParser类的具体用法?Java LLParser怎么用?Java LLParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LLParser类属于com.romanenco.cfrm.llparser包,在下文中一共展示了LLParser类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import com.romanenco.cfrm.llparser.LLParser; //导入依赖的package包/类
@Test
public void test() {
final ABGrammar grammar = new ABGrammar();
final Lexer lexer = new RegLexer(grammar);
final Parser parser = new LLParser(grammar);
final ParsingTreeNode parsingTree = parser.parse(lexer.tokenize("1+2"));
Assert.assertNotNull(parsingTree);
final ASTBuilder builder = new ASTBuilder();
builder.addSDTHandler(grammar.getProduction("SUM -> int + int"), new SumVisitor());
builder.build(parsingTree);
final Object attribute = parsingTree.getAttribute(SUM_ATTR);
Assert.assertNotNull(attribute);
Assert.assertEquals(3, attribute);
}
示例2: main
import com.romanenco.cfrm.llparser.LLParser; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
final Grammar dragonGrammar = new DragonLLGrammar();
final Lexer lexer = new RegLexer(dragonGrammar);
final Parser parser = new LLParser(dragonGrammar);
final BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in, Charset.defaultCharset()));
while (true) {
print("Enter expression: ");
final String input = reader.readLine();
if ((input == null)||input.isEmpty()) {
break;
}
processInput(input, lexer, parser);
}
}
示例3: Functionly
import com.romanenco.cfrm.llparser.LLParser; //导入依赖的package包/类
public Functionly(boolean silentRun) {
final FunctionlyGrammar grammar = new FunctionlyGrammar();
lexer = new RegLexer(grammar);
parser = new LLParser(grammar);
builder = new ASTBuilder();
AttributeHandlers.initForBuilder(grammar, builder);
semanticChecker = new SemanticVisitor();
if (silentRun) {
printer = new SilentPrinter();
} else {
printer = new FilePrinter();
}
}
示例4: getParser
import com.romanenco.cfrm.llparser.LLParser; //导入依赖的package包/类
private Parser getParser(Grammar grammar) {
return new LLParser(grammar);
}
示例5: parseSource
import com.romanenco.cfrm.llparser.LLParser; //导入依赖的package包/类
public static ParsingTreeNode parseSource(String input) {
final Lexer lexer = new RegLexer(GRAMMAR);
final Parser parser = new LLParser(GRAMMAR);
return parser.parse(lexer.tokenize(input));
}