Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Parser value type to enable programmatic parsing of token streams. The implementation uses a handle-based system with SlotMap for managing parse contexts, replacing the previous stack-only approach.
Key changes:
- Adds
Parseras a new value kind with methods for parsing identifiers, literals, punctuation, and token trees - Implements
parse X => |Y| { }expression syntax for creating parser scopes - Migrates from stack-based to handle-based parser management using SlotMap for better lifetime safety
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/expressions/parser.rs | New file implementing ParserExpression with parsing methods (ident, punct, literal, etc.) |
| src/expressions/control_flow.rs | Adds ParseExpression struct implementing the parse => |input| {} syntax |
| src/interpretation/input_handler.rs | Refactored to use SlotMap instead of Vec for managing parse stacks |
| src/interpretation/interpreter.rs | Updated start_parse to return ParserHandle and accept handle parameter in closure |
| src/expressions/value.rs | Adds Parser variant to ExpressionValue enum with cloneable handle semantics |
| src/misc/keywords.rs | Adds "parse" as a new keyword |
| src/expressions/expression_parsing.rs | Integrates ParseExpression into expression parser with improved error message |
| src/expressions/type_resolution/interface_macros.rs | Adds [ignore_type_assertion] attribute for methods with complex return types |
| src/extensions/errors_and_spans.rs | Removes wrapper methods start() and end(), uses direct field access instead |
| tests/parsing.rs | New test file for parser functionality |
| tests/literal.rs | Adds tests for to_literal().to_debug_string() round-tripping |
| Cargo.toml | Adds slotmap dependency for handle-based parser management |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| #[test] | ||
| #[cfg_attr(miri, ignore = "incompatible with miri")] | ||
| fn test_transfoming_compilation_failures() { |
There was a problem hiding this comment.
Typo in function name: "transfoming" should be "transforming"
| fn test_transfoming_compilation_failures() { | |
| fn test_transforming_compilation_failures() { |
| ValueKind::Stream => false, | ||
| ValueKind::Range => true, | ||
| ValueKind::Iterator => false, | ||
| // A parser is a handle, to can be cloned transparently. |
There was a problem hiding this comment.
Typo in comment: "to can be cloned" should be "so can be cloned"
| // A parser is a handle, to can be cloned transparently. | |
| // A parser is a handle, so can be cloned transparently. |
| @@ -548,3 +548,75 @@ impl AttemptExpression { | |||
| self.braces.control_flow_err("No attempt arm ran successfully. You may wish to add a fallback arm `{} => { None }` to ignore the error or to propogate a better message: `{} => { %[<tokens for error span>].error(\"Error message\") }`.") | |||
There was a problem hiding this comment.
Typo in error message: "propogate" should be "propagate"
| self.braces.control_flow_err("No attempt arm ran successfully. You may wish to add a fallback arm `{} => { None }` to ignore the error or to propogate a better message: `{} => { %[<tokens for error span>].error(\"Error message\") }`.") | |
| self.braces.control_flow_err("No attempt arm ran successfully. You may wish to add a fallback arm `{} => { None }` to ignore the error or to propagate a better message: `{} => { %[<tokens for error span>].error(\"Error message\") }`.") |
No description provided.