A simple (naive) LL(1) parser in Python.
- You can send pull requests, I'd appreciate.
- The first parameter receives the start symbol, the second receives the grammar:
parser = PredictiveParser("S", {
# Each nonterminal contains a list of productions:
# S -> hello
"S": [["hello"]]
})
- Empty productions are represented by [""]:
parser = PredictiveParser("S", {
# S -> hello T
"S": [["hello", "T"]],
# T -> + | hello | ε
"T": [["+"], ["hello"], [""]]
})
- A complete usage is found in examples.