Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECE - Evaluate FieldDeclaration and MethodInvocation #19

Merged
merged 23 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update main.pegjs to support boolean literal
  • Loading branch information
1001mei authored and xyliew25 committed Feb 18, 2024
commit 1c740a7888cccdac56ecb821a1523d2912a7de31
8 changes: 6 additions & 2 deletions src/compiler/__tests__/main.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ HexDigits = HexDigit ([_]*HexDigit)*
HexDigit = [a-fA-F0-9]

BooleanLiteral
= "true"
/ "false"
= value:("true" / "false") {
return {
kind: "BooleanLiteral",
value: value,
}
}

CharacterLiteral = ['] (EscapeSequence / !['\\] .) [']

Expand Down
19 changes: 19 additions & 0 deletions src/compiler/__tests__/tests/ifElse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ const testCases: testCase[] = [
`,
expectedLines: ["ok", "done"],
},
{
comment: "if without else, trivial conditional expression",
program: `
public class Main {
public static void main(String[] args) {
if (true) {
System.out.println("ok");
}
if (false) {
System.out.println("uh oh");
}
if (true) {
System.out.println("done");
}
}
}
`,
expectedLines: ["ok", "done"],
},
{
comment: "if and else",
program: `
Expand Down