.. (לתיקייה המכילה) | ||
For an if / while statement followed by a block {} how many scopes should we open? | |
Two scopes. One for the if / while and one for the block. Notice that in this case the if / while scope will be empty. The test t2.{in,out} shows such an example. |
How should the dangling else problem be resolved? | |
The dangling else should be resolved as in C language. Meaning that: if (a) if (b) ... else ... is interpreted as: if (a) { if (b) ... else ... } |
If a precondition uses a variable or a function, what should we check? | |
You should check that the precondition makes use of defined identifiers. Meaning that a function should be defined before the current function and a variable should be an argument of the function. |
If during parsing I see a main function with parameters or with a return type other than void should I exit with an errorMainMissing? | |
No. Checking that there exists a main function with the correct parameters should only be done after parsing the entire program. |
Asuume the statement: | |
As explained in the precedence table, the relational operators are non-associative, and thus the following: bool a = 1 < 2 < 3; should raise a syntax error. |
Can a function argument have the same identifier as a variable that is defined in some other function? | |
Yes. Since the variable is not defined in the same scope of the argument nor in its ancestor. For example: bool foo(int x, int y) { int z; return x < y;<br>} bool bar(int z) { return z > 0; } void main() { return; } is a valid program. |