Skip to content

Instantly share code, notes, and snippets.

@adamnew123456
Last active February 2, 2017 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamnew123456/b9ffcfe6b46ba3cd443e3be8679fbe48 to your computer and use it in GitHub Desktop.
Save adamnew123456/b9ffcfe6b46ba3cd443e3be8679fbe48 to your computer and use it in GitHub Desktop.
Sample MiniJava File For Parser
class Bean {}
class Main {
// Visibility Access Type id
public static int x;
public int[] x;
private static boolean x;
private Bean x;
private Bean[] xIs_A_Good_Variable_Name18283_28AXY;
// Visibility Access (Type | void) id '(' ParameterList? ')' '{' Statement* '}'
public static int f(boolean a, int[] b, Bean c, Bean[] d) { }
public int[] f(boolean a, int[] b, Bean c, Bean[] d) { }
private static boolean f(boolean a, int[] b, Bean c, Bean[] d) { }
private Bean f(boolean a) { }
private Bean[] f() { }
public static void f(boolean a, int[] b, Bean c, Bean[] d) { }
public void f(boolean a, int[] b, Bean c, Bean[] d) { }
private static void f(boolean a) { }
private void f() { }
/*
* { Statement* }
* | Type id '=' Expression ';'
* | Reference '=' Expression ';'
* | Reference '(' ArgumentList? ')' ';'
* | return Expression? ';'
* | if '(' Expression ')' Statement ('else' Statement)?
* | while '(' Expression ')' Statement
*/
public void testStatements() {
boolean x = true;
x = false;
Bean b = new Bean();
this.b.foo[27].bar.baz[x] = -(x >= true || !(y && z));
if (b.foo[27].bar.baz[x](1, false, new int[68], b[9])) {
while (((((x))))) {
}
}
if (false) {
return;
} else {
return 57 * 98 != 42 < true + (new Bean[false != function[42](1,2,3)]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment