def defMacro(theInput, theOutput): global syntaxRules global pythonSyntaxArray print("Calling defMacro") print("Define a macro with the input " + theInput + " with the output " + theOutput) syntaxRules += [[[theInput], theOutput]] pythonSyntaxArray = polishNotation2.makeReallyNewInfoArray(syntaxRules, "Python")
polishNotation2.testMacro("absolute value of -3") polishNotation2.testMacro("5 is not equal to 3") polishNotation2.testMacro("5 does not equal 3") polishNotation2.testMacro("'hello' does not contain 'o'") #polishNotation2.testMacro("the array [1,2,3,4] from index 1 to index 3") #polishNotation2.testMacro("all occurrences of 1 in the array [1,2,3,2,3,1]") #polishNotation2.testMacro("arrange [1,2,3,4] randomly") polishNotation2.testMacro("rotate the array [[1,0,3],[1,0,3],[1,0,3]] 90 degrees clockwise") polishNotation2.testMacro("rotate the array [[1,0],[1,0]] 90 degrees counterclockwise") polishNotation2.testMacro("rotate the array [[1,0],[1,0]] 180 degrees") polishNotation2.testMacro("convert '10' from base 2 to base 10") polishNotation2.testMacro("(print { x }) if (x == 1)") ''' syntaxRules = syntaxRules.syntaxRules javaSyntaxArray = polishNotation2.makeReallyNewInfoArray(syntaxRules, "Java") pythonSyntaxArray = polishNotation2.makeReallyNewInfoArray(syntaxRules, "Python") crossLanguageSyntaxArray = polishNotation2.makeReallyNewInfoArray(syntaxRules, "crosslanguage") print(polishNotation2.testMacro( ''' print{1}; print{1}; while (i < 100) print{i}; if (i < 10) print{i}; print{i}; ''', crossLanguageSyntaxArray )) print(polishNotation2.testMacro( '''