% $Id: OzFrontendTest.oz,v 1.6 2009/09/02 20:16:04 leavens Exp leavens $ \insert 'Desugar.oz' \insert 'Unparse.oz' local [OzFrontend] = {Module.link ['OzFrontend.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 proc {Reporter error(coord:Coord kind:_ msg:Message)} % ENSURES: Output shows the message {System.showInfo {PositionMsg Coord}#': '#Message} end in local PT = {ParseFile "AppendMap.ozc" Reporter} in {System.showInfo {Value.toVirtualString PT 20 20}} {System.showInfo {Unparse PT}} end {System.showInfo {Value.toVirtualString {ParseVS "local Res in Res=2 end" Reporter} 20 20}} local PT = {ParseVS "fun {Two} 2 end local R in R={Two} end" Reporter} in {System.showInfo {Value.toVirtualString PT 20 20}} {System.showInfo {Value.toVirtualString {Desugar PT} 20 20}} {System.showInfo {Unparse {Desugar PT}}} end {System.showInfo {Value.toVirtualString {ParseFile "tests/ParseError1.oz" Reporter} 20 20}} end