work in progess

This commit is contained in:
Олег Бородин
2025-10-12 09:45:29 +02:00
parent 0c47735432
commit ba9f88879d
7 changed files with 52 additions and 42 deletions

View File

@@ -923,11 +923,11 @@ uninstall-am: uninstall-binPROGRAMS uninstall-sbinPROGRAMS
.PRECIOUS: Makefile
test: libxtools/cllexer_test
test:: libxtools/cllexer_test
cd libxtools && ./cllexer_test
#test: libxtools/clcomp_test
# cd libxtools && ./clcomp_test
test:: libxtools/clcomp_test
cd libxtools && ./clcomp_test
#test: libxtools/clconfig_test
# cd libxtools && ./clconfig_test

View File

@@ -63,11 +63,11 @@ noinst_PROGRAMS += libxtools/cllexer_test
libxtools_cllexer_test_SOURCES = libxtools/cllexer_test.c
libxtools_cllexer_test_LDADD = $(libxtools_NAME)
test: libxtools/cllexer_test
test:: libxtools/cllexer_test
cd libxtools && ./cllexer_test
#test: libxtools/clcomp_test
# cd libxtools && ./clcomp_test
test:: libxtools/clcomp_test
cd libxtools && ./clcomp_test
#test: libxtools/clconfig_test
# cd libxtools && ./clconfig_test

View File

@@ -923,11 +923,11 @@ uninstall-am: uninstall-binPROGRAMS uninstall-sbinPROGRAMS
.PRECIOUS: Makefile
test: libxtools/cllexer_test
test:: libxtools/cllexer_test
cd libxtools && ./cllexer_test
#test: libxtools/clcomp_test
# cd libxtools && ./clcomp_test
test:: libxtools/clcomp_test
cd libxtools && ./clcomp_test
#test: libxtools/clconfig_test
# cd libxtools && ./clconfig_test

View File

@@ -11,43 +11,47 @@
#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]);
void clcomp_init(clcomp_t* comp, vmapper_t* mapper, char** argv, int argc) {
comp->argv = argv;
comp->argc = argc;
comp->argn = 1;
comp->mapper = mapper;
if (comp->argc > comp->argn) {
cllexer_init(&(comp->lexer), comp->argv[comp->argn]);
}
}
int clcomp_gettok(clcomp_t* lexer, char* token) {
int clcomp_gettok(clcomp_t* comp, char* token) {
if (lexer->argn > lexer->argc) {
if (comp->argn > comp->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]);
int toktype = cllexer_gettok(&(comp->lexer), token);
if (toktype == TOKEN_ENDF && comp->argn != comp->argc) {
comp->argn++;
cllexer_init(&(comp->lexer), comp->argv[comp->argn]);
strcpy(token, "space");
return TOKEN_SPACE;
}
return toktype;
}
/*
int clcomp_parse(clcomp_t* lexer, char* token) {
int clcomp_parse(clcomp_t* comp) {
char token[1024];
int toktype = TOKEN_NULL;
int i = 0;
while (toktype != TOKEN_ENDF) {
toktype = cllexer_gettok(&lex, token);
toktype = clcomp_gettok(comp, token);
printf("cllexer_gettok res: %d: %d [%s]\n", i, toktype, token);
i++;
}
*/
return 0;
}
void clcomp_destroy(clcomp_t* clcomp) {

View File

@@ -7,21 +7,19 @@
#ifndef GCLEXER_H_QWERTY
#define GCLEXER_H_QWERTY
//#include <string.h>
//#include <stdbool.h>
//#include <stdio.h>
#include <cllexer.h>
#include <vmapper.h>
typedef struct {
char** argv;
int argc;
int argn;
cllexer_t alex;
cllexer_t lexer;
vmapper_t* mapper;
} clcomp_t;
void clcomp_init(clcomp_t* lexer, char** argv, int argc);
int clcomp_gettok(clcomp_t* lexer, char* token);
void clcomp_init(clcomp_t* clcomp, vmapper_t* mapper, char** argv, int argc);
int clcomp_gettok(clcomp_t* clcomp, char* token);
int clcomp_parse(clcomp_t* clcomp);
void clcomp_destroy(clcomp_t* clcomp);
#endif

View File

@@ -10,6 +10,7 @@
#include <cllexer.h>
#include <clcomp.h>
#include <vmapper.h>
int main(int argc, char **argv) {
(void)argc;
@@ -18,9 +19,15 @@ int main(int argc, char **argv) {
char*_argv[] = { argv[0], "--qwerty=12345", "--foo=bar" };
int _argc = 2;
clcomp_t lex;
clcomp_init(&lex, _argv, _argc);
vmapper_t vmapper;
vmapper_init(&vmapper);
clcomp_t clcomp;
clcomp_init(&clcomp, &vmapper, _argv, _argc);
clcomp_parse(&clcomp);
/*
char token[1024];
int toktype = TOKEN_NULL;
int i = 0;
@@ -29,6 +36,6 @@ int main(int argc, char **argv) {
printf("clcomp_gettok res: %d: %d [%s]\n", i, toktype, token);
i++;
}
*/
return 0;
}

View File

@@ -11,7 +11,7 @@
#include <clconfig.h>
void clconfig_init(clconfig_t* clconfig, int argc, char **argv) {
clcomp_init(&(clconfig->lexer), argv, argc);
//clcomp_init(&(clconfig->lexer), argv, argc);
vmapper_init(&(clconfig->mapper));
}
@@ -44,11 +44,12 @@ int __main(int argc, char **argv) {
(void)argc;
(void)argv;
/*
char*_argv[] = { argv[0], "--qwerty=-num12345", "--foo=-bar" };
int _argc = 2;
clcomp_t lex;
clcomp_init(&lex, _argv, _argc);
clcomp_t clcomp;
clcomp_init(&clcomp, _argv, _argc);
char token[1024];
int toktype = TOKEN_NULL;
@@ -58,6 +59,6 @@ int __main(int argc, char **argv) {
printf("%d: %d [%s]\n", i, toktype, token);
i++;
}
*/
return 0;
}