Skip to content

feat(parser): add line number support for $LINENO and error messages#132

Merged
chaliy merged 1 commit intomainfrom
claude/add-line-numbers-vjPWm
Feb 4, 2026
Merged

feat(parser): add line number support for $LINENO and error messages#132
chaliy merged 1 commit intomainfrom
claude/add-line-numbers-vjPWm

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 4, 2026

Summary

  • Add comprehensive source location tracking throughout the parser and interpreter
  • Implement working $LINENO variable that returns actual line number during execution
  • Include line/column information in parse error messages

Changes

  • New types: Position (line/column/offset) and Span (start/end positions) in parser/span.rs
  • Lexer: Track line/column as tokenizing, emit SpannedToken with source locations
  • AST nodes: All command-level nodes now include span field
  • Parser: Thread span information from tokens into AST nodes
  • Errors: New ParseAt error variant includes line/column in messages
  • Interpreter: Track current execution line, return in $LINENO expansion
  • Tests: New tests for multiline $LINENO, loops, and parse error locations

Test plan

  • cargo fmt --check passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • cargo test --lib --features http_client - 603 tests pass
  • cargo test --test spec_tests - 13 tests pass
  • New $LINENO tests verify multiline and loop line tracking
  • Parse error tests verify location info in errors

https://claude.ai/code/session_01Gds1BKwWLE8SPEFN5txZfe

Add comprehensive source location tracking throughout the parser and interpreter:

- New Span and Position types for tracking source locations (line/column/offset)
- Lexer tracks line/column as it tokenizes, emits SpannedToken
- All AST command nodes now include span field
- Parser threads spans through to AST nodes
- ParseAt error variant includes line/column in error messages
- $LINENO variable now returns actual line number from command span
- New tests for $LINENO in multiline scripts and loops
- Tests for parse error location reporting

https://claude.ai/code/session_01Gds1BKwWLE8SPEFN5txZfe
@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 1653211 into main Feb 4, 2026
8 checks passed
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