Skip to content

Remove dependency on pest and pest-ast.#7

Merged
peterhuene merged 3 commits intomainfrom
logos
Nov 7, 2023
Merged

Remove dependency on pest and pest-ast.#7
peterhuene merged 3 commits intomainfrom
logos

Conversation

@peterhuene
Copy link
Copy Markdown
Member

This PR removes the dependency on pest and pest-ast.

A custom lexer is now implemented using logos; this allows for easy parsing of doc comments at any point in the token stream.

The blackbox of pest-ast has been removed in favor of implementing a Parse and Peek trait on the AST types. AST types no longer have to mirror the pest grammar, so they have been simplified.

Top-level resource declarations have been removed from the grammar as they must appear inside of interface and world declarations.

bail! has been removed in parsing and resolution in favor of custom thiserror-derived error types.

Error reporting has been improved with more colors and removing redundant information.

No new tests were added; parsing test baselines have substantial changes as a result of the AST simplification.

Resolution failure test baselines have changed as a result of the error formatting changes, but the error messages themselves should remain the same.

This commit removes the dependency on `pest` and `pest-ast`.

A custom lexer is now implemented using `logos`; this allows for easy parsing
of doc comments at any point in the token stream.

The blackbox of `pest-ast` has been removed in favor of implementing a `Parse`
and `Peek` trait on the AST types. AST types no longer have to mirror the pest
grammar, so they have been simplified.

Top-level resource declarations have been removed from the grammar as they must
appear inside of interface and world declarations.

`bail!` has been removed in parsing and resolution in favor of custom
`thiserror`-derived error types.

Error reporting has been improved with more colors and removing redundant
information.

No new tests were added; parsing test baselines have substantial changes as a
result of the AST simplification.

Resolution failure test baselines have changed as a result of the error
formatting changes, but the error messages themselves should remain the same.
@peterhuene
Copy link
Copy Markdown
Member Author

While this is a substantial change, a large chunk of the changes come from updated test baselines.

Just use an array of `Token` now that tokens are only a single byte (they used
to be much larger before a previous refactoring).

Additionally, add test coverage for multiple expected tokens errors.

Fix a bug where a failed lookahead used the current token position instead of
the last position in the source where the next token is EOI.
Copy link
Copy Markdown
Collaborator

@fibonacci1729 fibonacci1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is much easier to understand than pest!!

@peterhuene peterhuene merged commit 205dc16 into main Nov 7, 2023
@peterhuene peterhuene deleted the logos branch November 7, 2023 23:29
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