Skip to content

Commit c1be8af

Browse files
Pass --parser=prase.y explicitly as prism is default in 3.4
1 parent f63d9e4 commit c1be8af

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<select id="action" class="plrb-tools-more-tools-button">
3232
<option value="eval">Evaluate</option>
3333
<option value="compile">Compile</option>
34-
<option value="syntax">Syntax</option>
34+
<option value="syntax">Syntax (parse.y)</option>
3535
<option value="syntax+prism">Syntax (Prism)</option>
3636
</select>
3737
<button id="button-run" class="plrb-tools-do-button">

src/ruby.worker.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,23 @@ export class RubyWorker {
236236
switch (action) {
237237
case "eval": break
238238
case "compile": extraArgs.push("--dump=insns"); break
239-
case "syntax": extraArgs.push("--dump=parsetree"); break
240-
case "syntax+prism":
239+
case "syntax": {
241240
const rubyVersion = this._rubyVersion();
242-
if (rubyVersion.startsWith("3.3.")) {
243-
// --dump=prism_parsetree exists only in 3.3.x
244-
extraArgs.push("--dump=prism_parsetree");
241+
if (rubyVersion.startsWith("3.2.")) {
242+
// 3.2.x and earlier do not have explicit --parser=parse.y
243+
extraArgs.push("--dump=parsetree");
245244
} else {
246-
// After 3.3.x, --parser=prism is introduced
247-
// https://bugs.ruby-lang.org/issues/20270
248-
extraArgs.push("--parser=prism");
245+
// 3.3.x and later have --parser=parse.y
246+
extraArgs.push("--parser=parse.y");
249247
extraArgs.push("--dump=parsetree");
250248
}
251249
break
250+
}
251+
case "syntax+prism": {
252+
extraArgs.push("--parser=prism");
253+
extraArgs.push("--dump=parsetree");
254+
break
255+
}
252256
default: throw new Error(`Unknown action: ${action}`)
253257
}
254258

0 commit comments

Comments
 (0)