CMSC 430
syntax1.txt
// Missing Operator in Expression function main returns integer; begin 8 + 2 9 * 3; end;
syntax2.txt
// Error in Function Header, Missing Colon function main a integer returns integer; b: integer is 3 * 2; begin if a <= 0 then b + 3; else b * 4; endif; end;
syntax3.txt
// Error in Variable Declaration function main a: integer returns integer; b integer is if a > 5 then a * 3; else 2 + a; endif; c: real is 3.5; begin if a <= 0 then b + 3; else b * 4; endif; end;
syntax4.txt
// Multiple Errors, Error in Case Clause and Missing Others Clause function main a: integer returns integer; begin switch a is case 1 => a 2; case 2 => 5; endswitch; end;
syntax5.txt
-- Multiple Errors function main a integer returns real; b: integer is * 2; c: real is 6.0; begin if a > c then b + / .4; else switch b is case => 2; case 2 => c; endswitch; endif; end;
test1.txt
// Function with Arithmetic Expression function main returns integer; begin 7 + 2 * (5 + 4); end;
test10.txt
// Two Parameter Declarations function main a: integer, b: real returns real; c: real is .7; begin a + b * c; end;
test11.txt
// Arithmetic Operators function main returns integer; begin 9 + ~2 - (5 - 1) / 2 % 3 * 3 ^ 1 ^ 2; end;
test12.txt
// Relational and Logical Operators function main returns integer; begin when 5 > 8 & 3 = 3 | 9 < 1 & !(3 <> 7) | 6 <= 7 & 3 >= 9, 1 : 0; end;
test13.txt
// Comprehensive Test with Nested If function main a: integer, b: character, c: real returns real; d: integer is #8e; e: real is 3.75; f: character is 'A'; g: list of integer is (1, 3, 5); begin if ~a > 5 & a < 1 & !(c = 5.8 | c <> .7E4) then if c >= 7.5E-2 & c <= 5.2 then when a >= d, a + 2 - 7.9E+2 / 9 * 4 : 8.9; elsif g(1) = a ^ 2 % 3 then a % 2 - 5 / c; else fold left + (1, 2, 3) endfold; endif; else fold right - g endfold; endif; end;
test14.txt
// Comprehensive Test with Nested Switch function main a: integer, b: real returns real; c: integer is 8; d: real is .7E2; begin switch a is case 1 => a * 2 / d ^ 2; case 2 => a + 5.3E+2 - b; case 3 => switch d is case 1 => a % 2; others => 9.1E-1; endswitch; case 4 => a / 2 - c; others => a + 4.7 * b; endswitch; end;
test2.txt
// Function with When Statement function main returns integer; begin when 3 < 2 & 6 < 7, 7 * 2 : 7 + 2; end;
test3.txt
// Function with a Switch Statement function main returns character; a: integer is 2 * 2 + 1; begin switch a is case 1 => 'a'; case 2 => 'b'; others => 'c'; endswitch; end;
test4.txt
// Function with a List Variable function main returns integer; primes: list of integer is (2, 3, 5, 7); begin primes(1) + primes(2); end;
test5.txt
// Function with a Real and Character Variables and Literals function main returns character; a: real is 7.8e-1; begin when a < .45, '\n' : 'A'; end;
test6.txt
// Function with an If Statemnt function main a: integer returns integer; begin if a < 10 then 1; elsif a < 20 then 2; elsif a < 30 then 3; else 4; endif; end;
test7.txt
// Left and Right Fold Statement function main returns integer; a: list of integer is (1, 2, 3); begin switch a(1) is case 1 => fold right - (2,3, 4) endfold; case 2 => fold left + a endfold; others => 0; endswitch; end;
test8.txt
// Multiple Integer Variable Initializations function main returns integer; b: integer is 5 + 1 - 4; c: integer is 2 + 3; begin b + 1 - c; end;
test9.txt
// Single Parameter Declaration function main a: integer returns integer; begin a + 1; end;