Skip to content

Conversation

WilliamRagstad
Copy link
Member

@WilliamRagstad WilliamRagstad commented Jul 25, 2025

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 Comma token type.

Debugging Enhancements

  • Added detailed debug logging in eval_all to log the number and content of expressions being evaluated.
  • Updated eval_expr to log expressions using print_expr instead of print_sexpr for improved clarity.

Refactoring and Code Simplification

  • Introduced the eval_assignment function to handle assignment expressions more robustly, supporting complex patterns like function definition sugar, destructuring to tuples, records, and lists.
  • Replaced CheckedAst::FunctionDef with CheckedAst::Lambda for consistency in function definitions.
  • Removed redundant code for handling end-of-file error labels in print_error_report.

Lexer Improvements

  • Added factory functions for creating Lexer instances from various sources (e.g., strings, files, stdin).
  • Replaced the Comma token type with an operator token (Op(",".to_string())) for consistency in token handling [1] [2].

Feature Updates

  • Enhanced UnsignedInteger, SignedInteger, and RecordKey enums with the Hash trait to support their use as keys in hash-based collections [1] [2].

Testing Adjustments

  • Updated tests to reflect the removal of the Comma token and the introduction of eval_assignment and CheckedAst::Lambda [1] [2].

These changes collectively enhance the maintainability, functionality, and debugging capabilities of the codebase, aligning with best practices for extensibility and clarity.

@WilliamRagstad WilliamRagstad linked an issue Jul 25, 2025 that may be closed by this pull request
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.
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.

Function definitions
1 participant