ANONYMOUS wrote
This is not what Chris means. He means to not submit header files (e.g. you can't submit a header file you wrote). You still have to import header files or compilation will fail.
Your code won't compile if you do this.
This is what ...
ANONYMOUS wrote
You can make assumptions about any of the project requirements that are unclear. In the doc you are stating what you believe you are meant to do or what you believe the requirements are telling you to do. E.g. one assumption could be ...
ANONYMOUS wrote
No, I don't think so, since they represent the command line arguments. However, since it hasn't been clarified you can put whatever you assume in the doc.
ANONYMOUS wrote
Possibly, but it is a bit ambiguous you could probably have an assumption in your assumption doc about it.
This definitely has to be true.
I believe the point 9 is stating that in the ml file the function definition has to come before t...
ANONYMOUS wrote
Option d is wrong. You just had a lucky number choice where the result is the same.
If you first divide by ten you perform integer division and so the result becomes 2409, modulo 100 gives 09, which is 9 in this case.
A is correct. modu...
ANONYMOUS wrote
I believe Chris intended students to actually parse the strings themselves. If you want confirmation, you will have to ask Amitava. Honestly, I don't think regex.h will make your life easier.
ANONYMOUS wrote
I mean a lot of the advice given on the forum is based off the project requirements and clarifications Chris made, so it really depends on which advice you are talking about.
A rule of thumb for assumptions is If you make an assumpti...
ANONYMOUS wrote
This is a statement, so yes. pqr will be zero so it won't matter. sas will cause the error, since there are two identifiers followed after each other in a statement, which is invalid syntax.
This is invalid syntax.
program
A program is made up of zero or more program items.
program-item
A program item is either a statement or a function, a function can have zero or more identifiers.
statement
A statement is either an assignment or a pri...
ANONYMOUS wrote
The file is temporary and will be deleted by your program. So, you can name it whatever you want (but make 110 sure the name doesn't and will not collide with other file names when run on other people's computers). However, the reaso...
ANONYMOUS wrote
Write them to the file into their respective identifiers. E.g. arg0 is argv 2
assumption.
I believe Chris said that you can assume the appropriate number of command line arguments are passed to the ml program
https secure.csse.uwa....
ANONYMOUS wrote
You can't pass "integers" to a function; the arguments are always doubles, so even if you pass 2, because the argument was defined to be a double, it will become 2.0. Every time you see a constant number, just put (double) in front of...
ANONYMOUS wrote
Amitava needs to answer this one.
From project specification
"Your submission will be examined, compiled, and run on a contemporary Ubuntu Linux or macOS platform. Your project only needs to execute successfully on one of these platfo...
Hi Yuxuan
You are allowed to make assumptions and submit them with your code submission. I believe the original intension was that all expressions will be valid, so you don't need to check them. Statements in a function should be 1 tab and everything ...
ANONYMOUS wrote
Yea that's fine as long as you delete all the files you create.
The only thing that needs to be a single file is the runml program itself.
ANONYMOUS wrote
Yes, otherwise if you have already done it Amitava said you can state the assumptions you made in a file. So, you can do either, just state what assumption you made.
If you want to be 100 sure you can ask Amitava.
You can always do something with var to remove the warning. Literally just do var var 1 and the warning will go away.
ANONYMOUS wrote
Technically they're not considered "identifiers" just "variables". So, in other words, they're an exception to the rule. As stated in the project description
"8.the variables arg0, arg1, and so on, provide access to the program's comm...
ANONYMOUS wrote
It does apply to comments. He made the change to make sure the project isn't too hard.
From Oxford English Dictionary
"white space n. (a) Typography the blank areas of a page or other piece of printed matter, as margins, gutters betwe...
ANONYMOUS wrote
You are missing something.
You replace the identifiers (in the ml file) arg0, arg1, arg2, etc. By the command line arguments that are passed to run ml. e.g.
. runml somefile.ml 1 2 3
means that in the ml file the parameters will be initi...
ANONYMOUS wrote
Why can't the same identifier name be reused? After the function ends the program would believe it is seeing the identifier for the first time and so would initialize it to 0.
ANONYMOUS wrote
I believe Chris said either in the forum or the project sheet that all statements must start at the lefthand most side of the file unless it is a statement in a function.
Not sure where a comment could appear (because technically comme...
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.
That would make the most logical sense. Since warnings can be errors and do something unintended.
No guarantees about the...
Yes, I forgot there are no "if" statements in ml, because there are no "if" statements, it would run forever. So, don't worry about recursion. Can't see the point in testing an infinite loop.
ANONYMOUS wrote
Hey guys, ml accepts whole numbers, there is no example in the ml file where there is a decimal point after a whole number, e.g. 2.0 would just appear as 2 in the ml file. I'm assuming as more decimal places are required they will be ...
You wouldn't need to check mismatched brackets as Chris said expression checking isn't necessary.
Yes, if 24.00, print as 24. if 24.5, print as 24.500000
Not sure but better to be safe than sorry and assume it can be as deep as it is in C.
Hi Trisha,
Sorry for the delay.
If no clarification is given, better to be safe than sorry and assume it is possible. This functionality is allowed within the ml syntax.
Identifiers and functions shouldn't have the same name.
Syntax of ml allows this. You should be able to just copy the function call into c and it would work.
You need to change the format string of printf so that you print the double without any decimal places. Answered here
https secure.csse.uwa.edu.au run help2002?p np opt U245 hl integer
I would say so. Some warning in C are straight up errors and res...
ANONYMOUS wrote
Hi I don't believe empty lines are allowed in ml, all the sample files have no empty lines and instead use a comment to create an "empty" line.
ANONYMOUS wrote
Depends on whether the function returns a value or not. You could just always have the function return a double and just add return 0.0 to the end of the function if there is no return value.
ANONYMOUS wrote
If the ml file prints then the correct output should appear in the terminal. The ml file should throw an error if there a syntax error in the ml file. Likewise the ml file should correctly run and not throw an error if there are no er...
Hi Zexu,
"7.variables do not need to be defined before being used in an expression, and are automatically initialised to the (real) value 0.0"
"12. a function's parameters and any other identifiers used in a function body are local to that function, an...
Hi
From my understanding, Chris said "appearing" so, you should only see at most 50 unique identifiers in a single ml file. So, in the case above b would count towards the total.
ANONYMOUS wrote
Hi
From my understanding, Chris said "appearing" so, you should only see at most 50 unique identifiers in a single ml file. So, in the case above b would count towards the total.
Actually sorry, I just realized made a mistake the datatype used should be doubles not floats because it has more precision (e.g. reduces rounding errors). So that way if you're multiplying dividing real numbers and showing 6 decimal plac...
ANONYMOUS wrote
"4.only a single datatype is supported - real numbers, such as 2.71828"
All parameters will be real numbers (doubles) as that is the only datatype supported.
np.
It is this bit "Otherwise, whitespace can (but doesn't need to) appear anywhere else"
In other words, both ways of calling the function as you have shown above are correct. A function call can have white space but doesn't need to have white sp...
ANONYMOUS wrote
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 st...
Hi Harrison
Sorry for the delay, unfortunately, there's been sudden changes to the teaching staff, so I have to wait for the new unit coordinator to clarify these questions.
Answered here https secure.csse.uwa.edu.au run help2002?p np opt U201
perr...
ANONYMOUS wrote
Honestly it would be very hard to tell if a statement is meant to be in a function but it isn't. Since ml syntax allows statements to be inside or outside a function, there's no way of telling if they belong to a function if they aren...
There are no integers in the ml program, all the constants are real numbers, as that is the only datatype supported by ml. So, all the constant integer values in the ml program are actually floats. e.g. "2" is technically "2.0". If there are rounding...
ANONYMOUS wrote
There are no guarantees what the last statement in a function will be, it could return, it could print, or it could be another statement (the syntax of ml allows this). So, relying on seeing a particular statement to know if the funct...
ANONYMOUS wrote
You do not need to display the comments in the c file. Since the c file gets deleted anyway. So, when you come across a comment in ml you can just ignore it.
Ok let me try writing this out again, since half of my response got deleted. When you run your program like so
. runml sample.ml
runml (your project) will read the ml file given as the first parameter (in this case sample.ml), it will validate th...
ANONYMOUS wrote
Hi anon, I'm not 100 sure what you are asking but when you run your program like so
. runml sample.ml
runml (your project) will read the ml file given as the first parameter (in this case sample.ml), it will validate the m...
Hi Chenjun,
When printed, numbers that are exact integers must be printed without any decimal places; other numbers must be printed with exactly 6 decimal places.
Your program wouldn't need two datatypes, it would just need to change the format string ...
ANONYMOUS wrote
Hi anon, I believe your question in answered in these two posts
https secure.csse.uwa.edu.au run help2002?p np opt U145
https secure.csse.uwa.edu.au run help2002?opt U132
Yes, that would break my cool idea. However, we can still fix it, just keep track of the quotes too. If we saw a quote ignore everything until we see another quote.
Unfortunately, ml only supports real numbers, which makes me sad as this circumstance ...
Hi Guys,
Sorry about the delays replying. Some questions about project requirements are really good so I need further clarification (from teaching staff) before I can respond (I don't want to make the project too hard). So, for now if you are unsure o...
I should also mention you'd likely need to recursively "check" functions, e.g. If you're checking the parameters and encounter another function, start checking the new function.
But like I said I'm not sure if it is necessary.
I'm not sure if it is necessary but it does sound like fun (if you're me anyway).
You could check the number of arguments by counting the number of commas and the number of open brackets without a closing bracket. If number of open brackets is 1, then...
Hi
Functions don't always have a return statement (see sample05.ml). Your other question in this post https secure.csse.uwa.edu.au run help2002?p np opt U145
Hey Guys, sadly I am not the prof, but I believe your questions are answered by the following posts
1. https secure.csse.uwa.edu.au run help2002?p np opt U145
2.https secure.csse.uwa.edu.au run help2002?opt U132
Hi, the way I remember it is that refers to a pointer if a datatype comes before it e.g. int . If there is no type beforehand, then is the dereference operation.
e.g. int p , declares a pointer to an int.
p refers to...
ANONYMOUS wrote
You're right. I think there is a typo in the answer. None of the options are correct. However, there is one option that is very close to the correct answer. Can you see which one it is?
ANONYMOUS wrote
One place to the left means index - 1 .
e.g. If an integer is at index 3 it will be at index 2 after the code runs. Likewise, if an integer is at index 1, then after the code runs it will be at index 0.
I hope that makes sense.
Hi Guys,
I am just reminding you to always keep up to date with the lectures, workshops and labs . If you don't you will struggle with this unit as there is a lot of content.
Do not skip the lab exercises they are assessable and build up the fou...
Hey Jinyoung
If I remember correctly floats are 4 bytes and doubles are 8 bytes (hence the name double) but Chris may need to clarify.
An integer value must be at least 2 bytes (or 16 bits) but it is usually 4 bytes (32 bits). It's a bit confusing ...