Merged
Conversation
Closed
Implemented parsing of the unit type '()' as an empty tuple in the parser and added corresponding handling in the type checker. Refactored CheckedAst and related code to use 'ty' and 'ret_ty' fields for consistency. Added tests for unit parsing and invalid function calls involving unit type.
Refactors the record field parsing logic to use `parse_expr(COMMA_PREC)` instead of `parse_top_expr` for value parsing, ensuring correct precedence handling. Also updates token consumption and tracking of the last token's line info for better error reporting and parsing accuracy.
Removed TokenKind::Newline from the is_terminator check in the lexer. Updated parser tests to unwrap the result earlier and add debugging output for unexpected cases.
The specialize module has been moved from core/src/parser to core/src/type_checker, and related imports and module declarations have been updated accordingly. Intrinsic operator definitions and constants were relocated from op.rs to parser.rs. Type handling logic was removed from the parser, and function signatures were updated to reflect these changes.
Moved parser specialization functions (assignment, member access, binding patterns, etc.) from type_checker/specialize.rs to a new parser/utils.rs module. Updated parser and type checker code to use the new utils module, fixed a typo in the AST enum (MemderAccess -> MemberAccess), and removed unused type registration in stdlib/init.rs. This improves code organization and separation of concerns between parsing and type checking.
Renamed TokenKind to Token and updated all references in lexer, parser, and tests. Simplified AST assignment and type handling, removed LiteralType and annotation from Assignment, and updated related parser logic and tests. Moved parser/utils.rs into parser.rs as a module. These changes improve code clarity and unify token and AST representations.
Introduces a new is_newline method to the Token implementation for easier checking of newline tokens. Also resets VSCode color customizations in settings.json.
Refactored the binding pattern conversion logic from parser.rs to pattern.rs by implementing BindPattern::from_expr and LiteralPattern::from_value. This improves code organization and encapsulation of pattern-related functionality. Also updated references to use the new methods and fixed a typo in a comment.
Commented out handling of Ast::LiteralType in type checker and specialize modules. Assignment type annotations are now ignored, and related code paths for literal type expressions are disabled to simplify type checking logic.
Member
Author
|
This PR has grown into much more than just functions, but also a massive refactoring of the whole compiler. So, this must now be merged into main for new features to be started in parallel. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and refactorings to the interpreter, type checker, and CLI components. The most significant changes include enhanced assignment evaluation with pattern matching, updates to function and lambda handling, improved test coverage and correctness, and minor CLI and error reporting tweaks.
Interpreter and Pattern Matching Improvements
BindPattern), enabling assignments to tuples, records, lists, wildcards, literals, and rest patterns through the neweval_assignmentfunction incore/src/interpreter/eval.rs. This improves language expressiveness and correctness for pattern-based assignments.Function and Lambda Handling
Lambdaandret_tyinstead of previous function structures, aligning with changes in AST and type representations. This improves consistency and clarity in function handling. [1] [2] [3] [4]Test Coverage and Correctness
stdlib) for module parsing, ensuring all tests run with the correct environment and type definitions. [1] [2] [3] [4] [5] [6] [7] [8] [9]Type and Value Representation
Hashtrait derivations toUnsignedInteger,SignedInteger, andRecordKeyenums, improving compatibility with hash-based collections and supporting future features. [1] [2] [3]RecordKeyand adjusted formatting accordingly.CLI and Error Reporting Tweaks
These changes collectively enhance the language's pattern matching capabilities, improve function/lambda consistency, strengthen test reliability, and polish the CLI and error handling experience.This pull request introduces several updates and improvements across multiple components of the codebase, focusing on enhanced debugging, code refactoring, and feature modifications. Key changes include adding debug logging, refactoring assignment evaluation, updating lexer functionality, and removing the
Commatoken type.Debugging Enhancements
eval_allto log the number and content of expressions being evaluated.eval_exprto log expressions usingprint_exprinstead ofprint_sexprfor improved clarity.Refactoring and Code Simplification
eval_assignmentfunction to handle assignment expressions more robustly, supporting complex patterns like function definition sugar, destructuring to tuples, records, and lists.CheckedAst::FunctionDefwithCheckedAst::Lambdafor consistency in function definitions.print_error_report.Lexer Improvements
Lexerinstances from various sources (e.g., strings, files, stdin).Commatoken type with an operator token (Op(",".to_string())) for consistency in token handling [1] [2].Feature Updates
UnsignedInteger,SignedInteger, andRecordKeyenums with theHashtrait to support their use as keys in hash-based collections [1] [2].Testing Adjustments
Commatoken and the introduction ofeval_assignmentandCheckedAst::Lambda[1] [2].These changes collectively enhance the maintainability, functionality, and debugging capabilities of the codebase, aligning with best practices for extensibility and clarity.