aboutsummaryrefslogtreecommitdiffstats
path: root/tools/yacc.py
diff options
context:
space:
mode:
authorTomas Kukosa <tomas.kukosa@siemens.com>2006-08-15 13:14:43 +0000
committerTomas Kukosa <tomas.kukosa@siemens.com>2006-08-15 13:14:43 +0000
commit42f51129ff7c12ebbc4043a278b8b34597e19944 (patch)
treed62118ceba4f7a06e2464c98180b8790445dd79c /tools/yacc.py
parentc285c838f7493eda9370d3cb7ba4aa38d1de6dcf (diff)
Ply updated to version 1.8
svn path=/trunk/; revision=18910
Diffstat (limited to 'tools/yacc.py')
-rwxr-xr-xtools/yacc.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/yacc.py b/tools/yacc.py
index 4c6e97d613..cc5840c139 100755
--- a/tools/yacc.py
+++ b/tools/yacc.py
@@ -48,7 +48,9 @@
# own risk!
# ----------------------------------------------------------------------------
-__version__ = "1.7"
+__version__ = "1.8"
+
+import types
#-----------------------------------------------------------------------------
# === User configurable parameters ===
@@ -103,7 +105,10 @@ class YaccProduction:
self.pbstack = []
def __getitem__(self,n):
- return self.slice[n].value
+ if type(n) == types.IntType:
+ return self.slice[n].value
+ else:
+ return [s.value for s in self.slice[n.start:n.stop:n.step]]
def __setitem__(self,n,v):
self.slice[n].value = v
@@ -200,6 +205,8 @@ class Parser:
# Get the next symbol on the input. If a lookahead symbol
# is already set, we just use that. Otherwise, we'll pull
# the next token off of the lookaheadstack or from the lexer
+ if debug > 1:
+ print 'state', statestack[-1]
if not lookahead:
if not lookaheadstack:
lookahead = get_token() # Get the next token
@@ -216,6 +223,12 @@ class Parser:
ltype = lookahead.type
t = actions.get((s,ltype),None)
+ if debug > 1:
+ print 'action', t
+ if t is None:
+ t = actions.get((s,'#'),None)
+ if debug > 1:
+ print 'default action', t
if t is not None:
if t > 0:
# shift a symbol on the stack