/usr/share/GvRng/translate.py is in gvrng 4.4-3~deb9u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # see INFO for license
import build
import gvrparser
import re
def stripComments(program):
return [line.split("#")[0].replace(':', ' : ') for line in program.splitlines()]
def getTokens(lines):
return [ {
'statement' : word,
'line' : idx,
'indent': len(lines[idx])-len(lines[idx].lstrip())
} for idx in range(len(lines)) for word in lines[idx].split()
]
def gvrToSyntaxTree(gvr):
if not re.search('\S', gvr):
raise gvrparser.ParseEmptyFileException()
return gvrparser.parseProgram(getTokens(stripComments(gvr)))
def gvrToPython(gvr):
return build.buildProgram(gvrToSyntaxTree(gvr))
|