Download TABLE INPUT METHOD - Department of Computing and Software
Transcript
The syntax of the TIM parser productions then is as follows:
Construct
<TokenName>
NonTerminal()
void NonTerminal(): #Node {}
{
Y1…Ym
}
// comment
/* comment */
LOOKAHEAD(k)
@TTS_NODE@
(Y1…Ym) #ConditionalNode(>n)
Description
A token, member of Vt. Token TokenName must
be declared in the scanner section.
A non-terminal, member of Vn
Declares
a
NonTerminal→Y1…Ym
rule.
#NodeName declares that a syntax tree will always
be constructed for this rule.
Comment starts at // until the end of line
Comment is contained between matching /* and */
Declares to use local look-ahead of k tokens. Used
for rule conflict resolution.
Declares the preceding token to be a representative
token for the rule – this information is used to
reconstruct input string from the stored syntax tree
(see Appendix C: Translating Stored Expressions to
Strings).
This optional construct placed around Y1…Ym
indicates that a syntax tree node will be constructed
only if as a result of processing of non-terminals it
will have more than n child nodes. If there are less
than n child nodes, node is not created. The child
nodes will be assigned to a nearest node up the tree.
Table 26: Meaning of parser rule constructs
The rules of a TIM parser are further constrained by the input string
reconstruction algorithm described in Appendix C: Translating Stored Expressions to
Strings below.
112