forked from GitHub/gf-core
fix the tree extractor in the incremental parser to check for cyclic charts and coercion rules.
This commit is contained in:
@@ -93,13 +93,16 @@ extractExps (State pinfo chart items) start = exps
|
|||||||
let (FRule fn _ args cat lins) = allRules pinfo ! ruleid
|
let (FRule fn _ args cat lins) = allRules pinfo ! ruleid
|
||||||
lbl <- indices lins
|
lbl <- indices lins
|
||||||
fid <- Map.lookup (PK c lbl 0) (passive st)
|
fid <- Map.lookup (PK c lbl 0) (passive st)
|
||||||
go fid
|
go Set.empty fid
|
||||||
|
|
||||||
go fid = do
|
go rec fid
|
||||||
set <- IntMap.lookup fid (forest st)
|
| Set.member fid rec = mzero
|
||||||
|
| otherwise = do set <- IntMap.lookup fid (forest st)
|
||||||
Passive ruleid args <- Set.toList set
|
Passive ruleid args <- Set.toList set
|
||||||
let (FRule fn _ _ cat lins) = allRules pinfo ! ruleid
|
let (FRule fn _ _ cat lins) = allRules pinfo ! ruleid
|
||||||
args <- mapM go args
|
if fn == wildCId
|
||||||
|
then go (Set.insert fid rec) (head args)
|
||||||
|
else do args <- mapM (go (Set.insert fid rec)) args
|
||||||
return (EApp fn args)
|
return (EApp fn args)
|
||||||
|
|
||||||
process fn !rules [] acc_chart = acc_chart
|
process fn !rules [] acc_chart = acc_chart
|
||||||
|
|||||||
Reference in New Issue
Block a user