--[[ Expression Language 1 Prefix Parser Test Script H. Conrad CunninL1gham, Professor Computer and Information Science University of Mississippi Developed for CSci 450/503, Organization of Programming Languaages, Fall 2016 1234567890123456789012345678901234567890123456789012345678901234567890 2016-09-21: Expression Language 1 prefix parser partial test script adapted from infix parser test script --]] -- Set module "parameters" UTILITIES = "utilities" PARSER = "parser_prefix_01" ABS_SYNTAX = "abs_syn_01" VALUES = "values_01" -- Import Utilities module local util = require(UTILITIES) local show_data, treeConcat = util.show_data, util.treeConcat -- printTree not currently used -- Import Parser module local par = require(PARSER) local parse = par.parse -- PARTIAL TESTING print( "\nLIMITIED TESTING OF PREFIX PARSER FOR EXPRESSION LANGUAGE 1.\n") local varx = "x" print("input: " .. varx) print("output: " .. treeConcat(parse(varx))) local varxyz = " xyz_1 " print("input: " .. varxyz) print("output: " .. treeConcat(parse(varxyz))) local int370 = "370" print("input: " .. int370) print("output: " .. treeConcat(parse(int370))) local int37 = " 37 " print("input: " .. int37) print("output: ".. treeConcat(parse(int37))) local neg99 = " -99 " print("input: " .. neg99) print("output: ".. treeConcat(parse(neg99))) local negx = "-x" print("input: " .. negx) print("output: " .. treeConcat(parse(negx))) local negy = " - y " print("input: " .. negy) print("output: " .. treeConcat(parse(negy))) local negate99 = "(neg 99)" print("input: " .. negate99) print("output: " .. treeConcat(parse(negate99))) local term2 = "(+ a 24)" print("input: " .. term2) print("output: " .. treeConcat(parse(term2))) local term3 = "(- (+ a 24) x_yz)" print("input: " .. term3) print("output: " .. treeConcat(parse(term3))) local factor2 = "(* a 24) " print("input: " .. factor2) print("output: " .. treeConcat(parse(factor2))) local factor3 = "(/ (* a 24) xyz)" print("input: " .. factor3) print("output: " .. treeConcat(parse(factor3))) local mix1 = "(+ 2 (* 3 (* 4 6)))" print("input: " .. mix1) print("output: " .. treeConcat(parse(mix1))) local mix2 = " (+ (* xx 2) (* 3 (- y z)))" print("input: " .. mix2) print("output: " .. treeConcat(parse(mix2))) local eq1 = "(== abc 34)" print("input: " .. eq1) print("output: " .. treeConcat(parse(eq1))) local eq2 = "(== (+ x (* 3 y)) (- 34 1))" print("input: " .. eq2) print("output: " .. treeConcat(parse(eq2))) local if1 = "(if (< a 3) (+ x 1) (- 3 2))" print("input: " .. if1) print("output: " .. treeConcat(parse(if1))) local if2 = "(if (<= a 3) (+ x 1) (if (>= x 7) 3 x))" print("input: " .. if2) print("output: " .. treeConcat(parse(if2))) local negex1 = "(neg (+ x 3))" print("input: " .. negex1) print("output: " .. treeConcat(parse(negex1)))