Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the symbol table to store actual definitions #19

Open
c3d opened this issue Feb 7, 2020 · 0 comments
Open

Rework the symbol table to store actual definitions #19

c3d opened this issue Feb 7, 2020 · 0 comments

Comments

@c3d
Copy link
Owner

c3d commented Feb 7, 2020

Currently, the symbol table in the compiler is implemented as an XL prefix, renamed as Scope, containing definitions that are stored as infix.

The addition of a symbol is done by inserting them in a somewhat nonsensical name for a rewrite and its children. This means that printing a symbol table as a regular tree gives a somewhat unexpected result.

(lldb) xl symbols
nil tell host:text, code:tree as integer is builtin tell
( invoke host:text, code:tree as tree is builtin invoke
nil; reply code:tree as integer is builtin reply
( listen_forking as integer is builtin listen_forking
nil; nil); listen_hook hook:tree as tree is builtin listen_hook
( listen_received is listen_received
nil; nil); nil); ask host:text, code:tree as tree is builtin ask
( listen_on port:integer as integer is builtin listen_on
nil; nil); listen as integer is builtin listen
nil; nil

This is for an entry that really contains the following definitions:

xl symbols.pointer
tell host:text, code:tree as integer is builtin tell
invoke host:text, code:tree as tree is builtin invoke
reply code:tree as integer is builtin reply
listen_forking as integer is builtin listen_forking
listen_hook hook:tree as tree is builtin listen_hook
listen_received is listen_received
ask host:text, code:tree as tree is builtin ask
listen_on port:integer as integer is builtin listen_on
listen as integer is builtin listen

The lookup is O(log(N)) by selecting which branch to follow using a tree hash.

I believe that it's possible to store the entries without the nil, simply balancing between left and right as you need.

c3d added a commit that referenced this issue Feb 15, 2020
…propriate

Using the semantic names clarifies the intent. Also it may make it easier
to perform some improvements related to GitHub issue #19.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant