Skip to content

Instantly share code, notes, and snippets.

@alenbasic
Created August 10, 2016 13:35
Show Gist options
  • Save alenbasic/9f077a8203fc67f26fe6038f31b45b2e to your computer and use it in GitHub Desktop.
Save alenbasic/9f077a8203fc67f26fe6038f31b45b2e to your computer and use it in GitHub Desktop.
A text "call graph" generator for SQR files. Checks procedures for calls to other procedures and prints the procedures and the calls they make.
#!/usr/bin/python
import sys
f = open(sys.argv[1],'r').readlines()
arr = []
proc = False
for line in f:
if "begin-pro" in line:
print line.strip()
proc = True
elif proc and "do " in line:
try:
if line.index("!") < line.index("d"):
continue
except ValueError as error:
pass
line = line.strip()
line = line.split("!")
arr.append(line[0])
elif "end-pro" in line:
for l in arr:
print "\t- %s" % l
print ""
arr = []
proc = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment