-let book =
- [ Test.case
- "Book test 1: an array type and an array variable"
- ~code:
- " \
- /* an array type and an array variable */ \
- let \
- type arrtype = array of int \
- var arr1:arrtype := \
- arrtype [10] of 0 \
- in \
- arr1 \
- end \
- "
- ~out_lexing:(
- let open Tiger_parser in
- [ LET;
- TYPE; ID "arrtype"; EQ; ARRAY; OF; ID "int";
- VAR; ID "arr1"; COLON; ID "arrtype"; ASSIGN;
- ID "arrtype"; LBRACK; INT 10; RBRACK; OF; INT 0;
- IN;
- ID "arr1";
- END
- ]
- )
- ; Test.case
- "Book test 2: arr1 is valid since expression 0 is int = myint"
- ~code:
- " \
- /* arr1 is valid since expression 0 is int = myint */ \
- let \
- type myint = int \
- type arrtype = array of myint \
- var arr1:arrtype := \
- arrtype [10] of 0 \
- in \
- arr1 \
- end \
- "
- ~out_lexing:(
- let open Tiger_parser in
- [ LET;
- TYPE; ID "myint"; EQ; ID "int";
- TYPE; ID "arrtype"; EQ; ARRAY; OF; ID "myint";
- VAR; ID "arr1"; COLON; ID "arrtype"; ASSIGN;
- ID "arrtype"; LBRACK; INT 10; RBRACK; OF; INT 0;
- IN;
- ID "arr1";
- END
- ]
+let micro =
+ let open Tiger_parser in
+ [ (let code = "nil" in Test.case code ~code ~out_lexing:(Some [NIL]))
+ ; (let code = "5" in Test.case code ~code ~out_lexing:(Some [INT 5]))
+ ; (let code = "-5" in Test.case code ~code ~out_lexing:(Some [MINUS; INT 5]))
+ ; ( let code = "f()" in
+ Test.case
+ code
+ ~code
+ ~out_lexing:(Some [ID "f"; LPAREN; RPAREN])
+ (* TODO: Be more specific *)
+ ~is_error_expected_semant:(Some Error.is_unknown_id)
+ )
+ ; ( let code = "abc.i" in
+ Test.case
+ code
+ ~code
+ ~out_lexing:(Some [ID "abc"; DOT; ID "i"])
+ (* TODO: Be more specific *)
+ ~is_error_expected_semant:(Some Error.is_unknown_id)
+ )
+ ; ( let code = "abc[0]" in
+ Test.case
+ code
+ ~code
+ ~out_lexing:(Some [ID "abc"; LBRACK; INT 0; RBRACK])
+ (* TODO: Be more specific *)
+ ~is_error_expected_semant:(Some Error.is_unknown_id)
+ )
+ ; ( let code = "abc[0] := foo()" in
+ Test.case
+ code
+ ~code
+ ~out_lexing:
+ (Some [ID "abc"; LBRACK; INT 0; RBRACK; ASSIGN; ID "foo"; LPAREN; RPAREN])
+ (* TODO: Be more specific *)
+ ~is_error_expected_semant:(Some Error.is_unknown_id)
+ )
+ ; ( let code = "abc [5] of nil" in
+ Test.case
+ code
+ ~code
+ ~out_lexing:(Some [ID "abc"; LBRACK; INT 5; RBRACK; OF; NIL])
+ (* TODO: Be more specific *)
+ ~is_error_expected_semant:(Some Error.is_unknown_type)