This commit is contained in:
Олег Бородин
2025-10-12 08:12:00 +02:00
parent c04418d725
commit 0c47735432
16 changed files with 479 additions and 220 deletions

55
libxtools/clcomp.c Normal file
View File

@@ -0,0 +1,55 @@
/*
*
* Copyright 2023 Oleg Borodin <borodin@unix7.org>
*
*/
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <cllexer.h>
#include <clcomp.h>
void clcomp_init(clcomp_t* lexer, char** argv, int argc) {
lexer->argv = argv;
lexer->argc = argc;
lexer->argn = 1;
if (lexer->argc > lexer->argn) {
cllexer_init(&(lexer->alex), lexer->argv[lexer->argn]);
}
}
int clcomp_gettok(clcomp_t* lexer, char* token) {
if (lexer->argn > lexer->argc) {
strcpy(token, "EOF");
return TOKEN_ENDF;
}
int toktype = cllexer_gettok(&(lexer->alex), token);
if (toktype == TOKEN_ENDF && lexer->argn != lexer->argc) {
lexer->argn++;
cllexer_init(&(lexer->alex), lexer->argv[lexer->argn]);
strcpy(token, "space");
return TOKEN_SPACE;
}
return toktype;
}
/*
int clcomp_parse(clcomp_t* lexer, char* token) {
while (toktype != TOKEN_ENDF) {
toktype = cllexer_gettok(&lex, token);
printf("cllexer_gettok res: %d: %d [%s]\n", i, toktype, token);
i++;
}
*/
void clcomp_destroy(clcomp_t* clcomp) {
(void)clcomp;
}