Files
helmetc/libxtools/clcomp.c
Олег Бородин 0c47735432 renaming
2025-10-12 08:12:00 +02:00

56 lines
1.2 KiB
C

/*
*
* 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;
}