diff options
author | Tomas Kukosa <tomas.kukosa@siemens.com> | 2006-08-15 13:14:43 +0000 |
---|---|---|
committer | Tomas Kukosa <tomas.kukosa@siemens.com> | 2006-08-15 13:14:43 +0000 |
commit | 42f51129ff7c12ebbc4043a278b8b34597e19944 (patch) | |
tree | d62118ceba4f7a06e2464c98180b8790445dd79c /tools | |
parent | c285c838f7493eda9370d3cb7ba4aa38d1de6dcf (diff) |
Ply updated to version 1.8
svn path=/trunk/; revision=18910
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/lex.py | 2 | ||||
-rwxr-xr-x | tools/yacc.py | 17 |
2 files changed, 16 insertions, 3 deletions
diff --git a/tools/lex.py b/tools/lex.py index be9fb0ea22..15af21357b 100755 --- a/tools/lex.py +++ b/tools/lex.py @@ -186,7 +186,7 @@ scanner you have defined. # ----------------------------------------------------------------------------- -__version__ = "1.7" +__version__ = "1.8" import re, types, sys, copy 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 |