ll1parser new facctory method
This commit is contained in:
@ -5,6 +5,8 @@ import parser.grammar.LL1GrammarAnalyzer;
|
||||
import util.ast.AST;
|
||||
import util.ast.Node;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
@ -17,6 +19,10 @@ public class LL1Parser {
|
||||
this.parsetable = parsetable;
|
||||
}
|
||||
|
||||
public static LL1Parser fromGrammar(Path path) throws IOException {
|
||||
return LL1Parser.fromGrammar(Grammar.fromFile(path));
|
||||
}
|
||||
|
||||
public static LL1Parser fromGrammar(Grammar grammar) {
|
||||
LL1GrammarAnalyzer analyzer = new LL1GrammarAnalyzer(grammar);
|
||||
return new LL1Parser(analyzer.getTable());
|
||||
|
Reference in New Issue
Block a user