1 module Error = Tiger_error
2 module Test = Tiger_test
5 let open Tiger_parser in
6 [ (let code = "nil" in Test.case code ~code ~out_lexing:(Some [NIL]))
7 ; (let code = "5" in Test.case code ~code ~out_lexing:(Some [INT 5]))
8 ; (let code = "-5" in Test.case code ~code ~out_lexing:(Some [MINUS; INT 5]))
9 ; ( let code = "f()" in
13 ~out_lexing:(Some [ID "f"; LPAREN; RPAREN])
14 (* TODO: Be more specific *)
15 ~is_error_expected_semant:(Some Error.is_unknown_id)
17 ; ( let code = "abc.i" in
21 ~out_lexing:(Some [ID "abc"; DOT; ID "i"])
22 (* TODO: Be more specific *)
23 ~is_error_expected_semant:(Some Error.is_unknown_id)
25 ; ( let code = "abc[0]" in
29 ~out_lexing:(Some [ID "abc"; LBRACK; INT 0; RBRACK])
30 (* TODO: Be more specific *)
31 ~is_error_expected_semant:(Some Error.is_unknown_id)
33 ; ( let code = "abc[0] := foo()" in
38 (Some [ID "abc"; LBRACK; INT 0; RBRACK; ASSIGN; ID "foo"; LPAREN; RPAREN])
39 (* TODO: Be more specific *)
40 ~is_error_expected_semant:(Some Error.is_unknown_id)
42 ; ( let code = "abc [5] of nil" in
46 ~out_lexing:(Some [ID "abc"; LBRACK; INT 5; RBRACK; OF; NIL])
47 (* TODO: Be more specific *)
48 ~is_error_expected_semant:(Some Error.is_unknown_type)
50 ; ( let code = "f(\"a\", 3, foo)" in
55 (Some [ID "f"; LPAREN; STRING "a"; COMMA; INT 3; COMMA; ID "foo"; RPAREN])
56 ~is_error_expected_semant:(Some Error.is_unknown_id)
76 type a = {x:int, y:int} \
77 type b = {x:int, y:int} /* new type generated */ \
78 var foo : a := a {x = 1, y = 2} \
79 var bar : b := b {x = 1, y = 2} \
81 foo = bar /* incompatible types */ \
86 "Incompatible records"
88 (* TODO: Be more specific *)
89 ~is_error_expected_semant:(Some Error.is_wrong_type)
94 Tiger_test_cases_book.read ~from_dir:dir