Skip to content

Add parser values#21

Merged
dhedey merged 3 commits intodevelopfrom
parser-value
Nov 29, 2025
Merged

Add parser values#21
dhedey merged 3 commits intodevelopfrom
parser-value

Conversation

@dhedey
Copy link
Owner

@dhedey dhedey commented Nov 29, 2025

No description provided.

@dhedey dhedey requested a review from Copilot November 29, 2025 00:45
@dhedey dhedey merged commit c62e917 into develop Nov 29, 2025
13 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 Parser as 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() {
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

Typo in function name: "transfoming" should be "transforming"

Suggested change
fn test_transfoming_compilation_failures() {
fn test_transforming_compilation_failures() {

Copilot uses AI. Check for mistakes.
ValueKind::Stream => false,
ValueKind::Range => true,
ValueKind::Iterator => false,
// A parser is a handle, to can be cloned transparently.
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

Typo in comment: "to can be cloned" should be "so can be cloned"

Suggested change
// A parser is a handle, to can be cloned transparently.
// A parser is a handle, so can be cloned transparently.

Copilot uses AI. Check for mistakes.
@@ -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\") }`.")
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

Typo in error message: "propogate" should be "propagate"

Suggested change
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\") }`.")

Copilot uses AI. Check for mistakes.
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.

1 participant