Repository navigation
fix(ja-notation): walk the syntax trees with a stack of their own - #2271
Merged
smalruby3-editor-bot[bot] merged 10 commits intoNov 19, 2026
Merged
smalruby3-editor-bot[bot] merged 10 commits into
smalruby3-editor-bot[bot] merged 10 commits into
Conversation
…them The Japanese mode is written for a program that runs alone, as on a terminal, and has no stage. Ruby → Japanese tells each `$a` (a variable or a list of the stage) at its name as `stage-variable`, which the editor says as "ステージの変数($a)は日本語モードでは書けません。Ruby モードでは書けます。", in place of the no-ja-form error of the whole statement. Closes #1706 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Out of the strings and the comments, the lexer makes the full-width letters and digits half-width before it reads them (`x1` is `x1`, `and` is `and`), as the auto-correct of the Ruby mode does. A full-width letter is no longer a name of its own (the decision of #1714 is taken back). The strings and the comments keep what is written. Closes #2266 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block of the DNCL-like form closed by the closing word of another kind (a もし closed by を繰り返す, a counting loop by を実行する) is now an error (`closer-kind`) that says the word of the block, even when the Ruby could be made: the students are told as much as can be. A block forgotten inside the one the word closes is told as not closed. `end` still closes any. Closes #2268 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The walks of the syntax trees (the reading of the Japanese, the building and writing of the Ruby, the reading of the prism tree and the writing of the Japanese) were recursive, so an expression of some thousands of terms, a chain of parentheses or signs, or blocks deep in blocks ran out of the call stack. They are generators now, run by `run` (src/run.js) with a stack of its own; the index shift of the settings counts in a loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…an error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🚀 Preview deployed (stg API): https://preview.smalruby.app/fix-ja-notation-iterative-walk-77b6d97c/ |
smalruby3-editor-bot
Bot
merged commit Nov 19, 2026
0d5c637
into
topic/japanese-mode-1731
11 checks passed
This was referenced Nov 19, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
日本語モード EPIC #1731 の確認ページの答え L4(J3・J4 の申し送り)。ja-notation の構文木をたどる処理を再帰でなくし、数千項の式・数千重ねたかっこ・深いブロックでも呼び出しのスタックが尽きないようにする。
Changes Made
src/run.js(新規): 構文木をたどる処理をジェネレーターで書き、子をたどるところでyieldすると、runが自前のスタック(配列)で動かす。誤りのthrowは待っている親に投げ戻す。eachは並び(引数・要素)を順にたどる。parse.jsの式の読み方(ExpressionReaderの再帰下降すべて)、build-ruby.js(式・文・ブロック)、write-ruby.js(式・文)、write-ja.js(式・文・ブロック)、read-ruby.js(式・文・ブロック・rawの中の読み)。build-ruby.jsのwalkStatements/walkExpressionsと、settings.jsの添字のずらし(dropsToRuby/dropsToJaの相互再帰)はくり返しにした。callsなど)に渡すhelpers.expressionは、runを通す同期の関数のまま(表の書き方は変えない)。dncl-to-ruby.js/ruby-to-dncl.jsのRangeErrorの受け止めは残し、説明を直した(Ruby → 日本語では prism 自身が構文木を JavaScript に読み出すところで再帰するため、数千項の+は prism が解析できない)。docs/dncl/README.md(構文木をたどる処理・ファイル表・テスト一覧)、packages/ja-notation/README.md(守ること)。+を N 項もしを N 重(標準の形・DNCL 風の形)(この PR の後は、手元の確かめで N = 10000 まで全部通った。)
Test Coverage
packages/ja-notation/test/deep.test.js(新規): 5000 項の+/and、5000 重のかっこ・右に深い式・符号・not・呼び出し・添字、1000 重のブロック(両方の形)、writeJaの書き戻し、Ruby → 日本語の 1000 項の+・3000 個の&&・1000 個のelsif(prism が解析できる範囲)。直す前のソースでは 13 件中 9 件が落ちることを確かめた。繰り返しで作るプログラムなので JSON データには入れていない。test/unit/lib/dncl/dncl-long-program.test.js(新規): スモウルビーの表を通して同じことを確かめる。UPDATE_JA_GOLDEN=1): 差なし(動きは変えていない)。Closes #2270
🤖 Generated with Claude Code