A
aramildaern
Hi everyone! I don't mean to intrude, but ive heard great things about this group and ive stumped myself with my python code.
heres my code:
#! /usr/bin/python
import sys
global labelList
labelList= dict()
global counter
counter = 0
def execute(line):
if line.find(":rint") != -1:
stripPrint = line.find(":rint")
startPrint = line.find('"', stripPrint)
stopPrint = line.find('"', startPrint + 1)
printSection = line[startPrint + 1 : stopPrint]
print(printSection)
if line.find("::label") != -1:
stripLabel = line.find("::label")
startLabel = line.find(' ', stripLabel)
stopLabel = line.find('--', startLabel + 1)
label = line[startLabel + 1 : stopLabel]
line.strip("\r\n")
labelList[label] = counter
if len(sys.argv) < 2:
print("error: no input files")
print("compilation terminated")
else:
fileName = sys.argv[1]
jadeFile = open(fileName, 'r')
for line in jadeFile:
counter = counter + 1
execute(line)
jadeFile.close()
i = 0
while i < len(labelList):
print(labelList.keys(), ":", labelList.values())
i = i + 1
and its giving me a bunch of errors thanks for the help in advance!
heres my code:
#! /usr/bin/python
import sys
global labelList
labelList= dict()
global counter
counter = 0
def execute(line):
if line.find(":rint") != -1:
stripPrint = line.find(":rint")
startPrint = line.find('"', stripPrint)
stopPrint = line.find('"', startPrint + 1)
printSection = line[startPrint + 1 : stopPrint]
print(printSection)
if line.find("::label") != -1:
stripLabel = line.find("::label")
startLabel = line.find(' ', stripLabel)
stopLabel = line.find('--', startLabel + 1)
label = line[startLabel + 1 : stopLabel]
line.strip("\r\n")
labelList[label] = counter
if len(sys.argv) < 2:
print("error: no input files")
print("compilation terminated")
else:
fileName = sys.argv[1]
jadeFile = open(fileName, 'r')
for line in jadeFile:
counter = counter + 1
execute(line)
jadeFile.close()
i = 0
while i < len(labelList):
print(labelList.keys(), ":", labelList.values())
i = i + 1
and its giving me a bunch of errors thanks for the help in advance!