Skip to content

Commit

Permalink
Revert optional EOS in VariableStatement
Browse files Browse the repository at this point in the history
  • Loading branch information
arnav-ag committed Mar 31, 2024
1 parent 3dbd81d commit 6015202
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
32 changes: 13 additions & 19 deletions src/parser/ooga.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,11 @@ function peg$parse(input, options) {
}
};
var peg$f76 = function(id, init) {
return id;
return {
tag: "VariableDeclaration",
id: id,
expression: extractOptional(init, 1)
}
};
var peg$f77 = function() {
return { tag: "ContinueStatement", label: null };
Expand Down Expand Up @@ -5373,11 +5377,13 @@ function peg$parse(input, options) {
s6 = null;
}
s7 = peg$parseEOS();
if (s7 === peg$FAILED) {
s7 = null;
if (s7 !== peg$FAILED) {
peg$savedPos = s0;
s0 = peg$f63(s3, s5, s6);
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$savedPos = s0;
s0 = peg$f63(s3, s5, s6);
} else {
peg$currPos = s0;
s0 = peg$FAILED;
Expand Down Expand Up @@ -5953,20 +5959,8 @@ function peg$parse(input, options) {
s2 = peg$FAILED;
}
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 59) {
s3 = peg$c30;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e47); }
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s0 = peg$f76(s1, s2);
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$savedPos = s0;
s0 = peg$f76(s1, s2);
} else {
peg$currPos = s0;
s0 = peg$FAILED;
Expand Down
16 changes: 12 additions & 4 deletions src/parser/ooga.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,19 @@ SequenceStatement
}

VariableStatement
= VarToken __ id:Identifier __ type:(InitType)? init:(__ Initialiser)? EOS? {
= VarToken __ id:Identifier __ type:(InitType)? init:(__ Initialiser)? EOS {
return {
tag: "VariableDeclaration",
id: id,
expression: extractOptional(init, 1)
}
}
/ id:Identifier init:(__ ShorthandInitialiser)? EOS {
return id;
return {
tag: "VariableDeclaration",
id: id,
expression: extractOptional(init, 1)
}
}

ConstantStatement
Expand Down Expand Up @@ -720,8 +724,12 @@ ForInitStatement
expression: extractOptional(init, 1)
}
}
/ id:Identifier init:(__ ShorthandInitialiser) ";" {
return id;
/ id:Identifier init:(__ ShorthandInitialiser) {
return {
tag: "VariableDeclaration",
id: id,
expression: extractOptional(init, 1)
}
}

ForTest
Expand Down

0 comments on commit 6015202

Please sign in to comment.