Skip to content

[KUU-4825] Move template expression brace depth scan to Lean - #16392

Queued
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1796249644-kuu-4825-tmplscan
Queued

devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1796249644-kuu-4825-tmplscan

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

KUU-4825: 文字列テンプレート式の中括弧深さスキャン(scanTemplateExpression)を Lean に移行しました。

  • ParserProofs/TemplateScan.lean: テンプレート本体をバイトレベルで走査する状態機械。空白・行コメント・ネストしたブロックコメント・バッククォート識別子を内部でスキップしつつ {/} の深さを追跡。引用符("/"""/')とネストしたテンプレート開始(${)は pause イベント — スキャンはそこで停止し、Swift が再帰スキャンを実行してから再開するため、モデルは文字列内部の規則を一切必要としない
  • 証明17件(native_decide): 文字列・文字リテラル・コメント・バッククォート内の } は閉じ括弧とみなされない、外側閉じ括弧での停止位置、EOF での未終端停止位置、ネストしたブロックコメントの深さ追跡、pause 後の深さの引き継ぎ
  • Swift 統合: イベント列を忠実に replay — イベント間のギャップは元のループと同じく consumeTrivia + scanNextTokens で処理し、brace イベントは brace トークン、pause イベントは scanString/scanRawString/scanCharLiteral/テンプレート再帰に委譲。失敗時は offset 未変更のまま元のループにフォールバック
  • 過剰ネスト時の復帰経路(skipTemplateExpression)は深さカウンタのガードが Swift 側に残る構造上そのまま維持(ネスト深度のカウント自体は再帰をまたぐホスト側の状態のため)

動作確認

  • lake build ParserProofs.TemplateScan ParserProofs.Tests.TemplateScan ParserProofs.Runtime.TemplateScanFFI — 全証明通過
  • bash Scripts/swift_test.sh --filter 'TemplateScanLeanTests' — 11/11 件パス(単純テンプレート・文字列/文字リテラル/コメント/バッククォート内の閉じ括弧の非終了・ネストテンプレート・brace トークン・未終端診断・raw文字列)

回していない範囲

  • レキサ全体のゴールデン・791オラクルケースは CI に委譲
  • 65536 バイトを超えるテンプレート本体はフォールバック経路

Link to Devin session: https://app.devin.ai/sessions/c88a4cfee40b4aaa8902b365f6e93500
Open in Devin Desktop: https://app.devin.ai/desktop/session/c88a4cfee40b4aaa8902b365f6e93500?variant=devin
Requested by: @fumiya-kume

KUU-4825

Co-Authored-By: sushi@mercari.com <fumiya.kume@hotmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot added this pull request to the merge queue Dec 3, 2026
Any commits made after this event will not be merged.
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