ANONYMOUS wrote:
> I have seen this sentence in the project sheet: "Writing a compiler for any programming language is an enormous task, clearly not one suited for this project. However, what many have recognised, is that C is an excellent language to support other languages and that C has an extensive toolchain supporting compilation and linking. "
> Does it mean we are not supposed to manually translate the language? Is there an existing one that we can use? Like functions or libraries?
> If we are supposed to manually translate it, does it mean we only need to solve those 8 sample ml files? Like the function may only do the same as what these 8 files do etc.
I feel you are reading too deeply into that section of that paragraph. If you continue reading:
"The strategy is to first translate programs written in other languages, such as our ml, to C, to compile that translated C code using a standard C compiler, and to finally execute the resultant program. This sequence is often termed transpiling, the 'joining' of the words translating and compiling. In this role, C is often described as a high-level assembly language, sometimes a 'wallpaper language'."
The sample 8 files are just some examples to give everyone an idea of the possible ml files their project may be tested against. You need to (ideally) solve all ml files, not just the 8 provided. As stated in the project goal:
"The goal of this project is to implement a C11 program, named runml, which accepts a single command-line argument providing the pathname of a text file containing a program written in ml, [added 28/8] and any optional command-line arguments to be passed the transpiled program when it is executed. Successful execution of runml will involve checking the syntax of the ml program, translating that valid ml program to a C11 program, compilation of the resultant C program and, finally, execution of the compiled program."
I'm not sure what you mean by translating the file manually. The program you will write will translate the ml file into a c source file (as well as compile, run and then delete the files it created). You can use header files such as string.h, stdlib.h, etc. to help.