本文整理匯總了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));
}