% $Id: REPTk.oz,v 1.2 2009/09/02 13:58:57 leavens Exp leavens $ %\insert 'ReducerPrinting.oz' \insert 'Unparse.oz' local [OzFrontend QTk] = {Module.link ['OzFrontend.ozf' 'x-oz://system/wp/QTk.ozf']} StdParseFile = OzFrontend.parseFile StdParseVirtualString = OzFrontend.parseVirtualString fun {GetSwitch SName} % ENSURES: Return false for all switches (a default value) false end fun {ParseFile FileName Reporter} % ENSURES: Result is an AST for the file named FileName (or parseError) {StdParseFile FileName Reporter GetSwitch {NewDictionary}} end fun {ParseVS VS Reporter} % ENSURES: Result is an AST for the virtual string VS (or parseError) {StdParseVirtualString VS Reporter GetSwitch {NewDictionary}} end fun {PositionMsg pos(FileName Line Column)} % ENSURES: Result is a virtual string describing an error position case FileName of '' then '' else 'File "'#FileName#'", ' end #'line '#{Value.toVirtualString Line 2 2} #', character '#{Value.toVirtualString Column 2 2} end In Out proc {Reporter error(coord:Coord kind:_ msg:Message)} % ENSURES: Output shows the message {Out set({PositionMsg Coord}#': '#Message)} end D=td(tdrubberframe(glue:nswe lr(glue:nswe label(text:"Statement") text(handle:In glue:nswe)) lr(glue:nswe label(text:"Parse Tree") text(handle:Out glue:nswe tdscrollbar:true))) lr(glue:we button(glue:we text:"Show Parse Tree" action: proc {$} PT = {ParseVS {In get($)} Reporter} in {Out set({Value.toVirtualString PT 20 20})} end)) button(glue:we text:"Quit" action:toplevel#close)) W={QTk.build D} in {W show(wait:true)} end