-- file : calctest2.adb -- ($Id$) -- Test driver for the package Calc2. -- to compile: "gnatmake calctest2" -- to execute: "calctest2" or "calctest2 " -- to terminate: control-D (end of file), or control-C with Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; with Ada.Exceptions; with Calc2; procedure CalcTest2 is Input : File_Type; begin if Ada.Command_Line.Argument_Count = 1 then begin Open (Input, In_File, Ada.Command_Line.Argument (1)); Set_Input (Input); exception when others => Put_Line ("scanner: unable to open file " & Ada.Command_Line.Argument (1)); return; end; elsif Ada.Command_Line.Argument_Count /= 0 then Put_Line ("scanner: too many arguments"); end if; loop begin Put_Line ("please enter an expression"); Put_Line ("-> " & Integer'Image (Calc2.Calc)); exception when E : Calc2.Syntax_Error => Put_Line ("syntax error: " & Ada.Exceptions.Exception_Message (E)); when End_Error => raise; when X : others => Put_Line ("other exception: " & Ada.Exceptions.Exception_Name (X)); end; end loop; exception when End_Error => null; end CalcTest2;