Skip to content

fix(parser,interpreter): add support for arithmetic commands and C-style for loops#36

Merged
chaliy merged 1 commit intomainfrom
claude/fix-benchmark-timeouts-nSpcA
Feb 1, 2026
Merged

fix(parser,interpreter): add support for arithmetic commands and C-style for loops#36
chaliy merged 1 commit intomainfrom
claude/fix-benchmark-timeouts-nSpcA

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 1, 2026

Summary

  • Fixes 4 benchmark timeouts (arith_increment, ctrl_for_range, str_concat, complex_string_build)
  • Adds support for variable assignment with quoted strings (a="Hello")
  • Adds support for arithmetic commands (((x++)))
  • Adds support for C-style for loops (for ((i=0; i<5; i++)))

Test plan

  • All 284 library tests pass
  • Clippy passes with no warnings
  • All 4 previously failing benchmarks now pass:
    • arith_increment: 0.017ms (was 1000ms timeout)
    • ctrl_for_range: 0.019ms (was 1000ms timeout)
    • str_concat: 0.014ms (was 1000ms timeout)
    • complex_string_build: 0.018ms (was 1000ms timeout)

…yle for loops

Fixes 4 benchmark timeouts (arith_increment, ctrl_for_range, str_concat, complex_string_build):

1. Variable assignment with quoted strings (a="Hello"):
   - Updated lexer to include quoted strings as part of assignment words
   - Updated parser to strip quotes from scalar assignment values
   - Single-quoted values are treated as literals (no expansion)
   - Double-quoted values allow variable expansion

2. Arithmetic commands ((expression)):
   - Added DoubleLeftParen and DoubleRightParen tokens
   - Added CompoundCommand::Arithmetic variant
   - Parser now handles ((expression)) as standalone commands
   - Interpreter evaluates expressions with side effects (++, --, =, +=, etc.)

3. C-style for loops (for ((init; cond; step))):
   - Added ArithmeticForCommand AST type
   - Parser recognizes (( after 'for' keyword
   - Handles <, >, &&, || operators inside (( )) context
   - Interpreter executes init, checks condition, runs body, executes step
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@chaliy chaliy merged commit 649c6ab into main Feb 1, 2026
4 checks passed
@chaliy chaliy deleted the claude/fix-benchmark-timeouts-nSpcA branch February 1, 2026 23:46
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