equal
deleted
inserted
replaced
74 |
74 |
75 (*store chain if it does not already exist*) |
75 (*store chain if it does not already exist*) |
76 val (new_chain, chains') = case chain_from of NONE => (NONE, chains) | SOME from => |
76 val (new_chain, chains') = case chain_from of NONE => (NONE, chains) | SOME from => |
77 let val old_tos = these (AList.lookup (op =) chains from) in |
77 let val old_tos = these (AList.lookup (op =) chains from) in |
78 if member (op =) old_tos lhs then (NONE, chains) |
78 if member (op =) old_tos lhs then (NONE, chains) |
79 else (SOME from, AList.update (op =) (from, lhs ins old_tos) chains) |
79 else (SOME from, AList.update (op =) (from, insert (op =) lhs old_tos) chains) |
80 end; |
80 end; |
81 |
81 |
82 (*propagate new chain in lookahead and lambda lists; |
82 (*propagate new chain in lookahead and lambda lists; |
83 added_starts is used later to associate existing |
83 added_starts is used later to associate existing |
84 productions with new starting tokens*) |
84 productions with new starting tokens*) |
334 let |
334 let |
335 val tk_prods = (these o AList.lookup (op =) nt_prods) (SOME tk); |
335 val tk_prods = (these o AList.lookup (op =) nt_prods) (SOME tk); |
336 |
336 |
337 val tk_prods' = |
337 val tk_prods' = |
338 if not lambda then p :: tk_prods |
338 if not lambda then p :: tk_prods |
339 else p ins tk_prods; |
339 else insert (op =) p tk_prods; |
340 (*if production depends on lambda NT we |
340 (*if production depends on lambda NT we |
341 have to look for duplicates*) |
341 have to look for duplicates*) |
342 in |
342 in |
343 nt_prods |
343 nt_prods |
344 |> AList.update (op =) (SOME tk, tk_prods') |
344 |> AList.update (op =) (SOME tk, tk_prods') |