with Ada.Text_Io; use Ada;
with OpenFile; use OpenFile;
with ReadToken; use ReadToken;
with LookUp; use LookUp;
with SymbolTable; use SymbolTable;
with Ada.Integer_Text_IO;
with Ada.IO_Exceptions;
package body Lex is
procedure Lexeme(lFile : Text_IO.File_Type; sFile : Text_IO.File_Type; fFile : in File_Type; lFlag : Boolean; eFlag : Boolean; fFlag : Boolean) is
InFile : Text_IO.File_Type;
OutFile : Text_IO.File_Type;
Token : String(1..15):=(others=> ' ');
Status : Boolean;
Symbol : Integer;
Index : Integer:=1;
SymbolTable : Table;
Line_Number : Integer:=1;
begin
--OpenReadFile(InFile); -- Get file to process
OpenWriteFile(OutFile); -- Get file to output to
--read a token
ReadNextToken(Line_Number, fFile, Token, Status);
return;
while Status loop -- as long as we have more continue
LookUpSymbol(Token, Symbol); -- get the token
Insert(Line_Number, SymbolTable, Index, Token, Symbol); -- insert the token/symbol
ReadNextToken(Line_Number,fFile, Token, Status); --repeat
Index:=Index + 1; --loop
end loop;
Index:=Index-1; --fix for Print
Print(SymbolTable,Index,OutFile); -- display that of SymbolTable
Text_IO.Put("Output written...");
exception
when ADA.IO_EXCEPTIONS.NAME_ERROR =>
Text_IO.Put ("Sorry- you entered an invalid file name: ");
when Error: others =>
Text_IO.Put ("Unexpected exception: ");
end Lexeme;
end Lex;