From Free Speech:
diff --git a/pycscope.py b/pycscope.py
index 4e9d07f..39c5b2b 100755
--- a/pycscope.py
+++ b/pycscope.py
@@ -607,7 +607,7 @@ def isTrailerFuncCall(cst):
"""
if len(cst) < 4:
return False
-
+ printCst(cst)
return (cst[-2][0] == symbol.trailer) \
and (cst[-2][1][0] == token.DOT) \
and (cst[-2][2][0] == token.NAME) \
@@ -769,6 +769,7 @@ def processNonTerminal(ctx, cst):
ctx.setMark(cst[-2][2], Mark.FUNC_CALL)
# Suspend COMMA processing in trailers
ctx.in_trailer = ctx.spb_lvl[token.LPAR];
+ print("in_trailer: %s" % ctx.in_trailer)
def processTerminal(ctx, cst):
""" Process a given CST tuple representing a terminal symbol
@@ -914,7 +915,7 @@ def processTerminal(ctx, cst):
return lineno
-def walkCst(ctx, cst):
+def walkCst(ctx, cst, processing=True):
""" Scan the CST (tuple) for tokens, appending index lines to the buffer.
"""
indent = 0
@@ -924,12 +925,13 @@ def walkCst(ctx, cst):
while stack:
cst, indent = stack.pop()
- #print("%5d%s%s" % (lineno, " " * indent, nodeNames[cst[0]]))
+ print("%5d%s%s" % (lineno, " " * indent, nodeNames[cst[0]]))
- if token.ISNONTERMINAL(cst[0]):
- processNonTerminal(ctx, cst)
- else:
- lineno = processTerminal(ctx, cst)
+ if processing:
+ if token.ISNONTERMINAL(cst[0]):
+ processNonTerminal(ctx, cst)
+ else:
+ lineno = processTerminal(ctx, cst)
indented = False
for i in range(len(cst)-1, 0, -1):
@@ -944,6 +946,11 @@ def walkCst(ctx, cst):
e.lineno = lineno
raise e
+def printCst(cst):
+ print("CST subtree starts:")
+ walkCst(None, cst, False) # just print the tree
+ print("CST subtree ends")
+
def parseSource(sourcecode, indexbuff, indexbuff_len, dump=False):
"""Parses python source code and puts the resulting index information into the buffer.
"""
From Free Speech: