HeyPuter / phoenix

🔥 Puter's pure-javascript shell
https://puter.com/app/terminal
GNU Affero General Public License v3.0
90 stars 15 forks source link

WIP: New parser #67

Closed AtkinsSJ closed 5 months ago

AtkinsSJ commented 6 months ago

Current status:

Questions:

KernelDeimos commented 6 months ago

The FOAM framework's combinator parser uses a concept called "actions"; an action is a function that's named after a symbol in the grammar, and it transforms the result of that symbol (the current return value of symbol(<symbol's name>)) before it gets returned.

In the face of the issues you're describing, this approach seems to solve everything. There's one little thing about it I didn't like though; these transformations coupled with the grammar, making it difficult for example to choose between outputs such as: AST, high-level AST ("abstract logic tree"), CST. If we can implement these in a way where actions are de-coupled from the grammar I think that might be really flexible.

Regarding $discard, I there are two options: Sequence, Repeat, etc all need to check for it; vs parsers always return arrays (and an abstract layer removes items with $discard)

KernelDeimos commented 5 months ago

Merging now so it doesn't get lost - merging into monorepo-prep-2