All pastes #597930 Raw Edit

parse.adb

public text v1 · immutable
#597930 ·published 2007-06-30 22:56 UTC
rendered paste body
WITH Text_IO;
USE Text_IO;

WITH Ada.Command_Line;
USE Ada.Command_Line;

WITH Lex;
USE Lex;

WITH Ada.Command_Line;
USE Ada.Command_Line;
WITH Ada.Strings.Unbounded;
USE Ada.Strings.Unbounded;


procedure parse is
lFile	:	Text_IO.File_Type;
sFile	:	Text_IO.File_Type;
fFile	:	File_Type;
lFlag	:	Boolean;
eFlag	:	Boolean;
fFlag	:	Boolean;

procedure something is
begin    FOR i IN 1..Argument_Count LOOP
      IF (Argument(i) = "/l" OR Argument(i) = "/L") THEN
        Create(File=>lFile, Mode=>Out_File, Name=>Argument(i + 1));
        Put_Line("File " & Argument(i + 1) & " has been opened for outputting lexemes");
        lFlag := TRUE;
      END IF;
      IF (Argument(i) = "/s" OR Argument(i) = "/S") THEN
        Create(File=>sFile, Mode=>Out_File, Name=>Argument(i + 1));
        Put_Line("File " & Argument(i + 1) & " has been opened for outputting the symbol table");
        lFlag := TRUE;
      END IF;
      IF (Argument(i) = "/e" OR Argument(i) = "/E") THEN
        Put_Line("Echo as processed has been set");
        eFlag := TRUE;
      END IF;
          IF (Argument(i) = "/f" OR Argument(i) = "/F") THEN
        Open(File=>fFile, Mode=>In_File, Name=>Argument(i + 1));
        Put_Line("File open for reading" & Argument(i + 1));
        fFlag := TRUE;
      END IF;
    END LOOP;
    EXCEPTION
      WHEN Status_Error => New_Line;
                           Put_Line("That file is already open.");
      WHEN Use_Error => New_Line;
                        Put_Line("That file cannot be read.");
      WHEN OTHERS => New_Line;
                     Put_Line("Unexpected error on opening file.");

end something;

begin

something;
Lexeme(lFile,sFile,fFile,lFlag,eFlag,fFlag);

end parse;