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

Replace lexer with external impl #4655

Closed
michaeljklein opened this issue Mar 27, 2024 · 0 comments · Fixed by #4656
Closed

Replace lexer with external impl #4655

michaeljklein opened this issue Mar 27, 2024 · 0 comments · Fixed by #4656
Assignees

Comments

@michaeljklein
Copy link
Contributor

No description provided.

@Savio-Sou Savio-Sou added this to Noir Mar 21, 2024
@michaeljklein michaeljklein self-assigned this Mar 27, 2024
@michaeljklein michaeljklein converted this from a draft issue Mar 27, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 15, 2024
# Description

## Problem\*

Resolves #4655

## Summary\*

NOTE: I've added `CC0-1.0` to `deny.toml`. Its purpose is to release
work to the public domain.

### TL;DR

[`lalrpop`](https://github.com/lalrpop/lalrpop) generates a part of a
parser for our grammar and the `noirc_frontend/experimental_parser`
feature can be used to run it alongside the existing parser: when the
existing `chumsky` parser succeeds, the `lalrpop` parser is run and the
results compared.

### Detail

Run with `cargo test --features=noirc_frontend/experimental_parser`

Originally investigating lalrpop for _lexing_, now for _parsing_:
- lalrpop doesn't handle string literals with escape characters well
  + this is due to how LR(1) parsers handle context
+ I realized this after discovering that all of the larger examples
(solidity, python, etc) use the lexer to handle strings
- pivoted this PR to use our existing lexer
+ this entailed a version of `Token` without `String` so that e.g.
`Token::Str("hi")` can be matched on. (which is essential to lalrpop)
  + currently using a shim to minimize impact to the rest of the code:
    * conversion to/from `SpannedToken`
* lexing the whole input into a `Vec` and using `iter()` to feed token
lifetimes to lalrpop
- current state:
+ WIP parsing use statements (missing support for recursive statements)
  + unit tests for use statements test lalrpop parser
+ feature flag `experimental_parser` enables running the experimental
parser on every part of the AST that's successfully parsed with the
existing chomsky parser

Changes:
- Now rejecting whitespace other than `\t \n\r`

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: Maxim Vezenov <mvezenov@gmail.com>
Co-authored-by: Tom French <tom@tomfren.ch>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant