Content deleted Content added
Removed vandalism from recent edits |
m →Example: ; : ! {{code}} |
||
Line 24:
Constructing the action and goto table as is done for LR(0) parsers would give the following item sets and tables:
: S → • E
: + E → • 1 E
: + E → • 1
: E → 1 • E
: E → 1 •
Line 35:
: + E → • 1
: S → E •
: E → 1 E •
Line 45:
{| class="wikitable"
|- align="center"
|- align="center"
!1||$||E
|- align="center"
!0
|- align="center"
!1
|- align="center"
!2
|- align="center"
!3
|}
Line 61 ⟶ 66:
{| class="wikitable"
|- align="center"
|S||E||1 |- align="center"
|$||$||1,$ |}
Line 74 ⟶ 81:
}
for example, {{code|mustBeAdded(r2, "1")}} is false, because the left hand side of rule 2 is "E", and 1 is not in E's follow set.
Contrariwise, {{code|mustBeAdded(r2, "$")}} is true, because "$" is in E's follow set.
By using mustBeAdded on each reduce action in the action table, the result is a conflict-free action table:
Line 81 ⟶ 88:
{| class="wikitable"
|- align="center"
|- align="center"
!1||$||E
|- align="center"
!0
|- align="center"
!1
|- align="center"
!2
|- align="center"
!3
|}
|