In old versions of Fortran that did not have the character data type, character strings were expressed in the following format:
<string literal> ::= <numeral> H <string>
where the <numeral>
is a base-ten integer (≥ 1), H
is a keyword, and <string>
is a sequence of characters.
The semantics of this string literal is correct if the numeric value of the base-ten numeral matches the length of the string.
Write an attribute grammar using only synthesized attributes for the nonterminals in the definition of <string literal>
. (25%)