It's UWAweek 47

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 828 articles.
Currently 98 other people reading this forum.


 UWA week 37 (2nd semester, week 7) ↓
SVG not supported

Login to reply

👍?
helpful
9:04pm Thu 12th Sep, Joshua N.

"Samay Gupta" <23*6*5*8@s*u*e*t*u*a*e*u*a*> wrote:
> Q1) I saw the thread that you shared but it means that we will have to store the expression, evaluate it and then handle the value. something like - > double temp = <entire expression>; > if (temp==int(temp)){....}
It would. Or you can write an if statement in the c version of the ml file to change what is printed, then let c do the hard work.
> Q2) So if i understand correctly, the expectation is that runml.c should compile the translated code using "cc -std=c11 -Wall -Werror -o runml runml.c"?
That would make the most logical sense. Since warnings can be errors and do something unintended.
> Q3) One related question, ml can have code like this - > > x <- 3 > function add a > return a+5 > > add(x) > > function multiply b > return b*5 > > multiply(x) > print x > > I can keep first line outside main function (global variable), and then parse entire ml code find all functions and then move them to the top (outside main) in translated code. any suggestions, or can we assume that all the functions in ml language will be declared first (ahead of other expressions/statements)?
No guarantees about the order in which statements appear in ml. You could store the functions in one file and the main function in another. Or you could store two arrays one containing the function definitions and the other containing the contents that will be in main and then they just write the function definitions first and then write the contents to main next. Or you could go through the file twice find the functions write them to the file and then go through the file a second time and get the statements. There are many ways to approach it.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy