Skip to content

Conversation

@yhk1038
Copy link
Contributor

@yhk1038 yhk1038 commented Dec 28, 2025

Summary

Completely replaced regex-based parsing with token-based parser

Before → After

[Before]  Source → Regex Matching → AST
[After]   Source → Scanner → Tokens → Parser → IR → AST

Key Benefits

  • Overcomes regex limitations: Eliminates the fundamental limitation of regex-based parsing that struggles with context-dependent semantics
  • Foundation for incremental compilation: Token/IR caching enables recompiling only changed portions
  • Extensibility: Easier to add new syntax
  • Debugging: Token-level error location tracking

Others

  • Added ternary operator (? :) parsing support
  • Added splat (*) and double splat (**) argument parsing
  • Added keyword argument parsing
  • Added statement expressions (if/case/begin) as assignment values
  • Fixed generic type compatibility in type inference
  • RuboCop metrics limits adjusted

- Replace monolithic parser_combinator.rb (2833 lines) with modular architecture
- Add Scanner for tokenization with regex literal support
- Create IR::InterpolatedString for string interpolation parsing
- Fix type inference for interpolated strings (returns String)
- Add TRuby::ParseError for unified error handling
- Organize parsers into primitives/, combinators/, and token/ directories
- Each file contains exactly one class (snake_case filename matches PascalCase class)
…ressions

- Add ternary operator (? :) parsing in ExpressionParser
- Support double splat (**opts) and single splat (*args) in method calls
- Support keyword arguments (name: value) in method calls
- Allow case/if/unless/begin as assignment right-hand side values
- Improve generic type compatibility (Array[untyped] with Array[T])

Fixes type inference errors in keyword_args samples.
@yhk1038 yhk1038 merged commit a7c451d into main Dec 28, 2025
10 checks passed
@yhk1038 yhk1038 deleted the feature/parser-combinator-migration branch December 28, 2025 23:21
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