% $Id: DesugarTest.oz,v 1.1 2006/09/22 05:28:54 leavens Exp $
%
% This file is meant to be compiled as an expression,
% not fed as a statement.  Use
%
%    ozc DesugarTest.oz
%
% and then run it as in:
%
%    ozengine OzParserTest.ozf small_pgm.oz
%
% AUTHOR: Chris Cornelison and Gary T. Leavens
%         based on section 4.5.1 in "The Mozart Compiler" by Leif Kornstaedt.

declare
functor OzParserTest
import
   Narrator('class')
   ErrorListener('class')
   Application(getArgs)
   Compiler(parseOzFile)
   Inspector(inspect)
   System(printInfo)
define
   PrivateNarratorO
   NarratorO = {New Narrator.'class' init(?PrivateNarratorO)}
   ListenerO = {New ErrorListener.'class' init(NarratorO)}
   
   fun {Parse FileName}
      {Compiler.parseOzFile
       FileName
       PrivateNarratorO
       fun {$ Switch} Switch == gump end 
       {NewDictionary}
      }
   end
in 
   case {Application.getArgs plain} of [FileName] then
      {Inspector.inspect {Parse FileName}}
   end

   if {ListenerO hasErrors($)} then
      {System.printInfo {ListenerO getVS($)}}
      {ListenerO reset()}
   end 
end
