![]() |
.. (לתיקייה המכילה) | |
What should happen when a MATH program tries to print an uninitialized variable? | |
This error is of mixed type - both compile-time and run-time, although in this specific grammar all such checks can be done during compilation. This feature will be left untested, so you're allowed not to implement handling for this case. |
1. Regarding casting: if there is a cast from int to real, such as | |
1. double(5) 2. self casting is up to you 3. '\n' 4. Consider this as an exclusion 5. Do what you were tought in programming courses. We expect you to provide stable and consistent program. |
In your example you use the keyword %left when you defined the var OP. | |
This is the way for setting operator associativity. See cheatsheet for details. |
i tried | |
At least reccomended to change it from + to "+". You may also define it by some variable: %type PLUS, annd support it by LEX definition. |
1. in scanf and prinf, in the complex format, it is written "%lf+%lfi". | |
1.For "print 1-1i" you'll print 1.000000+-1.000000i, according to the format specification. For "print 1+1i" you'll print 1.000000+1.000000i Assume, that for input you can only recive positive pairs like 3+5i, 4.5+2.3i. This should be enough to solve the ambiguity. 2. Ident is a nice thing. Identing is recommended, implementation is up to you. 3. Yes, undeclaredIdentifierError(). 4. man scanf. 5. No, the C-implementation is implicit. For run-time corectness we'll validate only final outputs of "print" statement. But still, your C-code will be checked for standing in assignment criteria. |
in the semantics of the rule | |
There must be "\n". |
We have a question regarding the memory management: are we allowed to allocate | |
You're writing some code that gonna be executed by others (course staff for example). So your code must be accurate and stable meaning that the memory must be managed correctly. |
1. from previous questions in the FAQ section it is implied that "1+i" | |
1. Right, fixed. print can be applied only to some identifier. We used the simplified syntax to illustrate the behaviour 2. No. 3. Same as C: 3/2 = 1. 4. CORRECTED: IT IS LEGAL. WE WON"T TEST THIS FEATURE. |
1. from previous questions in the FAQ section it is implied that "1+i" | |
1. right, it should be 1+1i. Remember though, that print can be applied only to some identifier. 2. No. 3. C-like: 3/2 = 1 4. No, you use undeclared variable. |
Can we use some temporal complex variables for computations? | |
You're allowed to use ONE temporal complex variable, it should be also allocated in DATA. |
Consider a definition like: "int a; int b=a;" (or "int a=5; int | |
My fault - it's run-time check, so you shouldn't check it in compilation time. I fixed the FAQ. |
do you forbid the use of global variables in any way? | |
In the generated code - surely. But you may use them in yacc itself. |
should we ignore the possibility of dividing by zero in complex numbers as well? | |
yep |
Is there a bonus if the program allows more than 50 variables? are there any other possible bonuses? | |
Not really. Personally I would promise bounty for caught cheaters, but not this time. |
What should we do if the program has symbols after the body, i.e. | |
Let BISON hadle it by it's default way. |
May we assume that malloc always succeed? | |
Yes |
may we "postpone" claculations which can be done during compile time, | |
yes |
may we assume that no lexical errors exist ? | |
You must report lexicalError in such case |
If there are few errors, which one are we supposed to print? | |
You are supposed to report the earliest error you meet. In this case, before you approach 5.0 you can detect identifierRedeclarationError . |
Are we allowed to use a temporary file to write to (while parsing), and to read | |
no |
if there are aninitialized variables, should they be printed in the generated code? (in the example you wrote, there is only an initialized variable). | |
Assume, that no uninitialized variable will be printed |
what should be in the target code when there is assign to a complex number: | |
This a subject to your implementation. |
what should be done if there is exp->id , when the id is not initialized | |
No special treatment should be for checking variable initialization. This is not compile-time check. |
what is the proper code for exp -> TYPE L_PAREN EXP R_PAREN when the type | |
This is well-defined in the exercise. It must report complexConversionError. |
if any lexical or syntactical error is encountered, | |
Yes, in this case you're allowed not to free allocated memory. |
should i explicitly tell bison to end the program when it reduces to S | |
it's ok to consider that the compilation is over and to produce final c-code. Don't terminate Bison explicitly. |