Hi, Just had a few questions about the assignment.
First, what should happen if divide by zero occurs, are we expected to do static analysis at compile time, throw an error at run time, or is it UB?
Second, in example 5 a function call is done using printsum 12 6, without any brackets or separators in the function call, whilst all other examples use function(args) as the syntax. Should we be able to parse both?
Also, with respect to command line arguments, should our program check if the number of arguments passed to the program is sufficient and print to stderr like follows
if (argcount < 2) {
fprintf(stderr, "%s: program expected at least 1 argument",
argvalue[0]);
exit(EXIT_FAILURE);
}
First, what should happen if divide by zero occurs, are we expected to do static analysis at compile time, throw an error at run time, or is it UB?
The focus of the project is not on designing and fully implementing a mini-language - it's 'only' about performing a quite mechanical syntactic translation from one language to another (C11), compiling, and then executing the program. The goals of the project are to encourage you to learn, and then assess your understanding of some core concepts listed on the project's description. In short, it's about C and operating-systems, not language design.
So, there's no need to worry about the division-by-zero cases - implement something if you wish (full static analysis will near impossible without execute the program at compile-time), but division-by-zero won't be tested.
Second, in example 5 a function call is done using printsum 12 6, without any brackets or separators in the function call, whilst all other examples use function(args) as the syntax. Should we be able to parse both?
Thanks; corrected.
Also, with respect to command line arguments, should our program check if the number of arguments passed to the program is sufficient and print to stderr like follows
This is the 2nd point of the 'Project requirements'.
My question about argument checking was poorly worded. It is clear to me that runml should perform argument checking, what I meant to ask was whether the ml scripts compiled by our program should perform argument checking as well. For example if a ml script is as follows,
print arg0 + arg1
```.
Should we assume that all arguments will be provided or should we generate C code to check if 2 arguments are provided? Additionally, does ```arg0``` in ml represent the name of the executable like ```argv[0]`` does in C or is it the first real number argument provided?
Sorry for the inconvenience.
My question about argument checking was poorly worded. It is clear to me that runml should perform argument checking, what I meant to ask was whether the ml scripts compiled by our program should perform argument checking as well.
A good question (but, unfortunately, something I was hoping would be recognised as something that "should be done", rather than "must be done").
Yes.
The ml variable arg0 'comes from' C's argv[1], as the C program's name is unlikely to be a real-valued number.