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

Scoping refactor #12

Closed
Botffy opened this issue Oct 12, 2019 · 0 comments
Closed

Scoping refactor #12

Botffy opened this issue Oct 12, 2019 · 0 comments

Comments

@Botffy
Copy link
Owner

Botffy commented Oct 12, 2019

Currently we maintain a LeBlanc-Cook symbol table to keep track of lexical scoping. However, the language will actually only have two scopes: local and global. Only functions and procedures will have their own lexical scope. Also, it was decided that name shadowing shall not be allowed.

Accordingly, the current implementation is overly complex, and should be simplified. Greatly.

Throw the LeBlanc-Cook symbol table away entirely, and maintain only two maps: one for the global scope, and one for the currently active local scope, if there is one. When declaring a name, Context should check availabilty in the global scope, then in the local scope. If the name is still free, the name is declared in local scope, if there is one, otherwise in the global scope. All other cases shall result in errors.

This is also a good possibility to clean up Context a bit, especially wrt the declaration functions which are in general inconsistent.

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