(*======================================================================*)
(*                        Modula-2 Lexical Analyzer                     *)
(*======================================================================*)
(*  Version:  1.00              Author:   Dennis Brueni                 *)
(*  Date:     07-07-91          Changes:  original                      *)
(*======================================================================*)
(*  The lexical analyzer is implemented as a Finite State Automaton     *)
(*  which recoginizes the next valid Modula-2 token from the input      *)
(*  channel specified at the time SetSourceFile is called.              *)
(*======================================================================*)

DEFINITION MODULE LexAn;

IMPORT SymLists,FSM;


VAR PrintTokens:  BOOLEAN;

(*----------------------------------------------------------------------*)
(*  SETSOURCEFILE   Informs the Lexical Analyzer of the name of the     *)
(*                  Modula-2 Source file for it to parse.  It will      *)
(*                  then open the file for reading, or return FALSE     *)
(*                  if unsuccessful.  If SetSourceFile is not performed *)
(*                  LexAn will assume the Standard input channel.       *)
(*                                                                      *)
(*  PARAMETER   FileName:  A valid AmigaDOS path/filename.              *)
(*                                                                      *)
(*  RETURNS     TRUE if successful, FALSE if not.                       *)
(*----------------------------------------------------------------------*)

PROCEDURE SetSourceFile(FileName: ARRAY OF CHAR):BOOLEAN;

(*----------------------------------------------------------------------*)
(*  SETDESTFILE     Informs the Lexical Analyzer of the name of the     *)
(*                  Modula-2 Source file for it to produce.  It will    *)
(*                  then open the file for writing, or return FALSE     *)
(*                  if unsuccessful.  If SetDestFile is not performed   *)
(*                  LexAn will assume the Standard output channel.      *)
(*                                                                      *)
(*  PARAMETER   FileName:  A valid AmigaDOS path/filename.              *)
(*                                                                      *)
(*  RETURNS     TRUE if successful, FALSE if not.                       *)
(*----------------------------------------------------------------------*)

PROCEDURE SetDestFile(FileName: ARRAY OF CHAR):BOOLEAN;

(*----------------------------------------------------------------------*)
(*  FEEDMACRO   Feeds a macro into GetToken's personal macro list.      *)
(*              When this list is empty, GetToken reads from the source *)
(*              file.                                                   *)
(*                                                                      *)
(*  PARAMETER   list - The macro list to feed in                        *)
(*----------------------------------------------------------------------*)

PROCEDURE FeedMacro(list: SymLists.SymList);

(*----------------------------------------------------------------------*)
(*  GETTOKEN    Moves current token pointer to the next BSU (Basic      *)
(*              Syntactic Unit) of the Oberon program.  This single     *)
(*              function is the main interface to the Lexical Analyzer. *)
(*----------------------------------------------------------------------*)

PROCEDURE GetToken;

(*----------------------------------------------------------------------*)
(*  PRINTTOKEN  This Procedure provides a standard way to print token   *)
(*              information, including the token type, length, and the  *)
(*              string comprising the token.  The token is passed by    *)
(*              reference for efficiency only, it is not changed.       *)
(*                                                                      *)
(*  PARAMETERS  Token :  The token record to print out                  *)
(*----------------------------------------------------------------------*)

PROCEDURE PrintToken(VAR Token: FSM.TokenRec);

END LexAn.