Skip to content

fix(ja-notation): tell a closing word of another kind of block - #2269

Merged
smalruby3-editor-bot[bot] merged 7 commits into
topic/japanese-mode-1731from
fix/ja-notation-closer-kind
Nov 19, 2026
Merged

smalruby3-editor-bot[bot] merged 7 commits into
topic/japanese-mode-1731from
fix/ja-notation-closer-kind

Conversation

@smalruby3-editor-bot

Copy link
Copy Markdown

Summary

日本語モード EPIC #1731 の確認ページの答え W3。DNCL 風の形で、閉じる言葉とブロックの種類が合わないときを誤りにする(初心者に少しでも多く指摘する)。

重ねて作っています: #2267(W8)のブランチの上に作ったので、#2263 → #2267 → この PR の順にマージしてください。

日本語 これまで これから
もし x > 0 ならば / 表示する(x) / を繰り返す 数が合うので誤りにしない 3 行目に「「もし〜ならば」は「を繰り返す」ではなく「を実行する」で閉じてください」
i を 1 から 3 まで 1 ずつ増やしながら / … / を実行する 誤りにしない(増分は足す) 「「〜ずつ増やしながら」は「を実行する」ではなく「を繰り返す」で閉じてください」
x < 3 の間繰り返す: / x = x + 1 / と定義する 誤りにしない 「「〜の間繰り返す:」は「と定義する」ではなく「を繰り返す」で閉じてください」
〜の間 の中の もし を閉じ忘れて を繰り返す もし を閉じて、外が閉じていない もし の行に「「もし〜ならば」を「を実行する」で閉じてください」(前と同じ文)
… の間 / … / end 閉じる 閉じる(end はどのブロックも閉じる。Ruby と同じ)

標準の形(字下げ)では閉じる言葉を書かないので関係しない。

Changes Made

  • ja-notation parse.js: 閉じの行の言葉をブロックの種類(closerOf)と照らし合わせる。合わないとき、間のブロックがすべて DNCL 風の形で、外に合うブロックがあれば内側を unclosed にして外を閉じ(matchingCloser)、無ければ closer-kind(word・expected・opener・direction・colon)の誤りにする。
  • scratch-gui ja-notation-errors.js: closer-kind の文(: で開いたものは標準の形の名前)。closerFormBlockErrors の説明を直した(ja-notation が同じことを言うようになった)。
  • docs: docs/dncl/README.md(DNCL 風の形の読み方・閉じ忘れのエラーの表と説明・誤りの欄)、docs/smalruby-dncl-spec.ja.md(終端キーワード)。

Test Coverage

  • packages/ja-notation/test/data/parse.json: 誤り 6 行(もし / 〜の間 / 減らしながら / 関数 / : で開いたもの / 内側の閉じ忘れ)と、end が 〜の間 も閉じる same 1 行。
  • packages/ja-notation/test/data/ja-to-ruby.json: 「数える繰り返しをほかの言葉で閉じても増分を足す」を、誤りになる期待に書きかえ。
  • test/unit/lib/dncl/dncl-validator.test.js: 「数が合えば誤りにしない」を誤りになる期待に書きかえ、数える繰り返し・: で開いたもの・end を足した。
  • ゴールデン(UPDATE_JA_GOLDEN=1): 差なし(コーパスに種類の違う閉じの言葉で閉じたプログラムが無い)。

Closes #2268

🤖 Generated with Claude Code

smalruby3-editor-bot Bot and others added 3 commits November 19, 2026 07:54
…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>
…an error

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🚀 Preview deployed (stg API): https://preview.smalruby.app/fix-ja-notation-closer-kind-3b499791/

This branch was previously deployed

1 inactive deployment
stg — 9f4b8495 Deployed Nov 19, 2026 by smalruby3-editor-bot[bot] via cleanup #443
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.

0 participants