As part of a Compiler Principles course I'm taking in my university, we're writing a compiler that's implemented in OCaml, which compiles Scheme code into CISC-like assembly (which is just C macros). the basic operation of the compiler is such:
- Read a
*.scm
file and convert it to an OCamlstring
. - Parse the string and perform various analyses.
- Run a code generator on the AST output from the semantic analyzer, that outputs text into a
*.c
file. - Compile that file with GCC and run it in the terminal.
Well, all is good and well, except for this: I'm trying to read an input file, that's around 4000 lines long, and is basically one huge expressions that's a mix of Scheme if
& and
.
I'm executing the compiler via utop
. When I try to read the input file, I immediately get a stack overflow error message. It is my initial guess that the file is just to large for OCaml to handle, but I wasn't able to find any documentation that would support this theory.
Any suggestions?