(* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. *) import cstdio, common const CHUNK_SIZE := 85536u type ElnaLexerState = ( start, colon, identifier, decimal, leading_zero, greater, minus, left_paren, less, dot, comment, closing_comment, character, character_escape, string, string_escape, number_sign, trait, finish ) ElnaLexerToken* = record kind: ElnaLexerKind; start: String; (* DEPRECATED *) position: ElnaPosition end ElnaLexerBooleanToken* = record(ElnaLexerToken) value: Bool end ElnaLexerCharacterToken* = record(ElnaLexerToken) value: Char end ElnaLexerStringToken* = record(ElnaLexerToken) value: String end ElnaLexerIntegerToken* = record(ElnaLexerToken) value: Int end TransitionAction = proc(lexer: ^Lexer; token: ^ElnaLexerToken) (* DEPRECATED should be replaced with TransitionAction (but keeping the type name). *) ElnaLexerAction = (none, accumulate, skip, single, eof, finalize, composite, key_id, integer, delimited) ElnaLexerTransition = record action: ElnaLexerAction; next_state: ElnaLexerState end ElnaLexerCursor = record state: ElnaLexerState; start: ^Char; finish: ^Char; token: ^ElnaLexerToken; position: ElnaPosition end BufferPosition* = record iterator: ^Char; location: ElnaLocation end Lexer* = record input: ^FILE; buffer: ^Char; size: Word; length: Word; start: BufferPosition; current: BufferPosition end ElnaLexerKind* = ( identifier, _const, _var, _proc, _type, _begin, _end, _if, _then, _else, _elsif, _extern, _record, boolean, null, and, _or, _xor, not, _return, _cast, trait, left_paren, right_paren, left_square, right_square, greater_equal, less_equal, greater_than, less_than, not_equal, equals, semicolon, dot, comma, plus, _import, minus, multiplication, division, remainder, assignment, colon, hat, at, comment, string, character, integer, word, _while, _defer, exclamation, shift_right, shift_left, pipe, _case, _do, _of, eof ) (** * Classification table assigns each possible character to a group (class). All * characters of the same group a handled equivalently. *) ElnaLexerClass = ( invalid, digit, alpha, space, colon, equals, left_paren, right_paren, asterisk, backslash, single, hex, zero, x, eof, dot, minus, single_quote, double_quote, greater, less, other, number_sign ) end.