diff --git a/smop/graphviz.py b/smop/graphviz.py index 25f90981..79a91456 100644 --- a/smop/graphviz.py +++ b/smop/graphviz.py @@ -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") diff --git a/smop/node.py b/smop/node.py index bcfed61d..2f55ce59 100644 --- a/smop/node.py +++ b/smop/node.py @@ -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 diff --git a/smop/parse.py b/smop/parse.py index f45c255e..e98a6f36 100644 --- a/smop/parse.py +++ b/smop/parse.py @@ -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"