Module parser :: Class LR1table
[hide private]
[frames] | no frames]

Class LR1table

source code

LRtable --+
          |
         LR1table

Class for construction of a LR1 table

Items are represented by a pair of integers (number of rule, position of dot)

Instance Methods [hide private]
 
closure(self, items)
The closure of a set of LR(1) items I is the set of items construted from I by the two rules:
source code
 
goto(self, items, s)
goto(I,X) where I is a set of items and X a grammar symbol is the closure of the set of all items (A -> sX.r,a) such that (A -> s.Xr,a) in I
source code
 
items(self)
An LR(1) item of a grammar G is a production of G with a dot at some position of the right hand side and a terminal: (rule_number,dot_position,terminal) (aho86:_compil page 231)
source code
 
print_items(self, c)
Print LR(1) items
source code
 
NextToDot(self, item)
returns symbol next to the dot or empty string
source code
 
AfterDot(self, item)
returns symbol next to the dot or empty string
source code
 
dotatend(self, item, i) source code

Inherited from LRtable: __init__, add_action, make_action_goto, resolve_shift_reduce, rules_precedence

Instance Variables [hide private]

Inherited from LRtable: Log, gr, operators

Method Details [hide private]

closure(self, items)

source code 

The closure of a set of LR(1) items I is the set of items construted from I by the two rules:

  • every item of I is in closure(I)
  • If [A -> s.Bt,a] in closure(I),for B ->r and each terminal b in first(ta), add [B ->.r,b] to closure(I)