Skip to content

Commit

Permalink
New field: ident.column
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Jul 8, 2014
1 parent 8339ab3 commit e26bce6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion smop/graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ def resolve(t,fp,func_name):
fp.write('graph [rankdir="LR"];\n')
for u in node.postorder(t):
if u.__class__ in (node.ident,node.param):
fp.write("%s [label=%s_%s_%s];\n" % (u.lexpos,u.name,u.lineno,u.lexpos))
fp.write("%s [label=%s_%s_%s];\n" % (u.lexpos,u.name,u.lineno,u.column))
if u.defs:
for v in u.defs:
fp.write("%s -> %s" % (u.lexpos,v.lexpos))
if u.lexpos < v.lexpos:
fp.write('[color=red]')
else:
fp.write('[label=%s.%s]' % (v.lineno,v.column))
fp.write(';\n')
fp.write("}\n")

Expand Down
2 changes: 1 addition & 1 deletion smop/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class number(atom,recordtype("number","value lineno lexpos",default=None)):
def __str__(self):
return str(self.value)

class ident(atom,recordtype("ident","name lineno lexpos defs",default=None)):
class ident(atom,recordtype("ident","name lineno column lexpos defs",default=None)):
def __str__(self):
return self.name

Expand Down
4 changes: 3 additions & 1 deletion smop/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,11 @@ def p_expr_ident(p):
if p[1] == "nargin":
global use_nargin
use_nargin += 1
#import pdb; pdb.set_trace()
p[0] = node.ident(name=p[1],
lineno=p.lineno(1),
lexpos=p.lexpos(1))
lexpos=p.lexpos(1),
column=p.lexpos(1) - p.lexer.lexdata.rfind("\n",0,p.lexpos(1)))

def p_expr_number(p):
"number : NUMBER"
Expand Down

0 comments on commit e26bce6

Please sign in to comment.