Index: trunk/src_plugins/io_bxl/lex_test.c =================================================================== --- trunk/src_plugins/io_bxl/lex_test.c (revision 30564) +++ trunk/src_plugins/io_bxl/lex_test.c (nonexistent) @@ -1,65 +0,0 @@ -#include -#include - -#include "bxl.h" -#include "bxl_lex.h" -#include "bxl_gram.h" - -int verbose = 0; - -void pcb_bxl_error(pcb_bxl_ctx_t *ctx, pcb_bxl_STYPE tok, const char *s) -{ - fprintf(stderr, "%s at %ld:%ld\n", s, tok.line, tok.first_col); -} - - -int main(int argc, char *argv[]) -{ - int chr; - pcb_bxl_ureglex_t lctx; - pcb_bxl_yyctx_t yyctx; - pcb_bxl_ctx_t bctx; - - pcb_bxl_lex_init(&lctx, pcb_bxl_rules); - pcb_bxl_parse_init(&yyctx); - - while((chr = fgetc(stdin)) > 0) { - pcb_bxl_STYPE lval; - int res = pcb_bxl_lex_char(&lctx, &lval, chr); - if (res == UREGLEX_MORE) - continue; - if (res >= 0) { - pcb_bxl_res_t yres; - - printf("token: %d ", res); - lval.line = lctx.loc_line[0]; - lval.first_col = lctx.loc_col[0]; - yres = pcb_bxl_parse(&yyctx, &bctx, res, &lval); - printf("yres=%d\n", yres); - if (yres != 0) { - printf("Stopped at %ld:%ld\n", lval.line, lval.first_col); - break; - } - } - if ((res >= 0) && verbose) { - int n; - printf("TOKEN: rule %d\n", res); - for(n = 0; n < lctx.num_rules; n++) { - ureglex_t *s = &lctx.state[n]; - printf(" %sres=%d", res == n ? "*" : " ", s->exec_state); - if (s->exec_state > 0) { - printf(" '%s' '%s'", s->bopat[0], s->eopat[0]); - printf(" at %ld:%ld\n", lctx.loc_line[0], lctx.loc_col[0]); - } - else - printf("\n"); - } -/* printf(" buf=%d/'%s'\n", ctx.buff_used, ctx.buff);*/ - } - else if (res < 0) - printf("ERROR %d\n", res); - pcb_bxl_lex_reset(&lctx); - } - - return 0; -} Index: trunk/src_plugins/io_bxl/Makefile =================================================================== --- trunk/src_plugins/io_bxl/Makefile (revision 30564) +++ trunk/src_plugins/io_bxl/Makefile (nonexistent) @@ -1,11 +0,0 @@ -CFLAGS = -g -Wall - -lex_test: lex_test.o bxl_lex.o bxl_gram.o - -bxl_lex.c bxl_lex.h: bxl_lex.ul bxl_gram.h bxl.h - ureglex -l bxl_lex.ul -c bxl_lex.c -h bxl_lex.h - -bxl_gram.c bxl_gram.h: bxl_gram.y - byaccic -v bxl_gram.desc -o bxl_gram.c -H bxl_gram.h bxl_gram.y - -lex_test.o: bxl_gram.h bxl_lex.h Index: trunk/tests/io_bxl/Makefile =================================================================== --- trunk/tests/io_bxl/Makefile (nonexistent) +++ trunk/tests/io_bxl/Makefile (revision 30565) @@ -0,0 +1,13 @@ +ROOT=../.. +PLG=$(ROOT)/src_plugins/io_bxl +CFLAGS = -g -Wall -I$(PLG) + +test_parse: test_parse.o $(PLG)/bxl_lex.o $(PLG)/bxl_gram.o + +$(PLG)/bxl_lex.c $(PLG)/bxl_lex.h: $(PLG)/bxl_lex.ul $(PLG)/bxl_gram.h $(PLG)/bxl.h + ureglex -l $(PLG)/bxl_lex.ul -c $(PLG)/bxl_lex.c -h $(PLG)/bxl_lex.h + +$(PLG)/bxl_gram.c $(PLG)/bxl_gram.h: $(PLG)/bxl_gram.y + byaccic -v $(PLG)/bxl_gram.desc -o $(PLG)/bxl_gram.c -H $(PLG)/bxl_gram.h $(PLG)/bxl_gram.y + +test_parse.o: $(PLG)/bxl_gram.h $(PLG)/bxl_lex.h Index: trunk/tests/io_bxl/test_parse.c =================================================================== --- trunk/tests/io_bxl/test_parse.c (nonexistent) +++ trunk/tests/io_bxl/test_parse.c (revision 30565) @@ -0,0 +1,65 @@ +#include +#include + +#include "bxl.h" +#include "bxl_lex.h" +#include "bxl_gram.h" + +int verbose = 0; + +void pcb_bxl_error(pcb_bxl_ctx_t *ctx, pcb_bxl_STYPE tok, const char *s) +{ + fprintf(stderr, "%s at %ld:%ld\n", s, tok.line, tok.first_col); +} + + +int main(int argc, char *argv[]) +{ + int chr; + pcb_bxl_ureglex_t lctx; + pcb_bxl_yyctx_t yyctx; + pcb_bxl_ctx_t bctx; + + pcb_bxl_lex_init(&lctx, pcb_bxl_rules); + pcb_bxl_parse_init(&yyctx); + + while((chr = fgetc(stdin)) > 0) { + pcb_bxl_STYPE lval; + int res = pcb_bxl_lex_char(&lctx, &lval, chr); + if (res == UREGLEX_MORE) + continue; + if (res >= 0) { + pcb_bxl_res_t yres; + + printf("token: %d ", res); + lval.line = lctx.loc_line[0]; + lval.first_col = lctx.loc_col[0]; + yres = pcb_bxl_parse(&yyctx, &bctx, res, &lval); + printf("yres=%d\n", yres); + if (yres != 0) { + printf("Stopped at %ld:%ld\n", lval.line, lval.first_col); + break; + } + } + if ((res >= 0) && verbose) { + int n; + printf("TOKEN: rule %d\n", res); + for(n = 0; n < lctx.num_rules; n++) { + ureglex_t *s = &lctx.state[n]; + printf(" %sres=%d", res == n ? "*" : " ", s->exec_state); + if (s->exec_state > 0) { + printf(" '%s' '%s'", s->bopat[0], s->eopat[0]); + printf(" at %ld:%ld\n", lctx.loc_line[0], lctx.loc_col[0]); + } + else + printf("\n"); + } +/* printf(" buf=%d/'%s'\n", ctx.buff_used, ctx.buff);*/ + } + else if (res < 0) + printf("ERROR %d\n", res); + pcb_bxl_lex_reset(&lctx); + } + + return 0; +}