def testCodeSamples(codeSamples, langs, theSyntaxRules):
    listOfExceptions = []
    for current1 in codeSamples:
        code = syntaxRules.testMacro(theSyntaxRules,current1)
        #raise Exception(code)
        #raise Exception(code)
        for current2 in langs:
            try:
                testCode(code, current2)
            except EngScriptException as e:
                import traceback
                listOfExceptions += [str(e).split(" is not yet defined for ")]
                print traceback.format_exc()
    if listOfExceptions != []:
        currentFunction = listOfExceptions[0][0]
        stringToPrint = ""
        for i in range(1, len(listOfExceptions)):
            if listOfExceptions[i][0] == listOfExceptions[i - 1][0] and len(listOfExceptions[i]) > 1:
                listOfExceptions[i][1] = listOfExceptions[i-1][1] + "," + listOfExceptions[i][1]
                listOfExceptions[i-1] = []
        for i in listOfExceptions:
            if (i != []) and (len(i) == 2):
                stringToPrint = stringToPrint + i[0] + " is not yet defined for " + i[1]+"\n"
        #raise Exception(stringToPrint)
        
        text_file = open("listOfErrors.txt", "w+")
        text_file.write(stringToPrint)
        print(stringToPrint)
        text_file.close()
    return listOfExceptions
def getFilesInLanguages(langs, theSyntaxRules):
    theFileNames = []
    for fileName in os.listdir("EngScript_examples"):
        if fileName.endswith(".txt"):
            theFileNames += [fileName]
    for current in langs:
        for fileName in theFileNames:
            try:
                inputFilePath = "EngScript_examples/"+fileName
                inputText = getFileText(inputFilePath, fileName.replace(".txt", ""))
                theOutputString = outputString(current, syntaxRules.testMacro(theSyntaxRules,inputText), fileName.replace(".txt", ""))
                #print(theOutputString)
                getFileInLanguage(
                    lang = current,
                    theOutputString = theOutputString,
                    outputPath = "EngScript_examples/"+current+"/",
                    outputFile = fileName.replace(".txt", "")+"."+polyglotCodeGenerator.getFileExtension(current),
                    theSyntaxRules = theSyntaxRules
                )
            except Exception as e:
                pass