Repository navigation
feat(dncl): EPIC #1731 日本語モードを共通テスト用プログラム表記へ(topic・draft) - #2206
Draft
smalruby3-editor-bot[bot] wants to merge 293 commits into
Draft
smalruby3-editor-bot[bot] wants to merge 293 commits into
smalruby3-editor-bot[bot] wants to merge 293 commits into
Conversation
|
🚀 Preview deployed (stg API): https://preview.smalruby.app/topic-japanese-mode-1731-33b729d5/ |
…ation-2099 refactor(dncl): Ruby → 日本語を prism の構文木 → JaAST → 日本語を書く経路に切りかえる (J4)
…yntax tree The settings of a Japanese program (where the array indexes start, the comment mark, the note of the logical operators) are read from the fixed sentences in the comments at the top, into `program.settings` of the JaAST (ja-notation/settings.js), both from the Japanese (parse) and from the Ruby (readRuby). With indexes from 1, buildRuby shifts each index on the tree (`A[i]` -> `@A[i - 1]`, `A[1]` -> `@A[0]`, `A[i + 1]` -> `@A[i]`) and readRuby shifts it back; the two are each other's inverse, so both round trips are stable. With the mark `//`, `//` starts a comment when reading and the comments are written with `//`. The golden stays the same (default settings). The index-range hint says nothing for a program with indexes from 1. Closes #2100 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(dncl): keep the settings in the JaAST and shift indexes on the syntax tree (J5)
Take the ja-notation library out of scratch-gui into packages/ja-notation (@smalruby/ja-notation, MIT, no dependency, ESM source with no build). scratch-gui imports it as a workspace dependency. The tests of the library alone (parse, jaToRuby with no table and a plain table, rubyToJa with no table, writeJa, the settings both ways) run with node --test on JSON data in packages/ja-notation/test/data/, so a Ruby implementation can run the same data. The tests through the Smalruby table (corpus, golden, blocks) stay in scratch-gui; the golden is the same. Closes #2101 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chore(dncl): move ja-notation to a workspace package with JSON test data (J6)
`@namae + "には「く」がある"` was the wrong instruction when the code never set `@namae` (a one-line program of the Japanese mode). In Ruby `x + "..."` runs only when `x` is a String, so join it unless the code sets the name to a number, a list or a hash. The 「」 were not the cause. Remove #2168 from KNOWN_BUGS of the corpus test and make the golden again (only that program changes: it now has blocks). Closes #2168 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`myfunc(3)` before `def myfunc(x)` was the wrong instruction: the converter knew the procedure only after it came to the def. A call that no other block takes now declares the procedure from the analysis (`procedures.definitions`): one def of the name, only required arguments of the same number, no super, not in a module. The def fills it in with the same argument IDs. A value call of a def that returns nothing is the same error as when the def comes first. The corpus test checks that the programs of #2167 and #2168 now have blocks in the golden, made again (only those two programs change). Closes #2167 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lexer of ja-notation read names only from ASCII, the kana blocks and
U+4E00-U+9FFF, so 々, 〆, the CJK extensions and other letters Ruby takes
in a name were "cannot be read" errors, and the Ruby → Japanese output of
@佐々木 could not be read back.
Names now start with an ASCII letter, _, any letter (\p{L}), a letter
number (\p{Nl}) or a character of the kana blocks, and go on with digits
(\p{Nd}) and combining marks (\p{M}) too; characters out of the BMP are
read whole. The checks of the editor (paren-utils, the validator, the
paste tidy and the index shift) use the same test from ja-notation.
Closes #1714
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…silently
Ruby → Japanese kept case/when, hashes, symbols, modifier unless/if, the
ternary operator, nil and $g as Ruby with no error, so the Japanese mode
then said "@ cannot be used" or "{ cannot be read". The outermost Ruby
kept as RubyCode is now told (no-ja-form) at its keyword or start, unless
an error already tells it; nothing is added after a prism syntax error.
The editor shows it as unsupportedNotation ("「case」は日本語モードでは
書けません。Ruby モードでは書けます。"). With no table, constants (A) are
read as names, as buildRuby writes them.
Closes #1740
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(dncl): join a name never set to a number with a string literal
fix(dncl): convert a call written before the def of its method
A[0], A[1] = A[1], A[0] made the Ruby "[]=, []= = ...": the writer took the name of the []= call for the name of a variable. Index targets are now written as elements, and readRuby reads an IndexTargetNode with one index back as an element, so the swap goes both ways (with the settings of indexes from 1 too). Other index targets have no Japanese form. Closes #2237 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(dncl): read every name the Japanese mode writes (佐々木 is one name)
…se tab 表示する and 【外部からの入力】 now mean only the console. The say block (say/puts/print/p) and ask and wait with answer of the stage are told as unsupported commands with a message that names the console block, and the blocks are not changed. The Japanese mode palette hides the looks and sensing categories. Closes #2623 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The code in a #{} of a double-quoted Ruby string is code, so it is made half-width again
("#{x + 1}" -> "#{x + 1}"), as it was before strings were kept.
A string now ends at the end of its line in the Ruby tab too: while a quote is being typed
(an IME ” has no closing pair), the strings on the lines below were read as code and changed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…opic/autopilot-2623
…opic/autopilot-2620
…opic/autopilot-2621
…ine end A \ at the end of a line skipped the newline, so the string went on to the next line and the text of the strings below was read as code and made half-width. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The say and ask blocks are no longer passed through in the Japanese tab (#2623). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The issue was not seen with short programs without a list, so the run test also uses the program with a list. Make the ordered Ruby only after the check of the Japanese lines with an error. Refs #2620 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The console was shown only when the Japanese tab was active, so a reload in the Code tab of the Japanese mode showed the stage. Show it in every tab but the Ruby tab while the program is written in Japanese (not in a lesson that does not allow it). Closes #2628 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(dncl): keep full-width characters inside strings and comments (#2621)
A lesson that does not allow Japanese could start in the Code tab of the Japanese mode, where the console now shows after a reload, and keep the console in place of the stage of the lesson. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(dncl): keep the order of functions after running the Japanese program (#2620)
fix(dncl): show the console after reloading in the Japanese mode (#2628)
…opic/autopilot-2623
The rules of the problem (the patterns of settings) leave the more menu of the Japanese tab. The green band over the editor shows the rules now and a link to change them, which opens a popup like the auto-correct settings: cards with a small example each, the sentences written at the top, and Cancel / OK. Decided by the mockup with the maintainer (plan C). Refs #2606 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
say is now a block the Japanese tab cannot write (#2623), so the valid program used console.puts instead, and the when_flag_clicked test keeps checking only when_flag_clicked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…opic/autopilot-2606
…spec The Japanese mode palette no longer has the looks and sensing categories (#2623). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the class PC (1300x600) and a phone held sideways the popup of the rules of the problem was taller than the screen and the overlay does not scroll, so the ok button could not be pressed. Bring the popup up and let its body scroll. Let the whole height of the band press the change link. Refs #2606 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(dncl): treat the say and ask blocks as unsupported in the japanese tab (#2623)
fix(dncl): pick the rules of the problem in a popup from the green band (#2606)
The rules popup gets a link 「ほかの約束を頼む」. After a confirm dialog it opens the feedback form with the kind (機能要望) and the request filled in, so the user only writes the rule. The prefilled URL is built by src/lib/feedback-form.js from the ids of the form questions. Closes #2635 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match the name used by the other Japanese messages (the feedback link), and make the English confirm read naturally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(dncl): let students ask to add a problem rule from the rules popup (#2635)
This branch was successfully 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.
EPIC #1731 の topic(draft)
日本語モードを、共通テスト用プログラム表記を読む力をつける機能へ切り替える EPIC #1731 の作業を集める topic ブランチ。sub-issue の PR は AI がレビューしてこの topic にマージする(
.claude/rules/topic-branches.md)。@smalruby/ja-notation): J1 feat(dncl): ja-notation に JaAST と標準の形の解析・組み立て・Ruby を書く処理を作る(テストの中だけ) #2096・J2 feat(dncl): DNCL 風の形の読みこみを ja-notation の同じ解析に入れる #2097・J3 refactor(dncl): 日本語 → Ruby を ja-notation の経路に切りかえ、古い前処理と行の変換を消す #2098・J4 refactor(dncl): Ruby → 日本語を prism の構文木 → JaAST → 日本語を書く経路に切りかえる #2099・J5 feat(dncl): 添字の始まり・コメントの記号などの設定を JaAST の設定にし、組み立てで構文木を変えて表す #2100・J6 chore(dncl): ja-notation をワークスペースのパッケージに取り出し、テストのデータを JSON にする #2101|の後ろの空白のずれは深くても浅くても誤り)・fix(dncl): Ruby → 日本語で (式).include? や引数付き・続きのメソッドが組み込みに戻らない #1699(テストで固定)deleteProcedure経由に直した).github/workflows/ci-cd.ymlを含むため)。マージ後に AI がnpm installを 1 回する。npm installを 1 回(ワークスペースpackages/ja-notationのリンクを作る)。🤖 Generated with Claude Code