private static Expression ParseBitshiftExpression(Scanner scanner) { Expression left = ParseAddExpression(scanner); while (true) { if (scanner.TryGetDelimiter("<<")) { Expression right = ParseAddExpression(scanner); left = new LeftShiftExpression(left, right); } else if (scanner.TryGetDelimiter(">>")) { Expression right = ParseAddExpression(scanner); left = new RightShiftExpression(left, right); } else { return(left); } } }
private static Expression ParseBitshiftExpression(Scanner scanner) { Expression left = ParseAddExpression(scanner); while (true) { if (scanner.TryGetDelimiter("<<")) { Expression right = ParseAddExpression(scanner); left = new LeftShiftExpression(left,right); } else if (scanner.TryGetDelimiter(">>")) { Expression right = ParseAddExpression(scanner); left = new RightShiftExpression(left,right); } else { return left; } } }
private static Expression ParseAssigmentExpression(Scanner scanner) { Expression left = ParseLogicalOrExpression(scanner); if (scanner.TryGetDelimiter("=")) { Expression right = ParseAssigmentExpression(scanner); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("+=")) { Expression right = ParseAssigmentExpression(scanner); right = new AddExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("-=")) { Expression right = ParseAssigmentExpression(scanner); right = new SubtractExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("*=")) { Expression right = ParseAssigmentExpression(scanner); right = new MultiplyExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("/=")) { Expression right = ParseAssigmentExpression(scanner); right = new DivideExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("%=")) { Expression right = ParseAssigmentExpression(scanner); right = new ModuloExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("<<=")) { Expression right = ParseAssigmentExpression(scanner); right = new LeftShiftExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter(">>=")) { Expression right = ParseAssigmentExpression(scanner); right = new RightShiftExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("&=")) { Expression right = ParseAssigmentExpression(scanner); right = new BitwiseAndExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("^=")) { Expression right = ParseAssigmentExpression(scanner); right = new BitwiseXorExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("|=")) { Expression right = ParseAssigmentExpression(scanner); right = new BitwiseOrExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("&&=")) { Expression right = ParseAssigmentExpression(scanner); right = new LogicalAndExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("^^=")) { Expression right = ParseAssigmentExpression(scanner); right = new LogicalXorExpression(left,right); return new AssignmentExpression(left,right); } else if (scanner.TryGetDelimiter("||=")) { Expression right = ParseAssigmentExpression(scanner); right = new LogicalOrExpression(left,right); return new AssignmentExpression(left,right); } else { return left; } }
private static Expression ParseAssigmentExpression(Scanner scanner) { Expression left = ParseLogicalOrExpression(scanner); if (scanner.TryGetDelimiter("=")) { Expression right = ParseAssigmentExpression(scanner); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("+=")) { Expression right = ParseAssigmentExpression(scanner); right = new AddExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("-=")) { Expression right = ParseAssigmentExpression(scanner); right = new SubtractExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("*=")) { Expression right = ParseAssigmentExpression(scanner); right = new MultiplyExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("/=")) { Expression right = ParseAssigmentExpression(scanner); right = new DivideExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("%=")) { Expression right = ParseAssigmentExpression(scanner); right = new ModuloExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("<<=")) { Expression right = ParseAssigmentExpression(scanner); right = new LeftShiftExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter(">>=")) { Expression right = ParseAssigmentExpression(scanner); right = new RightShiftExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("&=")) { Expression right = ParseAssigmentExpression(scanner); right = new BitwiseAndExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("^=")) { Expression right = ParseAssigmentExpression(scanner); right = new BitwiseXorExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("|=")) { Expression right = ParseAssigmentExpression(scanner); right = new BitwiseOrExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("&&=")) { Expression right = ParseAssigmentExpression(scanner); right = new LogicalAndExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("^^=")) { Expression right = ParseAssigmentExpression(scanner); right = new LogicalXorExpression(left, right); return(new AssignmentExpression(left, right)); } else if (scanner.TryGetDelimiter("||=")) { Expression right = ParseAssigmentExpression(scanner); right = new LogicalOrExpression(left, right); return(new AssignmentExpression(left, right)); } else { return(left); } }