Next: PTHL Improvements, Previous: PTHL Code to Write, Up: PTHL (TC-0) [Contents][Index]
Escapes in string can be translated at the scanning stage, or kept as
is. That is, the string "\n"
can produce a token STRING
with the semantic value \n
(translation) or \\n
(no
translation). You are free to choose your favorite implementation, but
keep in mind that if you translate, you’ll have to “untranslate”
later (i.e., convert \n
back to \\n
).
We encourage you to do this translation, but the other solution is also correct, as long as the next steps of your compiler follow the same conventions as your input.
You must check for bad escapes whatever solution you choose.
No. Language extensions (see Language Extensions in Tiger Compiler Reference Manual) such as metavariables keywords (‘_decs’, ‘_exp’, ‘_lvalue’, ‘_namety’) and casts (‘_cast’) are not required for PTHL.
Handling metavariables constructs becomes mandatory at TC-2 (see TC-2 Code to Write) where they are used within TWEASTs (Text With Embedded AST, see ast.pdf), while casts are only needed for the optional bounds checking assignment (see TC-B).
int
?The set of valid integer values is the set of signed 32-bit integers in 2’s complement, that is the integer interval [-2^{31}, 2^{31}-1].
Although an integer value can be any number in [-2^{31}, 2^{31}-1], it is however not possible to represent the literal -2^{31} (= -2147483648) for technical reasons. It is however possible to create an integer value representing this number.
To put it in nutshell, the following declaration is not valid:
var i := -2147483648
whereas this one is:
var i := -2147483647 - 1
Next: PTHL Improvements, Previous: PTHL Code to Write, Up: PTHL (TC-0) [Contents][Index]