DEFINITION MODULE Lexer;

FROM FIO IMPORT File;

TYPE
  PLexerBuffer = POINTER TO CHAR;
  Lexer = RECORD
    Input: File;
    Buffer: PLexerBuffer;
    Size: CARDINAL;
    Length: CARDINAL;
    Start: PLexerBuffer;
    Current: PLexerBuffer
  END;
  PLexer = POINTER TO Lexer;
  LexerKind = (
    lexerKindEof,
    lexerKindIdentifier,
    lexerKindIf,
    lexerKindThen,
    lexerKindElse,
    lexerKindElsif,
    lexerKindWhile,
    lexerKindDo,
    lexerKindProc,
    lexerKindBegin,
    lexerKindEnd,
    lexerKindImplementation,
    lexerKindConst,
    lexerKindVar,
    lexerKindCase,
    lexerKindOf,
    lexerKindType,
    lexerKindRecord,
    lexerKindUnion,
    lexerKindPipe,
    lexerKindTo,
    lexerKindBoolean,
    lexerKindNull,
    lexerKindAnd,
    lexerKindOr,
    lexerKindNot,
    lexerKindReturn,
    lexerKindDefinition,
    lexerKindRange,
    lexerKindLeftParen,
    lexerKindRightParen,
    lexerKindLeftSquare,
    lexerKindRightSquare,
    lexerKindGreaterEqual,
    lexerKindLessEqual,
    lexerKindGreaterThan,
    lexerKindLessThan,
    lexerKindNotEqual,
    lexerKindEqual,
    lexerKindSemicolon,
    lexerKindDot,
    lexerKindComma,
    lexerKindPlus,
    lexerKindMinus,
    lexerKindMultiplication,
    lexerKindDivision,
    lexerKindRemainder,
    lexerKindAssignment,
    lexerKindColon,
    lexerKindHat,
    lexerKindAt,
    lexerKindComment,
    lexerKindInteger,
    lexerKindWord,
    lexerKindCharacter,
    lexerKindString,
    lexerKindFrom,
    lexerKindPointer,
    lexerKindArray,
    lexerKindTrait,
    lexerKindProgram,
    lexerKindModule,
    lexerKindImport
  );
  LexerToken = RECORD
    CASE Kind: LexerKind OF
      lexerKindBoolean: booleanKind: BOOLEAN
    END
  END;
  PLexerToken = POINTER TO LexerToken;

PROCEDURE LexerInitialize(ALexer: PLexer; Input: File);
PROCEDURE LexerDestroy(ALexer: PLexer);
(* Returns the last read token. *)
PROCEDURE LexerCurrent(ALexer: PLexer): LexerToken;
(* Read and return the next token. *)
PROCEDURE LexerLex(ALexer: PLexer): LexerToken;

END Lexer.
