PTHL FAQ

Translating escapes in the scanner (or not)

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.

Must lexical and syntactic extensions be implemented?

No. Language extensions (see Language Extensions in Tiger Compiler Reference Manual) such as metavariables keywords (_chunks, _exp, _lvalue, _namety) and casts (_cast) are not required for PTHL.

Handling metavariables constructs becomes mandatory at TC-2 (TC-2 Code to Write) where they are used within TWEASTs (Text With Embedded AST, see 04-ast.pdf), while casts are only needed for the optional bounds checking assignment (TC-B, Array bounds checking).

What values can be represented by an 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]\).

What values can be represented by an integer literal?

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