35 lines
523 B
OCaml
35 lines
523 B
OCaml
let sample_program =
|
|
{|
|
|
struct Point {
|
|
int x;
|
|
int y;
|
|
};
|
|
|
|
int sum_array(int[] arr) {
|
|
int total = 0;
|
|
foreach (int n in arr) {
|
|
total = total + n;
|
|
}
|
|
return total;
|
|
}
|
|
|
|
int main() {
|
|
struct Point p;
|
|
int[] nums;
|
|
int x = 1 + 2 * 3;
|
|
p.x = x;
|
|
if (x > 0) {
|
|
x = x + p.x;
|
|
} else {
|
|
x = 0;
|
|
}
|
|
x = sum_array(nums);
|
|
return x;
|
|
}
|
|
|}
|
|
|
|
let () =
|
|
match Spooky.parse_and_type_check sample_program with
|
|
| Ok ast -> Printf.printf "Program parsed and type-checked successfully.\n"
|
|
| Error msg -> Printf.printf "Error: %s\n" msg
|