diff options
Diffstat (limited to 'parser.lua')
-rw-r--r-- | parser.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/parser.lua b/parser.lua index 0cd2853..bfa7dd3 100644 --- a/parser.lua +++ b/parser.lua @@ -39,6 +39,17 @@ local function get_next_common(state, in_pos, token) if state[STATE] then local st = state[STATE] local rule = st[token] + do -- pre-hooks + local pos = -1 + local hook = st[pos] + while hook ~= nil do + if hook then + hook(state, token, rule) + end + pos = pos - 1 + hook = st[pos] + end + end transition = rule if transition == nil then transition = st[""] @@ -143,6 +154,10 @@ return { if not rule then local t = state[COLLECT] t[#t+1] = token + if t.coalesce and #t > t.coalesce then + t[1] = table.concat(t) + for i=2, #t do t[i] = nil end + end end end, } |