class binarynode(treenode)def __init__(selfleftright)inherited methods self leftself right leftright left/right branches def validate(selfdict)self left validate(dictrecurse down branches self right validate(dictdef trace(selflevel)print(level '[self label ']'self left trace(level+ self right trace(level+ class timesnode(binarynode)label '*def apply(selfdict)return self left apply(dictself right apply(dictclass dividenode(binarynode)label '/def apply(selfdict)return self left apply(dictself right apply(dictclass plusnode(binarynode)label '+def apply(selfdict)return self left apply(dictself right apply(dictclass minusnode(binarynode)label '-def apply(selfdict)return self left apply(dictself right apply(dictleaves class numnode(treenode)def __init__(selfnum)self num num already numeric def apply(selfdict)use default validate return self num def trace(selflevel)print(level repr(self num)as codewas 'self numclass varnode(treenode)def __init__(selftextstart)self name text variable name self column start column for errors def validate(selfdict)if not self name in dict keys()raise undefinederror(self nameself columndef apply(selfdict)return dict[self namevalidate before apply def assign(selfvaluedict)dict[self namevalue local extension text and language