Skip to content

Conversation

@stringhandler
Copy link

@stringhandler stringhandler commented Feb 9, 2026

Built on #185, so that would need to be merged first

gerau and others added 10 commits February 4, 2026 15:51
The lexer parses incoming code into tokens, which makes it simpler to
process using `chumsky`.
This commit introduce multiple changes, because it full rewrite of
parsing and error

Changes in `error.rs`:
- Change `Span` to use byte offsets in place of old `Position`
- Change `Display` function to calculate line and columns with inner
function
- Change `RichError` implementation to use new `Span` structure
- Implement `chumsky` error traits, so it can be used in error reporting
  of parsers
- add `expected..found` error
- remove unused `cmr` function for `Span` and unused error messages

Changes in `parse.rs`:
- Fully rewrite `pest` parsers to `chumsky` parsers.
- Change `ParseFromStr` trait to use this change.
This adds `ParseFromStrWithErrors`, which would take `ErrorCollector`
and return an `Option` of AST.
Also changes `TemplateProgram` to use new trait with collector
This adds tests to ensure that the compiler using the `chumsky` parser
produces the same Simplicity program as when using the `pest` parser for
the default examples.

The programs were compiled using an old `simc` version with debug
symbols into .json files, and located in `test-data/` folder.
We are no longer need this as we are no longer using the `pest` parser.
@gerau
Copy link
Contributor

gerau commented Feb 9, 2026

Could we make the else expression optional? Maybe we could evaluate a missing else as the unit type (), so this would prevent conflicts when using an if statement in an assignment, for example.

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

Successfully merging this pull request may close these issues.

2 participants