27 March 2000 Release 2.22 Notes for New Users of PCCTS Version 1.33MR22
9
Ambiguity Aid (-ck 1 -aa if_stmt -aad 1)
This identifies the command line options relevant to the ambiguity analysis.
Choice 1: if_stmt/3 line 6 file ifstmt.g
Choice 2: if_stmt/3 line 6 file ifstmt.g
Choice 1 and Choice 2 are the two alternatives that have ambiguous prediction
expressions. In this case, both choices are on line 6 of the file and the third line of
rule if_stmt (i.e. if_stmt/3).
Intersection of lookahead[1] sets:
ELSE
The intersection of the lookahead sets is simply a restatement of the ambiguity set, but
in an easier to read format. The number of sets should be equal to the -ck value. In
this example, the ck value is 1 and there is only one such set. If the intersection were
empty then there would be no ambiguity and no need for an ambiguity report.
Choice:1 Depth:1 Group:1 (ELSE)
Choice 1: This is a traceback of one way one might run across the token ELSE.
1 #token ELSE if_stmt/3 line 6 ifstmt.g
Starting from line 6 one can easily find an ELSE by flowing into the optional element
of the if_stmt ("{ ELSE stmt }"). The expression "if_stmt/3" says that this is on the
third line of the rule "if_stmt".
Choice:2 Depth:1 Group:2 (ELSE)
Choice 2: This is a traceback of another way one might run across the token ELSE.
The ambiguity exists because there are two such paths. Sometimes I find it easier to
work from the bottom to the top, other times from the top to the bottom. In this case
I'll work from item 1 to item 4.
1 end if_stmt if_stmt/4 line 7 ifstmt.g
Item 1: Instead of flowing forward into the optional ELSE block (as with choice 1) we
pass over it and flow off the end of the if_stmt (hence "end if_stmt") at line 7. Thus we
have an if_stmt with no ELSE clause.
IF e1 THEN s1
2 end stmt stmt/3 line 3 ifstmt.g
Item 2: The if_stmt (item 1) was referenced from stmt at line 3. The use of line 3 is
confusing. The line number is 3 because we have flowed out of the if_stmt at line 1
and out of the implicit and invisible block which encloses the top level alternatives of a
rule. It is as though the rule has been written:
stmt:
( if_stmt
| assign_stmt
) ;
3 in {...} block if_stmt/3 line 6 ifstmt.g
Item 3: After flowing out of the stmt mentioned in item 2 we find ourselves entering
the {...} block in if_stmt at line 6. The only way to flow into the {...} block on line 6 is
by flowing out of the THEN clause on line 5. Recall that we have just flowed out of an
if_stmt that had no ELSE clause (item 1). Thus we now have something like this:
IF e2 THEN IF e1 THEN s1 ...
where the underline identifies an inner if_stmt from item 1.
4 #token ELSE if_stmt/3 line 6 ifstmt.g
Item 4: In item 3 we flowed into the {...} clause on line 6. We have now found the
ELSE token at the start of the {...} clause. Thus we now have something that like this: