comparison ide/compiler/nodes.py @ 4:0d5ef85b8698

Improved link between ast viewer and code edit
author windel-eee
date Wed, 21 Sep 2011 19:05:18 +0200
parents 92df07bc2081
children
comparison
equal deleted inserted replaced
3:77202b0e0f40 4:0d5ef85b8698
1 """ 1 """
2 Parse tree elements 2 Parse tree elements
3 """ 3 """
4 class Node: 4 class Node:
5 location = None
5 def getChildren(self): 6 def getChildren(self):
6 children = [] 7 children = []
7 members = dir(self) 8 members = dir(self)
8 for member in members: 9 for member in members:
9 member = getattr(self, member) 10 member = getattr(self, member)
14 if isinstance(mi, Node): 15 if isinstance(mi, Node):
15 children.append(mi) 16 children.append(mi)
16 return children 17 return children
17 18
18 class Symbol(Node): 19 class Symbol(Node):
19 pass 20 pass
21
22 class Id(Node):
23 def __init__(self, name):
24 self.name = name
25 def __repr__(self):
26 return 'ID {0}'.format(self.name)
20 27
21 # Selectors: 28 # Selectors:
22 class Field(Node): 29 class Field(Node):
23 def __init__(self, fieldname): 30 def __init__(self, fieldname):
24 self.fieldname = fieldname 31 self.fieldname = fieldname