local Column = {} --Assume methods
local State = {}
local Production = {}
function predict()
--Given term, find all terms with
--Same name, insert into current
--Column
end
function scan()
--If next symbol is non terminal
--Advance current state and
--Insert into next Column
--Insert tokens that are expecting the current token, next
end
function complete()
--Given completed term, find
--all terms previously indexing
--that term, add advanced term to current
--Column
end
while true do
local token = self.lexer.next
local Column = Column.new(...)
for state in Column do
if state.complete then
complete(state)
else
if state.symbols[state.dot] == n then
predictor(state)
else
scan(state)
end
end
end
end
Vocab:
Non terminal → Terms/ Defined Production rules: (Production) → Symbols
Terminal → Literals, RegExps, Tokens: Production → [(Token), (Literal), Non terminal, (Regexp)]
Column → Group of states
State → Current state of a production
Production → Defined non-terminal/rule
Pseudo code