From 81043b67437445dcf83055098490e04cc88ff7ee Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 17 Oct 2026 23:50:44 +0200 Subject: Fix slice comparison by contents --- source/main.elna | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source/main.elna') diff --git a/source/main.elna b/source/main.elna index 12486bd..ee4079e 100644 --- a/source/main.elna +++ b/source/main.elna @@ -2,8 +2,27 @@ 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/. *) program() -import elna.lexer +import sys.posix.stdio, elna.lexer + +var + global_cursor: ElnaLexerCursor + sample_source_text := "Here.are a few 'tokens' or if\0" + token: ^ElnaLexerToken begin - elna_lexer_transitions() + elna_lexer_transitions(); + global_cursor := { ElnaLexerCursor; + start: sample_source_text.ptr, + cursor: sample_source_text.ptr, + position: 1u + }; + + repeat + token := elna_lexer_lex(@global_cursor); + + printf("Token: %.*s, length: %lu, final state: %i, position: %lu, kind: %i\n\0".ptr, + global_cursor.cursor - global_cursor.start, global_cursor.start, + global_cursor.cursor - global_cursor.start, global_cursor.state, + global_cursor.position, token^.kind) + until global_cursor.state = ElnaLexerState.eof end. -- cgit v1.2.3