Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rewrite progress + removes ArgumentList in favour of list of strings
While and if done
  • Loading branch information
gvx committed Mar 17, 2011
1 parent e440cc0 commit 8fc01b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
20 changes: 16 additions & 4 deletions eval.py
Expand Up @@ -109,8 +109,8 @@ def pushvalue(self, value):

def pushword(self, word, closure):
if isinstance(word, Closure):
for name in word.node.arguments.children:
word.setlocal(name.value, self.popvalue())
for name in word.node.arguments:
word.setlocal(name, self.popvalue())
return word.body, word
elif callable(word):
return word(self, closure)
Expand Down Expand Up @@ -154,9 +154,21 @@ def getnextupnode(self, node, closure):
p.closure.setlocal(p.countername, item)
return p.body
elif isinstance(node, ConditionClause):
if isinstance(p, (WhileStatement, IfClause, ElseIfClause)):
if isinstance(p, WhileStatement):
if self.popvalue():
return p.body
elif isinstance(p, (IfClause, ElseIfClause)):
if self.popvalue()
return p.children[0]
else:
c = p.parent.elseifclauses
i = p in c and c.index(p) or -1
if i < len(c) - 1:
return c[i+1]
elif p.parent.elseclause:
return p.parent.elseclause
node = p.parent
continue
elif isinstance(p, ForStatement):
item = self.popvalue()
hidden = self.popvalue()
Expand All @@ -180,7 +192,7 @@ def getnextupnode(self, node, closure):
if self.gettype(p.func) == 'ident':
p.func = closure.getword(p.func)
return self.pushword(p.func, closure)
elif isinstance(p, (IfClause, ElseIfClause)):
elif isinstance(node, (IfClause, ElseIfClause)):
node = p.parent
continue
elif isinstance(p, LabdaStatement):
Expand Down
9 changes: 1 addition & 8 deletions func.py
Expand Up @@ -3,7 +3,7 @@
class LabdaStatement(SimpleStatement):
def __init__(self, parent, arguments, linenr):
SimpleStatement.__init__(self, parent, linenr)
self.arguments = ArgumentList(self, arguments)
self.arguments = arguments

class FuncStatement(LabdaStatement):
def __init__(self, parent, arguments, linenr):
Expand All @@ -13,10 +13,3 @@ def __init__(self, parent, arguments, linenr):
class LocalFuncStatement(FuncStatement):
def __init__(self, parent, arguments, linenr):
FuncStatement.__init__(self, parent, arguments, linenr)

class ArgumentList(Clause):
def __init__(self, parent, tokens):
Node.__init__(self, None)
self.parent = parent
for token in tokens:
WordList.gettokenclass(token)(self, token)

0 comments on commit 8fc01b1

Please sign in to comment.