4 -- binders :: ast => name => occurences
5 -- unbound :: name => occurences
6 -- scope :: name => ast
8 local bound_id, unbound, cfg, scope = { }, { }, { scope={ } }, scope:new()
10 -- * id: identifier entering in scope
11 -- * ast: statement or expr carrying this id, on of:
12 -- Local, Localrec, Forin, Fornum, Function.
13 function cfg.binder (id, ast)
15 scope.current[id[1]] = ast
18 -- identifier occurence, not as a binder: reference this occurence
21 local binder = scope.current[id_name]
22 if binder then bound_id[id] = binder
24 local occ = scope.current[id_name]free_id[id_name]
25 if occ then table.insert (occ, id)
26 else free_id[id_name] = { id } end
30 function cfg.scope.down() scope:push() end
32 function cfg.scope.up() scope:pop() end
35 return bound_id, free_id