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

Reimplement the parser #225

Closed
16 tasks
IovoslavIovchev opened this issue Jan 18, 2020 · 2 comments
Closed
16 tasks

Reimplement the parser #225

IovoslavIovchev opened this issue Jan 18, 2020 · 2 comments
Assignees
Labels
parser Issues surrounding the parser

Comments

@IovoslavIovchev
Copy link
Contributor

In its current implementation, the parser works recursively, which is fine if you are doing simple expression parsing. But once you start parsing a long series of tokens, a stack overflow may occur (such is the case in #162).

What I propose is to start reimplementing the parser in small logical chunks. This includes:

  • eliminating recursive calls and making the parsing iterative
  • trying to keep the expressions as linear as possible (e.g. binary operators being represented in reverse polish notation, instead of a tree)

As I said, the work can be split into small chunks, such as:

  • var
  • let
  • const
  • return
  • functions
  • blocks
  • new
  • if, else if, else & ternary
  • loops
  • objects
  • arrays
  • switch
  • typeof
  • binary operators
  • unary operators
  • regular expressions

Note: this list might not be exhaustive

@jasonwilliams
Copy link
Member

Good to match up with https://tc39.es/ecma262/#sec-ecmascript-language-lexical-grammar

Good to support concurrent tokens coming through channel.

good to be broken out into functions for specific expressions.

@jasonwilliams
Copy link
Member

jasonwilliams commented Mar 31, 2020

@IovoslavIovchev whats the state of this issue now that the parser has been rebuilt?
There is conversation on how we break the parser up happening jasonwilliams#281 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Issues surrounding the parser
Projects
None yet
Development

No branches or pull requests

2 participants