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

Class LRtable

source code

Known Subclasses:

Class for construction of a LR table

Instance Methods [hide private]
 
__init__(self, cfgr, operators=None, noconflicts=1, expect=0) source code
 
make_action_goto(self)
make action[i,X] and goto[i,X] All pairs (i,s) not in action and goto dictionaries are 'error'
source code
 
rules_precedence(self)
Rule precedence obtained as the precedence of the right most terminal.
source code
 
add_action(self, i, a, action, j)
Set (action,j) for state i and symbol a or raise conflict error.
source code
 
resolve_shift_reduce(self, i, a, s, r)
Operators precedence resolution or standard option: shift
source code
Instance Variables [hide private]
  Log
Log report for LR table construction
  gr
a context-free grammar
  operators
operators
Method Details [hide private]

__init__(self, cfgr, operators=None, noconflicts=1, expect=0)
(Constructor)

source code 
Parameters:
  • cfgr - a context-free grammar
  • operators - operators
  • noconflicts (integer) - if 0 LRtable conflicts are not resolved, unless for spcecial operator rules
  • expect (integer) - exact number of expected LR shift/reduce conflicts

add_action(self, i, a, action, j)

source code 

Set (action,j) for state i and symbol a or raise conflict error. Conficts are resolved using the following rules:

  • shift/reduce: if precedence/assoc information is available

try to use it; otherwise conflict is resolved in favor of shift

  • reduce/reduce: choosing the production rule listed first

resolve_shift_reduce(self, i, a, s, r)

source code 

Operators precedence resolution or standard option: shift

s: rule for shift r: rule for reduce