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

Feature: Extract namespace/symbol handling from parser to allow forward references #15

Open
mmastrac opened this issue Dec 7, 2022 · 0 comments

Comments

@mmastrac
Copy link
Owner

mmastrac commented Dec 7, 2022

The namespace and symbol management in the current parser is very ad-hoc. We have multiple symbols we need to resolve, each it their own ad-hoc namespaces:

  1. Builtins
  2. Modules/module symbols
  3. User vars/consts
  4. User functions
  5. Additional built-in functions

We should extract all of these into a single place for managing namespaces. As each of these comes along with some "baggage" (ie: modules have a module pointer, vars have a slot index, etc), we need to stash some context information alongside the symbol name.

In addition to simplifying symbol lookup:

  • we can also implement block scoping for variables, allowing users to define var and const wherever they find it most appropriate to do so, rather than at the top of the function.
  • we can more easily run the parser twice over the source code and pick up function definitions later in the file as forward references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant