def test_parser(expr): parser = parser2.Parser() # tree type is parser wrapper parser.lex.newtext(expr) # subtrees evaluate when clicked tree = parser.analyse() # input line parses new expr entry.delete(0, END) # vars set in wrapper dictionary entry.insert(0, expr) # see lang/text chapter for parser if tree: viewer.drawTree(tree)
def onInputLine(self, line, viewer): # on input line p = parser2.Parser() # parse expr text p.lex.newtext(line) # draw resulting tree t = p.analyse() if t: viewer.drawTree(t)
def test5(): p = parser2.Parser() p.lex.newtext("set temp 1 + 3 * 2 * 3 + 4") t = p.analyse() if t: pviewer.drawTree(t)
def test6(): p = parser2.Parser() p.lex.newtext("set result temp + ((1 + 3) * 2) * (3 + 4)") t = p.analyse() if t: pviewer.drawTree(t)
def test4(): p = parser2.Parser() p.lex.newtext("1 + 3 * (2 * 3 + 4)") t = p.analyse() if t: pviewer.drawTree(t)