Skip to content

feat(lexer): add comment scanning with @__PURE__ detection#4

Merged
ohah merged 1 commit intomainfrom
feature/lexer-comments
Mar 18, 2026
Merged

feat(lexer): add comment scanning with @__PURE__ detection#4
ohah merged 1 commit intomainfrom
feature/lexer-comments

Conversation

@ohah
Copy link
Copy Markdown
Owner

@ohah ohah commented Mar 18, 2026

Summary

  • Single-line (//) and multi-line (/* */) comment scanning
  • Comments skipped (not tokenized) — next() loops via .undetermined return
  • @__PURE__, #__PURE__, @__NO_SIDE_EFFECTS__ detection (D025)
  • Multi-line comments track newlines for accurate line table

Test plan

  • zig build test 통과 (55 tests)
  • zig fmt --check src/ 통과
  • Single/multi-line comment skipping
  • PURE comment variants
  • Comment at EOF, comment-only source

🤖 Generated with Claude Code

Comments:
- Single-line comments (// ... \n) — skipped, not tokenized
- Multi-line comments (/* ... */) — skipped, newlines tracked for line table
- Comments return .undetermined → next() loops to scan actual token
- U+2028/U+2029 as line terminators in single-line comments

Pure comment detection (D025):
- @__PURE__ in /* */ or // comments
- #__PURE__ (webpack convention)
- @__NO_SIDE_EFFECTS__
- Sets has_pure_comment_before flag on next token

Tests:
- Single-line comment skipping
- Multi-line comment skipping
- Multi-line comment with newline → has_newline_before
- @__PURE__, #__PURE__, @__NO_SIDE_EFFECTS__ detection
- Normal comment does not set pure flag
- Comment at EOF
- Comment-only source
- Slash after comment not confused

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ohah ohah merged commit e861b35 into main Mar 18, 2026
ohah added a commit that referenced this pull request Mar 21, 2026
플랜 PR #4 항목 5 구현: 예약어/글로벌 이름 충돌 체크.
- isReservedName(): JS 예약어 41개 + 글로벌 객체 29개
- computeRenames에서 후보 이름이 예약어/글로벌이면 다음 번호로 건너뜀
- Rolldown renamer.rs와 동일 패턴

2개 유닛 테스트 (JS reserved words, global objects).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ohah added a commit that referenced this pull request Mar 21, 2026
플랜 PR #4 항목 5 구현: 예약어/글로벌 이름 충돌 체크.
- isReservedName(): JS 예약어 41개 + 글로벌 객체 29개
- computeRenames에서 후보 이름이 예약어/글로벌이면 다음 번호로 건너뜀
- Rolldown renamer.rs와 동일 패턴

2개 유닛 테스트 (JS reserved words, global objects).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant