From 4b2ab25ed08ebc2425f8e37228194170e50c16c1 Mon Sep 17 00:00:00 2001 From: Kate F Date: Sun, 21 Jul 2024 22:17:33 +0100 Subject: [PATCH] Remove fsm.opt and split print hooks from options. The important part of the diff here is just: ```diff --- a/src/libfsm/internal.h +++ b/src/libfsm/internal.h @@ -11,7 +11,6 @@ #include #include -#include #include @@ -76,7 +75,6 @@ struct fsm { struct fsm_capture_info *capture_info; struct endid_info *endid_info; - const struct fsm_options *opt; }; ``` Everything else is fallout from not needing to pass around the options struct. This leaves the options struct only used for the print routines. --- fuzz/target.c | 78 ++-- include/fsm/fsm.h | 15 +- include/fsm/options.h | 41 +-- include/fsm/parser.h | 3 +- include/fsm/print.h | 40 ++- include/fsm/vm.h | 4 +- include/re/literal.h | 2 - include/re/re.h | 2 - include/re/strings.h | 4 +- src/fsm/main.c | 8 +- src/libfsm/charset.c | 2 - src/libfsm/clone.c | 4 +- src/libfsm/closure.c | 1 - src/libfsm/concat.c | 6 - src/libfsm/consolidate.c | 3 +- src/libfsm/determinise.c | 2 - src/libfsm/endids.c | 1 + src/libfsm/endids.h | 3 - src/libfsm/epsilons.c | 5 +- src/libfsm/equal.c | 7 +- src/libfsm/fsm.c | 20 +- src/libfsm/internal.h | 2 - src/libfsm/libfsm.syms | 2 - src/libfsm/merge.c | 11 +- src/libfsm/minimise.c | 4 +- src/libfsm/minimise_test_oracle.c | 1 + src/libfsm/parser.act | 7 +- src/libfsm/parser.c | 9 +- src/libfsm/parser.h | 4 +- src/libfsm/print.c | 72 ++-- src/libfsm/print.h | 38 +- src/libfsm/print/api.c | 18 +- src/libfsm/print/awk.c | 37 +- src/libfsm/print/c.c | 57 +-- src/libfsm/print/dot.c | 39 +- src/libfsm/print/fsm.c | 30 +- src/libfsm/print/go.c | 51 +-- src/libfsm/print/ir.c | 7 +- src/libfsm/print/ir.h | 4 +- src/libfsm/print/irdot.c | 15 +- src/libfsm/print/irjson.c | 18 +- src/libfsm/print/json.c | 29 +- src/libfsm/print/llvm.c | 30 +- src/libfsm/print/rust.c | 77 ++-- src/libfsm/print/sh.c | 24 +- src/libfsm/print/vmasm.c | 43 ++- src/libfsm/print/vmc.c | 41 ++- src/libfsm/print/vmdot.c | 40 ++- src/libfsm/print/vmops.c | 56 ++- src/libfsm/reverse.c | 4 - src/libfsm/state.c | 1 + src/libfsm/trim.c | 1 + src/libfsm/union.c | 7 +- src/libfsm/vm.c | 29 +- src/libfsm/walk2.c | 6 +- src/libre/ac.h | 1 - src/libre/ast.h | 2 - src/libre/ast_analysis.h | 2 - src/libre/ast_compile.c | 10 +- src/libre/ast_compile.h | 2 - src/libre/ast_new_from_fsm.c | 1 + src/libre/ast_rewrite.c | 2 +- src/libre/dialect/comp.h | 1 - src/libre/dialect/glob/parser.c | 41 ++- src/libre/dialect/glob/parser.h | 4 +- src/libre/dialect/like/parser.c | 41 ++- src/libre/dialect/like/parser.h | 4 +- src/libre/dialect/literal/parser.c | 29 +- src/libre/dialect/literal/parser.h | 4 +- src/libre/dialect/native/parser.c | 207 ++++++----- src/libre/dialect/native/parser.h | 4 +- src/libre/dialect/pcre/parser.c | 321 +++++++++-------- src/libre/dialect/pcre/parser.h | 4 +- src/libre/dialect/sql/parser.c | 157 ++++---- src/libre/dialect/sql/parser.h | 4 +- src/libre/parser.act | 1 - src/libre/re.c | 11 +- src/libre/re_strings.c | 7 +- src/lx/ast.c | 2 - src/lx/main.c | 20 +- src/lx/parser.act | 16 +- src/lx/parser.c | 339 +++++++++--------- src/lx/parser.h | 11 +- src/lx/print.c | 6 +- src/lx/print.h | 10 +- src/lx/print/c.c | 91 +++-- src/lx/print/dot.c | 39 +- src/lx/print/dump.c | 25 +- src/lx/print/h.c | 7 +- src/lx/print/zdot.c | 5 +- src/lx/tokens.c | 1 + src/re/main.c | 65 ++-- src/retest/cvtpcre.c | 11 +- src/retest/main.c | 4 +- src/retest/reperf.c | 4 +- src/retest/runner.c | 41 ++- src/retest/runner.h | 4 +- tests/aho_corasick/actest.c | 4 +- tests/capture/captest.c | 2 +- tests/capture/capture3.c | 14 +- tests/capture/capture4.c | 10 +- tests/capture/capture5.c | 6 +- tests/capture/capture_concat1.c | 4 +- tests/capture/capture_concat2.c | 4 +- tests/capture/capture_union1.c | 4 +- tests/endids/endids0.c | 2 +- tests/endids/endids0_many_endids.c | 2 +- .../endids10_minimise_partial_overlap.c | 4 +- tests/endids/endids1_determinise.c | 2 +- .../endids/endids1_determinise_and_minimise.c | 2 +- tests/endids/endids2_union.c | 4 +- tests/endids/endids2_union_many_endids.c | 2 +- tests/endids/endids4.c | 4 +- tests/endids/endids5.c | 4 +- tests/endids/endids6.c | 4 +- tests/endids/endids7.c | 4 +- tests/endids/endids7_with_duplicates.c | 4 +- tests/endids/endids8.c | 4 +- tests/endids/endids9.c | 4 +- tests/gen/gen3.c | 2 +- tests/minimise/minimise_test_case_list.c | 6 +- tests/re_strings/testutil.c | 2 +- 122 files changed, 1424 insertions(+), 1306 deletions(-) diff --git a/fuzz/target.c b/fuzz/target.c index c9d5d4a6e..543891bb9 100644 --- a/fuzz/target.c +++ b/fuzz/target.c @@ -75,8 +75,6 @@ scanner_next(void *opaque) } #endif -static const struct fsm_options opt; - static struct fsm * build(const char *pattern) { @@ -95,7 +93,7 @@ build(const char *pattern) }; time_get(&pre); - fsm = re_comp(RE_PCRE, scanner_next, &s, NULL, &opt, RE_MULTI, &err); + fsm = re_comp(RE_PCRE, scanner_next, &s, NULL, RE_MULTI, &err); time_get(&post); delta_usec = time_diff_usec(&pre, &post); total_usec += delta_usec; @@ -133,24 +131,28 @@ build(const char *pattern) } static int -codegen(const struct fsm *fsm) +codegen(const struct fsm *fsm, enum fsm_io io_mode) { + const struct fsm_options opt = { + .io = io_mode, + }; + FILE *dev_null = fopen("/dev/null", "w"); assert(dev_null != NULL); - fsm_print(dev_null, fsm, FSM_PRINT_C); + fsm_print(dev_null, fsm, &opt, NULL, FSM_PRINT_C); fclose(dev_null); return 1; } static int -build_and_codegen(const char *pattern) +build_and_codegen(const char *pattern, enum fsm_io io_mode) { struct fsm *fsm = build(pattern); if (fsm == NULL) { return EXIT_SUCCESS; } - if (!codegen(fsm)) { + if (!codegen(fsm, io_mode)) { return EXIT_SUCCESS; } @@ -176,7 +178,7 @@ shuffle_minimise(const char *pattern) .offset = 0 }; - fsm = re_comp(RE_PCRE, scanner_next, &s, NULL, &opt, RE_MULTI, &err); + fsm = re_comp(RE_PCRE, scanner_next, &s, NULL, RE_MULTI, &err); if (fsm == NULL) { /* ignore invalid regexp syntax, etc. */ @@ -245,14 +247,14 @@ shuffle_minimise(const char *pattern) __func__, s_i, pattern, expected_state_count, cp_state_count); fprintf(stderr, "== original input:\n"); - fsm_print(stderr, fsm, FSM_PRINT_FSM); + fsm_print(stderr, fsm, NULL, NULL, FSM_PRINT_FSM); fprintf(stderr, "== expected:\n"); - fsm_print(stderr, oracle_min, FSM_PRINT_FSM); + fsm_print(stderr, oracle_min, NULL, NULL, FSM_PRINT_FSM); fprintf(stderr, "== got:\n"); - fsm_print(stderr, cp, FSM_PRINT_FSM); + fsm_print(stderr, cp, NULL, NULL, FSM_PRINT_FSM); fsm_free(cp); fsm_free(oracle_min); @@ -287,7 +289,7 @@ fuzz_all_print_functions(FILE *f, const char *pattern, bool det, bool min, const .io = io_mode, }; - fsm = re_comp(RE_PCRE, scanner_next, &s, NULL, &opt, RE_MULTI, &err); + fsm = re_comp(RE_PCRE, scanner_next, &s, NULL, RE_MULTI, &err); if (fsm == NULL) { /* ignore invalid regexp syntax, etc. */ return EXIT_SUCCESS; @@ -313,28 +315,28 @@ fuzz_all_print_functions(FILE *f, const char *pattern, bool det, bool min, const /* see if this triggers any asserts */ int r = 0; - r |= fsm_print(f, fsm, FSM_PRINT_AMD64_ATT); - r |= fsm_print(f, fsm, FSM_PRINT_AMD64_GO); - r |= fsm_print(f, fsm, FSM_PRINT_AMD64_NASM); - - r |= fsm_print(f, fsm, FSM_PRINT_API); - r |= fsm_print(f, fsm, FSM_PRINT_AWK); - r |= fsm_print(f, fsm, FSM_PRINT_C); - r |= fsm_print(f, fsm, FSM_PRINT_DOT); - r |= fsm_print(f, fsm, FSM_PRINT_FSM); - r |= fsm_print(f, fsm, FSM_PRINT_GO); - r |= fsm_print(f, fsm, FSM_PRINT_IR); - r |= fsm_print(f, fsm, FSM_PRINT_IRJSON); - r |= fsm_print(f, fsm, FSM_PRINT_JSON); - r |= fsm_print(f, fsm, FSM_PRINT_LLVM); - r |= fsm_print(f, fsm, FSM_PRINT_RUST); - r |= fsm_print(f, fsm, FSM_PRINT_SH); - r |= fsm_print(f, fsm, FSM_PRINT_VMC); - r |= fsm_print(f, fsm, FSM_PRINT_VMDOT); - - r |= fsm_print(f, fsm, FSM_PRINT_VMOPS_C); - r |= fsm_print(f, fsm, FSM_PRINT_VMOPS_H); - r |= fsm_print(f, fsm, FSM_PRINT_VMOPS_MAIN); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_AMD64_ATT); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_AMD64_GO); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_AMD64_NASM); + + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_API); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_AWK); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_C); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_DOT); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_FSM); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_GO); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_IR); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_IRJSON); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_JSON); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_LLVM); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_RUST); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_SH); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_VMC); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_VMDOT); + + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_VMOPS_C); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_VMOPS_H); + r |= fsm_print(f, fsm, &opt, NULL, FSM_PRINT_VMOPS_MAIN); assert(r == 0 || errno != 0); @@ -380,8 +382,12 @@ harness_fuzzer_target(const uint8_t *data, size_t size) const char *pattern = (const char *)data_buf; switch (get_run_mode()) { - case MODE_DEFAULT: - return build_and_codegen(pattern); + case MODE_DEFAULT: { + const uint8_t b0 = data_buf[0]; + const enum fsm_io io_mode = (b0 >> 2) % 3; + + return build_and_codegen(pattern, io_mode); + } case MODE_SHUFFLE_MINIMISE: return shuffle_minimise(pattern); diff --git a/include/fsm/fsm.h b/include/fsm/fsm.h index c08b16549..877d5c1bf 100644 --- a/include/fsm/fsm.h +++ b/include/fsm/fsm.h @@ -11,7 +11,6 @@ struct fsm; struct fsm_alloc; -struct fsm_options; struct path; /* XXX */ struct fsm_capture; struct fsm_combine_info; @@ -35,14 +34,12 @@ typedef unsigned int fsm_end_id_t; * from fsm_new() is expected to be passed as the "fsm" argument to the * functions in this API. * - * An options pointer may be passed for control over various details of - * FSM construction and output. This may be NULL, in which case default - * options are used. + * An fsm_alloc pointer may be passed for callbacks on memory allocation. + * This may be NULL, in which case the default libc functions are used. * When non-NULL, the storage pointed to must remain extant until fsm_free(). * * Returns NULL on error; see errno. * TODO: perhaps automatically create a start state, and never have an empty FSM - * TODO: also fsm_parse should create an FSM, not add into an existing one */ struct fsm * fsm_new(const struct fsm_alloc *alloc); @@ -69,14 +66,6 @@ fsm_free(struct fsm *fsm); struct fsm * fsm_clone(const struct fsm *fsm); -/* Returns the options of an FSM */ -const struct fsm_options * -fsm_getoptions(const struct fsm *fsm); - -/* Sets the options of an FSM */ -void -fsm_setoptions(struct fsm *fsm, const struct fsm_options *opts); - /* * Copy the contents of src over dst, and free src. * diff --git a/include/fsm/options.h b/include/fsm/options.h index 5254ce2a9..b5e81fec2 100644 --- a/include/fsm/options.h +++ b/include/fsm/options.h @@ -7,11 +7,6 @@ #ifndef FSM_OPTIONS_H #define FSM_OPTIONS_H -#include - -struct fsm; -struct fsm_state; - enum fsm_io { FSM_IO_GETC, FSM_IO_STR, @@ -28,6 +23,10 @@ enum fsm_ambig { AMBIG_SINGLE = AMBIG_ERROR | AMBIG_EARLIEST }; +/* + * Print options. + * This is separate to because we also borrow it for libre. + */ struct fsm_options { /* boolean: true indicates to omit names for states in output */ unsigned int anonymous_states:1; @@ -73,38 +72,6 @@ struct fsm_options { /* the name of the enclosing package; NULL to use `prefix` (default). */ const char *package_prefix; - - /* - * Hooks to override generated code. These give an oportunity to - * emit application-specific constructs, especially based on ids - * attached to end states. - * - * These hooks are optional, and default to whatever makes sense - * for the language. - * - * Placement in the output stream depends on the format. - * This replaces an entire "return xyz;" statement for C-like formats, - * but appends extra information for others. - */ - struct fsm_hooks { - /* character pointer, for C code fragment output. NULL for the default. */ - const char *cp; - - int (*args)(FILE *, const struct fsm_options *opt, - void *leaf_opaque); - - /* - * ids[] is sorted and does not have duplicates. - */ - int (*accept)(FILE *, const struct fsm_options *opt, - const fsm_end_id_t *ids, size_t count, - void *leaf_opaque); - - int (*reject)(FILE *, const struct fsm_options *opt, - void *leaf_opaque); - - void *hook_opaque; - } hooks; }; #endif diff --git a/include/fsm/parser.h b/include/fsm/parser.h index 9c512ae50..15e053dd1 100644 --- a/include/fsm/parser.h +++ b/include/fsm/parser.h @@ -3,9 +3,8 @@ struct fsm; struct fsm_alloc; -struct fsm_options; struct fsm * -fsm_parse(FILE *, const struct fsm_alloc *alloc, const struct fsm_options *); +fsm_parse(FILE *, const struct fsm_alloc *alloc); #endif diff --git a/include/fsm/print.h b/include/fsm/print.h index 61a2f7be8..ee889d211 100644 --- a/include/fsm/print.h +++ b/include/fsm/print.h @@ -7,9 +7,8 @@ #ifndef FSM_PRINT_H #define FSM_PRINT_H -#include - struct fsm; +struct fsm_options; enum fsm_print_lang { FSM_PRINT_NONE, /* No output */ @@ -38,6 +37,38 @@ enum fsm_print_lang { FSM_PRINT_VMOPS_MAIN }; +/* + * Hooks to override generated code. These give an oportunity to + * emit application-specific constructs, especially based on ids + * attached to end states. + * + * These hooks are optional, and default to whatever makes sense + * for the language. + * + * Placement in the output stream depends on the format. + * This replaces an entire "return xyz;" statement for C-like formats, + * but appends extra information for others. + */ +struct fsm_hooks { + /* character pointer, for C code fragment output. NULL for the default. */ + const char *cp; + + int (*args)(FILE *, const struct fsm_options *opt, + void *leaf_opaque, void *hook_opaque); + + /* + * ids[] is sorted and does not have duplicates. + */ + int (*accept)(FILE *, const struct fsm_options *opt, + const fsm_end_id_t *ids, size_t count, + void *leaf_opaque, void *hook_opaque); + + int (*reject)(FILE *, const struct fsm_options *opt, + void *leaf_opaque, void *hook_opaque); + + void *hook_opaque; +}; + /* * Print an FSM to the given file stream. The output is written in the format * specified. @@ -47,7 +78,10 @@ enum fsm_print_lang { * Returns 0, or -1 on error and errno will be set. An errno of ENOTSUP means * the requested IO API is not implemented for this output language. */ -int fsm_print(FILE *f, const struct fsm *fsm, enum fsm_print_lang lang); +int fsm_print(FILE *f, const struct fsm *fsm, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + enum fsm_print_lang lang); #endif diff --git a/include/fsm/vm.h b/include/fsm/vm.h index b45741f6a..6fab2c1a4 100644 --- a/include/fsm/vm.h +++ b/include/fsm/vm.h @@ -5,6 +5,7 @@ #include struct fsm; +struct fsm_options; struct fsm_dfavm; enum fsm_vm_compile_flags { @@ -34,7 +35,8 @@ struct fsm_dfavm * fsm_vm_compile(const struct fsm *fsm); struct fsm_dfavm * -fsm_vm_compile_with_options(const struct fsm *fsm, struct fsm_vm_compile_opts opts); +fsm_vm_compile_with_options(const struct fsm *fsm, + const struct fsm_options *opt, struct fsm_vm_compile_opts opts); struct fsm_dfavm * fsm_vm_read(FILE *f); diff --git a/include/re/literal.h b/include/re/literal.h index 23d445b2c..a76ceaa07 100644 --- a/include/re/literal.h +++ b/include/re/literal.h @@ -7,7 +7,6 @@ #ifndef RE_LITERAL_H #define RE_LITERAL_H -struct fsm_options; struct re_err; enum re_literal_category { @@ -20,7 +19,6 @@ enum re_literal_category { int re_is_literal(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, - const struct fsm_options *opt, enum re_flags flags, struct re_err *err, enum re_literal_category *category, char **s, size_t *n); diff --git a/include/re/re.h b/include/re/re.h index 33d32b940..20408e98a 100644 --- a/include/re/re.h +++ b/include/re/re.h @@ -9,7 +9,6 @@ struct fsm; struct fsm_alloc; -struct fsm_options; enum re_dialect { RE_LIKE, @@ -135,7 +134,6 @@ struct fsm * re_comp(enum re_dialect dialect, re_getchar_fun *f, void *opaque, const struct fsm_alloc *alloc, - const struct fsm_options *opt, enum re_flags flags, struct re_err *err); /* diff --git a/include/re/strings.h b/include/re/strings.h index 1c43e2e95..551ab2eb1 100644 --- a/include/re/strings.h +++ b/include/re/strings.h @@ -10,7 +10,6 @@ #include struct fsm_alloc; -struct fsm_options; struct re_strings; @@ -34,7 +33,7 @@ enum re_strings_flags { }; struct fsm * -re_strings(const struct fsm_alloc *alloc, const struct fsm_options *opt, +re_strings(const struct fsm_alloc *alloc, const char *a[], size_t n, enum re_strings_flags flags); @@ -53,7 +52,6 @@ re_strings_add_str(struct re_strings *g, const char *s, const fsm_end_id_t *endi struct fsm * re_strings_build(struct re_strings *g, const struct fsm_alloc *alloc, - const struct fsm_options *opt, enum re_strings_flags flags); #endif diff --git a/src/fsm/main.c b/src/fsm/main.c index 084b147aa..9665c9a2c 100644 --- a/src/fsm/main.c +++ b/src/fsm/main.c @@ -485,7 +485,7 @@ main(int argc, char *argv[]) if ((op & OP_ARITY) == 1) { /* argc < 1 is okay */ - q = fsm_parse((argc == 0) ? stdin : xopen(argv[0]), alloc, &opt); + q = fsm_parse((argc == 0) ? stdin : xopen(argv[0]), alloc); if (q == NULL) { exit(EXIT_FAILURE); } @@ -495,12 +495,12 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } - a = fsm_parse(xopen(argv[0]), alloc, &opt); + a = fsm_parse(xopen(argv[0]), alloc); if (a == NULL) { exit(EXIT_FAILURE); } - b = fsm_parse(xopen(argv[1]), alloc, &opt); + b = fsm_parse(xopen(argv[1]), alloc); if (b == NULL) { exit(EXIT_FAILURE); } @@ -713,7 +713,7 @@ main(int argc, char *argv[]) } } - if (-1 == fsm_print(stdout, fsm, lang)) { + if (-1 == fsm_print(stdout, fsm, &opt, NULL, lang)) { if (errno == ENOTSUP) { fprintf(stderr, "unsupported IO API\n"); } else { diff --git a/src/libfsm/charset.c b/src/libfsm/charset.c index e7c75fd88..3f987eaa8 100644 --- a/src/libfsm/charset.c +++ b/src/libfsm/charset.c @@ -41,8 +41,6 @@ fsm_intersect_charset(struct fsm *a, size_t n, const char *charset) return NULL; } - fsm_setoptions(b, a->opt); - if (!fsm_addstate(b, &state)) { goto error; } diff --git a/src/libfsm/clone.c b/src/libfsm/clone.c index 897fe027a..f6012f277 100644 --- a/src/libfsm/clone.c +++ b/src/libfsm/clone.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -33,15 +34,12 @@ fsm_clone(const struct fsm *fsm) size_t i; assert(fsm != NULL); - assert(fsm->opt != NULL); new = fsm_new_statealloc(fsm->alloc, fsm->statecount); if (new == NULL) { return NULL; } - fsm_setoptions(new, fsm->opt); - if (!fsm_addstate_bulk(new, fsm->statecount)) { fsm_free(new); return NULL; diff --git a/src/libfsm/closure.c b/src/libfsm/closure.c index a9902b6e4..b5b4f969f 100644 --- a/src/libfsm/closure.c +++ b/src/libfsm/closure.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/src/libfsm/concat.c b/src/libfsm/concat.c index 980159f12..9f8780247 100644 --- a/src/libfsm/concat.c +++ b/src/libfsm/concat.c @@ -13,7 +13,6 @@ #include #include #include -#include #include "internal.h" @@ -38,11 +37,6 @@ fsm_concat(struct fsm *a, struct fsm *b, return NULL; } - if (a->opt != b->opt) { - errno = EINVAL; - return NULL; - } - if (a->statecount == 0) { return b; } if (b->statecount == 0) { return a; } diff --git a/src/libfsm/consolidate.c b/src/libfsm/consolidate.c index 79a7d7f01..fc15d4c26 100644 --- a/src/libfsm/consolidate.c +++ b/src/libfsm/consolidate.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -74,8 +75,6 @@ fsm_consolidate(const struct fsm *src, goto cleanup; } - fsm_setoptions(dst, src->opt); - for (src_i = 0; src_i < mapping_count; src_i++) { #if LOG_MAPPING fprintf(stderr, "consolidate_mapping[%u]: %u\n", diff --git a/src/libfsm/determinise.c b/src/libfsm/determinise.c index 731bc5aef..a32d15a9e 100644 --- a/src/libfsm/determinise.c +++ b/src/libfsm/determinise.c @@ -185,8 +185,6 @@ fsm_determinise(struct fsm *nfa) goto cleanup; } - fsm_setoptions(dfa, nfa->opt); - #if DUMP_MAPPING { fprintf(stderr, "#### fsm_determinise: mapping\n"); diff --git a/src/libfsm/endids.c b/src/libfsm/endids.c index b93f6f9f1..695251f76 100644 --- a/src/libfsm/endids.c +++ b/src/libfsm/endids.c @@ -5,6 +5,7 @@ */ #include +#include #include #include "endids_internal.h" diff --git a/src/libfsm/endids.h b/src/libfsm/endids.h index a5697f10b..a921f7a93 100644 --- a/src/libfsm/endids.h +++ b/src/libfsm/endids.h @@ -1,9 +1,6 @@ #ifndef ENDIDS_H #define ENDIDS_H -#include -#include - int fsm_endid_init(struct fsm *fsm); diff --git a/src/libfsm/epsilons.c b/src/libfsm/epsilons.c index 8dc049eba..f7418947c 100644 --- a/src/libfsm/epsilons.c +++ b/src/libfsm/epsilons.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -152,7 +153,7 @@ fsm_remove_epsilons(struct fsm *nfa) #if LOG_RESULT fprintf(stderr, "=== %s: about to update capture actions\n", __func__); - fsm_print(stderr, nfa, FSM_PRINT_FSM); + fsm_print(stderr, nfa, NULL, NULL, FSM_PRINT_FSM); #endif if (!remap_capture_actions(nfa, eclosures)) { @@ -160,7 +161,7 @@ fsm_remove_epsilons(struct fsm *nfa) } #if LOG_RESULT - fsm_print(stderr, nfa, FSM_PRINT_FSM); + fsm_print(stderr, nfa, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### post_remove_epsilons", nfa); #endif diff --git a/src/libfsm/equal.c b/src/libfsm/equal.c index 21dd12e3a..02489b0b1 100644 --- a/src/libfsm/equal.c +++ b/src/libfsm/equal.c @@ -55,7 +55,7 @@ subtract(const struct fsm *a, const struct fsm *b) assert(a != NULL); assert(b != NULL); - assert(a->opt == b->opt); + assert(a->alloc == b->alloc); if (!ensure_dfa(a, &pa)) { return NULL; @@ -126,11 +126,6 @@ fsm_equal(const struct fsm *a, const struct fsm *b) return -1; } - if (a->opt != b->opt) { - errno = EINVAL; - return -1; - } - if (fsm_empty(a) && fsm_empty(b)) { return 1; } diff --git a/src/libfsm/fsm.c b/src/libfsm/fsm.c index e99e7ba96..ba2d2db26 100644 --- a/src/libfsm/fsm.c +++ b/src/libfsm/fsm.c @@ -6,12 +6,12 @@ #include #include +#include #include #include #include #include -#include #include #include @@ -65,7 +65,6 @@ fsm_new_statealloc(const struct fsm_alloc *alloc, size_t statealloc) } new->alloc = alloc; - new->opt = NULL; new->statealloc = statealloc; new->statecount = 0; new->endcount = 0; @@ -112,18 +111,6 @@ fsm_free(struct fsm *fsm) f_free(fsm->alloc, fsm); } -const struct fsm_options * -fsm_getoptions(const struct fsm *fsm) -{ - return fsm->opt; -} - -void -fsm_setoptions(struct fsm *fsm, const struct fsm_options *opts) -{ - fsm->opt = opts; -} - void fsm_move(struct fsm *dst, struct fsm *src) { @@ -135,11 +122,6 @@ fsm_move(struct fsm *dst, struct fsm *src) return; /* XXX */ } - if (dst->opt != src->opt) { - errno = EINVAL; - return; /* XXX */ - } - free_contents(dst); dst->states = src->states; diff --git a/src/libfsm/internal.h b/src/libfsm/internal.h index 3ab8545ef..f45e070ff 100644 --- a/src/libfsm/internal.h +++ b/src/libfsm/internal.h @@ -11,7 +11,6 @@ #include #include -#include #include @@ -76,7 +75,6 @@ struct fsm { struct fsm_capture_info *capture_info; struct endid_info *endid_info; - const struct fsm_options *opt; }; struct fsm * diff --git a/src/libfsm/libfsm.syms b/src/libfsm/libfsm.syms index 28dfb9cc9..8f73c6e13 100644 --- a/src/libfsm/libfsm.syms +++ b/src/libfsm/libfsm.syms @@ -61,8 +61,6 @@ fsm_print_vmops_main fsm_clone fsm_free fsm_new -fsm_setoptions -fsm_getoptions fsm_move fsm_merge fsm_addstate diff --git a/src/libfsm/merge.c b/src/libfsm/merge.c index b7e8a5993..f9ec44593 100644 --- a/src/libfsm/merge.c +++ b/src/libfsm/merge.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -204,11 +205,6 @@ fsm_mergeab(struct fsm *a, struct fsm *b, return NULL; } - if (a->opt != b->opt) { - errno = EINVAL; - return NULL; - } - /* * We merge b into a. */ @@ -232,11 +228,6 @@ fsm_merge(struct fsm *a, struct fsm *b, assert(b != NULL); assert(combine_info != NULL); - if (a->opt != b->opt) { - errno = EINVAL; - return NULL; - } - /* * We merge the smaller FSM into the larger FSM. * The number of allocate states is considered first, because realloc diff --git a/src/libfsm/minimise.c b/src/libfsm/minimise.c index 576dfeeee..bc03168c3 100644 --- a/src/libfsm/minimise.c +++ b/src/libfsm/minimise.c @@ -144,10 +144,10 @@ fsm_minimise(struct fsm *fsm) fprintf(stderr, "%s: expected minimal DFA with %zu states, got %zu\n", __func__, exp_count, got_count); fprintf(stderr, "== expected:\n"); - fsm_print(stderr, oracle, FSM_PRINT_FSM); + fsm_print(stderr, oracle, NULL, NULL, FSM_PRINT_FSM); fprintf(stderr, "== got:\n"); - fsm_print(stderr, dst, FSM_PRINT_FSM); + fsm_print(stderr, dst, NULL, NULL, FSM_PRINT_FSM); assert(!"non-minimal result"); } diff --git a/src/libfsm/minimise_test_oracle.c b/src/libfsm/minimise_test_oracle.c index d2cfa404d..ec6d0d83c 100644 --- a/src/libfsm/minimise_test_oracle.c +++ b/src/libfsm/minimise_test_oracle.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/src/libfsm/parser.act b/src/libfsm/parser.act index 9a882a24f..2596c3cff 100644 --- a/src/libfsm/parser.act +++ b/src/libfsm/parser.act @@ -158,7 +158,7 @@ struct fsm * fsm_parse(FILE *f, - const struct fsm_alloc *alloc, const struct fsm_options *opt); + const struct fsm_alloc *alloc); @}; @@ -414,7 +414,7 @@ %trailer% @{ - struct fsm *fsm_parse(FILE *f, const struct fsm_alloc *alloc, const struct fsm_options *opt) { + struct fsm *fsm_parse(FILE *f, const struct fsm_alloc *alloc) { struct act_state act_state_s; struct act_state *act_state; struct lex_state lex_state_s; @@ -423,7 +423,6 @@ struct lx *lx; assert(f != NULL); - assert(opt != NULL); lex_state = &lex_state_s; @@ -456,8 +455,6 @@ return NULL; } - fsm_setoptions(new, opt); - ADVANCE_LEXER; switch (CURRENT_TERMINAL) { case TOK_UNKNOWN: diff --git a/src/libfsm/parser.c b/src/libfsm/parser.c index 026e621ac..e4ac8a31b 100644 --- a/src/libfsm/parser.c +++ b/src/libfsm/parser.c @@ -1351,10 +1351,10 @@ ZL1:; /* BEGINNING OF TRAILER */ -#line 482 "src/libfsm/parser.act" +#line 479 "src/libfsm/parser.act" - struct fsm *fsm_parse(FILE *f, const struct fsm_alloc *alloc, const struct fsm_options *opt) { + struct fsm *fsm_parse(FILE *f, const struct fsm_alloc *alloc) { struct act_state act_state_s; struct act_state *act_state; struct lex_state lex_state_s; @@ -1363,7 +1363,6 @@ ZL1:; struct lx *lx; assert(f != NULL); - assert(opt != NULL); lex_state = &lex_state_s; @@ -1396,8 +1395,6 @@ ZL1:; return NULL; } - fsm_setoptions(new, opt); - ADVANCE_LEXER; switch (CURRENT_TERMINAL) { case TOK_UNKNOWN: @@ -1419,6 +1416,6 @@ ZL1:; return new; } -#line 1423 "src/libfsm/parser.c" +#line 1420 "src/libfsm/parser.c" /* END OF FILE */ diff --git a/src/libfsm/parser.h b/src/libfsm/parser.h index e7ca6f330..edeebb112 100644 --- a/src/libfsm/parser.h +++ b/src/libfsm/parser.h @@ -18,7 +18,7 @@ struct fsm * fsm_parse(FILE *f, - const struct fsm_alloc *alloc, const struct fsm_options *opt); + const struct fsm_alloc *alloc); #line 24 "src/libfsm/parser.h" @@ -27,7 +27,7 @@ extern void p_fsm(fsm, lex_state, act_state); /* BEGINNING OF TRAILER */ -#line 483 "src/libfsm/parser.act" +#line 480 "src/libfsm/parser.act" #line 33 "src/libfsm/parser.h" diff --git a/src/libfsm/print.c b/src/libfsm/print.c index 427ef5021..0cc4cd340 100644 --- a/src/libfsm/print.c +++ b/src/libfsm/print.c @@ -11,6 +11,7 @@ #include #include +#include #include #include "print.h" @@ -20,76 +21,97 @@ #include "print/ir.h" int -print_hook_args(FILE *f, const struct fsm_options *opt, +print_hook_args(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, int (*default_args)(FILE *f, const struct fsm_options *opt, - void *lang_opaque), + void *lang_opaque, void *hook_opaque), void *lang_opaque) { assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (default_args == NULL) { assert(lang_opaque == NULL); } - if (opt->hooks.accept != NULL) { - return opt->hooks.args(f, opt, lang_opaque); + if (hooks->accept != NULL) { + return hooks->args(f, opt, + lang_opaque, hooks->hook_opaque); } else if (default_args != NULL) { - return default_args(f, opt, lang_opaque); + return default_args(f, opt, + lang_opaque, hooks->hook_opaque); } return 0; } int -print_hook_accept(FILE *f, const struct fsm_options *opt, +print_hook_accept(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const fsm_end_id_t *ids, size_t count, int (*default_accept)(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque), + void *lang_opaque, void *hook_opaque), void *lang_opaque) { assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (default_accept == NULL) { assert(lang_opaque == NULL); } - if (opt->hooks.accept != NULL) { - return opt->hooks.accept(f, opt, ids, count, lang_opaque); + if (hooks->accept != NULL) { + return hooks->accept(f, opt, ids, count, + lang_opaque, hooks->hook_opaque); } else if (default_accept != NULL) { - return default_accept(f, opt, ids, count, lang_opaque); + return default_accept(f, opt, ids, count, + lang_opaque, hooks->hook_opaque); } return 0; } int -print_hook_reject(FILE *f, const struct fsm_options *opt, +print_hook_reject(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, int (*default_reject)(FILE *f, const struct fsm_options *opt, - void *lang_opaque), + void *lang_opaque, void *hook_opaque), void *lang_opaque) { assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (default_reject == NULL) { assert(lang_opaque == NULL); } - if (opt->hooks.reject != NULL) { - return opt->hooks.reject(f, opt, lang_opaque); + if (hooks->reject != NULL) { + return hooks->reject(f, opt, + lang_opaque, hooks->hook_opaque); } else if (default_reject != NULL) { - return default_reject(f, opt, lang_opaque); + return default_reject(f, opt, + lang_opaque, hooks->hook_opaque); } return 0; } int -fsm_print(FILE *f, const struct fsm *fsm, enum fsm_print_lang lang) +fsm_print(FILE *f, const struct fsm *fsm, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + enum fsm_print_lang lang) { + static const struct fsm_options opt_zero; + static const struct fsm_hooks hooks_zero; + struct dfavm_assembler_ir a; struct ir *ir; int r; @@ -106,8 +128,14 @@ fsm_print(FILE *f, const struct fsm *fsm, enum fsm_print_lang lang) vm_print_f *print_vm = NULL; assert(f != NULL); - assert(fsm != NULL); - assert(fsm->opt != NULL); + + if (opt == NULL) { + opt = &opt_zero; + } + + if (hooks == NULL) { + hooks = &hooks_zero; + } if (lang == FSM_PRINT_NONE) { return 0; @@ -145,17 +173,17 @@ fsm_print(FILE *f, const struct fsm *fsm, enum fsm_print_lang lang) ir = NULL; if (print_fsm != NULL) { - r = print_fsm(f, fsm->opt, fsm); + r = print_fsm(f, opt, hooks, fsm); goto done; } - ir = make_ir(fsm); + ir = make_ir(fsm, opt); if (ir == NULL) { return -1; } if (print_ir != NULL) { - r = print_ir(f, fsm->opt, ir); + r = print_ir(f, opt, hooks, ir); goto done; } @@ -168,7 +196,7 @@ fsm_print(FILE *f, const struct fsm *fsm, enum fsm_print_lang lang) } if (print_vm != NULL) { - r = print_vm(f, fsm->opt, a.linked); + r = print_vm(f, opt, hooks, a.linked); } dfavm_opasm_finalize_op(&a); diff --git a/src/libfsm/print.h b/src/libfsm/print.h index 8b6a9555a..993eb4440 100644 --- a/src/libfsm/print.h +++ b/src/libfsm/print.h @@ -8,31 +8,51 @@ #define FSM_INTERNAL_PRINT_H struct fsm; +struct fsm_options; +struct fsm_hooks; struct ir; struct dfavm_op_ir; int -print_hook_args(FILE *f, const struct fsm_options *opt, +print_hook_args(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, int (*default_args)(FILE *f, const struct fsm_options *opt, - void *lang_opaque), + void *lang_opaque, void *hook_opaque), void *lang_opaque); int -print_hook_accept(FILE *f, const struct fsm_options *opt, +print_hook_accept(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const fsm_end_id_t *ids, size_t count, int (*default_accept)(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque), + void *lang_opaque, void *hook_opaque), void *lang_opaque); int -print_hook_reject(FILE *f, const struct fsm_options *opt, - int (*default_reject)(FILE *f, const struct fsm_options *opt, void *lang_opaque), +print_hook_reject(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + int (*default_reject)(FILE *f, const struct fsm_options *opt, + void *lang_opaque, void *hook_opaque), void *lang_opaque); -typedef int fsm_print_f(FILE *f, const struct fsm_options *opt, const struct fsm *fsm); -typedef int ir_print_f(FILE *f, const struct fsm_options *opt, const struct ir *ir); -typedef int vm_print_f(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops); +typedef int fsm_print_f(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + const struct fsm *fsm); + +typedef int ir_print_f(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + const struct ir *ir); + +typedef int vm_print_f(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops); vm_print_f fsm_print_amd64_att; vm_print_f fsm_print_amd64_go; diff --git a/src/libfsm/print/api.c b/src/libfsm/print/api.c index e7232da42..d7cb70f1f 100644 --- a/src/libfsm/print/api.c +++ b/src/libfsm/print/api.c @@ -43,7 +43,10 @@ rangeclass(unsigned char x, unsigned char y) } int -fsm_print_api(FILE *f, const struct fsm *fsm_orig) +fsm_print_api(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + const struct fsm *fsm_orig) { struct fsm *fsm; fsm_state_t start, end; @@ -52,7 +55,8 @@ fsm_print_api(FILE *f, const struct fsm *fsm_orig) assert(f != NULL); assert(fsm_orig != NULL); - assert(fsm_orig->opt != NULL); + assert(opt != NULL); + assert(hooks != NULL); if (!fsm_has(fsm_orig, fsm_isend)) { errno = EINVAL; @@ -75,13 +79,13 @@ fsm_print_api(FILE *f, const struct fsm *fsm_orig) /* TODO: leaf callback for opaques */ - if (fsm->opt->fragment) { + if (opt->fragment) { fprintf(f, "\t"); } fprintf(f, "/* Generated by libfsm */\n"); fprintf(f, "\n"); - if (!fsm->opt->fragment) { + if (!opt->fragment) { fprintf(f, "#include LF_HEADER\n"); fprintf(f, "\n"); @@ -95,7 +99,7 @@ fsm_print_api(FILE *f, const struct fsm *fsm_orig) fprintf(f, "int\n"); fprintf(f, "%sfsm(struct fsm *fsm, fsm_state_t *x, fsm_state_t *y)\n", - fsm->opt->prefix != NULL ? fsm->opt->prefix : ""); + opt->prefix != NULL ? opt->prefix : ""); fprintf(f, "{\n"); } @@ -208,7 +212,7 @@ fsm_print_api(FILE *f, const struct fsm *fsm_orig) } else if (lo == hi - 1) { fprintf(f, "\tif (!fsm_addedge_literal(fsm, s[%u], s[%u], ", from, to); - c_escputcharlit(f, fsm->opt, lo); + c_escputcharlit(f, opt, lo); fprintf(f, ")) { return 0; }\n"); } else { fprintf(f, "\tfor (i = 0x%02x; i <= 0x%02x; i++) {", @@ -230,7 +234,7 @@ fsm_print_api(FILE *f, const struct fsm *fsm_orig) fprintf(f, "\n"); - if (!fsm->opt->fragment) { + if (!opt->fragment) { fprintf(f, "\n"); fprintf(f, "\treturn 1;\n"); diff --git a/src/libfsm/print/awk.c b/src/libfsm/print/awk.c index 54684fb93..de98f95eb 100644 --- a/src/libfsm/print/awk.c +++ b/src/libfsm/print/awk.c @@ -51,13 +51,14 @@ cmp_operator(int cmp) static int default_accept(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; switch (opt->ambig) { case AMBIG_NONE: @@ -108,13 +109,14 @@ default_accept(FILE *f, const struct fsm_options *opt, static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; fprintf(f, "return 0;"); @@ -144,15 +146,17 @@ print_cond(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt) } static int -print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, +print_end(FILE *f, const struct dfavm_op_ir *op, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, enum dfavm_op_end end_bits) { switch (end_bits) { case VM_END_FAIL: - return print_hook_reject(f, opt, default_reject, NULL); + return print_hook_reject(f, opt, hooks, default_reject, NULL); case VM_END_SUCC: - return print_hook_accept(f, opt, + return print_hook_accept(f, opt, hooks, op->endids.ids, op->endids.count, default_accept, NULL); @@ -179,7 +183,9 @@ print_branch(FILE *f, const struct dfavm_op_ir *op, const char *prefix) /* TODO: eventually to be non-static */ static int -fsm_print_awkfrag(FILE *f, const struct fsm_options *opt, +fsm_print_awkfrag(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, struct dfavm_op_ir *ops, const char *cp, const char *prefix) { @@ -187,6 +193,7 @@ fsm_print_awkfrag(FILE *f, const struct fsm_options *opt, assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); assert(cp != NULL); assert(prefix != NULL); @@ -236,7 +243,7 @@ fsm_print_awkfrag(FILE *f, const struct fsm_options *opt, switch (op->instr) { case VM_OP_STOP: print_cond(f, op, opt); - if (-1 == print_end(f, op, opt, op->u.stop.end_bits)) { + if (-1 == print_end(f, op, opt, hooks, op->u.stop.end_bits)) { return -1; } fprintf(f, ";"); @@ -244,7 +251,7 @@ fsm_print_awkfrag(FILE *f, const struct fsm_options *opt, case VM_OP_FETCH: { fprintf(f, "if (s == \"\") "); - if (-1 == print_end(f, op, opt, op->u.fetch.end_bits)) { + if (-1 == print_end(f, op, opt, hooks, op->u.fetch.end_bits)) { return -1; } fprintf(f, "\n"); @@ -279,13 +286,17 @@ fsm_print_awkfrag(FILE *f, const struct fsm_options *opt, } int -fsm_print_awk(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_awk(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { const char *prefix; const char *cp; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (opt->prefix != NULL) { prefix = opt->prefix; @@ -293,14 +304,14 @@ fsm_print_awk(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) prefix = "fsm_"; } - if (opt->hooks.cp != NULL) { - cp = opt->hooks.cp; + if (hooks->cp != NULL) { + cp = hooks->cp; } else { cp = "c"; /* XXX */ } if (opt->fragment) { - if (-1 == fsm_print_awkfrag(f, opt, ops, cp, prefix)) { + if (-1 == fsm_print_awkfrag(f, opt, hooks, ops, cp, prefix)) { return -1; } } else { @@ -322,7 +333,7 @@ fsm_print_awk(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) fprintf(f, ", l, c) {\n"); - if (-1 == fsm_print_awkfrag(f, opt, ops, cp, prefix)) { + if (-1 == fsm_print_awkfrag(f, opt, hooks, ops, cp, prefix)) { return -1; } diff --git a/src/libfsm/print/c.c b/src/libfsm/print/c.c index c22435baf..24a04e843 100644 --- a/src/libfsm/print/c.c +++ b/src/libfsm/print/c.c @@ -116,13 +116,14 @@ print_ids(FILE *f, static int default_accept(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; if (-1 == print_ids(f, opt->ambig, ids, count)) { return -1; @@ -133,13 +134,14 @@ default_accept(FILE *f, const struct fsm_options *opt, static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; fprintf(f, "return 0;"); @@ -206,7 +208,9 @@ print_groups(FILE *f, const struct fsm_options *opt, } static int -print_case(FILE *f, const struct ir *ir, const struct fsm_options *opt, +print_case(FILE *f, const struct ir *ir, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const char *cp, struct ir_state *cs) { @@ -219,7 +223,7 @@ print_case(FILE *f, const struct ir *ir, const struct fsm_options *opt, switch (cs->strategy) { case IR_NONE: fprintf(f, "\t\t\t"); - if (-1 == print_hook_reject(f, opt, default_reject, NULL)) { + if (-1 == print_hook_reject(f, opt, hooks, default_reject, NULL)) { return -1; } fprintf(f, "\n"); @@ -248,7 +252,7 @@ print_case(FILE *f, const struct ir *ir, const struct fsm_options *opt, print_groups(f, opt, ir_indexof(ir, cs), cs->u.partial.groups, cs->u.partial.n); fprintf(f, "\t\t\tdefault: "); - if (-1 == print_hook_reject(f, opt, default_reject, NULL)) { + if (-1 == print_hook_reject(f, opt, hooks, default_reject, NULL)) { return -1; } fprintf(f, "\n"); @@ -279,7 +283,7 @@ print_case(FILE *f, const struct ir *ir, const struct fsm_options *opt, print_ranges(f, opt, cs->u.error.error.ranges, cs->u.error.error.n); fprintf(f, " "); - if (-1 == print_hook_reject(f, opt, default_reject, NULL)) { + if (-1 == print_hook_reject(f, opt, hooks, default_reject, NULL)) { return -1; } fprintf(f, "\n"); @@ -335,7 +339,10 @@ print_stateenum(FILE *f, size_t n) } static int -print_endstates(FILE *f, const struct fsm_options *opt, const struct ir *ir) +print_endstates(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + const struct ir *ir) { unsigned i; @@ -359,7 +366,7 @@ print_endstates(FILE *f, const struct fsm_options *opt, const struct ir *ir) fprintf(f, "\tcase S%u: ", i); - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, ir->states[i].endids.ids, ir->states[i].endids.count, default_accept, NULL)) @@ -372,7 +379,7 @@ print_endstates(FILE *f, const struct fsm_options *opt, const struct ir *ir) /* unexpected EOT */ fprintf(f, "\tdefault: "); - if (-1 == print_hook_reject(f, opt, default_reject, NULL)) { + if (-1 == print_hook_reject(f, opt, hooks, default_reject, NULL)) { return -1; } fprintf(f, "\n"); @@ -382,7 +389,9 @@ print_endstates(FILE *f, const struct fsm_options *opt, const struct ir *ir) } int -fsm_print_cfrag(FILE *f, const struct ir *ir, const struct fsm_options *opt, +fsm_print_cfrag(FILE *f, const struct ir *ir, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const char *cp) { unsigned i; @@ -407,7 +416,7 @@ fsm_print_cfrag(FILE *f, const struct ir *ir, const struct fsm_options *opt, } fprintf(f, "\n"); - if (-1 == print_case(f, ir, opt, cp, &ir->states[i])) { + if (-1 == print_case(f, ir, opt, hooks, cp, &ir->states[i])) { return -1; } @@ -425,16 +434,19 @@ fsm_print_cfrag(FILE *f, const struct ir *ir, const struct fsm_options *opt, } static int -fsm_print_c_body(FILE *f, const struct ir *ir, const struct fsm_options *opt) +fsm_print_c_body(FILE *f, const struct ir *ir, + const struct fsm_options *opt, + const struct fsm_hooks *hooks) { const char *cp; assert(f != NULL); assert(ir != NULL); assert(opt != NULL); + assert(hooks != NULL); - if (opt->hooks.cp != NULL) { - cp = opt->hooks.cp; + if (hooks->cp != NULL) { + cp = hooks->cp; } else { switch (opt->io) { case FSM_IO_GETC: cp = "c"; break; @@ -465,7 +477,7 @@ fsm_print_c_body(FILE *f, const struct ir *ir, const struct fsm_options *opt) break; } - if (-1 == fsm_print_cfrag(f, ir, opt, cp)) { + if (-1 == fsm_print_cfrag(f, ir, opt, hooks, cp)) { return -1; } @@ -473,7 +485,7 @@ fsm_print_c_body(FILE *f, const struct ir *ir, const struct fsm_options *opt) fprintf(f, "\n"); /* end states */ - if (-1 == print_endstates(f, opt, ir)) { + if (-1 == print_endstates(f, opt, hooks, ir)) { return -1; } @@ -481,13 +493,16 @@ fsm_print_c_body(FILE *f, const struct ir *ir, const struct fsm_options *opt) } int -fsm_print_c(FILE *f, const struct fsm_options *opt, +fsm_print_c(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const struct ir *ir) { const char *prefix; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); assert(ir != NULL); if (opt->prefix != NULL) { @@ -497,7 +512,7 @@ fsm_print_c(FILE *f, const struct fsm_options *opt, } if (opt->fragment) { - if (-1 == fsm_print_c_body(f, ir, opt)) { + if (-1 == fsm_print_c_body(f, ir, opt, hooks)) { return -1; } } else { @@ -544,11 +559,11 @@ fsm_print_c(FILE *f, const struct fsm_options *opt, abort(); } - if (opt->hooks.args != NULL) { + if (hooks->args != NULL) { fprintf(stdout, ",\n"); fprintf(stdout, "\t"); - if (-1 == print_hook_args(f, opt, NULL, NULL)) { + if (-1 == print_hook_args(f, opt, hooks, NULL, NULL)) { return -1; } } @@ -582,7 +597,7 @@ fsm_print_c(FILE *f, const struct fsm_options *opt, if (ir->n == 0) { fprintf(f, "\treturn 0; /* no matches */\n"); } else { - if (-1 == fsm_print_c_body(f, ir, opt)) { + if (-1 == fsm_print_c_body(f, ir, opt, hooks)) { return -1; } } diff --git a/src/libfsm/print/dot.c b/src/libfsm/print/dot.c index 797bee340..aeb79b254 100644 --- a/src/libfsm/print/dot.c +++ b/src/libfsm/print/dot.c @@ -28,7 +28,7 @@ static int default_accept(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { fsm_state_t s; @@ -36,6 +36,8 @@ default_accept(FILE *f, const struct fsm_options *opt, assert(opt != NULL); assert(lang_opaque != NULL); + (void) hook_opaque; + s = * (fsm_state_t *) lang_opaque; fprintf(f, "label = <"); @@ -63,7 +65,7 @@ default_accept(FILE *f, const struct fsm_options *opt, static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { fsm_state_t s; @@ -71,6 +73,8 @@ default_reject(FILE *f, const struct fsm_options *opt, assert(opt != NULL); assert(lang_opaque != NULL); + (void) hook_opaque; + s = * (fsm_state_t *) lang_opaque; if (!opt->anonymous_states) { @@ -81,7 +85,10 @@ default_reject(FILE *f, const struct fsm_options *opt, } static int -print_state(FILE *f, const struct fsm_options *opt, const struct fsm *fsm, +print_state(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + const struct fsm *fsm, const char *prefix, fsm_state_t s) { struct fsm_edge e; @@ -91,6 +98,7 @@ print_state(FILE *f, const struct fsm_options *opt, const struct fsm *fsm, assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); assert(fsm != NULL); assert(prefix != NULL); assert(s < fsm->statecount); @@ -201,7 +209,9 @@ print_state(FILE *f, const struct fsm_options *opt, const struct fsm *fsm, } static int -print_dotfrag(FILE *f, const struct fsm_options *opt, +print_dotfrag(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const struct fsm *fsm, const char *prefix) { fsm_state_t s; @@ -216,7 +226,7 @@ print_dotfrag(FILE *f, const struct fsm_options *opt, if (!opt->anonymous_states) { fprintf(f, "\t%sS%-2u [ ", prefix, s); - if (-1 == print_hook_reject(f, opt, default_reject, &s)) { + if (-1 == print_hook_reject(f, opt, hooks, default_reject, &s)) { return -1; } @@ -226,9 +236,10 @@ print_dotfrag(FILE *f, const struct fsm_options *opt, fsm_end_id_t *ids; size_t count; - ids = NULL; count = fsm_endid_count(fsm, s); - if (count > 0) { + if (count == 0) { + ids = NULL; + } else { int res; ids = f_malloc(fsm->alloc, count * sizeof *ids); @@ -247,7 +258,7 @@ print_dotfrag(FILE *f, const struct fsm_options *opt, fprintf(f, ", "); - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, ids, count, default_accept, &s)) { @@ -261,7 +272,7 @@ print_dotfrag(FILE *f, const struct fsm_options *opt, /* TODO: show example here, unless !opt->comments */ - if (-1 == print_state(f, opt, fsm, prefix, s)) { + if (-1 == print_state(f, opt, hooks, fsm, prefix, s)) { return -1; } } @@ -270,13 +281,17 @@ print_dotfrag(FILE *f, const struct fsm_options *opt, } int -fsm_print_dot(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) +fsm_print_dot(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + const struct fsm *fsm) { const char *prefix; assert(f != NULL); assert(fsm != NULL); assert(opt != NULL); + assert(hooks != NULL); if (opt->prefix != NULL) { prefix = opt->prefix; @@ -285,7 +300,7 @@ fsm_print_dot(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) } if (opt->fragment) { - if (-1 == print_dotfrag(f, opt, fsm, prefix)) { + if (-1 == print_dotfrag(f, opt, hooks, fsm, prefix)) { return -1; } } else { @@ -314,7 +329,7 @@ fsm_print_dot(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) fprintf(f, "\n"); } - if (-1 == print_dotfrag(f, opt, fsm, prefix)) { + if (-1 == print_dotfrag(f, opt, hooks, fsm, prefix)) { return -1; } diff --git a/src/libfsm/print/fsm.c b/src/libfsm/print/fsm.c index a029a82c2..cd42e01a3 100644 --- a/src/libfsm/print/fsm.c +++ b/src/libfsm/print/fsm.c @@ -27,13 +27,15 @@ static int default_accept(FILE *f, const struct fsm_options *opt, - const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + const fsm_end_id_t *ids, size_t count, + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); + (void) hook_opaque; + if (count == 0) { return 0; } @@ -117,7 +119,9 @@ findany(const struct fsm *fsm, fsm_state_t state, fsm_state_t *a) } static int -print_state_comments(FILE *f, const struct fsm_options *opt, const struct fsm *fsm, +print_state_comments(FILE *f, + const struct fsm_options *opt, + const struct fsm *fsm, fsm_state_t dst) { fsm_state_t start; @@ -172,14 +176,15 @@ print_char_range(FILE *f, const struct fsm_options *opt, char lower, char upper) } static int -print_state(FILE *f, const struct fsm_options *opt, const struct fsm *fsm, +print_state(FILE *f, const struct fsm_options *opt, const struct fsm_hooks *hooks, + const struct fsm *fsm, fsm_state_t s) { assert(f != NULL); assert(opt != NULL); if (!fsm_isend(fsm, s)) { - if (-1 == print_hook_reject(f, opt, NULL, NULL)) { + if (-1 == print_hook_reject(f, opt, hooks, NULL, NULL)) { return -1; } } @@ -281,12 +286,17 @@ print_state(FILE *f, const struct fsm_options *opt, const struct fsm *fsm, } int -fsm_print_fsm(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) +fsm_print_fsm(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + const struct fsm *fsm) { fsm_state_t s, start; size_t end; assert(f != NULL); + assert(opt != NULL); + assert(hooks != NULL); assert(fsm != NULL); if (!opt->anonymous_states) { @@ -304,7 +314,7 @@ fsm_print_fsm(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) } for (s = 0; s < fsm->statecount; s++) { - if (-1 == print_state(f, opt, fsm, s)) { + if (-1 == print_state(f, opt, hooks, fsm, s)) { return -1; } } @@ -335,7 +345,9 @@ fsm_print_fsm(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) end--; count = fsm_endid_count(fsm, s); - if (count > 0) { + if (count == 0) { + ids = NULL; + } else { int res; ids = f_malloc(fsm->alloc, count * sizeof *ids); @@ -349,7 +361,7 @@ fsm_print_fsm(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) fprintf(f, "%u", s); - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, ids, count, default_accept, NULL)) diff --git a/src/libfsm/print/go.c b/src/libfsm/print/go.c index 442d20466..5a0ac9668 100644 --- a/src/libfsm/print/go.c +++ b/src/libfsm/print/go.c @@ -85,14 +85,15 @@ print_ids(FILE *f, static int default_accept(FILE *f, const struct fsm_options *opt, - const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + const fsm_end_id_t *ids, size_t count, + void *lang_opaque, void *hook_opaque) { - assert(f != NULL); - assert(opt != NULL); - assert(lang_opaque == NULL); + assert(f != NULL); + assert(opt != NULL); + assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; fprintf(f, "return true"); @@ -105,13 +106,14 @@ default_accept(FILE *f, const struct fsm_options *opt, static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { - assert(f != NULL); - assert(opt != NULL); - assert(lang_opaque == NULL); + assert(f != NULL); + assert(opt != NULL); + assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; fprintf(f, "{\n\t\treturn false\n\t}\n"); @@ -145,18 +147,20 @@ print_cond(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt) } static int -print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, +print_end(FILE *f, const struct dfavm_op_ir *op, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, enum dfavm_op_end end_bits) { switch (end_bits) { case VM_END_FAIL: - return print_hook_reject(f, opt, default_reject, NULL); + return print_hook_reject(f, opt, hooks, default_reject, NULL); case VM_END_SUCC: fprintf(f, "{\n"); fprintf(f, "\t\t"); - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, op->endids.ids, op->endids.count, default_accept, NULL)) @@ -196,7 +200,10 @@ print_fetch(FILE *f, const struct fsm_options *opt) /* TODO: eventually to be non-static */ static int -fsm_print_gofrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, +fsm_print_gofrag(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops, const char *cp) { struct dfavm_op_ir *op; @@ -265,12 +272,12 @@ fsm_print_gofrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops switch (op->instr) { case VM_OP_STOP: print_cond(f, op, opt); - print_end(f, op, opt, op->u.stop.end_bits); + print_end(f, op, opt, hooks, op->u.stop.end_bits); break; case VM_OP_FETCH: print_fetch(f, opt); - print_end(f, op, opt, op->u.fetch.end_bits); + print_end(f, op, opt, hooks, op->u.fetch.end_bits); break; case VM_OP_BRANCH: @@ -290,7 +297,10 @@ fsm_print_gofrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops } int -fsm_print_go(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_go(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { const char *prefix; const char *package_prefix; @@ -300,6 +310,7 @@ fsm_print_go(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (opt->prefix != NULL) { prefix = opt->prefix; @@ -314,7 +325,7 @@ fsm_print_go(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) } if (opt->fragment) { - if (-1 == fsm_print_gofrag(f, opt, ops, cp)) { + if (-1 == fsm_print_gofrag(f, opt, hooks, ops, cp)) { return -1; } } else { @@ -337,10 +348,10 @@ fsm_print_go(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) return -1; } - if (opt->hooks.args != NULL) { + if (hooks->args != NULL) { fprintf(stdout, ", "); - if (-1 == print_hook_args(f, opt, NULL, NULL)) { + if (-1 == print_hook_args(f, opt, hooks, NULL, NULL)) { return -1; } } @@ -369,7 +380,7 @@ fsm_print_go(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) fprintf(f, " {\n"); - if (-1 == fsm_print_gofrag(f, opt, ops, cp)) { + if (-1 == fsm_print_gofrag(f, opt, hooks, ops, cp)) { return -1; } diff --git a/src/libfsm/print/ir.c b/src/libfsm/print/ir.c index 3703afcba..083604ff9 100644 --- a/src/libfsm/print/ir.c +++ b/src/libfsm/print/ir.c @@ -335,7 +335,6 @@ make_state(const struct fsm *fsm, fsm_state_t state, } mode; assert(fsm != NULL); - assert(fsm->opt != NULL); assert(state < fsm->statecount); /* TODO: IR_TABLE */ @@ -433,13 +432,13 @@ make_state(const struct fsm *fsm, fsm_state_t state, } struct ir * -make_ir(const struct fsm *fsm) +make_ir(const struct fsm *fsm, const struct fsm_options *opt) { fsm_state_t start, i; struct ir *ir; assert(fsm != NULL); - assert(fsm->opt != NULL); + assert(opt != NULL); if (!fsm_getstart(fsm, &start)) { goto empty; @@ -498,7 +497,7 @@ make_ir(const struct fsm *fsm) goto error; } - if (!fsm->opt->comments) { + if (!opt->comments) { ir->states[i].example = NULL; } else { char *p; diff --git a/src/libfsm/print/ir.h b/src/libfsm/print/ir.h index 05ad758e7..02ab9a731 100644 --- a/src/libfsm/print/ir.h +++ b/src/libfsm/print/ir.h @@ -18,6 +18,8 @@ * we're done with graph algorithmics. */ +struct fsm_options; + enum ir_strategy { IR_NONE = 1 << 0, IR_SAME = 1 << 1, @@ -105,7 +107,7 @@ struct ir { /* TODO: can pass in mask of allowed strategies */ struct ir * -make_ir(const struct fsm *fsm); +make_ir(const struct fsm *fsm, const struct fsm_options *opt); void free_ir(const struct fsm *fsm, struct ir *ir); diff --git a/src/libfsm/print/irdot.c b/src/libfsm/print/irdot.c index db0f559ee..186365203 100644 --- a/src/libfsm/print/irdot.c +++ b/src/libfsm/print/irdot.c @@ -175,7 +175,9 @@ print_grouplinks(FILE *f, unsigned self, } static int -print_state(FILE *f, const struct fsm_options *opt, +print_state(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const struct ir *ir, const struct ir_state *cs) { assert(f != NULL); @@ -216,10 +218,10 @@ print_state(FILE *f, const struct fsm_options *opt, /* TODO: leaf callback for dot output */ /* showing hook in addition to existing content */ - if (cs->isend && opt->hooks.accept != NULL) { + if (cs->isend && hooks->accept != NULL) { fprintf(f, "\t\t "); - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, cs->endids.ids, cs->endids.count, NULL, NULL)) @@ -326,13 +328,16 @@ print_state(FILE *f, const struct fsm_options *opt, } int -fsm_print_ir(FILE *f, const struct fsm_options *opt, +fsm_print_ir(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const struct ir *ir) { size_t i; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); assert(ir != NULL); fprintf(f, "digraph G {\n"); @@ -349,7 +354,7 @@ fsm_print_ir(FILE *f, const struct fsm_options *opt, } for (i = 0; i < ir->n; i++) { - if (-1 == print_state(f, opt, ir, &ir->states[i])) { + if (-1 == print_state(f, opt, hooks, ir, &ir->states[i])) { return -1; } } diff --git a/src/libfsm/print/irjson.c b/src/libfsm/print/irjson.c index a15b47015..06c4c4208 100644 --- a/src/libfsm/print/irjson.c +++ b/src/libfsm/print/irjson.c @@ -114,11 +114,14 @@ print_groups(FILE *f, const struct fsm_options *opt, } static int -print_state(FILE *f, const struct fsm_options *opt, +print_state(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const struct ir_state *cs) { assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); assert(cs != NULL); fprintf(f, "\t\t{\n"); @@ -137,10 +140,10 @@ print_state(FILE *f, const struct fsm_options *opt, } /* showing hook in addition to existing content */ - if (cs->isend && opt->hooks.accept != NULL) { + if (cs->isend && hooks->accept != NULL) { fprintf(f, "\t\t\t\"endleaf\": "); - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, cs->endids.ids, cs->endids.count, NULL, NULL)) { @@ -166,8 +169,6 @@ print_state(FILE *f, const struct fsm_options *opt, fprintf(f, "\n"); } - /* TODO: leaf callback for json output */ - switch (cs->strategy) { case IR_NONE: break; @@ -215,13 +216,16 @@ print_state(FILE *f, const struct fsm_options *opt, } int -fsm_print_irjson(FILE *f, const struct fsm_options *opt, +fsm_print_irjson(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const struct ir *ir) { size_t i; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); assert(ir != NULL); fprintf(f, "{\n"); @@ -230,7 +234,7 @@ fsm_print_irjson(FILE *f, const struct fsm_options *opt, fprintf(f, "\t\"states\": [\n"); for (i = 0; i < ir->n; i++) { - if (-1 == print_state(f, opt, &ir->states[i])) { + if (-1 == print_state(f, opt, hooks, &ir->states[i])) { return -1; } diff --git a/src/libfsm/print/json.c b/src/libfsm/print/json.c index 1c5d9da4e..025d1fe6f 100644 --- a/src/libfsm/print/json.c +++ b/src/libfsm/print/json.c @@ -204,13 +204,17 @@ print_state(FILE *f, const struct fsm_options *opt, const struct fsm *fsm, } int -fsm_print_json(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) +fsm_print_json(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + const struct fsm *fsm) { fsm_state_t start; fsm_state_t i; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); assert(fsm != NULL); fprintf(f, "{\n"); @@ -242,7 +246,7 @@ fsm_print_json(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) } /* showing hook in addition to existing content */ - if (opt->hooks.accept != NULL) { + if (hooks->accept != NULL) { int notfirst; notfirst = 0; @@ -258,22 +262,25 @@ fsm_print_json(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) } count = fsm_endid_count(fsm, i); + if (count == 0) { + ids = NULL; + } else { + ids = f_malloc(fsm->alloc, count * sizeof *ids); + if (ids == NULL) { + return -1; + } - ids = f_malloc(fsm->alloc, count * sizeof *ids); - if (ids == NULL) { - return -1; + res = fsm_endid_get(fsm, i, count, ids); + assert(res == 1); } - res = fsm_endid_get(fsm, i, count, ids); - assert(res == 1); - if (notfirst) { fprintf(f, ", "); } fprintf(f, "{ %u, ", i); - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, ids, count, NULL, NULL)) { @@ -282,7 +289,9 @@ fsm_print_json(FILE *f, const struct fsm_options *opt, const struct fsm *fsm) fprintf(f, " }"); - f_free(fsm->alloc, ids); + if (count > 0) { + f_free(fsm->alloc, ids); + } notfirst = 1; } diff --git a/src/libfsm/print/llvm.c b/src/libfsm/print/llvm.c index 6cf49db28..ac87090df 100644 --- a/src/libfsm/print/llvm.c +++ b/src/libfsm/print/llvm.c @@ -98,7 +98,7 @@ cmp_operator(int cmp) static int default_accept(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { size_t i; @@ -106,6 +106,8 @@ default_accept(FILE *f, const struct fsm_options *opt, assert(opt != NULL); assert(lang_opaque != NULL); + (void) hook_opaque; + i = * (const size_t *) lang_opaque; switch (opt->ambig) { @@ -146,13 +148,14 @@ default_accept(FILE *f, const struct fsm_options *opt, static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; switch (opt->ambig) { case AMBIG_NONE: @@ -516,7 +519,10 @@ build_retlist(struct ret_list *list, const struct dfavm_op_ir *a) /* TODO: eventually to be non-static */ static int -fsm_print_llvmfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, +fsm_print_llvmfrag(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops, const char *cp) { struct ret_list retlist; @@ -613,7 +619,7 @@ fsm_print_llvmfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *o for (size_t i = 0; i < retlist.count; i++) { fprintf(f, "\t "); - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, retlist.a[i].ids, retlist.a[i].count, default_accept, &i)) { @@ -622,7 +628,7 @@ fsm_print_llvmfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *o } fprintf(f, "\t "); - if (-1 == print_hook_reject(f, opt, default_reject, NULL)) { + if (-1 == print_hook_reject(f, opt, hooks, default_reject, NULL)) { return -1; } @@ -736,13 +742,17 @@ fsm_print_llvmfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *o } int -fsm_print_llvm(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_llvm(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { const char *prefix; const char *cp; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (opt->prefix != NULL) { prefix = opt->prefix; @@ -750,14 +760,14 @@ fsm_print_llvm(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) prefix = "fsm_"; } - if (opt->hooks.cp != NULL) { - cp = opt->hooks.cp; + if (hooks->cp != NULL) { + cp = hooks->cp; } else { cp = "c"; /* XXX */ } if (opt->fragment) { - fsm_print_llvmfrag(f, opt, ops, cp); + fsm_print_llvmfrag(f, opt, hooks, ops, cp); return 0; } @@ -814,7 +824,7 @@ fsm_print_llvm(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) exit(EXIT_FAILURE); } - fsm_print_llvmfrag(f, opt, ops, cp); + fsm_print_llvmfrag(f, opt, hooks, ops, cp); fprintf(f, "}\n"); fprintf(f, "\n"); diff --git a/src/libfsm/print/rust.c b/src/libfsm/print/rust.c index eefe84b11..5c35747d9 100644 --- a/src/libfsm/print/rust.c +++ b/src/libfsm/print/rust.c @@ -53,7 +53,7 @@ print_ids(FILE *f, enum fsm_ambig ambig, const fsm_end_id_t *ids, size_t count) { switch (ambig) { - case AMBIG_NONE: + case AMBIG_NONE: fprintf(f, "return Some(())"); break; @@ -89,35 +89,37 @@ print_ids(FILE *f, static int default_accept(FILE *f, const struct fsm_options *opt, - const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + const fsm_end_id_t *ids, size_t count, + void *lang_opaque, void *hook_opaque) { - assert(f != NULL); - assert(opt != NULL); - assert(lang_opaque == NULL); - - (void) lang_opaque; - - if (-1 == print_ids(f, opt->ambig, ids, count)) { - return -1; - } - - return 0; + assert(f != NULL); + assert(opt != NULL); + assert(lang_opaque == NULL); + + (void) lang_opaque; + (void) hook_opaque; + + if (-1 == print_ids(f, opt->ambig, ids, count)) { + return -1; + } + + return 0; } - + static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { - assert(f != NULL); - assert(opt != NULL); - assert(lang_opaque == NULL); - - (void) lang_opaque; + assert(f != NULL); + assert(opt != NULL); + assert(lang_opaque == NULL); + + (void) lang_opaque; + (void) hook_opaque; fprintf(f, "return None"); - return 0; + return 0; } static int @@ -157,15 +159,17 @@ print_cond(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt) } static int -print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, +print_end(FILE *f, const struct dfavm_op_ir *op, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, enum dfavm_op_end end_bits) { switch (end_bits) { case VM_END_FAIL: - return print_hook_reject(f, opt, default_reject, NULL); + return print_hook_reject(f, opt, hooks, default_reject, NULL); case VM_END_SUCC: - return print_hook_accept(f, opt, + return print_hook_accept(f, opt, hooks, op->endids.ids, op->endids.count, default_accept, NULL); @@ -198,7 +202,10 @@ print_fetch(FILE *f) /* TODO: eventually to be non-static */ static int -fsm_print_rustfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, +fsm_print_rustfrag(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops, const char *cp) { struct dfavm_op_ir *op; @@ -312,7 +319,7 @@ fsm_print_rustfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *o if (op->cmp != VM_CMP_ALWAYS) { fprintf(f, "{ "); } - if (-1 == print_end(f, op, opt, op->u.stop.end_bits)) { + if (-1 == print_end(f, op, opt, hooks, op->u.stop.end_bits)) { return -1; } if (op->cmp != VM_CMP_ALWAYS) { @@ -360,7 +367,7 @@ fsm_print_rustfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *o fprintf(f, " "); fprintf(f, "None => "); - print_end(f, op, opt, op->u.fetch.end_bits); + print_end(f, op, opt, hooks, op->u.fetch.end_bits); fprintf(f, ",\n"); fprintf(f, " "); @@ -405,13 +412,17 @@ fsm_print_rustfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *o } int -fsm_print_rust(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_rust(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { const char *prefix; const char *cp; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (opt->prefix != NULL) { prefix = opt->prefix; @@ -419,14 +430,14 @@ fsm_print_rust(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) prefix = "fsm_"; } - if (opt->hooks.cp != NULL) { - cp = opt->hooks.cp; + if (hooks->cp != NULL) { + cp = hooks->cp; } else { cp = "c"; /* XXX */ } if (opt->fragment) { - fsm_print_rustfrag(f, opt, ops, cp); + fsm_print_rustfrag(f, opt, hooks, ops, cp); goto error; } @@ -460,7 +471,7 @@ fsm_print_rust(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) exit(EXIT_FAILURE); } - fsm_print_rustfrag(f, opt, ops, cp); + fsm_print_rustfrag(f, opt, hooks, ops, cp); fprintf(f, "}\n"); fprintf(f, "\n"); diff --git a/src/libfsm/print/sh.c b/src/libfsm/print/sh.c index a01369b24..05692df59 100644 --- a/src/libfsm/print/sh.c +++ b/src/libfsm/print/sh.c @@ -107,13 +107,14 @@ print_ids(FILE *f, static int default_accept(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; fprintf(f, "matched"); @@ -126,13 +127,14 @@ default_accept(FILE *f, const struct fsm_options *opt, static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; fprintf(f, "fail"); @@ -192,15 +194,17 @@ print_cond(FILE *f, const struct dfavm_op_ir *op) } static int -print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, +print_end(FILE *f, const struct dfavm_op_ir *op, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, enum dfavm_op_end end_bits) { switch (end_bits) { case VM_END_FAIL: - return print_hook_reject(f, opt, default_reject, NULL); + return print_hook_reject(f, opt, hooks, default_reject, NULL); case VM_END_SUCC: - return print_hook_accept(f, opt, + return print_hook_accept(f, opt, hooks, op->endids.ids, op->endids.count, default_accept, NULL); @@ -226,12 +230,16 @@ print_fetch(FILE *f) } int -fsm_print_sh(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_sh(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { struct dfavm_op_ir *op; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (opt->io != FSM_IO_STR) { errno = ENOTSUP; @@ -285,14 +293,14 @@ fsm_print_sh(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) switch (op->instr) { case VM_OP_STOP: print_cond(f, op); - if (-1 == print_end(f, op, opt, op->u.stop.end_bits)) { + if (-1 == print_end(f, op, opt, hooks, op->u.stop.end_bits)) { return -1; } break; case VM_OP_FETCH: print_fetch(f); - if (-1 == print_end(f, op, opt, op->u.fetch.end_bits)) { + if (-1 == print_end(f, op, opt, hooks, op->u.fetch.end_bits)) { return -1; } break; diff --git a/src/libfsm/print/vmasm.c b/src/libfsm/print/vmasm.c index 95250d8a0..c5ac87492 100644 --- a/src/libfsm/print/vmasm.c +++ b/src/libfsm/print/vmasm.c @@ -33,7 +33,9 @@ enum asm_dialect { }; static int -print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, +print_end(FILE *f, const struct dfavm_op_ir *op, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, enum asm_dialect dialect, const char *ret_reg, enum dfavm_op_end end_bits) { @@ -41,13 +43,13 @@ print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, switch (end_bits) { case VM_END_FAIL: - if (-1 == print_hook_reject(f, opt, NULL, NULL)) { + if (-1 == print_hook_reject(f, opt, hooks, NULL, NULL)) { return -1; } break; case VM_END_SUCC: - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, op->endids.ids, op->endids.count, NULL, NULL)) { @@ -83,7 +85,10 @@ print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, } static int -print_asm_amd64(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, +print_asm_amd64(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops, const char *prefix, enum asm_dialect dialect) { @@ -196,7 +201,7 @@ print_asm_amd64(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, switch (op->instr) { case VM_OP_STOP: { - if (-1 == print_end(f, op, opt, + if (-1 == print_end(f, op, opt, hooks, dialect, ret_reg, op->u.stop.end_bits)) { @@ -241,7 +246,7 @@ print_asm_amd64(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, case VM_OP_FETCH: { - if (-1 == print_end(f, op, opt, + if (-1 == print_end(f, op, opt, hooks, dialect, ret_reg, op->u.fetch.end_bits)) { @@ -350,13 +355,17 @@ print_asm_amd64(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, } static int -print_vmasm_encoding(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, +print_vmasm_encoding(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops, enum asm_dialect dialect) { const char *prefix; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (dialect == AMD64_GO) { if (opt->io != FSM_IO_STR && opt->io != FSM_IO_PAIR) { @@ -376,27 +385,33 @@ print_vmasm_encoding(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir prefix = "fsm_"; } - return print_asm_amd64(f, opt, ops, prefix, dialect); + return print_asm_amd64(f, opt, hooks, ops, prefix, dialect); } int -fsm_print_amd64_att(FILE *f, const struct fsm_options *opt, +fsm_print_amd64_att(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, struct dfavm_op_ir *ops) { - return print_vmasm_encoding(f, opt, ops, AMD64_ATT); + return print_vmasm_encoding(f, opt, hooks, ops, AMD64_ATT); } int -fsm_print_amd64_nasm(FILE *f, const struct fsm_options *opt, +fsm_print_amd64_nasm(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, struct dfavm_op_ir *ops) { - return print_vmasm_encoding(f, opt, ops, AMD64_NASM); + return print_vmasm_encoding(f, opt, hooks, ops, AMD64_NASM); } int -fsm_print_amd64_go(FILE *f, const struct fsm_options *opt, +fsm_print_amd64_go(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, struct dfavm_op_ir *ops) { - return print_vmasm_encoding(f, opt, ops, AMD64_GO); + return print_vmasm_encoding(f, opt, hooks, ops, AMD64_GO); } diff --git a/src/libfsm/print/vmc.c b/src/libfsm/print/vmc.c index b69203052..206e333ae 100644 --- a/src/libfsm/print/vmc.c +++ b/src/libfsm/print/vmc.c @@ -108,13 +108,14 @@ print_ids(FILE *f, static int default_accept(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; if (-1 == print_ids(f, opt->ambig, ids, count)) { return -1; @@ -125,13 +126,14 @@ default_accept(FILE *f, const struct fsm_options *opt, static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; fprintf(f, "return 0;"); @@ -163,15 +165,17 @@ print_cond(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt) } static int -print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, +print_end(FILE *f, const struct dfavm_op_ir *op, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, enum dfavm_op_end end_bits) { switch (end_bits) { case VM_END_FAIL: - return print_hook_reject(f, opt, default_reject, NULL); + return print_hook_reject(f, opt, hooks, default_reject, NULL); case VM_END_SUCC: - return print_hook_accept(f, opt, + return print_hook_accept(f, opt, hooks, op->endids.ids, op->endids.count, default_accept, NULL); @@ -353,7 +357,10 @@ walk_sequence(struct dfavm_op_ir *op, /* TODO: eventually to be non-static */ static int -fsm_print_cfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, +fsm_print_cfrag(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops, const char *cp) { struct dfavm_op_ir *op; @@ -423,7 +430,7 @@ fsm_print_cfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, switch (op->instr) { case VM_OP_STOP: print_cond(f, op, opt); - if (-1 == print_end(f, op, opt, op->u.stop.end_bits)) { + if (-1 == print_end(f, op, opt, hooks, op->u.stop.end_bits)) { return -1; } break; @@ -441,7 +448,7 @@ fsm_print_cfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, fprintf(f, "if (e - p < %zu || 0 != memcmp(p, \"", n); escputbuf(f, opt, c_escputc_str, buf, n); fprintf(f, "\", %zu)) ", n); - if (-1 == print_end(f, NULL, opt, end_bits)) { + if (-1 == print_end(f, NULL, opt, hooks, end_bits)) { return -1; } fprintf(f, "\n"); @@ -454,7 +461,7 @@ fsm_print_cfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, fprintf(f, "if (0 != strncmp(p, \""); escputbuf(f, opt, c_escputc_str, buf, n); fprintf(f, "\", %zu)) ", n); - if (-1 == print_end(f, NULL, opt, end_bits)) { + if (-1 == print_end(f, NULL, opt, hooks, end_bits)) { return -1; } fprintf(f, "\n"); @@ -465,7 +472,7 @@ fsm_print_cfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, op = tail; } else { print_fetch(f, opt); - if (-1 == print_end(f, op, opt, op->u.fetch.end_bits)) { + if (-1 == print_end(f, op, opt, hooks, op->u.fetch.end_bits)) { return -1; } if (opt->io == FSM_IO_PAIR) { @@ -502,7 +509,10 @@ fsm_print_cfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, } int -fsm_print_vmc(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_vmc(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { const char *prefix; @@ -511,6 +521,7 @@ fsm_print_vmc(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (opt->prefix != NULL) { prefix = opt->prefix; @@ -519,7 +530,7 @@ fsm_print_vmc(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) } if (opt->fragment) { - if (-1 == fsm_print_cfrag(f, opt, ops, cp)) { + if (-1 == fsm_print_cfrag(f, opt, hooks, ops, cp)) { return -1; } } else { @@ -568,11 +579,11 @@ fsm_print_vmc(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) abort(); } - if (opt->hooks.args != NULL) { + if (hooks->args != NULL) { fprintf(stdout, ",\n"); fprintf(stdout, "\t"); - if (-1 == print_hook_args(f, opt, NULL, NULL)) { + if (-1 == print_hook_args(f, opt, hooks, NULL, NULL)) { return -1; } } @@ -580,7 +591,7 @@ fsm_print_vmc(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) fprintf(f, ")\n"); fprintf(f, "{\n"); - if (-1 == fsm_print_cfrag(f, opt, ops, cp)) { + if (-1 == fsm_print_cfrag(f, opt, hooks, ops, cp)) { return -1; } diff --git a/src/libfsm/print/vmdot.c b/src/libfsm/print/vmdot.c index 90a8b0971..576d8c08d 100644 --- a/src/libfsm/print/vmdot.c +++ b/src/libfsm/print/vmdot.c @@ -48,13 +48,14 @@ cmp_operator(int cmp) static int default_accept(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; fprintf(f, "match"); @@ -75,13 +76,14 @@ default_accept(FILE *f, const struct fsm_options *opt, static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); assert(lang_opaque == NULL); (void) lang_opaque; + (void) hook_opaque; fprintf(f, "fail"); @@ -116,15 +118,17 @@ print_cond(FILE *f, const struct fsm_options *opt, const struct dfavm_op_ir *op) } static int -print_end(FILE *f, const struct fsm_options *opt, +print_end(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const struct dfavm_op_ir *op, enum dfavm_op_end end_bits) { switch (end_bits) { case VM_END_FAIL: - return print_hook_reject(f, opt, default_reject, NULL); + return print_hook_reject(f, opt, hooks, default_reject, NULL); case VM_END_SUCC: - return print_hook_accept(f, opt, + return print_hook_accept(f, opt, hooks, op->endids.ids, op->endids.count, default_accept, NULL); @@ -142,7 +146,10 @@ print_branch(FILE *f, const struct dfavm_op_ir *op) } static int -fsm_print_nodes(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_nodes(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { struct dfavm_op_ir *op; const char *example; @@ -204,7 +211,7 @@ fsm_print_nodes(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) print_cond(f, opt, op); fprintf(f, "\n"); fprintf(f, "\t\t\t", op->index); - if (-1 == print_end(f, opt, op, op->u.stop.end_bits)) { + if (-1 == print_end(f, opt, hooks, op, op->u.stop.end_bits)) { return -1; } fprintf(f, "\n"); @@ -213,7 +220,7 @@ fsm_print_nodes(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) case VM_OP_FETCH: fprintf(f, "\t\t\tfetch\n"); fprintf(f, "\t\t\t", op->index); - if (-1 == print_end(f, opt, op, op->u.fetch.end_bits)) { + if (-1 == print_end(f, opt, hooks, op, op->u.fetch.end_bits)) { return -1; } fprintf(f, "\n"); @@ -311,12 +318,15 @@ fsm_print_edges(FILE *f, const struct fsm_options *opt, const struct dfavm_op_ir /* TODO: eventually to be non-static */ static int -fsm_print_vmdotfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_vmdotfrag(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { assert(f != NULL); assert(opt != NULL); - if (-1 == fsm_print_nodes(f, opt, ops)) { + if (-1 == fsm_print_nodes(f, opt, hooks, ops)) { return -1; } fprintf(f, "\n"); @@ -327,13 +337,17 @@ fsm_print_vmdotfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir * } int -fsm_print_vmdot(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_vmdot(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (opt->fragment) { - if (-1 == fsm_print_vmdotfrag(f, opt, ops)) { + if (-1 == fsm_print_vmdotfrag(f, opt, hooks, ops)) { return -1; } } else { @@ -351,7 +365,7 @@ fsm_print_vmdot(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) fprintf(f, "\tstart [ shape = none, label = \"\" ];\n"); fprintf(f, "\tstart -> S0:i0:w [ style = bold ];\n"); - if (-1 == fsm_print_vmdotfrag(f, opt, ops)) { + if (-1 == fsm_print_vmdotfrag(f, opt, hooks, ops)) { return -1; } diff --git a/src/libfsm/print/vmops.c b/src/libfsm/print/vmops.c index 4520dc702..7eff8d4e9 100644 --- a/src/libfsm/print/vmops.c +++ b/src/libfsm/print/vmops.c @@ -53,7 +53,7 @@ cmp_operator(int cmp) static int default_accept(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { const char *prefix; @@ -61,6 +61,8 @@ default_accept(FILE *f, const struct fsm_options *opt, assert(opt != NULL); assert(lang_opaque != NULL); + (void) hook_opaque; + prefix = lang_opaque; // TODO: print ids @@ -74,7 +76,7 @@ default_accept(FILE *f, const struct fsm_options *opt, static int default_reject(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { const char *prefix; @@ -82,6 +84,8 @@ default_reject(FILE *f, const struct fsm_options *opt, assert(opt != NULL); assert(lang_opaque != NULL); + (void) hook_opaque; + prefix = lang_opaque; fprintf(f, "%sactionRET, 0", prefix); @@ -119,13 +123,15 @@ print_cond(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, } static int -print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, +print_end(FILE *f, const struct dfavm_op_ir *op, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const char *prefix, enum dfavm_op_end end_bits) { switch (end_bits) { case VM_END_FAIL: - if (-1 == print_hook_reject(f, opt, default_reject, + if (-1 == print_hook_reject(f, opt, hooks, default_reject, (void *) prefix)) { return -1; @@ -133,7 +139,7 @@ print_end(FILE *f, const struct dfavm_op_ir *op, const struct fsm_options *opt, break; case VM_END_SUCC: - if (-1 == print_hook_accept(f, opt, + if (-1 == print_hook_accept(f, opt, hooks, op->endids.ids, op->endids.count, default_accept, (void *) prefix)) @@ -178,7 +184,10 @@ print_fetch(FILE *f, const struct fsm_options *opt, const char *prefix) /* TODO: eventually to be non-static */ static int -fsm_print_vmopsfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, +fsm_print_vmopsfrag(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops, const char *prefix) { struct dfavm_op_ir *op; @@ -197,7 +206,7 @@ fsm_print_vmopsfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir * if (-1 == print_cond(f, op, opt, prefix)) { return -1; } - if (-1 == print_end(f, op, opt, prefix, op->u.stop.end_bits)) { + if (-1 == print_end(f, op, opt, hooks, prefix, op->u.stop.end_bits)) { return -1; } break; @@ -206,7 +215,7 @@ fsm_print_vmopsfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir * if (-1 == print_fetch(f, opt, prefix)) { return -1; } - if (-1 == print_end(f, op, opt, prefix, op->u.fetch.end_bits)) { + if (-1 == print_end(f, op, opt, hooks, prefix, op->u.fetch.end_bits)) { return -1; } break; @@ -230,13 +239,17 @@ fsm_print_vmopsfrag(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir * } int -fsm_print_vmops(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, +fsm_print_vmops(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops, enum vmops_dialect dialect) { const char *prefix; assert(f != NULL); assert(opt != NULL); + assert(hooks != NULL); if (opt->prefix != NULL) { prefix = opt->prefix; @@ -246,7 +259,7 @@ fsm_print_vmops(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, if (opt->fragment) { if (dialect == VMOPS_C) { - if (-1 == fsm_print_vmopsfrag(f, opt, ops, prefix)) { + if (-1 == fsm_print_vmopsfrag(f, opt, hooks, ops, prefix)) { return -1; } } @@ -258,7 +271,7 @@ fsm_print_vmops(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, fprintf(f, "#include \"%svmops.h\"\n", prefix); fprintf(f, "#endif /* %sLIBFSM_VMOPS_H */\n", prefix); fprintf(f, "struct %sop %sOps[] = {\n", prefix, prefix); - if (-1 == fsm_print_vmopsfrag(f, opt, ops, prefix)) { + if (-1 == fsm_print_vmopsfrag(f, opt, hooks, ops, prefix)) { return -1; } fprintf(f, "\t};\n"); @@ -413,20 +426,29 @@ fsm_print_vmops(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops, } int -fsm_print_vmops_c(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_vmops_c(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { - return fsm_print_vmops(f, opt, ops, VMOPS_C); + return fsm_print_vmops(f, opt, hooks, ops, VMOPS_C); } int -fsm_print_vmops_h(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_vmops_h(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { - return fsm_print_vmops(f, opt, ops, VMOPS_H); + return fsm_print_vmops(f, opt, hooks, ops, VMOPS_H); } int -fsm_print_vmops_main(FILE *f, const struct fsm_options *opt, struct dfavm_op_ir *ops) +fsm_print_vmops_main(FILE *f, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + struct dfavm_op_ir *ops) { - return fsm_print_vmops(f, opt, ops, VMOPS_MAIN); + return fsm_print_vmops(f, opt, hooks, ops, VMOPS_MAIN); } diff --git a/src/libfsm/reverse.c b/src/libfsm/reverse.c index b8e6d65f5..c7093738b 100644 --- a/src/libfsm/reverse.c +++ b/src/libfsm/reverse.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -29,7 +28,6 @@ fsm_reverse(struct fsm *fsm) struct state_set **epsilons; assert(fsm != NULL); - assert(fsm->opt != NULL); /* * Reversing an FSM means to reverse the language the FSM matches. @@ -59,8 +57,6 @@ fsm_reverse(struct fsm *fsm) return 0; } - fsm_setoptions(new, fsm->opt); - if (!fsm_addstate(new, &new->start)) { fsm_free(new); return 0; diff --git a/src/libfsm/state.c b/src/libfsm/state.c index 063cc78ab..47b7b5395 100644 --- a/src/libfsm/state.c +++ b/src/libfsm/state.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/src/libfsm/trim.c b/src/libfsm/trim.c index 8f7a1da37..4f45607bd 100644 --- a/src/libfsm/trim.c +++ b/src/libfsm/trim.c @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/src/libfsm/union.c b/src/libfsm/union.c index efc57ca65..a3b4b230c 100644 --- a/src/libfsm/union.c +++ b/src/libfsm/union.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -14,7 +15,6 @@ #include #include #include -#include #include "internal.h" @@ -43,11 +43,6 @@ fsm_union(struct fsm *a, struct fsm *b, return NULL; } - if (a->opt != b->opt) { - errno = EINVAL; - return NULL; - } - if (a->statecount == 0) { fsm_free(a); return b; } if (b->statecount == 0) { fsm_free(b); return a; } diff --git a/src/libfsm/vm.c b/src/libfsm/vm.c index ac896d096..c9205815f 100644 --- a/src/libfsm/vm.c +++ b/src/libfsm/vm.c @@ -12,6 +12,7 @@ #include #include +#include #include #include "internal.h" @@ -84,28 +85,33 @@ cmp_name(int cmp) } struct fsm_dfavm * -fsm_vm_compile_with_options(const struct fsm *fsm, struct fsm_vm_compile_opts opts) +fsm_vm_compile_with_options(const struct fsm *fsm, + const struct fsm_options *opt, + struct fsm_vm_compile_opts vmopts) { static const struct dfavm_assembler_ir zero; struct dfavm_assembler_ir a; struct ir *ir; struct fsm_dfavm *vm; - ir = make_ir(fsm); + assert(fsm != NULL); + assert(opt != NULL); + + ir = make_ir(fsm, opt); if (ir == NULL) { return NULL; } a = zero; - if (!dfavm_compile_ir(&a, ir, opts)) { + if (!dfavm_compile_ir(&a, ir, vmopts)) { free_ir(fsm, ir); return NULL; } free_ir(fsm, ir); - vm = dfavm_compile_vm(&a, opts); + vm = dfavm_compile_vm(&a, vmopts); if (vm == NULL) { return NULL; } @@ -120,8 +126,19 @@ fsm_vm_compile(const struct fsm *fsm) { // static const struct fsm_vm_compile_opts defaults = { FSM_VM_COMPILE_DEFAULT_FLAGS | FSM_VM_COMPILE_PRINT_IR_PREOPT | FSM_VM_COMPILE_PRINT_IR, NULL }; static const struct fsm_vm_compile_opts defaults = { FSM_VM_COMPILE_DEFAULT_FLAGS, FSM_VM_COMPILE_VM_V1, NULL }; - - return fsm_vm_compile_with_options(fsm, defaults); + static const struct fsm_options opt_default; + + assert(fsm != NULL); + + /* + * The only fsm_option make_ir() uses is .comments, + * for whether to generate examples. + * + * The caller won't use that, because the only user-facing + * vm interfaces are to interpret for execution. So we use + * default options here. + */ + return fsm_vm_compile_with_options(fsm, &opt_default, defaults); } void diff --git a/src/libfsm/walk2.c b/src/libfsm/walk2.c index 42db6b389..6d6ab022a 100644 --- a/src/libfsm/walk2.c +++ b/src/libfsm/walk2.c @@ -9,10 +9,10 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -567,8 +567,6 @@ fsm_walk2(const struct fsm *a, const struct fsm *b, goto error; } - fsm_setoptions(data.new, a->opt); - data.states = tuple_set_create(data.new->alloc, cmp_walk2_tuple); if (data.states == NULL) { goto error; @@ -603,8 +601,6 @@ fsm_walk2(const struct fsm *a, const struct fsm *b, return NULL; } - fsm_setoptions(new, a->opt); - return new; error: diff --git a/src/libre/ac.h b/src/libre/ac.h index edabca27c..c8a4f195f 100644 --- a/src/libre/ac.h +++ b/src/libre/ac.h @@ -11,7 +11,6 @@ struct fsm; struct fsm_state; -struct fsm_options; struct trie_graph; diff --git a/src/libre/ast.h b/src/libre/ast.h index d443db9af..9a2c9a877 100644 --- a/src/libre/ast.h +++ b/src/libre/ast.h @@ -312,10 +312,8 @@ ast_make_expr_named(struct ast_expr_pool **poolp, enum re_flags re_flags, const /* XXX: exposed for sake of re(1) printing an ast; * it's not part of the API proper */ -struct fsm_options; struct ast * re_parse(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, - const struct fsm_options *opt, enum re_flags flags, struct re_err *err, int *unsatisfiable); const char * diff --git a/src/libre/ast_analysis.h b/src/libre/ast_analysis.h index 0628bd127..013db708c 100644 --- a/src/libre/ast_analysis.h +++ b/src/libre/ast_analysis.h @@ -12,8 +12,6 @@ */ struct ast; -struct re_err; -struct fsm_options; enum ast_analysis_res { AST_ANALYSIS_OK, diff --git a/src/libre/ast_compile.c b/src/libre/ast_compile.c index 32dcd8bdf..0ea0b08d8 100644 --- a/src/libre/ast_compile.c +++ b/src/libre/ast_compile.c @@ -193,14 +193,13 @@ fsm_unionxy(struct fsm *a, struct fsm *b, fsm_state_t x, fsm_state_t y) static struct fsm * expr_compile(struct ast_expr *e, enum re_flags flags, const struct fsm_alloc *alloc, - const struct fsm_options *opt, struct re_err *err) { struct ast ast; ast.expr = e; - return ast_compile(&ast, flags, alloc, opt, err); + return ast_compile(&ast, flags, alloc, err); } static int @@ -885,13 +884,13 @@ comp_iter(struct comp_env *env, re_flags &= ~(unsigned)RE_REVERSE; a = expr_compile(n->u.subtract.a, re_flags, - env->fsm->alloc, fsm_getoptions(env->fsm), env->err); + env->fsm->alloc, env->err); if (a == NULL) { return 0; } b = expr_compile(n->u.subtract.b, re_flags, - env->fsm->alloc, fsm_getoptions(env->fsm), env->err); + env->fsm->alloc, env->err); if (b == NULL) { fsm_free(a); return 0; @@ -962,7 +961,6 @@ struct fsm * ast_compile(const struct ast *ast, enum re_flags re_flags, const struct fsm_alloc *alloc, - const struct fsm_options *opt, struct re_err *err) { fsm_state_t x, y; @@ -975,8 +973,6 @@ ast_compile(const struct ast *ast, return NULL; } - fsm_setoptions(fsm, opt); - if (!fsm_addstate(fsm, &x)) { goto error; } diff --git a/src/libre/ast_compile.h b/src/libre/ast_compile.h index 86a7bb882..4fed57af4 100644 --- a/src/libre/ast_compile.h +++ b/src/libre/ast_compile.h @@ -13,14 +13,12 @@ struct fsm; struct fsm_alloc; -struct fsm_options; struct re_err; struct fsm * ast_compile(const struct ast *ast, enum re_flags re_flags, const struct fsm_alloc *alloc, - const struct fsm_options *opt, struct re_err *err); #endif diff --git a/src/libre/ast_new_from_fsm.c b/src/libre/ast_new_from_fsm.c index 64322bc02..bafd998c6 100644 --- a/src/libre/ast_new_from_fsm.c +++ b/src/libre/ast_new_from_fsm.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include diff --git a/src/libre/ast_rewrite.c b/src/libre/ast_rewrite.c index 6f13447af..592dd58d5 100644 --- a/src/libre/ast_rewrite.c +++ b/src/libre/ast_rewrite.c @@ -147,7 +147,7 @@ compile_subexpr(struct ast_expr *e, const struct fsm_alloc *alloc, return 0; } - fsm = ast_compile(&ast, flags | RE_ANCHORED, alloc, NULL, NULL); + fsm = ast_compile(&ast, flags | RE_ANCHORED, alloc, NULL); if (fsm == NULL) { return 0; } diff --git a/src/libre/dialect/comp.h b/src/libre/dialect/comp.h index d223ab90e..4671bd921 100644 --- a/src/libre/dialect/comp.h +++ b/src/libre/dialect/comp.h @@ -15,7 +15,6 @@ typedef struct ast * re_dialect_parse_fun(re_getchar_fun *getchar, void *opaque, - const struct fsm_options *opt, enum re_flags flags, int overlap, struct re_err *err, struct re_pos *end); diff --git a/src/libre/dialect/glob/parser.c b/src/libre/dialect/glob/parser.c index 746220d4c..c8f021380 100644 --- a/src/libre/dialect/glob/parser.c +++ b/src/libre/dialect/glob/parser.c @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 22 "src/libre/parser.act" +#line 275 "src/libre/parser.act" #include @@ -304,7 +304,7 @@ ZL2_list_Hof_Hatoms:; } /* BEGINNING OF ACTION: ast-add-concat */ { -#line 1040 "src/libre/parser.act" +#line 1041 "src/libre/parser.act" if (!ast_add_expr_concat((ZIcat), (ZIa))) { goto ZL1; @@ -322,7 +322,7 @@ ZL2_list_Hof_Hatoms:; goto ZL2_list_Hof_Hatoms; /* END OF INLINE: list-of-atoms */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -348,7 +348,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: class-any */ { -#line 782 "src/libre/parser.act" +#line 784 "src/libre/parser.act" /* TODO: or the unicode equivalent */ (ZIa) = (*flags & RE_SINGLE) ? &class_any : &class_notnl; @@ -358,7 +358,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* END OF ACTION: class-any */ /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZIe) = ast_make_expr_named(act_state->poolp, *flags, (ZIa)); if ((ZIe) == NULL) { @@ -378,7 +378,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -397,7 +397,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZIe) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZIe) == NULL) { @@ -418,7 +418,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: class-any */ { -#line 782 "src/libre/parser.act" +#line 784 "src/libre/parser.act" /* TODO: or the unicode equivalent */ (ZIa) = (*flags & RE_SINGLE) ? &class_any : &class_notnl; @@ -428,7 +428,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* END OF ACTION: class-any */ /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZIg) = ast_make_expr_named(act_state->poolp, *flags, (ZIa)); if ((ZIg) == NULL) { @@ -440,7 +440,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* END OF ACTION: ast-make-named */ /* BEGINNING OF ACTION: count-zero-or-more */ { -#line 808 "src/libre/parser.act" +#line 809 "src/libre/parser.act" (ZIc) = ast_make_count(0, AST_COUNT_UNBOUNDED); @@ -449,7 +449,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* END OF ACTION: count-zero-or-more */ /* BEGINNING OF ACTION: ast-make-piece */ { -#line 897 "src/libre/parser.act" +#line 898 "src/libre/parser.act" if ((ZIc).min == 0 && (ZIc).max == 0) { (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); @@ -478,7 +478,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-atom */ { -#line 704 "src/libre/parser.act" +#line 708 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXATOM; @@ -490,7 +490,7 @@ ZL1:; /* END OF ACTION: err-expected-atom */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -523,7 +523,7 @@ p_re__glob(flags flags, lex_state lex_state, act_state act_state, err err, t_ast /* BEGINNING OF ACTION: make-group-id */ { -#line 881 "src/libre/parser.act" +#line 882 "src/libre/parser.act" (ZIid) = act_state->group_id++; @@ -537,7 +537,7 @@ p_re__glob(flags flags, lex_state lex_state, act_state act_state, err err, t_ast { /* BEGINNING OF ACTION: ast-make-concat */ { -#line 860 "src/libre/parser.act" +#line 861 "src/libre/parser.act" (ZIe) = ast_make_expr_concat(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -558,7 +558,7 @@ p_re__glob(flags flags, lex_state lex_state, act_state act_state, err err, t_ast { /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -575,7 +575,7 @@ p_re__glob(flags flags, lex_state lex_state, act_state act_state, err err, t_ast /* END OF INLINE: 119 */ /* BEGINNING OF ACTION: ast-make-group */ { -#line 911 "src/libre/parser.act" +#line 912 "src/libre/parser.act" (ZInode) = ast_make_expr_group(act_state->poolp, *flags, (ZIe), (ZIid)); if ((ZInode) == NULL) { @@ -601,7 +601,7 @@ p_re__glob(flags flags, lex_state lex_state, act_state act_state, err err, t_ast { /* BEGINNING OF ACTION: err-expected-eof */ { -#line 753 "src/libre/parser.act" +#line 757 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXEOF; @@ -626,7 +626,7 @@ ZL0:; /* BEGINNING OF TRAILER */ -#line 1052 "src/libre/parser.act" +#line 1207 "src/libre/parser.act" static int @@ -646,7 +646,6 @@ ZL0:; struct ast * DIALECT_PARSE(re_getchar_fun *f, void *opaque, - const struct fsm_options *opt, enum re_flags flags, int overlap, struct re_err *err, struct re_pos *end) { @@ -783,6 +782,6 @@ ZL0:; return NULL; } -#line 787 "src/libre/dialect/glob/parser.c" +#line 786 "src/libre/dialect/glob/parser.c" /* END OF FILE */ diff --git a/src/libre/dialect/glob/parser.h b/src/libre/dialect/glob/parser.h index c0ce31ed6..ec618caca 100644 --- a/src/libre/dialect/glob/parser.h +++ b/src/libre/dialect/glob/parser.h @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 281 "src/libre/parser.act" +#line 292 "src/libre/parser.act" #include @@ -28,7 +28,7 @@ extern void p_re__glob(flags, lex_state, act_state, err, t_ast__expr *); /* BEGINNING OF TRAILER */ -#line 1208 "src/libre/parser.act" +#line 1209 "src/libre/parser.act" #line 35 "src/libre/dialect/glob/parser.h" diff --git a/src/libre/dialect/like/parser.c b/src/libre/dialect/like/parser.c index 6543095e3..64bfe1078 100644 --- a/src/libre/dialect/like/parser.c +++ b/src/libre/dialect/like/parser.c @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 22 "src/libre/parser.act" +#line 275 "src/libre/parser.act" #include @@ -304,7 +304,7 @@ ZL2_list_Hof_Hatoms:; } /* BEGINNING OF ACTION: ast-add-concat */ { -#line 1040 "src/libre/parser.act" +#line 1041 "src/libre/parser.act" if (!ast_add_expr_concat((ZIcat), (ZIa))) { goto ZL1; @@ -322,7 +322,7 @@ ZL2_list_Hof_Hatoms:; goto ZL2_list_Hof_Hatoms; /* END OF INLINE: list-of-atoms */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -348,7 +348,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: class-any */ { -#line 782 "src/libre/parser.act" +#line 784 "src/libre/parser.act" /* TODO: or the unicode equivalent */ (ZIa) = (*flags & RE_SINGLE) ? &class_any : &class_notnl; @@ -358,7 +358,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* END OF ACTION: class-any */ /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZIe) = ast_make_expr_named(act_state->poolp, *flags, (ZIa)); if ((ZIe) == NULL) { @@ -378,7 +378,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -397,7 +397,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZIe) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZIe) == NULL) { @@ -418,7 +418,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: class-any */ { -#line 782 "src/libre/parser.act" +#line 784 "src/libre/parser.act" /* TODO: or the unicode equivalent */ (ZIa) = (*flags & RE_SINGLE) ? &class_any : &class_notnl; @@ -428,7 +428,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* END OF ACTION: class-any */ /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZIg) = ast_make_expr_named(act_state->poolp, *flags, (ZIa)); if ((ZIg) == NULL) { @@ -440,7 +440,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* END OF ACTION: ast-make-named */ /* BEGINNING OF ACTION: count-zero-or-more */ { -#line 808 "src/libre/parser.act" +#line 809 "src/libre/parser.act" (ZIc) = ast_make_count(0, AST_COUNT_UNBOUNDED); @@ -449,7 +449,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, /* END OF ACTION: count-zero-or-more */ /* BEGINNING OF ACTION: ast-make-piece */ { -#line 897 "src/libre/parser.act" +#line 898 "src/libre/parser.act" if ((ZIc).min == 0 && (ZIc).max == 0) { (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); @@ -478,7 +478,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-atom */ { -#line 704 "src/libre/parser.act" +#line 708 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXATOM; @@ -490,7 +490,7 @@ ZL1:; /* END OF ACTION: err-expected-atom */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -523,7 +523,7 @@ p_re__like(flags flags, lex_state lex_state, act_state act_state, err err, t_ast /* BEGINNING OF ACTION: make-group-id */ { -#line 881 "src/libre/parser.act" +#line 882 "src/libre/parser.act" (ZIid) = act_state->group_id++; @@ -537,7 +537,7 @@ p_re__like(flags flags, lex_state lex_state, act_state act_state, err err, t_ast { /* BEGINNING OF ACTION: ast-make-concat */ { -#line 860 "src/libre/parser.act" +#line 861 "src/libre/parser.act" (ZIe) = ast_make_expr_concat(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -558,7 +558,7 @@ p_re__like(flags flags, lex_state lex_state, act_state act_state, err err, t_ast { /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -575,7 +575,7 @@ p_re__like(flags flags, lex_state lex_state, act_state act_state, err err, t_ast /* END OF INLINE: 119 */ /* BEGINNING OF ACTION: ast-make-group */ { -#line 911 "src/libre/parser.act" +#line 912 "src/libre/parser.act" (ZInode) = ast_make_expr_group(act_state->poolp, *flags, (ZIe), (ZIid)); if ((ZInode) == NULL) { @@ -601,7 +601,7 @@ p_re__like(flags flags, lex_state lex_state, act_state act_state, err err, t_ast { /* BEGINNING OF ACTION: err-expected-eof */ { -#line 753 "src/libre/parser.act" +#line 757 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXEOF; @@ -626,7 +626,7 @@ ZL0:; /* BEGINNING OF TRAILER */ -#line 1052 "src/libre/parser.act" +#line 1207 "src/libre/parser.act" static int @@ -646,7 +646,6 @@ ZL0:; struct ast * DIALECT_PARSE(re_getchar_fun *f, void *opaque, - const struct fsm_options *opt, enum re_flags flags, int overlap, struct re_err *err, struct re_pos *end) { @@ -783,6 +782,6 @@ ZL0:; return NULL; } -#line 787 "src/libre/dialect/like/parser.c" +#line 786 "src/libre/dialect/like/parser.c" /* END OF FILE */ diff --git a/src/libre/dialect/like/parser.h b/src/libre/dialect/like/parser.h index 8563a04a6..f6c87ad7b 100644 --- a/src/libre/dialect/like/parser.h +++ b/src/libre/dialect/like/parser.h @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 281 "src/libre/parser.act" +#line 292 "src/libre/parser.act" #include @@ -28,7 +28,7 @@ extern void p_re__like(flags, lex_state, act_state, err, t_ast__expr *); /* BEGINNING OF TRAILER */ -#line 1208 "src/libre/parser.act" +#line 1209 "src/libre/parser.act" #line 35 "src/libre/dialect/like/parser.h" diff --git a/src/libre/dialect/literal/parser.c b/src/libre/dialect/literal/parser.c index f52793a0c..44547716b 100644 --- a/src/libre/dialect/literal/parser.c +++ b/src/libre/dialect/literal/parser.c @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 22 "src/libre/parser.act" +#line 275 "src/libre/parser.act" #include @@ -304,7 +304,7 @@ ZL2_list_Hof_Hatoms:; } /* BEGINNING OF ACTION: ast-add-concat */ { -#line 1040 "src/libre/parser.act" +#line 1041 "src/libre/parser.act" if (!ast_add_expr_concat((ZIcat), (ZIa))) { goto ZL1; @@ -322,7 +322,7 @@ ZL2_list_Hof_Hatoms:; goto ZL2_list_Hof_Hatoms; /* END OF INLINE: list-of-atoms */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -349,7 +349,7 @@ p_re__literal(flags flags, lex_state lex_state, act_state act_state, err err, t_ /* BEGINNING OF ACTION: make-group-id */ { -#line 881 "src/libre/parser.act" +#line 882 "src/libre/parser.act" (ZIid) = act_state->group_id++; @@ -363,7 +363,7 @@ p_re__literal(flags flags, lex_state lex_state, act_state act_state, err err, t_ { /* BEGINNING OF ACTION: ast-make-concat */ { -#line 860 "src/libre/parser.act" +#line 861 "src/libre/parser.act" (ZIe) = ast_make_expr_concat(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -384,7 +384,7 @@ p_re__literal(flags flags, lex_state lex_state, act_state act_state, err err, t_ { /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -401,7 +401,7 @@ p_re__literal(flags flags, lex_state lex_state, act_state act_state, err err, t_ /* END OF INLINE: 117 */ /* BEGINNING OF ACTION: ast-make-group */ { -#line 911 "src/libre/parser.act" +#line 912 "src/libre/parser.act" (ZInode) = ast_make_expr_group(act_state->poolp, *flags, (ZIe), (ZIid)); if ((ZInode) == NULL) { @@ -427,7 +427,7 @@ p_re__literal(flags flags, lex_state lex_state, act_state act_state, err err, t_ { /* BEGINNING OF ACTION: err-expected-eof */ { -#line 753 "src/libre/parser.act" +#line 757 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXEOF; @@ -467,7 +467,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, case (TOK_CHAR): /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -490,7 +490,7 @@ p_list_Hof_Hatoms_C_Catom(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZInode) == NULL) { @@ -506,7 +506,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-atom */ { -#line 704 "src/libre/parser.act" +#line 708 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXATOM; @@ -518,7 +518,7 @@ ZL1:; /* END OF ACTION: err-expected-atom */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -539,7 +539,7 @@ ZL0:; /* BEGINNING OF TRAILER */ -#line 1052 "src/libre/parser.act" +#line 1207 "src/libre/parser.act" static int @@ -559,7 +559,6 @@ ZL0:; struct ast * DIALECT_PARSE(re_getchar_fun *f, void *opaque, - const struct fsm_options *opt, enum re_flags flags, int overlap, struct re_err *err, struct re_pos *end) { @@ -696,6 +695,6 @@ ZL0:; return NULL; } -#line 700 "src/libre/dialect/literal/parser.c" +#line 699 "src/libre/dialect/literal/parser.c" /* END OF FILE */ diff --git a/src/libre/dialect/literal/parser.h b/src/libre/dialect/literal/parser.h index 672d23e8e..be58db4ea 100644 --- a/src/libre/dialect/literal/parser.h +++ b/src/libre/dialect/literal/parser.h @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 281 "src/libre/parser.act" +#line 292 "src/libre/parser.act" #include @@ -28,7 +28,7 @@ extern void p_re__literal(flags, lex_state, act_state, err, t_ast__expr *); /* BEGINNING OF TRAILER */ -#line 1208 "src/libre/parser.act" +#line 1209 "src/libre/parser.act" #line 35 "src/libre/dialect/literal/parser.h" diff --git a/src/libre/dialect/native/parser.c b/src/libre/dialect/native/parser.c index 05a3ff0e7..809383bf8 100644 --- a/src/libre/dialect/native/parser.c +++ b/src/libre/dialect/native/parser.c @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 22 "src/libre/parser.act" +#line 275 "src/libre/parser.act" #include @@ -326,7 +326,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -349,7 +349,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: ESC */ { -#line 386 "src/libre/parser.act" +#line 391 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] != '\0'); @@ -385,7 +385,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: HEX */ { -#line 527 "src/libre/parser.act" +#line 535 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -443,7 +443,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: OCT */ { -#line 484 "src/libre/parser.act" +#line 492 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -499,7 +499,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags /* END OF INLINE: 141 */ /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIr).type = AST_ENDPOINT_LITERAL; (ZIr).u.literal.c = (unsigned char) (ZIc); @@ -531,7 +531,7 @@ p_265(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 /* BEGINNING OF EXTRACT: CLOSECOUNT */ { -#line 378 "src/libre/parser.act" +#line 379 "src/libre/parser.act" ZI216 = lex_state->lx.start; ZIend = lex_state->lx.end; @@ -545,7 +545,7 @@ p_265(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-count */ { -#line 777 "src/libre/parser.act" +#line 778 "src/libre/parser.act" mark(&act_state->countstart, &(*ZI263)); mark(&act_state->countend, &(ZIend)); @@ -555,7 +555,7 @@ p_265(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 /* END OF ACTION: mark-count */ /* BEGINNING OF ACTION: count-range */ { -#line 824 "src/libre/parser.act" +#line 825 "src/libre/parser.act" if ((*ZIm) < (*ZIm)) { err->e = RE_ENEGCOUNT; @@ -586,7 +586,7 @@ p_265(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 case (TOK_COUNT): /* BEGINNING OF EXTRACT: COUNT */ { -#line 627 "src/libre/parser.act" +#line 636 "src/libre/parser.act" unsigned long u; char *e; @@ -618,7 +618,7 @@ p_265(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 case (TOK_CLOSECOUNT): /* BEGINNING OF EXTRACT: CLOSECOUNT */ { -#line 378 "src/libre/parser.act" +#line 379 "src/libre/parser.act" ZI219 = lex_state->lx.start; ZIend = lex_state->lx.end; @@ -636,7 +636,7 @@ p_265(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-count */ { -#line 777 "src/libre/parser.act" +#line 778 "src/libre/parser.act" mark(&act_state->countstart, &(*ZI263)); mark(&act_state->countend, &(ZIend)); @@ -646,7 +646,7 @@ p_265(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 /* END OF ACTION: mark-count */ /* BEGINNING OF ACTION: count-range */ { -#line 824 "src/libre/parser.act" +#line 825 "src/libre/parser.act" if ((ZIn) < (*ZIm)) { err->e = RE_ENEGCOUNT; @@ -696,7 +696,7 @@ ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms:; } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZIclass), (ZInode))) { goto ZL1; @@ -709,7 +709,7 @@ ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms:; goto ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms; /* END OF INLINE: expr::character-class::list-of-class-terms */ } - /* UNREACHED */ + /*UNREACHED*/ case (ERROR_TERMINAL): return; default: @@ -736,7 +736,7 @@ p_154(flags flags, lex_state lex_state, act_state act_state, err err) case (TOK_RANGE): /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZI155 = '-'; ZI156 = lex_state->lx.start; @@ -760,7 +760,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-range */ { -#line 718 "src/libre/parser.act" +#line 722 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXRANGE; @@ -795,7 +795,7 @@ ZL2_expr_C_Clist_Hof_Hpieces:; } /* BEGINNING OF ACTION: ast-add-concat */ { -#line 1040 "src/libre/parser.act" +#line 1041 "src/libre/parser.act" if (!ast_add_expr_concat((ZIcat), (ZIa))) { goto ZL1; @@ -815,7 +815,7 @@ ZL2_expr_C_Clist_Hof_Hpieces:; goto ZL2_expr_C_Clist_Hof_Hpieces; /* END OF INLINE: expr::list-of-pieces */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -849,7 +849,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -875,7 +875,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: ESC */ { -#line 386 "src/libre/parser.act" +#line 391 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] != '\0'); @@ -914,7 +914,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: HEX */ { -#line 527 "src/libre/parser.act" +#line 535 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -975,7 +975,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: OCT */ { -#line 484 "src/libre/parser.act" +#line 492 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -1031,7 +1031,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* END OF INLINE: 109 */ /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZInode) == NULL) { @@ -1064,7 +1064,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -1096,7 +1096,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: ESC */ { -#line 386 "src/libre/parser.act" +#line 391 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] != '\0'); @@ -1141,7 +1141,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: HEX */ { -#line 527 "src/libre/parser.act" +#line 535 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -1208,7 +1208,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: NAMED_CLASS */ { -#line 647 "src/libre/parser.act" +#line 648 "src/libre/parser.act" ZI243 = DIALECT_CLASS(lex_state->buf.a); if (ZI243 == NULL) { @@ -1241,7 +1241,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: OCT */ { -#line 484 "src/libre/parser.act" +#line 492 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -1325,7 +1325,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hclass(flags fl case (TOK_NAMED__CLASS): /* BEGINNING OF EXTRACT: NAMED_CLASS */ { -#line 647 "src/libre/parser.act" +#line 648 "src/libre/parser.act" ZIid = DIALECT_CLASS(lex_state->buf.a); if (ZIid == NULL) { @@ -1349,7 +1349,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hclass(flags fl ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-range-endpoint-class */ { -#line 844 "src/libre/parser.act" +#line 845 "src/libre/parser.act" (ZIr).type = AST_ENDPOINT_NAMED; (ZIr).u.named.class = (ZIid); @@ -1389,7 +1389,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: OPENGROUP */ { -#line 318 "src/libre/parser.act" +#line 319 "src/libre/parser.act" ZIstart = lex_state->lx.start; ZI167 = lex_state->lx.end; @@ -1403,7 +1403,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -1430,7 +1430,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: OPENGROUPCB */ { -#line 334 "src/libre/parser.act" +#line 335 "src/libre/parser.act" ZIstart = lex_state->lx.start; ZI186 = lex_state->lx.end; @@ -1444,7 +1444,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -1457,7 +1457,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ZItmp = ZInode; /* BEGINNING OF ACTION: make-literal-cbrak */ { -#line 885 "src/libre/parser.act" +#line 886 "src/libre/parser.act" (ZIcbrak) = ']'; @@ -1471,7 +1471,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZItmp), (ZInode1))) { goto ZL1; @@ -1493,7 +1493,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: OPENGROUPINV */ { -#line 326 "src/libre/parser.act" +#line 327 "src/libre/parser.act" ZIstart = lex_state->lx.start; ZI178 = lex_state->lx.end; @@ -1507,7 +1507,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -1520,7 +1520,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ZItmp = ZInode; /* BEGINNING OF ACTION: ast-make-invert */ { -#line 966 "src/libre/parser.act" +#line 995 "src/libre/parser.act" struct ast_expr *any; @@ -1577,7 +1577,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: OPENGROUPINVCB */ { -#line 342 "src/libre/parser.act" +#line 343 "src/libre/parser.act" ZIstart = lex_state->lx.start; ZI193 = lex_state->lx.end; @@ -1591,7 +1591,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -1604,7 +1604,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ZItmp = ZInode; /* BEGINNING OF ACTION: ast-make-invert */ { -#line 966 "src/libre/parser.act" +#line 995 "src/libre/parser.act" struct ast_expr *any; @@ -1647,7 +1647,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* END OF ACTION: ast-make-invert */ /* BEGINNING OF ACTION: make-literal-cbrak */ { -#line 885 "src/libre/parser.act" +#line 886 "src/libre/parser.act" (ZIcbrak) = ']'; @@ -1661,7 +1661,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZItmp), (ZInode1))) { goto ZL1; @@ -1693,7 +1693,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: CLOSEGROUP */ { -#line 350 "src/libre/parser.act" +#line 351 "src/libre/parser.act" ZI200 = ']'; ZI201 = lex_state->lx.start; @@ -1709,7 +1709,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-group */ { -#line 767 "src/libre/parser.act" +#line 768 "src/libre/parser.act" mark(&act_state->groupstart, &(ZIstart)); mark(&act_state->groupend, &(ZIend)); @@ -1728,7 +1728,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: CLOSEGROUPRANGE */ { -#line 360 "src/libre/parser.act" +#line 361 "src/libre/parser.act" ZIcrange = '-'; ZI203 = lex_state->lx.start; @@ -1744,7 +1744,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZIrange) = ast_make_expr_literal(act_state->poolp, *flags, (ZIcrange)); if ((ZIrange) == NULL) { @@ -1756,7 +1756,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* END OF ACTION: ast-make-literal */ /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZItmp), (ZIrange))) { goto ZL4; @@ -1767,7 +1767,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* END OF ACTION: ast-add-alt */ /* BEGINNING OF ACTION: mark-group */ { -#line 767 "src/libre/parser.act" +#line 768 "src/libre/parser.act" mark(&act_state->groupstart, &(ZIstart)); mark(&act_state->groupend, &(ZIend)); @@ -1785,7 +1785,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state { /* BEGINNING OF ACTION: err-expected-closegroup */ { -#line 725 "src/libre/parser.act" +#line 729 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXCLOSEGROUP; @@ -1821,7 +1821,7 @@ p_180(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZIc = '-'; ZIrstart = lex_state->lx.start; @@ -1842,7 +1842,7 @@ p_180(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp { /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode1) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZInode1) == NULL) { @@ -1865,7 +1865,7 @@ p_180(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIlower).type = AST_ENDPOINT_LITERAL; (ZIlower).u.literal.c = (unsigned char) (ZIc); @@ -1875,7 +1875,7 @@ p_180(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* END OF ACTION: ast-range-endpoint-literal */ /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZI183 = '-'; ZI184 = lex_state->lx.start; @@ -1896,7 +1896,7 @@ p_180(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp } /* BEGINNING OF ACTION: ast-make-range */ { -#line 1004 "src/libre/parser.act" +#line 1007 "src/libre/parser.act" unsigned char lower, upper; @@ -1935,7 +1935,7 @@ p_180(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* END OF INLINE: 182 */ /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((*ZItmp), (ZInode1))) { goto ZL1; @@ -1977,7 +1977,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_Hend(flags flags, lex_state lex_st /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZIc = '-'; ZI149 = lex_state->lx.start; @@ -1993,7 +1993,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_Hend(flags flags, lex_state lex_st ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIr).type = AST_ENDPOINT_LITERAL; (ZIr).u.literal.c = (unsigned char) (ZIc); @@ -2050,7 +2050,7 @@ p_expr_C_Cpiece(flags flags, lex_state lex_state, act_state act_state, err err, } /* BEGINNING OF ACTION: ast-make-piece */ { -#line 897 "src/libre/parser.act" +#line 898 "src/libre/parser.act" if ((ZIc).min == 0 && (ZIc).max == 0) { (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); @@ -2088,7 +2088,7 @@ p_expr(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__ex { /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2109,7 +2109,7 @@ p_expr(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__ex { /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2129,7 +2129,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-alts */ { -#line 711 "src/libre/parser.act" +#line 715 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXALTS; @@ -2141,7 +2141,7 @@ ZL1:; /* END OF ACTION: err-expected-alts */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2170,7 +2170,7 @@ p_195(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs { /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode1) = ast_make_expr_literal(act_state->poolp, *flags, (*ZIcbrak)); if ((ZInode1) == NULL) { @@ -2194,7 +2194,7 @@ p_195(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIr).type = AST_ENDPOINT_LITERAL; (ZIr).u.literal.c = (unsigned char) (*ZIcbrak); @@ -2204,7 +2204,7 @@ p_195(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs /* END OF ACTION: ast-range-endpoint-literal */ /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZI196 = '-'; ZI197 = lex_state->lx.start; @@ -2225,7 +2225,7 @@ p_195(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs } /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIlower).type = AST_ENDPOINT_LITERAL; (ZIlower).u.literal.c = (unsigned char) (*ZIcbrak); @@ -2235,7 +2235,7 @@ p_195(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs /* END OF ACTION: ast-range-endpoint-literal */ /* BEGINNING OF ACTION: ast-make-range */ { -#line 1004 "src/libre/parser.act" +#line 1007 "src/libre/parser.act" unsigned char lower, upper; @@ -2294,7 +2294,7 @@ p_re__native(flags flags, lex_state lex_state, act_state act_state, err err, t_a /* BEGINNING OF ACTION: make-group-id */ { -#line 881 "src/libre/parser.act" +#line 882 "src/libre/parser.act" (ZIid) = act_state->group_id++; @@ -2308,7 +2308,7 @@ p_re__native(flags flags, lex_state lex_state, act_state act_state, err err, t_a } /* BEGINNING OF ACTION: ast-make-group */ { -#line 911 "src/libre/parser.act" +#line 912 "src/libre/parser.act" (ZInode) = ast_make_expr_group(act_state->poolp, *flags, (ZIe), (ZIid)); if ((ZInode) == NULL) { @@ -2334,7 +2334,7 @@ p_re__native(flags flags, lex_state lex_state, act_state act_state, err err, t_a { /* BEGINNING OF ACTION: err-expected-eof */ { -#line 753 "src/libre/parser.act" +#line 757 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXEOF; @@ -2422,7 +2422,7 @@ ZL2_expr_C_Clist_Hof_Halts:; } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZIalts), (ZIa))) { goto ZL1; @@ -2441,7 +2441,7 @@ ZL2_expr_C_Clist_Hof_Halts:; goto ZL2_expr_C_Clist_Hof_Halts; /* END OF INLINE: expr::list-of-alts */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -2453,7 +2453,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-alts */ { -#line 711 "src/libre/parser.act" +#line 715 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXALTS; @@ -2485,7 +2485,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, /* BEGINNING OF EXTRACT: OPENCOUNT */ { -#line 370 "src/libre/parser.act" +#line 371 "src/libre/parser.act" ZI263 = lex_state->lx.start; ZI264 = lex_state->lx.end; @@ -2501,7 +2501,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, case (TOK_COUNT): /* BEGINNING OF EXTRACT: COUNT */ { -#line 627 "src/libre/parser.act" +#line 636 "src/libre/parser.act" unsigned long u; char *e; @@ -2541,7 +2541,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: count-zero-or-one */ { -#line 816 "src/libre/parser.act" +#line 817 "src/libre/parser.act" (ZIc) = ast_make_count(0, 1); @@ -2555,7 +2555,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: count-one-or-more */ { -#line 812 "src/libre/parser.act" +#line 813 "src/libre/parser.act" (ZIc) = ast_make_count(1, AST_COUNT_UNBOUNDED); @@ -2569,7 +2569,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: count-zero-or-more */ { -#line 808 "src/libre/parser.act" +#line 809 "src/libre/parser.act" (ZIc) = ast_make_count(0, AST_COUNT_UNBOUNDED); @@ -2582,7 +2582,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, { /* BEGINNING OF ACTION: count-one */ { -#line 820 "src/libre/parser.act" +#line 821 "src/libre/parser.act" (ZIc) = ast_make_count(1, 1); @@ -2599,7 +2599,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-count */ { -#line 697 "src/libre/parser.act" +#line 701 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXCOUNT; @@ -2611,7 +2611,7 @@ ZL1:; /* END OF ACTION: err-expected-count */ /* BEGINNING OF ACTION: count-one */ { -#line 820 "src/libre/parser.act" +#line 821 "src/libre/parser.act" (ZIc) = ast_make_count(1, 1); @@ -2640,7 +2640,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: class-any */ { -#line 782 "src/libre/parser.act" +#line 784 "src/libre/parser.act" /* TODO: or the unicode equivalent */ (ZIa) = (*flags & RE_SINGLE) ? &class_any : &class_notnl; @@ -2650,7 +2650,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: class-any */ /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZIe) = ast_make_expr_named(act_state->poolp, *flags, (ZIa)); if ((ZIe) == NULL) { @@ -2667,7 +2667,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-anchor-end */ { -#line 942 "src/libre/parser.act" +#line 943 "src/libre/parser.act" (ZIe) = ast_make_expr_anchor(act_state->poolp, *flags, AST_ANCHOR_END); if ((ZIe) == NULL) { @@ -2687,7 +2687,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: make-group-id */ { -#line 881 "src/libre/parser.act" +#line 882 "src/libre/parser.act" (ZIid) = act_state->group_id++; @@ -2701,7 +2701,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e } /* BEGINNING OF ACTION: ast-make-group */ { -#line 911 "src/libre/parser.act" +#line 912 "src/libre/parser.act" (ZIe) = ast_make_expr_group(act_state->poolp, *flags, (ZIg), (ZIid)); if ((ZIe) == NULL) { @@ -2725,7 +2725,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-anchor-start */ { -#line 935 "src/libre/parser.act" +#line 936 "src/libre/parser.act" (ZIe) = ast_make_expr_anchor(act_state->poolp, *flags, AST_ANCHOR_START); if ((ZIe) == NULL) { @@ -2765,7 +2765,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-atom */ { -#line 704 "src/libre/parser.act" +#line 708 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXATOM; @@ -2777,7 +2777,7 @@ ZL1:; /* END OF ACTION: err-expected-atom */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -2806,7 +2806,7 @@ p_246(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__cla { /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZInode) = ast_make_expr_named(act_state->poolp, *flags, (*ZI243)); if ((ZInode) == NULL) { @@ -2826,7 +2826,7 @@ p_246(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__cla /* BEGINNING OF ACTION: ast-range-endpoint-class */ { -#line 844 "src/libre/parser.act" +#line 845 "src/libre/parser.act" (ZIlower).type = AST_ENDPOINT_NAMED; (ZIlower).u.named.class = (*ZI243); @@ -2842,7 +2842,7 @@ p_246(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__cla } /* BEGINNING OF ACTION: mark-range */ { -#line 772 "src/libre/parser.act" +#line 773 "src/libre/parser.act" mark(&act_state->rangestart, &(*ZI244)); mark(&act_state->rangeend, &(ZIend)); @@ -2852,7 +2852,7 @@ p_246(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__cla /* END OF ACTION: mark-range */ /* BEGINNING OF ACTION: ast-make-range */ { -#line 1004 "src/libre/parser.act" +#line 1007 "src/libre/parser.act" unsigned char lower, upper; @@ -2908,7 +2908,7 @@ p_expr_C_Calt(flags flags, lex_state lex_state, act_state act_state, err err, t_ { /* BEGINNING OF ACTION: ast-make-concat */ { -#line 860 "src/libre/parser.act" +#line 861 "src/libre/parser.act" (ZInode) = ast_make_expr_concat(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2942,7 +2942,7 @@ p_250(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI { /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode) = ast_make_expr_literal(act_state->poolp, *flags, (*ZI247)); if ((ZInode) == NULL) { @@ -2962,7 +2962,7 @@ p_250(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIlower).type = AST_ENDPOINT_LITERAL; (ZIlower).u.literal.c = (unsigned char) (*ZI247); @@ -2978,7 +2978,7 @@ p_250(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI } /* BEGINNING OF ACTION: mark-range */ { -#line 772 "src/libre/parser.act" +#line 773 "src/libre/parser.act" mark(&act_state->rangestart, &(*ZI248)); mark(&act_state->rangeend, &(ZIend)); @@ -2988,7 +2988,7 @@ p_250(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI /* END OF ACTION: mark-range */ /* BEGINNING OF ACTION: ast-make-range */ { -#line 1004 "src/libre/parser.act" +#line 1007 "src/libre/parser.act" unsigned char lower, upper; @@ -3035,7 +3035,7 @@ ZL0:; /* BEGINNING OF TRAILER */ -#line 1052 "src/libre/parser.act" +#line 1207 "src/libre/parser.act" static int @@ -3055,7 +3055,6 @@ ZL0:; struct ast * DIALECT_PARSE(re_getchar_fun *f, void *opaque, - const struct fsm_options *opt, enum re_flags flags, int overlap, struct re_err *err, struct re_pos *end) { @@ -3192,6 +3191,6 @@ ZL0:; return NULL; } -#line 3196 "src/libre/dialect/native/parser.c" +#line 3195 "src/libre/dialect/native/parser.c" /* END OF FILE */ diff --git a/src/libre/dialect/native/parser.h b/src/libre/dialect/native/parser.h index 8b1c4d866..e19648892 100644 --- a/src/libre/dialect/native/parser.h +++ b/src/libre/dialect/native/parser.h @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 281 "src/libre/parser.act" +#line 292 "src/libre/parser.act" #include @@ -28,7 +28,7 @@ extern void p_re__native(flags, lex_state, act_state, err, t_ast__expr *); /* BEGINNING OF TRAILER */ -#line 1208 "src/libre/parser.act" +#line 1209 "src/libre/parser.act" #line 35 "src/libre/dialect/native/parser.h" diff --git a/src/libre/dialect/pcre/parser.c b/src/libre/dialect/pcre/parser.c index 2400a0812..78c11d795 100644 --- a/src/libre/dialect/pcre/parser.c +++ b/src/libre/dialect/pcre/parser.c @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 22 "src/libre/parser.act" +#line 275 "src/libre/parser.act" #include @@ -325,7 +325,7 @@ p_expr_C_Cflags_C_Cflag__set(flags flags, lex_state lex_state, act_state act_sta /* BEGINNING OF EXTRACT: FLAG_EXTENDED */ { -#line 665 "src/libre/parser.act" +#line 666 "src/libre/parser.act" ZIc = RE_EXTENDED; @@ -335,7 +335,7 @@ p_expr_C_Cflags_C_Cflag__set(flags flags, lex_state lex_state, act_state act_sta ADVANCE_LEXER; /* BEGINNING OF ACTION: re-flag-union */ { -#line 800 "src/libre/parser.act" +#line 801 "src/libre/parser.act" (ZIo) = (ZIi) | (ZIc); @@ -356,7 +356,7 @@ p_expr_C_Cflags_C_Cflag__set(flags flags, lex_state lex_state, act_state act_sta /* BEGINNING OF EXTRACT: FLAG_INSENSITIVE */ { -#line 661 "src/libre/parser.act" +#line 662 "src/libre/parser.act" ZIc = RE_ICASE; @@ -366,7 +366,7 @@ p_expr_C_Cflags_C_Cflag__set(flags flags, lex_state lex_state, act_state act_sta ADVANCE_LEXER; /* BEGINNING OF ACTION: re-flag-union */ { -#line 800 "src/libre/parser.act" +#line 801 "src/libre/parser.act" (ZIo) = (ZIi) | (ZIc); @@ -381,7 +381,7 @@ p_expr_C_Cflags_C_Cflag__set(flags flags, lex_state lex_state, act_state act_sta /* BEGINNING OF EXTRACT: FLAG_SINGLE */ { -#line 669 "src/libre/parser.act" +#line 670 "src/libre/parser.act" ZIc = RE_SINGLE; @@ -391,7 +391,7 @@ p_expr_C_Cflags_C_Cflag__set(flags flags, lex_state lex_state, act_state act_sta ADVANCE_LEXER; /* BEGINNING OF ACTION: re-flag-union */ { -#line 800 "src/libre/parser.act" +#line 801 "src/libre/parser.act" (ZIo) = (ZIi) | (ZIc); @@ -406,7 +406,7 @@ p_expr_C_Cflags_C_Cflag__set(flags flags, lex_state lex_state, act_state act_sta ZIo = ZIi; /* BEGINNING OF ACTION: err-unknown-flag */ { -#line 739 "src/libre/parser.act" +#line 743 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EFLAG; @@ -451,7 +451,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -474,7 +474,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: CONTROL */ { -#line 442 "src/libre/parser.act" +#line 448 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] == 'c'); @@ -522,7 +522,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags ADVANCE_LEXER; /* BEGINNING OF ACTION: err-unsupported */ { -#line 760 "src/libre/parser.act" +#line 764 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EUNSUPPORTED; @@ -538,7 +538,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: ESC */ { -#line 386 "src/libre/parser.act" +#line 391 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] != '\0'); @@ -574,7 +574,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: HEX */ { -#line 527 "src/libre/parser.act" +#line 535 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -632,7 +632,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: OCT */ { -#line 484 "src/libre/parser.act" +#line 492 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -685,7 +685,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags { /* BEGINNING OF EXTRACT: UNSUPPORTED */ { -#line 426 "src/libre/parser.act" +#line 429 "src/libre/parser.act" /* handle \1-\9 back references */ if (lex_state->buf.a[0] == '\\' && lex_state->buf.a[1] != '\0' && lex_state->buf.a[2] == '\0') { @@ -707,7 +707,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags ADVANCE_LEXER; /* BEGINNING OF ACTION: err-unsupported */ { -#line 760 "src/libre/parser.act" +#line 764 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EUNSUPPORTED; @@ -726,7 +726,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hliteral(flags /* END OF INLINE: 155 */ /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIr).type = AST_ENDPOINT_LITERAL; (ZIr).u.literal.c = (unsigned char) (ZIc); @@ -762,7 +762,7 @@ ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms:; } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZIclass), (ZInode))) { goto ZL1; @@ -775,7 +775,7 @@ ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms:; goto ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms; /* END OF INLINE: expr::character-class::list-of-class-terms */ } - /* UNREACHED */ + /*UNREACHED*/ case (ERROR_TERMINAL): return; default: @@ -822,7 +822,7 @@ ZL2_expr_C_Clist_Hof_Hpieces:; } /* BEGINNING OF ACTION: ast-add-concat */ { -#line 1040 "src/libre/parser.act" +#line 1041 "src/libre/parser.act" if (!ast_add_expr_concat((ZIcat), (ZIa))) { goto ZL1; @@ -851,7 +851,7 @@ ZL2_expr_C_Clist_Hof_Hpieces:; goto ZL2_expr_C_Clist_Hof_Hpieces; /* END OF INLINE: expr::list-of-pieces */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -874,7 +874,7 @@ p_293(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__cla { /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZInode) = ast_make_expr_named(act_state->poolp, *flags, (*ZI290)); if ((ZInode) == NULL) { @@ -894,7 +894,7 @@ p_293(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__cla /* BEGINNING OF ACTION: ast-range-endpoint-class */ { -#line 844 "src/libre/parser.act" +#line 845 "src/libre/parser.act" (ZIlower).type = AST_ENDPOINT_NAMED; (ZIlower).u.named.class = (*ZI290); @@ -910,7 +910,7 @@ p_293(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__cla } /* BEGINNING OF ACTION: mark-range */ { -#line 772 "src/libre/parser.act" +#line 773 "src/libre/parser.act" mark(&act_state->rangestart, &(*ZI291)); mark(&act_state->rangeend, &(ZIend)); @@ -920,7 +920,7 @@ p_293(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__cla /* END OF ACTION: mark-range */ /* BEGINNING OF ACTION: ast-make-range */ { -#line 1004 "src/libre/parser.act" +#line 1007 "src/libre/parser.act" unsigned char lower, upper; @@ -980,7 +980,7 @@ p_168(flags flags, lex_state lex_state, act_state act_state, err err) case (TOK_RANGE): /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZI169 = '-'; ZI170 = lex_state->lx.start; @@ -1004,7 +1004,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-range */ { -#line 718 "src/libre/parser.act" +#line 722 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXRANGE; @@ -1043,7 +1043,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -1069,7 +1069,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: CONTROL */ { -#line 442 "src/libre/parser.act" +#line 448 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] == 'c'); @@ -1124,7 +1124,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: ESC */ { -#line 386 "src/libre/parser.act" +#line 391 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] != '\0'); @@ -1163,7 +1163,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: HEX */ { -#line 527 "src/libre/parser.act" +#line 535 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -1224,7 +1224,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: NOESC */ { -#line 412 "src/libre/parser.act" +#line 417 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] != '\0'); @@ -1251,7 +1251,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: OCT */ { -#line 484 "src/libre/parser.act" +#line 492 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -1307,7 +1307,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* BEGINNING OF EXTRACT: UNSUPPORTED */ { -#line 426 "src/libre/parser.act" +#line 429 "src/libre/parser.act" /* handle \1-\9 back references */ if (lex_state->buf.a[0] == '\\' && lex_state->buf.a[1] != '\0' && lex_state->buf.a[2] == '\0') { @@ -1329,7 +1329,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err ADVANCE_LEXER; /* BEGINNING OF ACTION: err-unsupported */ { -#line 760 "src/libre/parser.act" +#line 764 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EUNSUPPORTED; @@ -1348,7 +1348,7 @@ p_expr_C_Cliteral(flags flags, lex_state lex_state, act_state act_state, err err /* END OF INLINE: 111 */ /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZInode) == NULL) { @@ -1381,7 +1381,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -1413,7 +1413,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: CONTROL */ { -#line 442 "src/libre/parser.act" +#line 448 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] == 'c'); @@ -1461,7 +1461,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ ADVANCE_LEXER; /* BEGINNING OF ACTION: err-unsupported */ { -#line 760 "src/libre/parser.act" +#line 764 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EUNSUPPORTED; @@ -1486,7 +1486,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: ESC */ { -#line 386 "src/libre/parser.act" +#line 391 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] != '\0'); @@ -1531,7 +1531,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: HEX */ { -#line 527 "src/libre/parser.act" +#line 535 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -1598,7 +1598,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: NAMED_CLASS */ { -#line 647 "src/libre/parser.act" +#line 648 "src/libre/parser.act" ZI290 = DIALECT_CLASS(lex_state->buf.a); if (ZI290 == NULL) { @@ -1631,7 +1631,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: NOESC */ { -#line 412 "src/libre/parser.act" +#line 417 "src/libre/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] != '\0'); @@ -1651,7 +1651,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZInode) == NULL) { @@ -1671,7 +1671,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: OCT */ { -#line 484 "src/libre/parser.act" +#line 492 "src/libre/parser.act" unsigned long u; char *s, *e; @@ -1733,7 +1733,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: UNSUPPORTED */ { -#line 426 "src/libre/parser.act" +#line 429 "src/libre/parser.act" /* handle \1-\9 back references */ if (lex_state->buf.a[0] == '\\' && lex_state->buf.a[1] != '\0' && lex_state->buf.a[2] == '\0') { @@ -1755,7 +1755,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ ADVANCE_LEXER; /* BEGINNING OF ACTION: err-unsupported */ { -#line 760 "src/libre/parser.act" +#line 764 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EUNSUPPORTED; @@ -1801,7 +1801,7 @@ p_expr_C_Ccomment(flags flags, lex_state lex_state, act_state act_state, err err ADVANCE_LEXER; /* BEGINNING OF ACTION: err-invalid-comment */ { -#line 683 "src/libre/parser.act" +#line 687 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EBADCOMMENT; @@ -1835,7 +1835,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hclass(flags fl case (TOK_NAMED__CLASS): /* BEGINNING OF EXTRACT: NAMED_CLASS */ { -#line 647 "src/libre/parser.act" +#line 648 "src/libre/parser.act" ZIid = DIALECT_CLASS(lex_state->buf.a); if (ZIid == NULL) { @@ -1859,7 +1859,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_C_Crange_Hendpoint_Hclass(flags fl ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-range-endpoint-class */ { -#line 844 "src/libre/parser.act" +#line 845 "src/libre/parser.act" (ZIr).type = AST_ENDPOINT_NAMED; (ZIr).u.named.class = (ZIid); @@ -1899,7 +1899,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: OPENGROUP */ { -#line 318 "src/libre/parser.act" +#line 319 "src/libre/parser.act" ZIstart = lex_state->lx.start; ZI181 = lex_state->lx.end; @@ -1913,7 +1913,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -1940,7 +1940,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: OPENGROUPCB */ { -#line 334 "src/libre/parser.act" +#line 335 "src/libre/parser.act" ZIstart = lex_state->lx.start; ZI200 = lex_state->lx.end; @@ -1954,7 +1954,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -1967,7 +1967,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ZItmp = ZInode; /* BEGINNING OF ACTION: make-literal-cbrak */ { -#line 885 "src/libre/parser.act" +#line 886 "src/libre/parser.act" (ZIcbrak) = ']'; @@ -1981,7 +1981,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZItmp), (ZInode1))) { goto ZL1; @@ -2003,7 +2003,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: OPENGROUPINV */ { -#line 326 "src/libre/parser.act" +#line 327 "src/libre/parser.act" ZIstart = lex_state->lx.start; ZI192 = lex_state->lx.end; @@ -2017,7 +2017,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2030,7 +2030,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ZItmp = ZInode; /* BEGINNING OF ACTION: ast-make-invert */ { -#line 966 "src/libre/parser.act" +#line 995 "src/libre/parser.act" struct ast_expr *any; @@ -2087,7 +2087,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: OPENGROUPINVCB */ { -#line 342 "src/libre/parser.act" +#line 343 "src/libre/parser.act" ZIstart = lex_state->lx.start; ZI207 = lex_state->lx.end; @@ -2101,7 +2101,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2114,7 +2114,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ZItmp = ZInode; /* BEGINNING OF ACTION: ast-make-invert */ { -#line 966 "src/libre/parser.act" +#line 995 "src/libre/parser.act" struct ast_expr *any; @@ -2157,7 +2157,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* END OF ACTION: ast-make-invert */ /* BEGINNING OF ACTION: make-literal-cbrak */ { -#line 885 "src/libre/parser.act" +#line 886 "src/libre/parser.act" (ZIcbrak) = ']'; @@ -2171,7 +2171,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZItmp), (ZInode1))) { goto ZL1; @@ -2203,7 +2203,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: CLOSEGROUP */ { -#line 350 "src/libre/parser.act" +#line 351 "src/libre/parser.act" ZI214 = ']'; ZI215 = lex_state->lx.start; @@ -2219,7 +2219,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-group */ { -#line 767 "src/libre/parser.act" +#line 768 "src/libre/parser.act" mark(&act_state->groupstart, &(ZIstart)); mark(&act_state->groupend, &(ZIend)); @@ -2238,7 +2238,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: CLOSEGROUPRANGE */ { -#line 360 "src/libre/parser.act" +#line 361 "src/libre/parser.act" ZIcrange = '-'; ZI217 = lex_state->lx.start; @@ -2254,7 +2254,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZIrange) = ast_make_expr_literal(act_state->poolp, *flags, (ZIcrange)); if ((ZIrange) == NULL) { @@ -2266,7 +2266,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* END OF ACTION: ast-make-literal */ /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZItmp), (ZIrange))) { goto ZL4; @@ -2277,7 +2277,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* END OF ACTION: ast-add-alt */ /* BEGINNING OF ACTION: mark-group */ { -#line 767 "src/libre/parser.act" +#line 768 "src/libre/parser.act" mark(&act_state->groupstart, &(ZIstart)); mark(&act_state->groupend, &(ZIend)); @@ -2295,7 +2295,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state { /* BEGINNING OF ACTION: err-expected-closegroup */ { -#line 725 "src/libre/parser.act" +#line 729 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXCLOSEGROUP; @@ -2338,7 +2338,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_Hend(flags flags, lex_state lex_st /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZIc = '-'; ZI163 = lex_state->lx.start; @@ -2354,7 +2354,7 @@ p_expr_C_Ccharacter_Hclass_C_Crange_Hendpoint_Hend(flags flags, lex_state lex_st ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIr).type = AST_ENDPOINT_LITERAL; (ZIr).u.literal.c = (unsigned char) (ZIc); @@ -2401,7 +2401,7 @@ p_317(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI { /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode) = ast_make_expr_literal(act_state->poolp, *flags, (*ZI314)); if ((ZInode) == NULL) { @@ -2421,7 +2421,7 @@ p_317(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIlower).type = AST_ENDPOINT_LITERAL; (ZIlower).u.literal.c = (unsigned char) (*ZI314); @@ -2437,7 +2437,7 @@ p_317(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI } /* BEGINNING OF ACTION: mark-range */ { -#line 772 "src/libre/parser.act" +#line 773 "src/libre/parser.act" mark(&act_state->rangestart, &(*ZI315)); mark(&act_state->rangeend, &(ZIend)); @@ -2447,7 +2447,7 @@ p_317(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI /* END OF ACTION: mark-range */ /* BEGINNING OF ACTION: ast-make-range */ { -#line 1004 "src/libre/parser.act" +#line 1007 "src/libre/parser.act" unsigned char lower, upper; @@ -2522,7 +2522,7 @@ p_expr_C_Cpiece(flags flags, lex_state lex_state, act_state act_state, err err, /* BEGINNING OF ACTION: count-one */ { -#line 820 "src/libre/parser.act" +#line 821 "src/libre/parser.act" (ZIc) = ast_make_count(1, 1); @@ -2531,7 +2531,7 @@ p_expr_C_Cpiece(flags flags, lex_state lex_state, act_state act_state, err err, /* END OF ACTION: count-one */ /* BEGINNING OF ACTION: ast-make-piece */ { -#line 897 "src/libre/parser.act" +#line 898 "src/libre/parser.act" if ((ZIc).min == 0 && (ZIc).max == 0) { (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); @@ -2578,7 +2578,7 @@ p_320(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 /* BEGINNING OF EXTRACT: CLOSECOUNT */ { -#line 378 "src/libre/parser.act" +#line 379 "src/libre/parser.act" ZI256 = lex_state->lx.start; ZIend = lex_state->lx.end; @@ -2592,7 +2592,7 @@ p_320(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-count */ { -#line 777 "src/libre/parser.act" +#line 778 "src/libre/parser.act" mark(&act_state->countstart, &(*ZI318)); mark(&act_state->countend, &(ZIend)); @@ -2602,7 +2602,7 @@ p_320(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 /* END OF ACTION: mark-count */ /* BEGINNING OF ACTION: count-range */ { -#line 824 "src/libre/parser.act" +#line 825 "src/libre/parser.act" if ((*ZIm) < (*ZIm)) { err->e = RE_ENEGCOUNT; @@ -2656,7 +2656,7 @@ p_expr(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__ex { /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2677,7 +2677,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-alts */ { -#line 711 "src/libre/parser.act" +#line 715 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXALTS; @@ -2689,7 +2689,7 @@ ZL1:; /* END OF ACTION: err-expected-alts */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2722,7 +2722,7 @@ p_321(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 /* BEGINNING OF EXTRACT: CLOSECOUNT */ { -#line 378 "src/libre/parser.act" +#line 379 "src/libre/parser.act" ZI261 = lex_state->lx.start; ZIend = lex_state->lx.end; @@ -2736,7 +2736,7 @@ p_321(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-count */ { -#line 777 "src/libre/parser.act" +#line 778 "src/libre/parser.act" mark(&act_state->countstart, &(*ZI318)); mark(&act_state->countend, &(ZIend)); @@ -2746,7 +2746,7 @@ p_321(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 /* END OF ACTION: mark-count */ /* BEGINNING OF ACTION: count-unbounded */ { -#line 804 "src/libre/parser.act" +#line 805 "src/libre/parser.act" (ZIn) = AST_COUNT_UNBOUNDED; @@ -2755,7 +2755,7 @@ p_321(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 /* END OF ACTION: count-unbounded */ /* BEGINNING OF ACTION: count-range */ { -#line 824 "src/libre/parser.act" +#line 825 "src/libre/parser.act" if ((ZIn) < (*ZIm)) { err->e = RE_ENEGCOUNT; @@ -2783,7 +2783,7 @@ p_321(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 /* BEGINNING OF EXTRACT: COUNT */ { -#line 627 "src/libre/parser.act" +#line 636 "src/libre/parser.act" unsigned long u; char *e; @@ -2811,7 +2811,7 @@ p_321(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 case (TOK_CLOSECOUNT): /* BEGINNING OF EXTRACT: CLOSECOUNT */ { -#line 378 "src/libre/parser.act" +#line 379 "src/libre/parser.act" ZI259 = lex_state->lx.start; ZIend = lex_state->lx.end; @@ -2829,7 +2829,7 @@ p_321(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-count */ { -#line 777 "src/libre/parser.act" +#line 778 "src/libre/parser.act" mark(&act_state->countstart, &(*ZI318)); mark(&act_state->countend, &(ZIend)); @@ -2839,7 +2839,7 @@ p_321(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI3 /* END OF ACTION: mark-count */ /* BEGINNING OF ACTION: count-range */ { -#line 824 "src/libre/parser.act" +#line 825 "src/libre/parser.act" if ((ZIn) < (*ZIm)) { err->e = RE_ENEGCOUNT; @@ -2885,7 +2885,7 @@ p_194(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZIc = '-'; ZIrstart = lex_state->lx.start; @@ -2906,7 +2906,7 @@ p_194(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp { /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode1) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZInode1) == NULL) { @@ -2929,7 +2929,7 @@ p_194(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIlower).type = AST_ENDPOINT_LITERAL; (ZIlower).u.literal.c = (unsigned char) (ZIc); @@ -2939,7 +2939,7 @@ p_194(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* END OF ACTION: ast-range-endpoint-literal */ /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZI197 = '-'; ZI198 = lex_state->lx.start; @@ -2960,7 +2960,7 @@ p_194(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp } /* BEGINNING OF ACTION: ast-make-range */ { -#line 1004 "src/libre/parser.act" +#line 1007 "src/libre/parser.act" unsigned char lower, upper; @@ -2999,7 +2999,7 @@ p_194(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* END OF INLINE: 196 */ /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((*ZItmp), (ZInode1))) { goto ZL1; @@ -3044,7 +3044,7 @@ p_expr_C_Cflags(flags flags, lex_state lex_state, act_state act_state, err err, ADVANCE_LEXER; /* BEGINNING OF ACTION: re-flag-none */ { -#line 796 "src/libre/parser.act" +#line 797 "src/libre/parser.act" (ZIempty__pos) = RE_FLAGS_NONE; @@ -3053,7 +3053,7 @@ p_expr_C_Cflags(flags flags, lex_state lex_state, act_state act_state, err err, /* END OF ACTION: re-flag-none */ /* BEGINNING OF ACTION: re-flag-none */ { -#line 796 "src/libre/parser.act" +#line 797 "src/libre/parser.act" (ZIempty__neg) = RE_FLAGS_NONE; @@ -3110,7 +3110,7 @@ p_expr_C_Cflags(flags flags, lex_state lex_state, act_state act_state, err err, ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-mask-re-flags */ { -#line 926 "src/libre/parser.act" +#line 931 "src/libre/parser.act" /* * Note: in cases like `(?i-i)`, the negative is @@ -3124,7 +3124,7 @@ p_expr_C_Cflags(flags flags, lex_state lex_state, act_state act_state, err err, /* END OF ACTION: ast-mask-re-flags */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -3144,7 +3144,7 @@ p_expr_C_Cflags(flags flags, lex_state lex_state, act_state act_state, err err, ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-get-re-flags */ { -#line 918 "src/libre/parser.act" +#line 919 "src/libre/parser.act" (ZIflags) = *flags; @@ -3153,7 +3153,7 @@ p_expr_C_Cflags(flags flags, lex_state lex_state, act_state act_state, err err, /* END OF ACTION: ast-get-re-flags */ /* BEGINNING OF ACTION: ast-mask-re-flags */ { -#line 926 "src/libre/parser.act" +#line 931 "src/libre/parser.act" /* * Note: in cases like `(?i-i)`, the negative is @@ -3172,7 +3172,7 @@ p_expr_C_Cflags(flags flags, lex_state lex_state, act_state act_state, err err, } /* BEGINNING OF ACTION: ast-set-re-flags */ { -#line 922 "src/libre/parser.act" +#line 923 "src/libre/parser.act" *flags = (ZIflags); @@ -3197,7 +3197,7 @@ p_expr_C_Cflags(flags flags, lex_state lex_state, act_state act_state, err err, { /* BEGINNING OF ACTION: err-expected-closeflags */ { -#line 746 "src/libre/parser.act" +#line 750 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXCLOSEFLAGS; @@ -3209,7 +3209,7 @@ p_expr_C_Cflags(flags flags, lex_state lex_state, act_state act_state, err err, /* END OF ACTION: err-expected-closeflags */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -3250,7 +3250,7 @@ p_expr_C_Cpiece_C_Clist_Hof_Hcounts(flags flags, lex_state lex_state, act_state } /* BEGINNING OF ACTION: ast-make-piece */ { -#line 897 "src/libre/parser.act" +#line 898 "src/libre/parser.act" if ((ZIc).min == 0 && (ZIc).max == 0) { (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); @@ -3275,7 +3275,7 @@ p_expr_C_Cpiece_C_Clist_Hof_Hcounts(flags flags, lex_state lex_state, act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: err-unsupported */ { -#line 760 "src/libre/parser.act" +#line 764 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EUNSUPPORTED; @@ -3292,7 +3292,7 @@ p_expr_C_Cpiece_C_Clist_Hof_Hcounts(flags flags, lex_state lex_state, act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: err-unsupported */ { -#line 760 "src/libre/parser.act" +#line 764 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EUNSUPPORTED; @@ -3384,7 +3384,7 @@ p_class_Hnamed(flags flags, lex_state lex_state, act_state act_state, err err, t case (TOK_NAMED__CLASS): /* BEGINNING OF EXTRACT: NAMED_CLASS */ { -#line 647 "src/libre/parser.act" +#line 648 "src/libre/parser.act" ZIid = DIALECT_CLASS(lex_state->buf.a); if (ZIid == NULL) { @@ -3408,7 +3408,7 @@ p_class_Hnamed(flags flags, lex_state lex_state, act_state act_state, err err, t ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZInode) = ast_make_expr_named(act_state->poolp, *flags, (ZIid)); if ((ZInode) == NULL) { @@ -3439,7 +3439,7 @@ p_209(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs { /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode1) = ast_make_expr_literal(act_state->poolp, *flags, (*ZIcbrak)); if ((ZInode1) == NULL) { @@ -3463,7 +3463,7 @@ p_209(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIr).type = AST_ENDPOINT_LITERAL; (ZIr).u.literal.c = (unsigned char) (*ZIcbrak); @@ -3473,7 +3473,7 @@ p_209(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs /* END OF ACTION: ast-range-endpoint-literal */ /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZI210 = '-'; ZI211 = lex_state->lx.start; @@ -3494,7 +3494,7 @@ p_209(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs } /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIlower).type = AST_ENDPOINT_LITERAL; (ZIlower).u.literal.c = (unsigned char) (*ZIcbrak); @@ -3504,7 +3504,7 @@ p_209(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZIs /* END OF ACTION: ast-range-endpoint-literal */ /* BEGINNING OF ACTION: ast-make-range */ { -#line 1004 "src/libre/parser.act" +#line 1007 "src/libre/parser.act" unsigned char lower, upper; @@ -3566,7 +3566,7 @@ ZL2_expr_C_Clist_Hof_Halts:; } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZIalts), (ZIa))) { goto ZL1; @@ -3585,7 +3585,7 @@ ZL2_expr_C_Clist_Hof_Halts:; goto ZL2_expr_C_Clist_Hof_Halts; /* END OF INLINE: expr::list-of-alts */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -3597,7 +3597,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-alts */ { -#line 711 "src/libre/parser.act" +#line 715 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXALTS; @@ -3629,7 +3629,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, /* BEGINNING OF EXTRACT: OPENCOUNT */ { -#line 370 "src/libre/parser.act" +#line 371 "src/libre/parser.act" ZI318 = lex_state->lx.start; ZI319 = lex_state->lx.end; @@ -3645,7 +3645,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, case (TOK_COUNT): /* BEGINNING OF EXTRACT: COUNT */ { -#line 627 "src/libre/parser.act" +#line 636 "src/libre/parser.act" unsigned long u; char *e; @@ -3685,7 +3685,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: count-zero-or-one */ { -#line 816 "src/libre/parser.act" +#line 817 "src/libre/parser.act" (ZIc) = ast_make_count(0, 1); @@ -3699,7 +3699,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: count-one-or-more */ { -#line 812 "src/libre/parser.act" +#line 813 "src/libre/parser.act" (ZIc) = ast_make_count(1, AST_COUNT_UNBOUNDED); @@ -3713,7 +3713,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: count-zero-or-more */ { -#line 808 "src/libre/parser.act" +#line 809 "src/libre/parser.act" (ZIc) = ast_make_count(0, AST_COUNT_UNBOUNDED); @@ -3732,7 +3732,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-count */ { -#line 697 "src/libre/parser.act" +#line 701 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXCOUNT; @@ -3744,7 +3744,7 @@ ZL1:; /* END OF ACTION: err-expected-count */ /* BEGINNING OF ACTION: count-one */ { -#line 820 "src/libre/parser.act" +#line 821 "src/libre/parser.act" (ZIc) = ast_make_count(1, 1); @@ -3774,7 +3774,7 @@ p_re__pcre(flags flags, lex_state lex_state, act_state act_state, err err, t_ast /* BEGINNING OF ACTION: make-group-id */ { -#line 881 "src/libre/parser.act" +#line 882 "src/libre/parser.act" (ZIid) = act_state->group_id++; @@ -3788,7 +3788,7 @@ p_re__pcre(flags flags, lex_state lex_state, act_state act_state, err err, t_ast } /* BEGINNING OF ACTION: ast-make-group */ { -#line 911 "src/libre/parser.act" +#line 912 "src/libre/parser.act" (ZInode) = ast_make_expr_group(act_state->poolp, *flags, (ZIe), (ZIid)); if ((ZInode) == NULL) { @@ -3814,7 +3814,7 @@ p_re__pcre(flags flags, lex_state lex_state, act_state act_state, err err, t_ast { /* BEGINNING OF ACTION: err-expected-eof */ { -#line 753 "src/libre/parser.act" +#line 757 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXEOF; @@ -3850,7 +3850,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: class-any */ { -#line 782 "src/libre/parser.act" +#line 784 "src/libre/parser.act" /* TODO: or the unicode equivalent */ (ZIa) = (*flags & RE_SINGLE) ? &class_any : &class_notnl; @@ -3860,7 +3860,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: class-any */ /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZIe) = ast_make_expr_named(act_state->poolp, *flags, (ZIa)); if ((ZIe) == NULL) { @@ -3877,7 +3877,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-anchor-end */ { -#line 942 "src/libre/parser.act" +#line 943 "src/libre/parser.act" (ZIe) = ast_make_expr_anchor(act_state->poolp, *flags, AST_ANCHOR_END); if ((ZIe) == NULL) { @@ -3894,7 +3894,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-anchor-end-nl */ { -#line 949 "src/libre/parser.act" +#line 950 "src/libre/parser.act" (ZIe) = ast_make_expr_anchor(act_state->poolp, *flags, AST_ANCHOR_END); if ((ZIe) == NULL) { @@ -3922,7 +3922,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: class-bsr */ { -#line 787 "src/libre/parser.act" +#line 789 "src/libre/parser.act" /* TODO: or the unicode equivalent */ (ZIclass__bsr) = &class_bsr; @@ -3932,7 +3932,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: class-bsr */ /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZIbsr) = ast_make_expr_named(act_state->poolp, *flags, (ZIclass__bsr)); if ((ZIbsr) == NULL) { @@ -3944,7 +3944,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-make-named */ /* BEGINNING OF ACTION: ast-make-concat */ { -#line 860 "src/libre/parser.act" +#line 861 "src/libre/parser.act" (ZIcrlf) = ast_make_expr_concat(act_state->poolp, *flags); if ((ZIcrlf) == NULL) { @@ -3956,7 +3956,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-make-concat */ /* BEGINNING OF ACTION: make-literal-cr */ { -#line 889 "src/libre/parser.act" +#line 890 "src/libre/parser.act" (ZIcr) = '\r'; @@ -3965,7 +3965,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: make-literal-cr */ /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZIecr) = ast_make_expr_literal(act_state->poolp, *flags, (ZIcr)); if ((ZIecr) == NULL) { @@ -3977,7 +3977,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-make-literal */ /* BEGINNING OF ACTION: make-literal-nl */ { -#line 893 "src/libre/parser.act" +#line 894 "src/libre/parser.act" (ZInl) = '\n'; @@ -3986,7 +3986,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: make-literal-nl */ /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZIenl) = ast_make_expr_literal(act_state->poolp, *flags, (ZInl)); if ((ZIenl) == NULL) { @@ -3998,7 +3998,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-make-literal */ /* BEGINNING OF ACTION: ast-add-concat */ { -#line 1040 "src/libre/parser.act" +#line 1041 "src/libre/parser.act" if (!ast_add_expr_concat((ZIcrlf), (ZIecr))) { goto ZL1; @@ -4009,7 +4009,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-add-concat */ /* BEGINNING OF ACTION: ast-add-concat */ { -#line 1040 "src/libre/parser.act" +#line 1041 "src/libre/parser.act" if (!ast_add_expr_concat((ZIcrlf), (ZIenl))) { goto ZL1; @@ -4020,7 +4020,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-add-concat */ /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZIe) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -4032,7 +4032,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-make-alt */ /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZIe), (ZIcrlf))) { goto ZL1; @@ -4043,7 +4043,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-add-alt */ /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZIe), (ZIbsr))) { goto ZL1; @@ -4063,7 +4063,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-get-re-flags */ { -#line 918 "src/libre/parser.act" +#line 919 "src/libre/parser.act" (ZIflags) = *flags; @@ -4072,7 +4072,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-get-re-flags */ /* BEGINNING OF ACTION: make-group-id */ { -#line 881 "src/libre/parser.act" +#line 882 "src/libre/parser.act" (ZIid) = act_state->group_id++; @@ -4086,7 +4086,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e } /* BEGINNING OF ACTION: ast-set-re-flags */ { -#line 922 "src/libre/parser.act" +#line 923 "src/libre/parser.act" *flags = (ZIflags); @@ -4095,7 +4095,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-set-re-flags */ /* BEGINNING OF ACTION: ast-make-group */ { -#line 911 "src/libre/parser.act" +#line 912 "src/libre/parser.act" (ZIe) = ast_make_expr_group(act_state->poolp, *flags, (ZIg), (ZIid)); if ((ZIe) == NULL) { @@ -4119,7 +4119,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-anchor-start */ { -#line 935 "src/libre/parser.act" +#line 936 "src/libre/parser.act" (ZIe) = ast_make_expr_anchor(act_state->poolp, *flags, AST_ANCHOR_START); if ((ZIe) == NULL) { @@ -4178,7 +4178,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-atom */ { -#line 704 "src/libre/parser.act" +#line 708 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXATOM; @@ -4190,7 +4190,7 @@ ZL1:; /* END OF ACTION: err-expected-atom */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -4223,7 +4223,7 @@ p_expr_C_Calt(flags flags, lex_state lex_state, act_state act_state, err err, t_ { /* BEGINNING OF ACTION: ast-make-concat */ { -#line 860 "src/libre/parser.act" +#line 861 "src/libre/parser.act" (ZInode) = ast_make_expr_concat(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -4244,7 +4244,7 @@ p_expr_C_Calt(flags flags, lex_state lex_state, act_state act_state, err err, t_ { /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -4287,7 +4287,7 @@ p_expr_C_Ctype(flags flags, lex_state lex_state, act_state act_state, err err, t } /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -4299,7 +4299,7 @@ p_expr_C_Ctype(flags flags, lex_state lex_state, act_state act_state, err err, t /* END OF ACTION: ast-make-alt */ /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZInode), (ZIclass))) { goto ZL1; @@ -4319,7 +4319,7 @@ ZL0:; /* BEGINNING OF TRAILER */ -#line 1052 "src/libre/parser.act" +#line 1207 "src/libre/parser.act" static int @@ -4339,7 +4339,6 @@ ZL0:; struct ast * DIALECT_PARSE(re_getchar_fun *f, void *opaque, - const struct fsm_options *opt, enum re_flags flags, int overlap, struct re_err *err, struct re_pos *end) { @@ -4476,6 +4475,6 @@ ZL0:; return NULL; } -#line 4480 "src/libre/dialect/pcre/parser.c" +#line 4479 "src/libre/dialect/pcre/parser.c" /* END OF FILE */ diff --git a/src/libre/dialect/pcre/parser.h b/src/libre/dialect/pcre/parser.h index a0543aebe..c0cfbabe3 100644 --- a/src/libre/dialect/pcre/parser.h +++ b/src/libre/dialect/pcre/parser.h @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 281 "src/libre/parser.act" +#line 292 "src/libre/parser.act" #include @@ -28,7 +28,7 @@ extern void p_re__pcre(flags, lex_state, act_state, err, t_ast__expr *); /* BEGINNING OF TRAILER */ -#line 1208 "src/libre/parser.act" +#line 1209 "src/libre/parser.act" #line 35 "src/libre/dialect/pcre/parser.h" diff --git a/src/libre/dialect/sql/parser.c b/src/libre/dialect/sql/parser.c index 078b8f67d..d380c5b7d 100644 --- a/src/libre/dialect/sql/parser.c +++ b/src/libre/dialect/sql/parser.c @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 22 "src/libre/parser.act" +#line 275 "src/libre/parser.act" #include @@ -311,7 +311,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hhead(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: INVERT */ { -#line 302 "src/libre/parser.act" +#line 303 "src/libre/parser.act" ZI203 = '^'; @@ -337,7 +337,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hhead(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZIc = '-'; ZI114 = lex_state->lx.start; @@ -353,7 +353,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hhead(flags flags, lex_state lex_state, act_ ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZInode) == NULL) { @@ -365,7 +365,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hhead(flags flags, lex_state lex_state, act_ /* END OF ACTION: ast-make-literal */ /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((*ZIclass), (ZInode))) { goto ZL1; @@ -401,7 +401,7 @@ p_re__sql(flags flags, lex_state lex_state, act_state act_state, err err, t_ast_ /* BEGINNING OF ACTION: make-group-id */ { -#line 881 "src/libre/parser.act" +#line 882 "src/libre/parser.act" (ZIid) = act_state->group_id++; @@ -415,7 +415,7 @@ p_re__sql(flags flags, lex_state lex_state, act_state act_state, err err, t_ast_ } /* BEGINNING OF ACTION: ast-make-group */ { -#line 911 "src/libre/parser.act" +#line 912 "src/libre/parser.act" (ZInode) = ast_make_expr_group(act_state->poolp, *flags, (ZIe), (ZIid)); if ((ZInode) == NULL) { @@ -441,7 +441,7 @@ p_re__sql(flags flags, lex_state lex_state, act_state act_state, err err, t_ast_ { /* BEGINNING OF ACTION: err-expected-eof */ { -#line 753 "src/libre/parser.act" +#line 757 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXEOF; @@ -484,7 +484,7 @@ ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms:; } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZIclass), (ZInode))) { goto ZL4; @@ -499,7 +499,7 @@ ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms:; { /* BEGINNING OF ACTION: err-expected-term */ { -#line 690 "src/libre/parser.act" +#line 694 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXTERM; @@ -522,7 +522,7 @@ ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms:; goto ZL2_expr_C_Ccharacter_Hclass_C_Clist_Hof_Hclass_Hterms; /* END OF INLINE: expr::character-class::list-of-class-terms */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -560,7 +560,7 @@ ZL2_expr_C_Clist_Hof_Hpieces:; } /* BEGINNING OF ACTION: ast-add-concat */ { -#line 1040 "src/libre/parser.act" +#line 1041 "src/libre/parser.act" if (!ast_add_expr_concat((ZIcat), (ZIa))) { goto ZL1; @@ -579,7 +579,7 @@ ZL2_expr_C_Clist_Hof_Hpieces:; goto ZL2_expr_C_Clist_Hof_Hpieces; /* END OF INLINE: expr::list-of-pieces */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -606,7 +606,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hterm(flags flags, lex_state lex_state, act_ /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -670,7 +670,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state case (TOK_OPENGROUP): /* BEGINNING OF EXTRACT: OPENGROUP */ { -#line 318 "src/libre/parser.act" +#line 319 "src/libre/parser.act" ZIopen__start = lex_state->lx.start; ZIopen__end = lex_state->lx.end; @@ -688,7 +688,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZIclass) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZIclass) == NULL) { @@ -713,7 +713,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: CLOSEGROUP */ { -#line 350 "src/libre/parser.act" +#line 351 "src/libre/parser.act" ZI154 = ']'; ZIclose__start = lex_state->lx.start; @@ -729,7 +729,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-group */ { -#line 767 "src/libre/parser.act" +#line 768 "src/libre/parser.act" mark(&act_state->groupstart, &(ZIopen__start)); mark(&act_state->groupend, &(ZIclose__end)); @@ -748,7 +748,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* BEGINNING OF EXTRACT: INVERT */ { -#line 302 "src/libre/parser.act" +#line 303 "src/libre/parser.act" ZI158 = '^'; @@ -760,7 +760,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZImask) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZImask) == NULL) { @@ -789,7 +789,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state case (TOK_CLOSEGROUP): /* BEGINNING OF EXTRACT: CLOSEGROUP */ { -#line 350 "src/libre/parser.act" +#line 351 "src/libre/parser.act" ZI163 = ']'; ZIclose__start = lex_state->lx.start; @@ -809,7 +809,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-group */ { -#line 767 "src/libre/parser.act" +#line 768 "src/libre/parser.act" mark(&act_state->groupstart, &(ZIopen__start)); mark(&act_state->groupend, &(ZIclose__end)); @@ -823,7 +823,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state { /* BEGINNING OF ACTION: err-expected-closegroup */ { -#line 725 "src/libre/parser.act" +#line 729 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXCLOSEGROUP; @@ -839,7 +839,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* END OF INLINE: 162 */ /* BEGINNING OF ACTION: ast-make-subtract */ { -#line 959 "src/libre/parser.act" +#line 960 "src/libre/parser.act" (ZInode) = ast_make_expr_subtract(act_state->poolp, *flags, (ZIclass), (ZImask)); if ((ZInode) == NULL) { @@ -862,7 +862,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state { /* BEGINNING OF ACTION: err-expected-closegroup */ { -#line 725 "src/libre/parser.act" +#line 729 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXCLOSEGROUP; @@ -874,7 +874,7 @@ p_expr_C_Ccharacter_Hclass(flags flags, lex_state lex_state, act_state act_state /* END OF ACTION: err-expected-closegroup */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -917,7 +917,7 @@ p_expr_C_Cpiece(flags flags, lex_state lex_state, act_state act_state, err err, } /* BEGINNING OF ACTION: ast-make-piece */ { -#line 897 "src/libre/parser.act" +#line 898 "src/libre/parser.act" if ((ZIc).min == 0 && (ZIc).max == 0) { (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); @@ -954,7 +954,7 @@ p_expr(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__ex { /* BEGINNING OF ACTION: ast-make-alt */ { -#line 867 "src/libre/parser.act" +#line 868 "src/libre/parser.act" (ZInode) = ast_make_expr_alt(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -975,7 +975,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-alts */ { -#line 711 "src/libre/parser.act" +#line 715 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXALTS; @@ -987,7 +987,7 @@ ZL1:; /* END OF ACTION: err-expected-alts */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -1019,7 +1019,7 @@ p_204(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZIc = '-'; ZI117 = lex_state->lx.start; @@ -1035,7 +1035,7 @@ p_204(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode) = ast_make_expr_literal(act_state->poolp, *flags, (ZIc)); if ((ZInode) == NULL) { @@ -1047,7 +1047,7 @@ p_204(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* END OF ACTION: ast-make-literal */ /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((*ZIclass), (ZInode))) { goto ZL1; @@ -1058,7 +1058,7 @@ p_204(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp /* END OF ACTION: ast-add-alt */ /* BEGINNING OF ACTION: ast-make-invert */ { -#line 966 "src/libre/parser.act" +#line 995 "src/libre/parser.act" struct ast_expr *any; @@ -1105,7 +1105,7 @@ p_204(flags flags, lex_state lex_state, act_state act_state, err err, t_ast__exp { /* BEGINNING OF ACTION: ast-make-invert */ { -#line 966 "src/libre/parser.act" +#line 995 "src/libre/parser.act" struct ast_expr *any; @@ -1167,7 +1167,7 @@ p_208(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI { /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZInode) = ast_make_expr_literal(act_state->poolp, *flags, (*ZI205)); if ((ZInode) == NULL) { @@ -1192,7 +1192,7 @@ p_208(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIa).type = AST_ENDPOINT_LITERAL; (ZIa).u.literal.c = (unsigned char) (*ZI205); @@ -1202,7 +1202,7 @@ p_208(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI /* END OF ACTION: ast-range-endpoint-literal */ /* BEGINNING OF EXTRACT: RANGE */ { -#line 308 "src/libre/parser.act" +#line 309 "src/libre/parser.act" ZI136 = '-'; ZI137 = lex_state->lx.start; @@ -1220,7 +1220,7 @@ p_208(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI case (TOK_CHAR): /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -1243,7 +1243,7 @@ p_208(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-range-endpoint-literal */ { -#line 839 "src/libre/parser.act" +#line 840 "src/libre/parser.act" (ZIz).type = AST_ENDPOINT_LITERAL; (ZIz).u.literal.c = (unsigned char) (ZIcz); @@ -1253,7 +1253,7 @@ p_208(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI /* END OF ACTION: ast-range-endpoint-literal */ /* BEGINNING OF ACTION: mark-range */ { -#line 772 "src/libre/parser.act" +#line 773 "src/libre/parser.act" mark(&act_state->rangestart, &(*ZI206)); mark(&act_state->rangeend, &(ZIend)); @@ -1263,7 +1263,7 @@ p_208(flags flags, lex_state lex_state, act_state act_state, err err, t_char *ZI /* END OF ACTION: mark-range */ /* BEGINNING OF ACTION: ast-make-range */ { -#line 1004 "src/libre/parser.act" +#line 1007 "src/libre/parser.act" unsigned char lower, upper; @@ -1321,7 +1321,7 @@ p_211(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 /* BEGINNING OF EXTRACT: CLOSECOUNT */ { -#line 378 "src/libre/parser.act" +#line 379 "src/libre/parser.act" ZI176 = lex_state->lx.start; ZIend = lex_state->lx.end; @@ -1335,7 +1335,7 @@ p_211(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-count */ { -#line 777 "src/libre/parser.act" +#line 778 "src/libre/parser.act" mark(&act_state->countstart, &(*ZI209)); mark(&act_state->countend, &(ZIend)); @@ -1345,7 +1345,7 @@ p_211(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 /* END OF ACTION: mark-count */ /* BEGINNING OF ACTION: count-range */ { -#line 824 "src/libre/parser.act" +#line 825 "src/libre/parser.act" if ((*ZIm) < (*ZIm)) { err->e = RE_ENEGCOUNT; @@ -1376,7 +1376,7 @@ p_211(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 case (TOK_COUNT): /* BEGINNING OF EXTRACT: COUNT */ { -#line 627 "src/libre/parser.act" +#line 636 "src/libre/parser.act" unsigned long u; char *e; @@ -1408,7 +1408,7 @@ p_211(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 case (TOK_CLOSECOUNT): /* BEGINNING OF EXTRACT: CLOSECOUNT */ { -#line 378 "src/libre/parser.act" +#line 379 "src/libre/parser.act" ZI179 = lex_state->lx.start; ZIend = lex_state->lx.end; @@ -1426,7 +1426,7 @@ p_211(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 ADVANCE_LEXER; /* BEGINNING OF ACTION: mark-count */ { -#line 777 "src/libre/parser.act" +#line 778 "src/libre/parser.act" mark(&act_state->countstart, &(*ZI209)); mark(&act_state->countend, &(ZIend)); @@ -1436,7 +1436,7 @@ p_211(flags flags, lex_state lex_state, act_state act_state, err err, t_pos *ZI2 /* END OF ACTION: mark-count */ /* BEGINNING OF ACTION: count-range */ { -#line 824 "src/libre/parser.act" +#line 825 "src/libre/parser.act" if ((ZIn) < (*ZIm)) { err->e = RE_ENEGCOUNT; @@ -1486,7 +1486,7 @@ ZL2_expr_C_Clist_Hof_Halts:; } /* BEGINNING OF ACTION: ast-add-alt */ { -#line 1046 "src/libre/parser.act" +#line 1047 "src/libre/parser.act" if (!ast_add_expr_alt((ZIalts), (ZIa))) { goto ZL1; @@ -1505,7 +1505,7 @@ ZL2_expr_C_Clist_Hof_Halts:; goto ZL2_expr_C_Clist_Hof_Halts; /* END OF INLINE: expr::list-of-alts */ } - /* UNREACHED */ + /*UNREACHED*/ default: break; } @@ -1517,7 +1517,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-alts */ { -#line 711 "src/libre/parser.act" +#line 715 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXALTS; @@ -1549,7 +1549,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, /* BEGINNING OF EXTRACT: OPENCOUNT */ { -#line 370 "src/libre/parser.act" +#line 371 "src/libre/parser.act" ZI209 = lex_state->lx.start; ZI210 = lex_state->lx.end; @@ -1565,7 +1565,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, case (TOK_COUNT): /* BEGINNING OF EXTRACT: COUNT */ { -#line 627 "src/libre/parser.act" +#line 636 "src/libre/parser.act" unsigned long u; char *e; @@ -1605,7 +1605,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: count-zero-or-one */ { -#line 816 "src/libre/parser.act" +#line 817 "src/libre/parser.act" (ZIc) = ast_make_count(0, 1); @@ -1619,7 +1619,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: count-one-or-more */ { -#line 812 "src/libre/parser.act" +#line 813 "src/libre/parser.act" (ZIc) = ast_make_count(1, AST_COUNT_UNBOUNDED); @@ -1633,7 +1633,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, ADVANCE_LEXER; /* BEGINNING OF ACTION: count-zero-or-more */ { -#line 808 "src/libre/parser.act" +#line 809 "src/libre/parser.act" (ZIc) = ast_make_count(0, AST_COUNT_UNBOUNDED); @@ -1646,7 +1646,7 @@ p_expr_C_Cpiece_C_Ccount(flags flags, lex_state lex_state, act_state act_state, { /* BEGINNING OF ACTION: count-one */ { -#line 820 "src/libre/parser.act" +#line 821 "src/libre/parser.act" (ZIc) = ast_make_count(1, 1); @@ -1663,7 +1663,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-count */ { -#line 697 "src/libre/parser.act" +#line 701 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXCOUNT; @@ -1675,7 +1675,7 @@ ZL1:; /* END OF ACTION: err-expected-count */ /* BEGINNING OF ACTION: count-one */ { -#line 820 "src/libre/parser.act" +#line 821 "src/libre/parser.act" (ZIc) = ast_make_count(1, 1); @@ -1704,7 +1704,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: class-any */ { -#line 782 "src/libre/parser.act" +#line 784 "src/libre/parser.act" /* TODO: or the unicode equivalent */ (ZIa) = (*flags & RE_SINGLE) ? &class_any : &class_notnl; @@ -1714,7 +1714,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: class-any */ /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZIe) = ast_make_expr_named(act_state->poolp, *flags, (ZIa)); if ((ZIe) == NULL) { @@ -1734,7 +1734,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* BEGINNING OF EXTRACT: CHAR */ { -#line 575 "src/libre/parser.act" +#line 579 "src/libre/parser.act" /* the first byte may be '\x00' */ assert(lex_state->buf.a[1] == '\0'); @@ -1753,7 +1753,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-literal */ { -#line 874 "src/libre/parser.act" +#line 875 "src/libre/parser.act" (ZIe) = ast_make_expr_literal(act_state->poolp, *flags, (ZIa)); if ((ZIe) == NULL) { @@ -1774,7 +1774,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: class-any */ { -#line 782 "src/libre/parser.act" +#line 784 "src/libre/parser.act" /* TODO: or the unicode equivalent */ (ZIa) = (*flags & RE_SINGLE) ? &class_any : &class_notnl; @@ -1784,7 +1784,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: class-any */ /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZIg) = ast_make_expr_named(act_state->poolp, *flags, (ZIa)); if ((ZIg) == NULL) { @@ -1796,7 +1796,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: ast-make-named */ /* BEGINNING OF ACTION: count-zero-or-more */ { -#line 808 "src/libre/parser.act" +#line 809 "src/libre/parser.act" (ZIc) = ast_make_count(0, AST_COUNT_UNBOUNDED); @@ -1805,7 +1805,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e /* END OF ACTION: count-zero-or-more */ /* BEGINNING OF ACTION: ast-make-piece */ { -#line 897 "src/libre/parser.act" +#line 898 "src/libre/parser.act" if ((ZIc).min == 0 && (ZIc).max == 0) { (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); @@ -1832,7 +1832,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e ADVANCE_LEXER; /* BEGINNING OF ACTION: make-group-id */ { -#line 881 "src/libre/parser.act" +#line 882 "src/libre/parser.act" (ZIid) = act_state->group_id++; @@ -1846,7 +1846,7 @@ p_expr_C_Cpiece_C_Catom(flags flags, lex_state lex_state, act_state act_state, e } /* BEGINNING OF ACTION: ast-make-group */ { -#line 911 "src/libre/parser.act" +#line 912 "src/libre/parser.act" (ZIe) = ast_make_expr_group(act_state->poolp, *flags, (ZIg), (ZIid)); if ((ZIe) == NULL) { @@ -1884,7 +1884,7 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-atom */ { -#line 704 "src/libre/parser.act" +#line 708 "src/libre/parser.act" if (err->e == RE_ESUCCESS) { err->e = RE_EXATOM; @@ -1896,7 +1896,7 @@ ZL1:; /* END OF ACTION: err-expected-atom */ /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZIe) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZIe) == NULL) { @@ -1932,7 +1932,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hnamed(flags flags, lex_state lex_state, act case (TOK_NAMED__CLASS): /* BEGINNING OF EXTRACT: NAMED_CLASS */ { -#line 647 "src/libre/parser.act" +#line 648 "src/libre/parser.act" ZIid = DIALECT_CLASS(lex_state->buf.a); if (ZIid == NULL) { @@ -1956,7 +1956,7 @@ p_expr_C_Ccharacter_Hclass_C_Cclass_Hnamed(flags flags, lex_state lex_state, act ADVANCE_LEXER; /* BEGINNING OF ACTION: ast-make-named */ { -#line 1033 "src/libre/parser.act" +#line 1034 "src/libre/parser.act" (ZInode) = ast_make_expr_named(act_state->poolp, *flags, (ZIid)); if ((ZInode) == NULL) { @@ -1986,7 +1986,7 @@ p_expr_C_Calt(flags flags, lex_state lex_state, act_state act_state, err err, t_ { /* BEGINNING OF ACTION: ast-make-concat */ { -#line 860 "src/libre/parser.act" +#line 861 "src/libre/parser.act" (ZInode) = ast_make_expr_concat(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2007,7 +2007,7 @@ p_expr_C_Calt(flags flags, lex_state lex_state, act_state act_state, err err, t_ { /* BEGINNING OF ACTION: ast-make-empty */ { -#line 853 "src/libre/parser.act" +#line 854 "src/libre/parser.act" (ZInode) = ast_make_expr_empty(act_state->poolp, *flags); if ((ZInode) == NULL) { @@ -2032,7 +2032,7 @@ ZL0:; /* BEGINNING OF TRAILER */ -#line 1052 "src/libre/parser.act" +#line 1207 "src/libre/parser.act" static int @@ -2052,7 +2052,6 @@ ZL0:; struct ast * DIALECT_PARSE(re_getchar_fun *f, void *opaque, - const struct fsm_options *opt, enum re_flags flags, int overlap, struct re_err *err, struct re_pos *end) { @@ -2189,6 +2188,6 @@ ZL0:; return NULL; } -#line 2193 "src/libre/dialect/sql/parser.c" +#line 2192 "src/libre/dialect/sql/parser.c" /* END OF FILE */ diff --git a/src/libre/dialect/sql/parser.h b/src/libre/dialect/sql/parser.h index e9850510a..c5e885439 100644 --- a/src/libre/dialect/sql/parser.h +++ b/src/libre/dialect/sql/parser.h @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 281 "src/libre/parser.act" +#line 292 "src/libre/parser.act" #include @@ -28,7 +28,7 @@ extern void p_re__sql(flags, lex_state, act_state, err, t_ast__expr *); /* BEGINNING OF TRAILER */ -#line 1208 "src/libre/parser.act" +#line 1209 "src/libre/parser.act" #line 35 "src/libre/dialect/sql/parser.h" diff --git a/src/libre/parser.act b/src/libre/parser.act index d8d0e2ac4..984036cb8 100644 --- a/src/libre/parser.act +++ b/src/libre/parser.act @@ -1068,7 +1068,6 @@ struct ast * DIALECT_PARSE(re_getchar_fun *f, void *opaque, - const struct fsm_options *opt, enum re_flags flags, int overlap, struct re_err *err, struct re_pos *end) { diff --git a/src/libre/re.c b/src/libre/re.c index 3e9ee5753..15af848b5 100644 --- a/src/libre/re.c +++ b/src/libre/re.c @@ -91,7 +91,6 @@ re_flags(const char *s, enum re_flags *f) struct ast * re_parse(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, - const struct fsm_options *opt, enum re_flags flags, struct re_err *err, int *unsatisfiable) { const struct dialect *m; @@ -109,7 +108,7 @@ re_parse(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, flags |= m->flags; - ast = m->parse(getc, opaque, opt, flags, m->overlap, err, &end); + ast = m->parse(getc, opaque, flags, m->overlap, err, &end); if (ast == NULL) { return NULL; @@ -177,7 +176,6 @@ re_parse(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, struct fsm * re_comp(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, const struct fsm_alloc *alloc, - const struct fsm_options *opt, enum re_flags flags, struct re_err *err) { struct ast *ast; @@ -195,7 +193,7 @@ re_comp(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, flags |= m->flags; - ast = re_parse(dialect, getc, opaque, opt, flags, err, &unsatisfiable); + ast = re_parse(dialect, getc, opaque, flags, err, &unsatisfiable); if (ast == NULL) { return NULL; } @@ -213,7 +211,7 @@ re_comp(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, ast->expr = ast_expr_tombstone; } - new = ast_compile(ast, flags, alloc, opt, err); + new = ast_compile(ast, flags, alloc, err); ast_free(ast); @@ -243,7 +241,6 @@ re_comp(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, */ int re_is_literal(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, - const struct fsm_options *opt, enum re_flags flags, struct re_err *err, enum re_literal_category *category, char **s, size_t *n) { @@ -264,7 +261,7 @@ re_is_literal(enum re_dialect dialect, int (*getc)(void *opaque), void *opaque, flags |= m->flags; - ast = re_parse(dialect, getc, opaque, opt, flags, err, &unsatisfiable); + ast = re_parse(dialect, getc, opaque, flags, err, &unsatisfiable); if (ast == NULL) { return -1; } diff --git a/src/libre/re_strings.c b/src/libre/re_strings.c index 34a9fa0fe..dc554c801 100644 --- a/src/libre/re_strings.c +++ b/src/libre/re_strings.c @@ -19,7 +19,7 @@ #include "ac.h" struct fsm * -re_strings(const struct fsm_alloc *alloc, const struct fsm_options *opt, +re_strings(const struct fsm_alloc *alloc, const char *a[], size_t n, enum re_strings_flags flags) { @@ -38,7 +38,7 @@ re_strings(const struct fsm_alloc *alloc, const struct fsm_options *opt, } } - fsm = re_strings_build(g, alloc, opt, flags); + fsm = re_strings_build(g, alloc, flags); re_strings_free(g); return fsm; @@ -84,7 +84,6 @@ re_strings_add_str(struct re_strings *g, const char *s, const fsm_end_id_t *endi struct fsm * re_strings_build(struct re_strings *g, const struct fsm_alloc *alloc, - const struct fsm_options *opt, enum re_strings_flags flags) { struct fsm *fsm; @@ -105,8 +104,6 @@ re_strings_build(struct re_strings *g, goto error; } - fsm_setoptions(fsm, opt); - have_end = 0; if ((flags & RE_STRINGS_AC_AUTOMATON) == 0 && (flags & RE_STRINGS_ANCHOR_RIGHT) == 0) { diff --git a/src/lx/ast.c b/src/lx/ast.c index 97977b803..58646ca68 100644 --- a/src/lx/ast.c +++ b/src/lx/ast.c @@ -123,8 +123,6 @@ ast_addmapping(struct ast_zone *z, struct fsm *fsm, return NULL; } - fsm_setoptions(m->fsm, fsm->opt); - m->token = token; m->to = to; m->conflict = NULL; diff --git a/src/lx/main.c b/src/lx/main.c index 572014171..fb7a176f4 100644 --- a/src/lx/main.c +++ b/src/lx/main.c @@ -308,15 +308,9 @@ zone_equal(const struct ast_zone *a, const struct ast_zone *b) return -1; } - { - /* opt.carryopaque = carryopaque; */ - - if (!fsm_determinise(q)) { - fsm_free(q); - return -1; - } - - /* opt.carryopaque = NULL; */ + if (!fsm_determinise(q)) { + fsm_free(q); + return -1; } { @@ -383,8 +377,6 @@ zone_minimise(void *arg) return "fsm_new"; } - fsm_setoptions(z->fsm, &opt); - if (!fsm_addstate(z->fsm, &start)) { pthread_mutex_lock(&zmtx); zerror = errno; @@ -647,7 +639,7 @@ main(int argc, char *argv[]) fprintf(stderr, "-- parsing:"); } - ast = lx_parse(stdin, alloc, &opt); + ast = lx_parse(stdin, alloc); if (ast == NULL) { return EXIT_FAILURE; } @@ -693,12 +685,10 @@ main(int argc, char *argv[]) zn = 0; } - /* opt.carryopaque = carryopaque; */ cur_zone = ast->zl; if (run_threads(concurrency, zone_determinise)) { return EXIT_FAILURE; } - /* opt.carryopaque = NULL; */ if (print_progress) { fprintf(stderr, "\n"); @@ -955,7 +945,7 @@ main(int argc, char *argv[]) fprintf(stderr, "-- output:"); } - lx_print(stdout, ast, lang); + lx_print(stdout, ast, &opt, lang); if (print_progress) { fprintf(stderr, "\n"); diff --git a/src/lx/parser.act b/src/lx/parser.act index 04001783f..0db0c3bb5 100644 --- a/src/lx/parser.act +++ b/src/lx/parser.act @@ -38,7 +38,6 @@ #include #include #include - #include #include @@ -68,7 +67,6 @@ enum lx_token lex_tok; enum lx_token lex_tok_save; unsigned int zn; - const struct fsm_options *opt; const struct fsm_alloc *alloc; }; @@ -136,8 +134,7 @@ typedef struct act_state * act_state; typedef struct ast * ast; - struct ast *lx_parse(FILE *f, - const struct fsm_alloc *alloc, const struct fsm_options *opt); + struct ast *lx_parse(FILE *f, const struct fsm_alloc *alloc); @}; @@ -317,8 +314,6 @@ @!; } - fsm_setoptions(@r, act_state->opt); - if (!fsm_addstate(@r, &start)) { perror("fsm_addstate"); @!; @@ -369,7 +364,7 @@ assert(@a != NULL); assert(@a->p != NULL); - @r = re_comp(RE_LITERAL, act_agetc, @a, act_state->alloc, act_state->opt, 0, &err); + @r = re_comp(RE_LITERAL, act_agetc, @a, act_state->alloc, 0, &err); if (@r == NULL) { assert(err.e != RE_EBADDIALECT); /* TODO: pass filename for .lx source */ @@ -384,7 +379,7 @@ assert(@a != NULL); assert(@a->p != NULL); - @r = re_comp(RE_NATIVE, act_agetc, @a, act_state->alloc, act_state->opt, @f, &err); + @r = re_comp(RE_NATIVE, act_agetc, @a, act_state->alloc, @f, &err); if (@r == NULL) { assert(err.e != RE_EBADDIALECT); /* TODO: pass filename for .lx source */ @@ -403,8 +398,6 @@ @!; } - fsm_setoptions(@r, act_state->opt); - if (!fsm_addstate(@r, &start)) { perror("fsm_addstate"); fsm_free(@r); @@ -824,7 +817,7 @@ %trailer% @{ - struct ast *lx_parse(FILE *f, const struct fsm_alloc *alloc, const struct fsm_options *opt) { + struct ast *lx_parse(FILE *f, const struct fsm_alloc *alloc) { struct act_state act_state_s; struct act_state *act_state; struct lex_state lex_state_s; @@ -856,7 +849,6 @@ /* This is a workaround for ADVANCE_LEXER assuming a pointer */ act_state = &act_state_s; - act_state->opt = opt; act_state->alloc = alloc; if (print_progress) { diff --git a/src/lx/parser.c b/src/lx/parser.c index b492f4cd5..f6f759693 100644 --- a/src/lx/parser.c +++ b/src/lx/parser.c @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 129 "src/lx/parser.act" +#line 127 "src/lx/parser.act" #include @@ -24,7 +24,6 @@ #include #include #include - #include #include @@ -54,7 +53,6 @@ enum lx_token lex_tok; enum lx_token lex_tok_save; unsigned int zn; - const struct fsm_options *opt; const struct fsm_alloc *alloc; }; @@ -112,7 +110,7 @@ return a->len--, (unsigned char) *a->p++; } -#line 116 "src/lx/parser.c" +#line 114 "src/lx/parser.c" #ifndef ERROR_TERMINAL @@ -184,11 +182,11 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-list */ { -#line 823 "src/lx/parser.act" +#line 816 "src/lx/parser.act" err_expected(lex_state, "list of mappings, bindings or zones"); -#line 192 "src/lx/parser.c" +#line 190 "src/lx/parser.c" } /* END OF ACTION: err-expected-list */ } @@ -206,17 +204,17 @@ p_pattern(lex_state lex_state, act_state act_state, zone ZIz, fsm *ZOr) /* BEGINNING OF EXTRACT: IDENT */ { -#line 231 "src/lx/parser.act" +#line 228 "src/lx/parser.act" ZIn = xstrdup(lex_state->buf.a); -#line 214 "src/lx/parser.c" +#line 212 "src/lx/parser.c" } /* END OF EXTRACT: IDENT */ ADVANCE_LEXER; /* BEGINNING OF ACTION: deref-var */ { -#line 283 "src/lx/parser.act" +#line 280 "src/lx/parser.act" struct ast_zone *z; @@ -243,7 +241,7 @@ p_pattern(lex_state lex_state, act_state act_state, zone ZIz, fsm *ZOr) goto ZL1; } -#line 247 "src/lx/parser.c" +#line 245 "src/lx/parser.c" } /* END OF ACTION: deref-var */ } @@ -254,18 +252,18 @@ p_pattern(lex_state lex_state, act_state act_state, zone ZIz, fsm *ZOr) /* BEGINNING OF EXTRACT: TOKEN */ { -#line 227 "src/lx/parser.act" +#line 224 "src/lx/parser.act" /* TODO: submatch addressing */ ZIt = xstrdup(lex_state->buf.a + 1); /* +1 for '$' prefix */ -#line 263 "src/lx/parser.c" +#line 261 "src/lx/parser.c" } /* END OF EXTRACT: TOKEN */ ADVANCE_LEXER; /* BEGINNING OF ACTION: deref-token */ { -#line 311 "src/lx/parser.act" +#line 308 "src/lx/parser.act" const struct ast_mapping *m; fsm_state_t start; @@ -279,8 +277,6 @@ p_pattern(lex_state lex_state, act_state act_state, zone ZIz, fsm *ZOr) goto ZL1; } - fsm_setoptions((ZIr), act_state->opt); - if (!fsm_addstate((ZIr), &start)) { perror("fsm_addstate"); goto ZL1; @@ -324,7 +320,7 @@ p_pattern(lex_state lex_state, act_state act_state, zone ZIz, fsm *ZOr) fsm_setstart((ZIr), start); -#line 328 "src/lx/parser.c" +#line 324 "src/lx/parser.c" } /* END OF ACTION: deref-token */ } @@ -378,7 +374,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } /* BEGINNING OF ACTION: op-reverse */ { -#line 684 "src/lx/parser.act" +#line 677 "src/lx/parser.act" assert((ZI210) != NULL); @@ -387,7 +383,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z goto ZL1; } -#line 391 "src/lx/parser.c" +#line 387 "src/lx/parser.c" } /* END OF ACTION: op-reverse */ p_212 (lex_state, act_state, &ZIz, &ZI210, &ZI206); @@ -402,7 +398,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } /* BEGINNING OF ACTION: subtract-exit */ { -#line 743 "src/lx/parser.act" +#line 736 "src/lx/parser.act" assert((ZI231) != NULL); @@ -422,7 +418,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } } -#line 426 "src/lx/parser.c" +#line 422 "src/lx/parser.c" } /* END OF ACTION: subtract-exit */ p_251 (lex_state, act_state, &ZIa, &ZIz, &ZIexit, &ZI232, &ZI233); @@ -453,7 +449,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } /* BEGINNING OF ACTION: op-complete */ { -#line 675 "src/lx/parser.act" +#line 668 "src/lx/parser.act" assert((ZI210) != NULL); @@ -462,7 +458,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z goto ZL1; } -#line 466 "src/lx/parser.c" +#line 462 "src/lx/parser.c" } /* END OF ACTION: op-complete */ p_212 (lex_state, act_state, &ZIz, &ZI210, &ZI206); @@ -477,7 +473,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } /* BEGINNING OF ACTION: subtract-exit */ { -#line 743 "src/lx/parser.act" +#line 736 "src/lx/parser.act" assert((ZI239) != NULL); @@ -497,7 +493,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } } -#line 501 "src/lx/parser.c" +#line 497 "src/lx/parser.c" } /* END OF ACTION: subtract-exit */ p_251 (lex_state, act_state, &ZIa, &ZIz, &ZIexit, &ZI240, &ZI241); @@ -513,11 +509,11 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z /* BEGINNING OF EXTRACT: IDENT */ { -#line 231 "src/lx/parser.act" +#line 228 "src/lx/parser.act" ZIn = xstrdup(lex_state->buf.a); -#line 521 "src/lx/parser.c" +#line 517 "src/lx/parser.c" } /* END OF EXTRACT: IDENT */ ADVANCE_LEXER; @@ -567,7 +563,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } /* BEGINNING OF ACTION: subtract-exit */ { -#line 743 "src/lx/parser.act" +#line 736 "src/lx/parser.act" assert((ZI248) != NULL); @@ -587,7 +583,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } } -#line 591 "src/lx/parser.c" +#line 587 "src/lx/parser.c" } /* END OF ACTION: subtract-exit */ p_251 (lex_state, act_state, &ZIa, &ZIz, &ZIexit, &ZI249, &ZI250); @@ -618,7 +614,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } /* BEGINNING OF ACTION: op-complement */ { -#line 666 "src/lx/parser.act" +#line 659 "src/lx/parser.act" assert((ZI210) != NULL); @@ -627,7 +623,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z goto ZL1; } -#line 631 "src/lx/parser.c" +#line 627 "src/lx/parser.c" } /* END OF ACTION: op-complement */ p_212 (lex_state, act_state, &ZIz, &ZI210, &ZI206); @@ -642,7 +638,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } /* BEGINNING OF ACTION: subtract-exit */ { -#line 743 "src/lx/parser.act" +#line 736 "src/lx/parser.act" assert((ZI223) != NULL); @@ -662,7 +658,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } } -#line 666 "src/lx/parser.c" +#line 662 "src/lx/parser.c" } /* END OF ACTION: subtract-exit */ p_251 (lex_state, act_state, &ZIa, &ZIz, &ZIexit, &ZI224, &ZI225); @@ -689,18 +685,18 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z /* BEGINNING OF EXTRACT: TOKEN */ { -#line 227 "src/lx/parser.act" +#line 224 "src/lx/parser.act" /* TODO: submatch addressing */ ZI253 = xstrdup(lex_state->buf.a + 1); /* +1 for '$' prefix */ -#line 698 "src/lx/parser.c" +#line 694 "src/lx/parser.c" } /* END OF EXTRACT: TOKEN */ ADVANCE_LEXER; /* BEGINNING OF ACTION: deref-token */ { -#line 311 "src/lx/parser.act" +#line 308 "src/lx/parser.act" const struct ast_mapping *m; fsm_state_t start; @@ -714,8 +710,6 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z goto ZL1; } - fsm_setoptions((ZI254), act_state->opt); - if (!fsm_addstate((ZI254), &start)) { perror("fsm_addstate"); goto ZL1; @@ -759,7 +753,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z fsm_setstart((ZI254), start); -#line 763 "src/lx/parser.c" +#line 757 "src/lx/parser.c" } /* END OF ACTION: deref-token */ p_197 (lex_state, act_state, ZI254, &ZI210); @@ -775,7 +769,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } /* BEGINNING OF ACTION: subtract-exit */ { -#line 743 "src/lx/parser.act" +#line 736 "src/lx/parser.act" assert((ZI259) != NULL); @@ -795,7 +789,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } } -#line 799 "src/lx/parser.c" +#line 793 "src/lx/parser.c" } /* END OF ACTION: subtract-exit */ p_251 (lex_state, act_state, &ZIa, &ZIz, &ZIexit, &ZI260, &ZI261); @@ -835,7 +829,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } /* BEGINNING OF ACTION: subtract-exit */ { -#line 743 "src/lx/parser.act" +#line 736 "src/lx/parser.act" assert((ZI268) != NULL); @@ -855,7 +849,7 @@ p_list_Hof_Hthings_C_Cthing(lex_state lex_state, act_state act_state, ast ZIa, z } } -#line 859 "src/lx/parser.c" +#line 853 "src/lx/parser.c" } /* END OF ACTION: subtract-exit */ p_251 (lex_state, act_state, &ZIa, &ZIz, &ZIexit, &ZI269, &ZI270); @@ -875,11 +869,11 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-thing */ { -#line 819 "src/lx/parser.act" +#line 812 "src/lx/parser.act" err_expected(lex_state, "mapping, binding or zone"); -#line 883 "src/lx/parser.c" +#line 877 "src/lx/parser.c" } /* END OF ACTION: err-expected-thing */ } @@ -905,11 +899,11 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-open */ { -#line 807 "src/lx/parser.act" +#line 800 "src/lx/parser.act" err_expected(lex_state, "'{'"); -#line 913 "src/lx/parser.c" +#line 907 "src/lx/parser.c" } /* END OF ACTION: err-expected-open */ } @@ -935,11 +929,11 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-close */ { -#line 811 "src/lx/parser.act" +#line 804 "src/lx/parser.act" err_expected(lex_state, "'}'"); -#line 943 "src/lx/parser.c" +#line 937 "src/lx/parser.c" } /* END OF ACTION: err-expected-close */ } @@ -961,14 +955,14 @@ ZL2_pattern_C_Cbody:; { /* BEGINNING OF EXTRACT: CHAR */ { -#line 222 "src/lx/parser.act" +#line 219 "src/lx/parser.act" assert(lex_state->buf.a[0] != '\0'); assert(lex_state->buf.a[1] == '\0'); ZIc = lex_state->buf.a[0]; -#line 972 "src/lx/parser.c" +#line 966 "src/lx/parser.c" } /* END OF EXTRACT: CHAR */ ADVANCE_LEXER; @@ -978,7 +972,7 @@ ZL2_pattern_C_Cbody:; { /* BEGINNING OF EXTRACT: ESC */ { -#line 152 "src/lx/parser.act" +#line 149 "src/lx/parser.act" assert(lex_state->buf.a[0] == '\\'); assert(lex_state->buf.a[1] != '\0'); @@ -996,7 +990,7 @@ ZL2_pattern_C_Cbody:; default: ZIc = '\0'; break; /* TODO: handle error */ } -#line 1000 "src/lx/parser.c" +#line 994 "src/lx/parser.c" } /* END OF EXTRACT: ESC */ ADVANCE_LEXER; @@ -1006,7 +1000,7 @@ ZL2_pattern_C_Cbody:; { /* BEGINNING OF EXTRACT: HEX */ { -#line 215 "src/lx/parser.act" +#line 212 "src/lx/parser.act" unsigned long u; char *e; @@ -1033,7 +1027,7 @@ ZL2_pattern_C_Cbody:; ZIc = (char) (unsigned char) u; -#line 1037 "src/lx/parser.c" +#line 1031 "src/lx/parser.c" } /* END OF EXTRACT: HEX */ ADVANCE_LEXER; @@ -1043,7 +1037,7 @@ ZL2_pattern_C_Cbody:; { /* BEGINNING OF EXTRACT: OCT */ { -#line 188 "src/lx/parser.act" +#line 185 "src/lx/parser.act" unsigned long u; char *e; @@ -1070,7 +1064,7 @@ ZL2_pattern_C_Cbody:; ZIc = (char) (unsigned char) u; -#line 1074 "src/lx/parser.c" +#line 1068 "src/lx/parser.c" } /* END OF EXTRACT: OCT */ ADVANCE_LEXER; @@ -1083,12 +1077,12 @@ ZL2_pattern_C_Cbody:; /* END OF INLINE: 84 */ /* BEGINNING OF ACTION: pattern-char */ { -#line 252 "src/lx/parser.act" +#line 249 "src/lx/parser.act" /* TODO */ *lex_state->p++ = (ZIc); -#line 1092 "src/lx/parser.c" +#line 1086 "src/lx/parser.c" } /* END OF ACTION: pattern-char */ /* BEGINNING OF INLINE: pattern::body */ @@ -1217,7 +1211,7 @@ ZL2_180:; } /* BEGINNING OF ACTION: op-alt */ { -#line 732 "src/lx/parser.act" +#line 725 "src/lx/parser.act" assert((ZI177) != NULL); assert((ZIb) != NULL); @@ -1228,7 +1222,7 @@ ZL2_180:; goto ZL1; } -#line 1232 "src/lx/parser.c" +#line 1226 "src/lx/parser.c" } /* END OF ACTION: op-alt */ /* BEGINNING OF INLINE: 180 */ @@ -1297,7 +1291,7 @@ p_expr_C_Cprefix_Hexpr(lex_state lex_state, act_state act_state, zone ZIz, fsm * } /* BEGINNING OF ACTION: op-reverse */ { -#line 684 "src/lx/parser.act" +#line 677 "src/lx/parser.act" assert((ZIq) != NULL); @@ -1306,7 +1300,7 @@ p_expr_C_Cprefix_Hexpr(lex_state lex_state, act_state act_state, zone ZIz, fsm * goto ZL1; } -#line 1310 "src/lx/parser.c" +#line 1304 "src/lx/parser.c" } /* END OF ACTION: op-reverse */ } @@ -1321,7 +1315,7 @@ p_expr_C_Cprefix_Hexpr(lex_state lex_state, act_state act_state, zone ZIz, fsm * } /* BEGINNING OF ACTION: op-complete */ { -#line 675 "src/lx/parser.act" +#line 668 "src/lx/parser.act" assert((ZIq) != NULL); @@ -1330,7 +1324,7 @@ p_expr_C_Cprefix_Hexpr(lex_state lex_state, act_state act_state, zone ZIz, fsm * goto ZL1; } -#line 1334 "src/lx/parser.c" +#line 1328 "src/lx/parser.c" } /* END OF ACTION: op-complete */ } @@ -1345,7 +1339,7 @@ p_expr_C_Cprefix_Hexpr(lex_state lex_state, act_state act_state, zone ZIz, fsm * } /* BEGINNING OF ACTION: op-complement */ { -#line 666 "src/lx/parser.act" +#line 659 "src/lx/parser.act" assert((ZIq) != NULL); @@ -1354,7 +1348,7 @@ p_expr_C_Cprefix_Hexpr(lex_state lex_state, act_state act_state, zone ZIz, fsm * goto ZL1; } -#line 1358 "src/lx/parser.c" +#line 1352 "src/lx/parser.c" } /* END OF ACTION: op-complement */ } @@ -1404,7 +1398,7 @@ ZL2_186:; } /* BEGINNING OF ACTION: op-intersect */ { -#line 721 "src/lx/parser.act" +#line 714 "src/lx/parser.act" assert((ZI183) != NULL); assert((ZIb) != NULL); @@ -1415,7 +1409,7 @@ ZL2_186:; goto ZL1; } -#line 1419 "src/lx/parser.c" +#line 1413 "src/lx/parser.c" } /* END OF ACTION: op-intersect */ /* BEGINNING OF INLINE: 186 */ @@ -1461,7 +1455,7 @@ ZL2_list_Hof_Hthings_C_Czone_Hthing_C_Clist_Hof_Hzone_Hto_Hmappings_C_Clist_Hof_ } /* BEGINNING OF ACTION: op-alt */ { -#line 732 "src/lx/parser.act" +#line 725 "src/lx/parser.act" assert((ZIold_Hexit) != NULL); assert((ZInew_Hexit) != NULL); @@ -1472,7 +1466,7 @@ ZL2_list_Hof_Hthings_C_Czone_Hthing_C_Clist_Hof_Hzone_Hto_Hmappings_C_Clist_Hof_ goto ZL1; } -#line 1476 "src/lx/parser.c" +#line 1470 "src/lx/parser.c" } /* END OF ACTION: op-alt */ /* BEGINNING OF INLINE: list-of-things::zone-thing::list-of-zone-to-mappings::list-of-zone-to-mappings-x */ @@ -1560,7 +1554,7 @@ ZL2_197:; ADVANCE_LEXER; /* BEGINNING OF ACTION: op-cross */ { -#line 582 "src/lx/parser.act" +#line 575 "src/lx/parser.act" fsm_state_t start, end; fsm_state_t old; @@ -1605,7 +1599,7 @@ ZL2_197:; fsm_setstart((ZIq), start); -#line 1609 "src/lx/parser.c" +#line 1603 "src/lx/parser.c" } /* END OF ACTION: op-cross */ /* BEGINNING OF INLINE: 197 */ @@ -1619,7 +1613,7 @@ ZL2_197:; ADVANCE_LEXER; /* BEGINNING OF ACTION: op-qmark */ { -#line 627 "src/lx/parser.act" +#line 620 "src/lx/parser.act" fsm_state_t start, end; fsm_state_t old; @@ -1664,7 +1658,7 @@ ZL2_197:; fsm_setstart((ZIq), start); -#line 1668 "src/lx/parser.c" +#line 1662 "src/lx/parser.c" } /* END OF ACTION: op-qmark */ /* BEGINNING OF INLINE: 197 */ @@ -1678,7 +1672,7 @@ ZL2_197:; ADVANCE_LEXER; /* BEGINNING OF ACTION: op-star */ { -#line 532 "src/lx/parser.act" +#line 525 "src/lx/parser.act" fsm_state_t start, end; fsm_state_t old; @@ -1728,7 +1722,7 @@ ZL2_197:; fsm_setstart((ZIq), start); -#line 1732 "src/lx/parser.c" +#line 1726 "src/lx/parser.c" } /* END OF ACTION: op-star */ /* BEGINNING OF INLINE: 197 */ @@ -1801,7 +1795,7 @@ p_204(lex_state lex_state, act_state act_state, zone *ZIz, fsm *ZI202, fsm *ZOq) } /* BEGINNING OF ACTION: op-subtract */ { -#line 710 "src/lx/parser.act" +#line 703 "src/lx/parser.act" assert((*ZI202) != NULL); assert((ZIb) != NULL); @@ -1812,7 +1806,7 @@ p_204(lex_state lex_state, act_state act_state, zone *ZIz, fsm *ZI202, fsm *ZOq) goto ZL1; } -#line 1816 "src/lx/parser.c" +#line 1810 "src/lx/parser.c" } /* END OF ACTION: op-subtract */ } @@ -1876,7 +1870,7 @@ p_208(lex_state lex_state, act_state act_state, zone *ZIz, fsm *ZI206, fsm *ZOq) } /* BEGINNING OF ACTION: op-concat */ { -#line 693 "src/lx/parser.act" +#line 686 "src/lx/parser.act" assert((*ZI206) != NULL); assert((ZIb) != NULL); @@ -1887,7 +1881,7 @@ p_208(lex_state lex_state, act_state act_state, zone *ZIz, fsm *ZI206, fsm *ZOq) goto ZL1; } -#line 1891 "src/lx/parser.c" +#line 1885 "src/lx/parser.c" } /* END OF ACTION: op-concat */ } @@ -1926,13 +1920,13 @@ p_212(lex_state lex_state, act_state act_state, zone *ZIz, fsm *ZI210, fsm *ZOq) } /* BEGINNING OF ACTION: op-product */ { -#line 705 "src/lx/parser.act" +#line 698 "src/lx/parser.act" fprintf(stderr, "unimplemented\n"); (ZIq) = NULL; goto ZL1; -#line 1936 "src/lx/parser.c" +#line 1930 "src/lx/parser.c" } /* END OF ACTION: op-product */ } @@ -1966,7 +1960,7 @@ p_215(lex_state lex_state, act_state act_state, fsm *ZOr) /* BEGINNING OF EXTRACT: RE */ { -#line 239 "src/lx/parser.act" +#line 236 "src/lx/parser.act" assert(lex_state->buf.a[0] == '/'); @@ -1980,13 +1974,13 @@ p_215(lex_state lex_state, act_state act_state, fsm *ZOr) ZIf |= RE_ANCHORED; /* regexps in lx are implicitly anchored */ ZIf |= RE_SINGLE; /* we can't assume we're lexing text */ -#line 1984 "src/lx/parser.c" +#line 1978 "src/lx/parser.c" } /* END OF EXTRACT: RE */ ADVANCE_LEXER; /* BEGINNING OF ACTION: pattern-buffer */ { -#line 266 "src/lx/parser.act" +#line 263 "src/lx/parser.act" size_t len; @@ -2011,19 +2005,19 @@ p_215(lex_state lex_state, act_state act_state, fsm *ZOr) lex_state->p = lex_state->a; -#line 2015 "src/lx/parser.c" +#line 2009 "src/lx/parser.c" } /* END OF ACTION: pattern-buffer */ /* BEGINNING OF ACTION: compile-regex */ { -#line 384 "src/lx/parser.act" +#line 379 "src/lx/parser.act" struct re_err err; assert((ZIa) != NULL); assert((ZIa)->p != NULL); - (ZIr) = re_comp(RE_NATIVE, act_agetc, (ZIa), act_state->alloc, act_state->opt, (ZIf), &err); + (ZIr) = re_comp(RE_NATIVE, act_agetc, (ZIa), act_state->alloc, (ZIf), &err); if ((ZIr) == NULL) { assert(err.e != RE_EBADDIALECT); /* TODO: pass filename for .lx source */ @@ -2031,16 +2025,16 @@ p_215(lex_state lex_state, act_state act_state, fsm *ZOr) exit(EXIT_FAILURE); } -#line 2035 "src/lx/parser.c" +#line 2029 "src/lx/parser.c" } /* END OF ACTION: compile-regex */ /* BEGINNING OF ACTION: free-arr */ { -#line 773 "src/lx/parser.act" +#line 766 "src/lx/parser.act" free((ZIa)); -#line 2044 "src/lx/parser.c" +#line 2038 "src/lx/parser.c" } /* END OF ACTION: free-arr */ } @@ -2052,7 +2046,7 @@ p_215(lex_state lex_state, act_state act_state, fsm *ZOr) ADVANCE_LEXER; /* BEGINNING OF ACTION: pattern-buffer */ { -#line 266 "src/lx/parser.act" +#line 263 "src/lx/parser.act" size_t len; @@ -2077,19 +2071,19 @@ p_215(lex_state lex_state, act_state act_state, fsm *ZOr) lex_state->p = lex_state->a; -#line 2081 "src/lx/parser.c" +#line 2075 "src/lx/parser.c" } /* END OF ACTION: pattern-buffer */ /* BEGINNING OF ACTION: compile-literal */ { -#line 369 "src/lx/parser.act" +#line 364 "src/lx/parser.act" struct re_err err; assert((ZIa) != NULL); assert((ZIa)->p != NULL); - (ZIr) = re_comp(RE_LITERAL, act_agetc, (ZIa), act_state->alloc, act_state->opt, 0, &err); + (ZIr) = re_comp(RE_LITERAL, act_agetc, (ZIa), act_state->alloc, 0, &err); if ((ZIr) == NULL) { assert(err.e != RE_EBADDIALECT); /* TODO: pass filename for .lx source */ @@ -2097,16 +2091,16 @@ p_215(lex_state lex_state, act_state act_state, fsm *ZOr) exit(EXIT_FAILURE); } -#line 2101 "src/lx/parser.c" +#line 2095 "src/lx/parser.c" } /* END OF ACTION: compile-literal */ /* BEGINNING OF ACTION: free-arr */ { -#line 773 "src/lx/parser.act" +#line 766 "src/lx/parser.act" free((ZIa)); -#line 2110 "src/lx/parser.c" +#line 2104 "src/lx/parser.c" } /* END OF ACTION: free-arr */ } @@ -2170,7 +2164,7 @@ ZL2_list_Hof_Hthings_C_Czone_Hthing_C_Clist_Hof_Hzone_Hfrom_Hmappings_C_Clist_Ho } /* BEGINNING OF ACTION: subtract-exit */ { -#line 743 "src/lx/parser.act" +#line 736 "src/lx/parser.act" assert((ZIr) != NULL); @@ -2190,12 +2184,12 @@ ZL2_list_Hof_Hthings_C_Czone_Hthing_C_Clist_Hof_Hzone_Hfrom_Hmappings_C_Clist_Ho } } -#line 2194 "src/lx/parser.c" +#line 2188 "src/lx/parser.c" } /* END OF ACTION: subtract-exit */ /* BEGINNING OF ACTION: add-mapping */ { -#line 460 "src/lx/parser.act" +#line 453 "src/lx/parser.act" struct ast_token *t; struct ast_mapping *m; @@ -2228,7 +2222,7 @@ ZL2_list_Hof_Hthings_C_Czone_Hthing_C_Clist_Hof_Hzone_Hfrom_Hmappings_C_Clist_Ho nmappings++; } -#line 2232 "src/lx/parser.c" +#line 2226 "src/lx/parser.c" } /* END OF ACTION: add-mapping */ /* BEGINNING OF INLINE: list-of-things::zone-thing::list-of-zone-from-mappings::list-of-zone-from-mappings-x */ @@ -2262,16 +2256,16 @@ p_lx(lex_state lex_state, act_state act_state, ast *ZOa) /* BEGINNING OF ACTION: no-zone */ { -#line 522 "src/lx/parser.act" +#line 515 "src/lx/parser.act" (ZIparent) = NULL; -#line 2270 "src/lx/parser.c" +#line 2264 "src/lx/parser.c" } /* END OF ACTION: no-zone */ /* BEGINNING OF ACTION: make-ast */ { -#line 431 "src/lx/parser.act" +#line 424 "src/lx/parser.act" (ZIa) = ast_new(); if ((ZIa) == NULL) { @@ -2279,12 +2273,12 @@ p_lx(lex_state lex_state, act_state act_state, ast *ZOa) goto ZL1; } -#line 2283 "src/lx/parser.c" +#line 2277 "src/lx/parser.c" } /* END OF ACTION: make-ast */ /* BEGINNING OF ACTION: make-zone */ { -#line 439 "src/lx/parser.act" +#line 432 "src/lx/parser.act" assert((ZIa) != NULL); @@ -2302,28 +2296,28 @@ p_lx(lex_state lex_state, act_state act_state, ast *ZOa) goto ZL1; } -#line 2306 "src/lx/parser.c" +#line 2300 "src/lx/parser.c" } /* END OF ACTION: make-zone */ /* BEGINNING OF ACTION: no-exit */ { -#line 518 "src/lx/parser.act" +#line 511 "src/lx/parser.act" (ZIexit) = NULL; -#line 2315 "src/lx/parser.c" +#line 2309 "src/lx/parser.c" } /* END OF ACTION: no-exit */ /* BEGINNING OF ACTION: set-globalzone */ { -#line 507 "src/lx/parser.act" +#line 500 "src/lx/parser.act" assert((ZIa) != NULL); assert((ZIz) != NULL); (ZIa)->global = (ZIz); -#line 2327 "src/lx/parser.c" +#line 2321 "src/lx/parser.c" } /* END OF ACTION: set-globalzone */ p_list_Hof_Hthings (lex_state, act_state, ZIa, ZIz, ZIexit); @@ -2347,11 +2341,11 @@ p_lx(lex_state lex_state, act_state act_state, ast *ZOa) { /* BEGINNING OF ACTION: err-expected-eof */ { -#line 815 "src/lx/parser.act" +#line 808 "src/lx/parser.act" err_expected(lex_state, "EOF"); -#line 2355 "src/lx/parser.c" +#line 2349 "src/lx/parser.c" } /* END OF ACTION: err-expected-eof */ } @@ -2364,7 +2358,7 @@ ZL1:; { /* BEGINNING OF ACTION: make-ast */ { -#line 431 "src/lx/parser.act" +#line 424 "src/lx/parser.act" (ZIa) = ast_new(); if ((ZIa) == NULL) { @@ -2372,17 +2366,17 @@ ZL1:; goto ZL4; } -#line 2376 "src/lx/parser.c" +#line 2370 "src/lx/parser.c" } /* END OF ACTION: make-ast */ /* BEGINNING OF ACTION: err-syntax */ { -#line 783 "src/lx/parser.act" +#line 776 "src/lx/parser.act" err(lex_state, "Syntax error"); exit(EXIT_FAILURE); -#line 2386 "src/lx/parser.c" +#line 2380 "src/lx/parser.c" } /* END OF ACTION: err-syntax */ } @@ -2439,7 +2433,7 @@ p_list_Hof_Hthings_C_Czone_Hthing_C_Czone_Hto_Hmapping(lex_state lex_state, act_ } /* BEGINNING OF ACTION: add-mapping */ { -#line 460 "src/lx/parser.act" +#line 453 "src/lx/parser.act" struct ast_token *t; struct ast_mapping *m; @@ -2472,12 +2466,12 @@ p_list_Hof_Hthings_C_Czone_Hthing_C_Czone_Hto_Hmapping(lex_state lex_state, act_ nmappings++; } -#line 2476 "src/lx/parser.c" +#line 2470 "src/lx/parser.c" } /* END OF ACTION: add-mapping */ /* BEGINNING OF ACTION: clone */ { -#line 763 "src/lx/parser.act" +#line 756 "src/lx/parser.act" assert((ZIr) != NULL); @@ -2487,7 +2481,7 @@ p_list_Hof_Hthings_C_Czone_Hthing_C_Czone_Hto_Hmapping(lex_state lex_state, act_ goto ZL1; } -#line 2491 "src/lx/parser.c" +#line 2485 "src/lx/parser.c" } /* END OF ACTION: clone */ } @@ -2523,11 +2517,11 @@ p_112(lex_state lex_state, act_state act_state, string *ZOt) { /* BEGINNING OF ACTION: err-expected-map */ { -#line 791 "src/lx/parser.act" +#line 784 "src/lx/parser.act" err_expected(lex_state, "'->'"); -#line 2531 "src/lx/parser.c" +#line 2525 "src/lx/parser.c" } /* END OF ACTION: err-expected-map */ } @@ -2538,12 +2532,12 @@ p_112(lex_state lex_state, act_state act_state, string *ZOt) case (TOK_TOKEN): /* BEGINNING OF EXTRACT: TOKEN */ { -#line 227 "src/lx/parser.act" +#line 224 "src/lx/parser.act" /* TODO: submatch addressing */ ZIt = xstrdup(lex_state->buf.a + 1); /* +1 for '$' prefix */ -#line 2547 "src/lx/parser.c" +#line 2541 "src/lx/parser.c" } /* END OF EXTRACT: TOKEN */ break; @@ -2557,11 +2551,11 @@ p_112(lex_state lex_state, act_state act_state, string *ZOt) { /* BEGINNING OF ACTION: no-token */ { -#line 514 "src/lx/parser.act" +#line 507 "src/lx/parser.act" (ZIt) = NULL; -#line 2565 "src/lx/parser.c" +#line 2559 "src/lx/parser.c" } /* END OF ACTION: no-token */ } @@ -2650,11 +2644,11 @@ ZL1:; { /* BEGINNING OF ACTION: err-expected-semi */ { -#line 799 "src/lx/parser.act" +#line 792 "src/lx/parser.act" err_expected(lex_state, "';'"); -#line 2658 "src/lx/parser.c" +#line 2652 "src/lx/parser.c" } /* END OF ACTION: err-expected-semi */ } @@ -2701,16 +2695,16 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit } /* BEGINNING OF ACTION: no-zone */ { -#line 522 "src/lx/parser.act" +#line 515 "src/lx/parser.act" (ZIto) = NULL; -#line 2709 "src/lx/parser.c" +#line 2703 "src/lx/parser.c" } /* END OF ACTION: no-zone */ /* BEGINNING OF ACTION: add-mapping */ { -#line 460 "src/lx/parser.act" +#line 453 "src/lx/parser.act" struct ast_token *t; struct ast_mapping *m; @@ -2743,7 +2737,7 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit nmappings++; } -#line 2747 "src/lx/parser.c" +#line 2741 "src/lx/parser.c" } /* END OF ACTION: add-mapping */ } @@ -2755,7 +2749,7 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit /* BEGINNING OF ACTION: make-zone */ { -#line 439 "src/lx/parser.act" +#line 432 "src/lx/parser.act" assert((*ZIa) != NULL); @@ -2773,12 +2767,12 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit goto ZL1; } -#line 2777 "src/lx/parser.c" +#line 2771 "src/lx/parser.c" } /* END OF ACTION: make-zone */ /* BEGINNING OF ACTION: add-mapping */ { -#line 460 "src/lx/parser.act" +#line 453 "src/lx/parser.act" struct ast_token *t; struct ast_mapping *m; @@ -2811,7 +2805,7 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit nmappings++; } -#line 2815 "src/lx/parser.c" +#line 2809 "src/lx/parser.c" } /* END OF ACTION: add-mapping */ p_list_Hof_Hthings_C_Czone_Hthing_C_Clist_Hof_Hzone_Hfrom_Hmappings_C_Clist_Hof_Hzone_Hfrom_Hmappings_Hx (lex_state, act_state, *ZIa, *ZIz, ZIchild, *ZIexit); @@ -2835,11 +2829,11 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit { /* BEGINNING OF ACTION: err-expected-to */ { -#line 803 "src/lx/parser.act" +#line 796 "src/lx/parser.act" err_expected(lex_state, "'..'"); -#line 2843 "src/lx/parser.c" +#line 2837 "src/lx/parser.c" } /* END OF ACTION: err-expected-to */ } @@ -2864,25 +2858,25 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit } /* BEGINNING OF ACTION: no-zone */ { -#line 522 "src/lx/parser.act" +#line 515 "src/lx/parser.act" (ZIx) = NULL; -#line 2872 "src/lx/parser.c" +#line 2866 "src/lx/parser.c" } /* END OF ACTION: no-zone */ /* BEGINNING OF ACTION: no-token */ { -#line 514 "src/lx/parser.act" +#line 507 "src/lx/parser.act" (ZIy) = NULL; -#line 2881 "src/lx/parser.c" +#line 2875 "src/lx/parser.c" } /* END OF ACTION: no-token */ /* BEGINNING OF ACTION: regex-any */ { -#line 400 "src/lx/parser.act" +#line 395 "src/lx/parser.act" fsm_state_t start, end; @@ -2892,8 +2886,6 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit goto ZL5; } - fsm_setoptions((ZIw), act_state->opt); - if (!fsm_addstate((ZIw), &start)) { perror("fsm_addstate"); fsm_free((ZIw)); @@ -2915,12 +2907,12 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit fsm_setstart((ZIw), start); fsm_setend((ZIw), end, 1); -#line 2919 "src/lx/parser.c" +#line 2911 "src/lx/parser.c" } /* END OF ACTION: regex-any */ /* BEGINNING OF ACTION: subtract-exit */ { -#line 743 "src/lx/parser.act" +#line 736 "src/lx/parser.act" assert((ZIw) != NULL); @@ -2940,12 +2932,12 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit } } -#line 2944 "src/lx/parser.c" +#line 2936 "src/lx/parser.c" } /* END OF ACTION: subtract-exit */ /* BEGINNING OF ACTION: add-mapping */ { -#line 460 "src/lx/parser.act" +#line 453 "src/lx/parser.act" struct ast_token *t; struct ast_mapping *m; @@ -2978,7 +2970,7 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit nmappings++; } -#line 2982 "src/lx/parser.c" +#line 2974 "src/lx/parser.c" } /* END OF ACTION: add-mapping */ } @@ -3005,11 +2997,11 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit { /* BEGINNING OF ACTION: err-expected-list */ { -#line 823 "src/lx/parser.act" +#line 816 "src/lx/parser.act" err_expected(lex_state, "list of mappings, bindings or zones"); -#line 3013 "src/lx/parser.c" +#line 3005 "src/lx/parser.c" } /* END OF ACTION: err-expected-list */ } @@ -3025,16 +3017,16 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit /* BEGINNING OF ACTION: no-exit */ { -#line 518 "src/lx/parser.act" +#line 511 "src/lx/parser.act" (ZIr2) = NULL; -#line 3033 "src/lx/parser.c" +#line 3025 "src/lx/parser.c" } /* END OF ACTION: no-exit */ /* BEGINNING OF ACTION: make-zone */ { -#line 439 "src/lx/parser.act" +#line 432 "src/lx/parser.act" assert((*ZIa) != NULL); @@ -3052,12 +3044,12 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit goto ZL1; } -#line 3056 "src/lx/parser.c" +#line 3048 "src/lx/parser.c" } /* END OF ACTION: make-zone */ /* BEGINNING OF ACTION: add-mapping */ { -#line 460 "src/lx/parser.act" +#line 453 "src/lx/parser.act" struct ast_token *t; struct ast_mapping *m; @@ -3090,7 +3082,7 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit nmappings++; } -#line 3094 "src/lx/parser.c" +#line 3086 "src/lx/parser.c" } /* END OF ACTION: add-mapping */ /* BEGINNING OF INLINE: 131 */ @@ -3109,11 +3101,11 @@ p_251(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit { /* BEGINNING OF ACTION: err-expected-list */ { -#line 823 "src/lx/parser.act" +#line 816 "src/lx/parser.act" err_expected(lex_state, "list of mappings, bindings or zones"); -#line 3117 "src/lx/parser.c" +#line 3109 "src/lx/parser.c" } /* END OF ACTION: err-expected-list */ } @@ -3157,11 +3149,11 @@ p_252(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit { /* BEGINNING OF ACTION: err-expected-bind */ { -#line 795 "src/lx/parser.act" +#line 788 "src/lx/parser.act" err_expected(lex_state, "'='"); -#line 3165 "src/lx/parser.c" +#line 3157 "src/lx/parser.c" } /* END OF ACTION: err-expected-bind */ } @@ -3176,7 +3168,7 @@ p_252(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit } /* BEGINNING OF ACTION: add-binding */ { -#line 492 "src/lx/parser.act" +#line 485 "src/lx/parser.act" struct var *v; @@ -3193,7 +3185,7 @@ p_252(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit goto ZL1; } -#line 3197 "src/lx/parser.c" +#line 3189 "src/lx/parser.c" } /* END OF ACTION: add-binding */ } @@ -3219,7 +3211,7 @@ p_252(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit /* BEGINNING OF ACTION: deref-var */ { -#line 283 "src/lx/parser.act" +#line 280 "src/lx/parser.act" struct ast_zone *z; @@ -3246,7 +3238,7 @@ p_252(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit goto ZL1; } -#line 3250 "src/lx/parser.c" +#line 3242 "src/lx/parser.c" } /* END OF ACTION: deref-var */ p_197 (lex_state, act_state, ZI273, &ZI210); @@ -3262,7 +3254,7 @@ p_252(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit } /* BEGINNING OF ACTION: subtract-exit */ { -#line 743 "src/lx/parser.act" +#line 736 "src/lx/parser.act" assert((ZI278) != NULL); @@ -3282,7 +3274,7 @@ p_252(lex_state lex_state, act_state act_state, ast *ZIa, zone *ZIz, fsm *ZIexit } } -#line 3286 "src/lx/parser.c" +#line 3278 "src/lx/parser.c" } /* END OF ACTION: subtract-exit */ p_251 (lex_state, act_state, ZIa, ZIz, ZIexit, &ZI279, &ZI280); @@ -3305,10 +3297,10 @@ ZL1:; /* BEGINNING OF TRAILER */ -#line 888 "src/lx/parser.act" +#line 880 "src/lx/parser.act" - struct ast *lx_parse(FILE *f, const struct fsm_alloc *alloc, const struct fsm_options *opt) { + struct ast *lx_parse(FILE *f, const struct fsm_alloc *alloc) { struct act_state act_state_s; struct act_state *act_state; struct lex_state lex_state_s; @@ -3340,7 +3332,6 @@ ZL1:; /* This is a workaround for ADVANCE_LEXER assuming a pointer */ act_state = &act_state_s; - act_state->opt = opt; act_state->alloc = alloc; if (print_progress) { @@ -3369,6 +3360,6 @@ ZL1:; return ast; } -#line 3373 "src/lx/parser.c" +#line 3364 "src/lx/parser.c" /* END OF FILE */ diff --git a/src/lx/parser.h b/src/lx/parser.h index 53085c140..fdaff9879 100644 --- a/src/lx/parser.h +++ b/src/lx/parser.h @@ -9,7 +9,7 @@ /* BEGINNING OF HEADER */ -#line 142 "src/lx/parser.act" +#line 139 "src/lx/parser.act" #include @@ -20,19 +20,18 @@ typedef struct act_state * act_state; typedef struct ast * ast; - struct ast *lx_parse(FILE *f, - const struct fsm_alloc *alloc, const struct fsm_options *opt); + struct ast *lx_parse(FILE *f, const struct fsm_alloc *alloc); -#line 27 "src/lx/parser.h" +#line 26 "src/lx/parser.h" /* BEGINNING OF FUNCTION DECLARATIONS */ extern void p_lx(lex_state, act_state, ast *); /* BEGINNING OF TRAILER */ -#line 890 "src/lx/parser.act" +#line 882 "src/lx/parser.act" -#line 37 "src/lx/parser.h" +#line 36 "src/lx/parser.h" /* END OF FILE */ diff --git a/src/lx/print.c b/src/lx/print.c index 6c65a52c0..de71a54ef 100644 --- a/src/lx/print.c +++ b/src/lx/print.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -14,7 +15,8 @@ #include "print.h" int -lx_print(FILE *f, const struct ast *ast, enum lx_print_lang lang) +lx_print(FILE *f, const struct ast *ast, const struct fsm_options *opt, + enum lx_print_lang lang) { lx_print_f *print; @@ -37,7 +39,7 @@ lx_print(FILE *f, const struct ast *ast, enum lx_print_lang lang) } // TODO: return int - print(f, ast); + print(f, ast, opt); return 0; } diff --git a/src/lx/print.h b/src/lx/print.h index 7452e86d7..771028e14 100644 --- a/src/lx/print.h +++ b/src/lx/print.h @@ -10,6 +10,7 @@ #include struct ast; +struct fsm_options; /* TODO: combine all variables here into an lx_outoptions struct */ struct prefix { @@ -55,9 +56,8 @@ extern enum api_tokbuf api_tokbuf; extern enum api_getc api_getc; extern enum api_exclude api_exclude; -extern struct fsm_options opt; - -typedef void (lx_print_f)(FILE *f, const struct ast *ast); +typedef void (lx_print_f)(FILE *f, + const struct ast *ast, const struct fsm_options *opt); lx_print_f lx_print_c; lx_print_f lx_print_dot; @@ -66,7 +66,9 @@ lx_print_f lx_print_h; lx_print_f lx_print_zdot; int -lx_print(FILE *f, const struct ast *ast, enum lx_print_lang lang); +lx_print(FILE *f, const struct ast *ast, + const struct fsm_options *opt, + enum lx_print_lang lang); #endif diff --git a/src/lx/print/c.c b/src/lx/print/c.c index bc5e5e91a..58f3279ce 100644 --- a/src/lx/print/c.c +++ b/src/lx/print/c.c @@ -27,7 +27,9 @@ /* XXX: abstraction */ int -fsm_print_cfrag(FILE *f, const struct ir *ir, const struct fsm_options *opt, +fsm_print_cfrag(FILE *f, const struct ir *ir, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, const char *cp); static int @@ -138,20 +140,19 @@ shortest_example(const struct fsm *fsm, const struct ast_token *token, static int accept_c(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { const struct ast *ast; const struct ast_mapping *m; - ast = opt->hooks.hook_opaque; - assert(f != NULL); assert(opt != NULL); - assert(opt->hooks.hook_opaque != NULL); assert(ids != NULL); assert(count > 0); assert(lang_opaque == NULL); + assert(hook_opaque != NULL); + ast = hook_opaque; m = ast_getendmappingbyendid(ids[0]); /* XXX: don't need this if complete */ @@ -173,14 +174,15 @@ accept_c(FILE *f, const struct fsm_options *opt, static int reject_c(FILE *f, const struct fsm_options *opt, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { assert(f != NULL); assert(opt != NULL); - assert(opt->hooks.hook_opaque != NULL); assert(lang_opaque == NULL); + assert(hook_opaque != NULL); - (void) opt->hooks.hook_opaque; + (void) lang_opaque; + (void) hook_opaque; /* XXX: don't need this if complete */ switch (opt->io) { @@ -338,7 +340,7 @@ print_lgetc(FILE *f) } static void -print_io(FILE *f) +print_io(FILE *f, const struct fsm_options *opt) { if (print_progress) { fprintf(stderr, " io"); @@ -356,7 +358,7 @@ print_io(FILE *f) fprintf(f, "\tassert(lx != NULL);\n"); - switch (opt.io) { + switch (opt->io) { case FSM_IO_GETC: fprintf(f, "\tassert(lx->lgetc != NULL);\n"); fprintf(f, "\n"); @@ -404,7 +406,7 @@ print_io(FILE *f) fprintf(f, "\t\tlx->end.saved_col = lx->end.col - 1;\n"); fprintf(f, "\t\tlx->end.col = 1;\n"); - if (opt.io == FSM_IO_STR) { /* ignore terminating '\0' */ + if (opt->io == FSM_IO_STR) { /* ignore terminating '\0' */ fprintf(f, "\t} else if (c == '\\0') { /* don't count terminating '\\0' */\n"); fprintf(f, "\t\tlx->end.byte--;\n"); fprintf(f, "\t\tlx->end.col--;\n"); @@ -426,7 +428,7 @@ print_io(FILE *f) fprintf(f, "{\n"); fprintf(f, "\tassert(lx != NULL);\n"); - switch (opt.io) { + switch (opt->io) { case FSM_IO_GETC: fprintf(f, "\tassert(lx->c == EOF);\n"); fprintf(f, "\n"); @@ -621,13 +623,15 @@ print_stateenum(FILE *f, const struct fsm *fsm) } static int -print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) +print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z, + const struct fsm_options *opt, const char *cp) { assert(f != NULL); assert(z != NULL); assert(z->fsm != NULL); assert(fsm_all(z->fsm, fsm_isdfa)); assert(ast != NULL); + assert(cp != NULL); /* TODO: prerequisite that the FSM is a DFA */ @@ -658,7 +662,7 @@ print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) fprintf(f, "\n"); } - switch (opt.io) { + switch (opt->io) { case FSM_IO_GETC: fprintf(f, "\twhile (c = lx_getc(lx), c != EOF) {\n"); break; @@ -687,34 +691,25 @@ print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) } { - const struct fsm_options *tmp; - static const struct fsm_options defaults; - struct fsm_options o = defaults; + static const struct fsm_hooks defaults; + struct fsm_hooks hooks = defaults; struct ir *ir; - tmp = z->fsm->opt; - - o.comments = z->fsm->opt->comments; - o.case_ranges = z->fsm->opt->case_ranges; - o.hooks.accept = accept_c; - o.hooks.reject = reject_c; - o.hooks.hook_opaque = (void *) ast; + assert(cp != NULL); - z->fsm->opt = &o; + hooks.accept = accept_c; + hooks.reject = reject_c; + hooks.hook_opaque = (void *) ast; - assert(opt.hooks.cp != NULL); - - ir = make_ir(z->fsm); + ir = make_ir(z->fsm, opt); if (ir == NULL) { /* TODO */ } /* XXX: abstraction */ - (void) fsm_print_cfrag(f, ir, &o, opt.hooks.cp); + (void) fsm_print_cfrag(f, ir, opt, &hooks, cp); free_ir(z->fsm, ir); - - z->fsm->opt = tmp; } if (~api_exclude & API_BUF) { @@ -765,7 +760,7 @@ print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) fprintf(f, "\t\tdefault:\n"); fprintf(f, "\t\t\tif (lx->push != NULL) {\n"); - fprintf(f, "\t\t\t\tif (-1 == lx->push(lx->buf_opaque, (char)%s)) {\n", opt.hooks.cp); + fprintf(f, "\t\t\t\tif (-1 == lx->push(lx->buf_opaque, (char)%s)) {\n", cp); fprintf(f, "\t\t\t\t\treturn %sERROR;\n", prefix.tok); fprintf(f, "\t\t\t\t}\n"); fprintf(f, "\t\t\t}\n"); @@ -776,7 +771,7 @@ print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) } else { fprintf(f, "\n"); fprintf(f, "\t\tif (lx->push != NULL) {\n"); - fprintf(f, "\t\t\tif (-1 == lx->push(lx->buf_opaque, (char)%s)) {\n", opt.hooks.cp); + fprintf(f, "\t\t\tif (-1 == lx->push(lx->buf_opaque, (char)%s)) {\n", cp); fprintf(f, "\t\t\t\treturn %sERROR;\n", prefix.tok); fprintf(f, "\t\t\t}\n"); fprintf(f, "\t\t}\n"); @@ -790,7 +785,7 @@ print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) { fsm_state_t i; - switch (opt.io) { + switch (opt->io) { case FSM_IO_GETC: fprintf(f, "\tlx->lgetc = NULL;\n"); fprintf(f, "\n"); @@ -888,7 +883,7 @@ print_name(FILE *f, const struct ast *ast) } static int -print_example(FILE *f, const struct ast *ast) +print_example(FILE *f, const struct ast *ast, const struct fsm_options *opt) { struct ast_token *t; struct ast_zone *z; @@ -935,7 +930,7 @@ print_example(FILE *f, const struct ast *ast) fprintf(f, "\t\tcase %s", prefix.tok); esctok(f, t->s); fprintf(f, ": return \""); - escputs(f, z->fsm->opt, c_escputc_str, buf); + escputs(f, opt, c_escputc_str, buf); fprintf(f, "%s", n >= (int) sizeof buf - 1 ? "..." : ""); fprintf(f, "\";\n"); } @@ -960,18 +955,20 @@ print_example(FILE *f, const struct ast *ast) } void -lx_print_c(FILE *f, const struct ast *ast) +lx_print_c(FILE *f, const struct ast *ast, const struct fsm_options *opt) { + const char *cp; const struct ast_zone *z; unsigned int zn; assert(f != NULL); assert(ast != NULL); + assert(opt != NULL); - switch (opt.io) { - case FSM_IO_GETC: opt.hooks.cp = "c"; break; - case FSM_IO_STR: opt.hooks.cp = "c"; break; - case FSM_IO_PAIR: opt.hooks.cp = "c"; break; + switch (opt->io) { + case FSM_IO_GETC: cp = "c"; break; + case FSM_IO_STR: cp = "c"; break; + case FSM_IO_PAIR: cp = "c"; break; } for (z = ast->zl; z != NULL; z = z->next) { @@ -1008,7 +1005,7 @@ lx_print_c(FILE *f, const struct ast *ast) fprintf(f, "\n"); - print_io(f); + print_io(f, opt); print_lgetc(f); print_buf(f); @@ -1025,7 +1022,7 @@ lx_print_c(FILE *f, const struct ast *ast) zn++; } - if (-1 == print_zone(f, ast, z)) { + if (-1 == print_zone(f, ast, z, opt, cp)) { return; /* XXX: handle error */ } } @@ -1035,7 +1032,7 @@ lx_print_c(FILE *f, const struct ast *ast) } if (~api_exclude & API_EXAMPLE) { - if (-1 == print_example(f, ast)) { + if (-1 == print_example(f, ast, opt)) { return; } } @@ -1051,7 +1048,7 @@ lx_print_c(FILE *f, const struct ast *ast) fprintf(f, "\t*lx = lx_default;\n"); fprintf(f, "\n"); - switch (opt.io) { + switch (opt->io) { case FSM_IO_GETC: fprintf(f, "\tlx->c = EOF;\n"); break; @@ -1085,7 +1082,7 @@ lx_print_c(FILE *f, const struct ast *ast) fprintf(f, "\tassert(lx->z != NULL);\n"); fprintf(f, "\n"); - switch (opt.io) { + switch (opt->io) { case FSM_IO_GETC: fprintf(f, "\tif (lx->lgetc == NULL) {\n"); break; @@ -1123,7 +1120,7 @@ lx_print_c(FILE *f, const struct ast *ast) fprintf(f, "\n"); - if (opt.io == FSM_IO_STR) { + if (opt->io == FSM_IO_STR) { fprintf(f, "void\n"); fprintf(f, "%sinput_str(struct %slx *lx, const char *p)\n", prefix.api, prefix.lx); fprintf(f, "{\n"); diff --git a/src/lx/print/dot.c b/src/lx/print/dot.c index d67a5e5ca..bf1a72063 100644 --- a/src/lx/print/dot.c +++ b/src/lx/print/dot.c @@ -67,7 +67,7 @@ mapping(FILE *f, const struct ast_mapping *m, const struct ast *ast) static int accept_dot(FILE *f, const struct fsm_options *opt, const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + void *lang_opaque, void *hook_opaque) { const struct ast_mapping *m; const struct ast *ast; @@ -75,12 +75,12 @@ accept_dot(FILE *f, const struct fsm_options *opt, assert(f != NULL); assert(opt != NULL); - assert(opt->hooks.hook_opaque != NULL); assert(ids != NULL); assert(count > 0); assert(lang_opaque != NULL); + assert(hook_opaque != NULL); - ast = opt->hooks.hook_opaque; + ast = hook_opaque; s = * (fsm_state_t *) lang_opaque; m = ast_getendmappingbyendid(ids[0]); @@ -164,7 +164,8 @@ singlestate(FILE *f, const struct fsm *fsm, const struct ast *ast, } static void -print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) +print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z, + const struct fsm_options *opt) { fsm_state_t start, i; @@ -172,6 +173,7 @@ print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) assert(ast != NULL); assert(z != NULL); assert(z->fsm != NULL); + assert(opt != NULL); (void) fsm_getstart(z->fsm, &start); @@ -188,28 +190,20 @@ print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) fprintf(f, "\t\n"); { - const struct fsm_options *tmp; - static const struct fsm_options defaults; - struct fsm_options opt = defaults; - char p[128]; + static const struct fsm_hooks defaults; + struct fsm_hooks hooks = defaults; + struct fsm_options o = *opt; - tmp = z->fsm->opt; + char p[128]; (void) sprintf(p, "z%u", zindexof(ast, z)); - opt.anonymous_states = anonymous_states; - opt.fragment = 1; /* XXX */ - opt.consolidate_edges = z->fsm->opt->consolidate_edges; - opt.comments = z->fsm->opt->comments; - opt.prefix = p; - opt.hooks.accept = accept_dot; - opt.hooks.hook_opaque = (void *) ast; + o.prefix = p; - z->fsm->opt = &opt; + hooks.accept = accept_dot; + hooks.hook_opaque = (void *) ast; - fsm_print(f, z->fsm, FSM_PRINT_DOT); - - z->fsm->opt = tmp; + fsm_print(f, z->fsm, &o, &hooks, FSM_PRINT_DOT); } for (i = 0; i < z->fsm->statecount; i++) { @@ -224,13 +218,14 @@ print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) } void -lx_print_dot(FILE *f, const struct ast *ast) +lx_print_dot(FILE *f, const struct ast *ast, const struct fsm_options *opt) { const struct ast_zone *z; unsigned int zn; fsm_state_t start; assert(f != NULL); + assert(opt != NULL); (void) fsm_getstart(ast->global->fsm, &start); @@ -295,7 +290,7 @@ lx_print_dot(FILE *f, const struct ast *ast) zn++; } - print_zone(f, ast, z); + print_zone(f, ast, z, opt); } fprintf(f, "}\n"); diff --git a/src/lx/print/dump.c b/src/lx/print/dump.c index 9b1b06b25..162630f88 100644 --- a/src/lx/print/dump.c +++ b/src/lx/print/dump.c @@ -13,10 +13,14 @@ #include "lx/print.h" -static void -print_dump(FILE *f) +void +lx_print_dump(FILE *f, const struct ast *ast, const struct fsm_options *opt) { assert(f != NULL); + assert(ast != NULL); + assert(opt != NULL); + + (void) ast; if (api_getc == API_FDGETC) { fprintf(f, "#define _POSIX_SOURCE\n"); @@ -67,7 +71,7 @@ print_dump(FILE *f) fprintf(f, "\tenum lx_token t;\n"); fprintf(f, "\tstruct lx lx = { 0 };\n"); - switch (opt.io) { + switch (opt->io) { case FSM_IO_GETC: fprintf(f, "\tint (*lgetc)(struct lx *lx);\n"); fprintf(f, "\tvoid *getc_opaque;\n"); @@ -113,7 +117,7 @@ print_dump(FILE *f) fprintf(f, "\n"); - if (opt.io == FSM_IO_GETC && (api_getc != API_AGETC && api_getc != API_SGETC)) { + if (opt->io == FSM_IO_GETC && (api_getc != API_AGETC && api_getc != API_SGETC)) { fprintf(f, "\tif (argc != 1) {\n"); fprintf(f, "\t\tfprintf(stderr, \"usage: dump\\n\");\n"); fprintf(f, "\t\treturn 1;\n"); @@ -172,7 +176,7 @@ print_dump(FILE *f) fprintf(f, "\tlx_init(&lx);\n"); fprintf(f, "\n"); - switch (opt.io) { + switch (opt->io) { case FSM_IO_GETC: fprintf(f, "\tlx.lgetc = lgetc;\n"); fprintf(f, "\tlx.getc_opaque = getc_opaque;\n"); @@ -303,14 +307,3 @@ print_dump(FILE *f) fprintf(f, "}\n"); } -void -lx_print_dump(FILE *f, const struct ast *ast) -{ - assert(f != NULL); - assert(ast != NULL); - - (void) ast; - - print_dump(f); -} - diff --git a/src/lx/print/h.c b/src/lx/print/h.c index c41b89662..01a34c62e 100644 --- a/src/lx/print/h.c +++ b/src/lx/print/h.c @@ -41,10 +41,11 @@ print_tokens(FILE *f, const struct ast *ast) } void -lx_print_h(FILE *f, const struct ast *ast) +lx_print_h(FILE *f, const struct ast *ast, const struct fsm_options *opt) { assert(f != NULL); assert(ast != NULL); + assert(opt != NULL); fprintf(f, "/* Generated by lx */\n"); /* TODO: date, input etc */ fprintf(f, "\n"); @@ -73,7 +74,7 @@ lx_print_h(FILE *f, const struct ast *ast) fprintf(f, "struct %slx {\n", prefix.lx); - switch (opt.io) { + switch (opt->io) { case FSM_IO_GETC: fprintf(f, "\tint (*lgetc)(struct %slx *lx);\n", prefix.lx); fprintf(f, "\tvoid *getc_opaque;\n"); @@ -233,7 +234,7 @@ lx_print_h(FILE *f, const struct ast *ast) fprintf(f, "\n"); } - if (opt.io == FSM_IO_STR) { + if (opt->io == FSM_IO_STR) { fprintf(f, "void %sinput_str(struct %slx *lx, const char *p);\n", prefix.api, prefix.lx); fprintf(f, "\n"); } diff --git a/src/lx/print/zdot.c b/src/lx/print/zdot.c index 7fa9b8b07..3fcf72b56 100644 --- a/src/lx/print/zdot.c +++ b/src/lx/print/zdot.c @@ -74,13 +74,16 @@ print_zone(FILE *f, const struct ast *ast, const struct ast_zone *z) } void -lx_print_zdot(FILE *f, const struct ast *ast) +lx_print_zdot(FILE *f, const struct ast *ast, const struct fsm_options *opt) { const struct ast_zone *z; unsigned int zn; assert(f != NULL); assert(ast != NULL); + assert(opt != NULL); + + (void) opt; fprintf(f, "digraph %sG {\n", prefix.api); fprintf(f, "\trankdir = TB;\n"); diff --git a/src/lx/tokens.c b/src/lx/tokens.c index 3736ddf51..ac2fd52a9 100644 --- a/src/lx/tokens.c +++ b/src/lx/tokens.c @@ -6,6 +6,7 @@ #include #include +#include #include diff --git a/src/re/main.c b/src/re/main.c index 16c152cc0..e196103d4 100644 --- a/src/re/main.c +++ b/src/re/main.c @@ -425,8 +425,8 @@ printexample(FILE *f, const struct fsm *fsm, fsm_state_t state) static int accept_c(FILE *f, const struct fsm_options *opt, - const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + const fsm_end_id_t *ids, size_t count, + void *lang_opaque, void *hook_opaque) { const struct match *m; unsigned n; @@ -434,9 +434,11 @@ accept_c(FILE *f, const struct fsm_options *opt, assert(opt != NULL); assert(lang_opaque == NULL); + assert(hook_opaque == NULL); (void) opt; (void) lang_opaque; + (void) hook_opaque; n = 0; @@ -467,8 +469,8 @@ accept_c(FILE *f, const struct fsm_options *opt, static int accept_rust(FILE *f, const struct fsm_options *opt, - const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + const fsm_end_id_t *ids, size_t count, + void *lang_opaque, void *hook_opaque) { const struct match *m; unsigned n; @@ -476,9 +478,11 @@ accept_rust(FILE *f, const struct fsm_options *opt, assert(opt != NULL); assert(lang_opaque == NULL); + assert(hook_opaque == NULL); (void) opt; (void) lang_opaque; + (void) hook_opaque; n = 0; @@ -509,8 +513,8 @@ accept_rust(FILE *f, const struct fsm_options *opt, static int accept_llvm(FILE *f, const struct fsm_options *opt, - const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + const fsm_end_id_t *ids, size_t count, + void *lang_opaque, void *hook_opaque) { const struct match *m; unsigned n; @@ -518,8 +522,10 @@ accept_llvm(FILE *f, const struct fsm_options *opt, assert(opt != NULL); assert(lang_opaque != NULL); + assert(hook_opaque == NULL); (void) opt; + (void) hook_opaque; n = 0; @@ -552,8 +558,8 @@ accept_llvm(FILE *f, const struct fsm_options *opt, static int accept_dot(FILE *f, const struct fsm_options *opt, - const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + const fsm_end_id_t *ids, size_t count, + void *lang_opaque, void *hook_opaque) { const struct match *m; fsm_state_t s; @@ -561,8 +567,10 @@ accept_dot(FILE *f, const struct fsm_options *opt, assert(opt != NULL); assert(lang_opaque != NULL); + assert(hook_opaque == NULL); (void) opt; + (void) hook_opaque; s = * (fsm_state_t *) lang_opaque; @@ -610,17 +618,19 @@ accept_dot(FILE *f, const struct fsm_options *opt, static int accept_json(FILE *f, const struct fsm_options *opt, - const fsm_end_id_t *ids, size_t count, - void *lang_opaque) + const fsm_end_id_t *ids, size_t count, + void *lang_opaque, void *hook_opaque) { const struct match *m; size_t i; assert(opt != NULL); assert(lang_opaque == NULL); + assert(hook_opaque == NULL); (void) opt; (void) lang_opaque; + (void) hook_opaque; fprintf(f, "[ "); @@ -683,10 +693,12 @@ int main(int argc, char *argv[]) { static const struct fsm_options zero_options; + static const struct fsm_hooks zero_hooks; /* TODO: use alloc hooks for -Q accounting */ struct fsm_alloc *alloc = NULL; struct fsm_options opt; + struct fsm_hooks hooks; struct fsm *fsm; struct fsm *(*join)(struct fsm *, struct fsm *, @@ -711,6 +723,7 @@ main(int argc, char *argv[]) atexit(do_fsm_cleanup); opt = zero_options; + hooks = zero_hooks; /* note these defaults are the opposite than for fsm(1) */ opt.anonymous_states = 1; @@ -871,7 +884,7 @@ main(int argc, char *argv[]) literal_r = re_is_literal(dialect, fsm_fgetc, f, - &opt, flags, &err, + flags, &err, &literal_category, &literal_s, &literal_n); fclose(f); @@ -882,7 +895,7 @@ main(int argc, char *argv[]) literal_r = re_is_literal(dialect, fsm_sgetc, &s, - &opt, flags, &err, + flags, &err, &literal_category, &literal_s, &literal_n); } @@ -945,11 +958,11 @@ main(int argc, char *argv[]) f = xopen(argv[0]); if (!fsmfiles) { - ast = re_parse(dialect, fsm_fgetc, f, &opt, flags, &err, NULL); + ast = re_parse(dialect, fsm_fgetc, f, flags, &err, NULL); } else { struct fsm *fsm; - fsm = fsm_parse(f, alloc, &opt); + fsm = fsm_parse(f, alloc); if (fsm == NULL) { perror("fsm_parse"); return EXIT_FAILURE; @@ -971,7 +984,7 @@ main(int argc, char *argv[]) s = argv[0]; - ast = re_parse(dialect, fsm_sgetc, &s, &opt, flags, &err, NULL); + ast = re_parse(dialect, fsm_sgetc, &s, flags, &err, NULL); } if (ast == NULL) { @@ -1001,8 +1014,6 @@ main(int argc, char *argv[]) return EXIT_FAILURE; } - fsm_setoptions(fsm, &opt); - fsm_to_cleanup = fsm; { @@ -1027,9 +1038,9 @@ main(int argc, char *argv[]) f = xopen(argv[i]); if (!fsmfiles) { - new = re_comp(dialect, fsm_fgetc, f, alloc, &opt, flags, &err); + new = re_comp(dialect, fsm_fgetc, f, alloc, flags, &err); } else { - new = fsm_parse(f, alloc, &opt); + new = fsm_parse(f, alloc); if (new == NULL) { perror("fsm_parse"); return EXIT_FAILURE; @@ -1042,7 +1053,7 @@ main(int argc, char *argv[]) s = argv[i]; - new = re_comp(dialect, fsm_sgetc, &s, alloc, &opt, flags, &err); + new = re_comp(dialect, fsm_sgetc, &s, alloc, flags, &err); } if (new == NULL) { @@ -1259,32 +1270,32 @@ main(int argc, char *argv[]) switch (fsm_lang) { case FSM_PRINT_C: case FSM_PRINT_VMC: - opt.hooks.accept = accept_c; + hooks.accept = accept_c; break; case FSM_PRINT_RUST: - opt.hooks.accept = accept_rust; + hooks.accept = accept_rust; break; case FSM_PRINT_LLVM: - opt.hooks.accept = accept_llvm; + hooks.accept = accept_llvm; break; case FSM_PRINT_DOT: case FSM_PRINT_VMDOT: - opt.hooks.accept = patterns ? accept_dot : NULL; + hooks.accept = patterns ? accept_dot : NULL; break; case FSM_PRINT_JSON: - opt.hooks.accept = patterns ? accept_json : NULL; + hooks.accept = patterns ? accept_json : NULL; break; default: - opt.hooks.accept = NULL; + hooks.accept = NULL; break; } - if (-1 == fsm_print(stdout, fsm, fsm_lang)) { + if (-1 == fsm_print(stdout, fsm, &opt, &hooks, fsm_lang)) { if (errno == ENOTSUP) { fprintf(stderr, "unsupported IO API\n"); } else { diff --git a/src/retest/cvtpcre.c b/src/retest/cvtpcre.c index 3eaa57ad1..d35b8459d 100644 --- a/src/retest/cvtpcre.c +++ b/src/retest/cvtpcre.c @@ -430,13 +430,10 @@ state_name(enum state st) int main(int argc, char **argv) { - static const struct fsm_options zero_options; - struct str l; enum state state; size_t count, nparsed, linenum, regexp_line; int re_ok = 0; - struct fsm_options opt; char **skip; size_t nskip; @@ -455,12 +452,6 @@ main(int argc, char **argv) l = init_str; state = ST_DEFAULT; - opt = zero_options; - opt.comments = 0; - opt.anonymous_states = 1; - opt.consolidate_edges = 1; - opt.io = FSM_IO_GETC; - count = 0; nparsed = 0; linenum = 0; @@ -620,7 +611,7 @@ main(int argc, char **argv) comp_err = err_zero; - fsm = re_comp(RE_PCRE, fsm_sgetc, &re, NULL, &opt, mods, &comp_err); + fsm = re_comp(RE_PCRE, fsm_sgetc, &re, NULL, mods, &comp_err); re_ok = (fsm != NULL); if (re_ok) { fsm_free(fsm); diff --git a/src/retest/main.c b/src/retest/main.c index c3dd4e74c..2183688ba 100644 --- a/src/retest/main.c +++ b/src/retest/main.c @@ -978,7 +978,7 @@ process_test_file(const char *filename, } re_str = regexp; - fsm = re_comp(dialect, fsm_sgetc, &re_str, alloc, &opt, flags, &err); + fsm = re_comp(dialect, fsm_sgetc, &re_str, alloc, flags, &err); if (fsm == NULL) { fprintf(stderr, "line %d: error with %s regexp /%s/%s: %s\n", linenum, dialect_name, regexp, flagdesc, re_strerror(err.e)); @@ -1062,7 +1062,7 @@ process_test_file(const char *filename, fprintf(stderr, "REGEXP matching for /%s/%s\n", regexp, flagdesc); #endif /* DEBUG_TEST_REGEXP */ - ret = fsm_runner_initialize(fsm, &runner, impl, vm_opts); + ret = fsm_runner_initialize(fsm, &opt, &runner, impl, vm_opts); fsm_free(fsm); diff --git a/src/retest/reperf.c b/src/retest/reperf.c index bcdbc5559..65fd9072a 100644 --- a/src/retest/reperf.c +++ b/src/retest/reperf.c @@ -688,7 +688,7 @@ perf_case_run(struct perf_case *c, enum halt halt, re = c->regexp.data; - fsm = re_comp(c->dialect, fsm_sgetc, &re, alloc, &opt, flags, &comp_err); + fsm = re_comp(c->dialect, fsm_sgetc, &re, alloc, flags, &comp_err); if (fsm == NULL) { return ERROR_PARSING_REGEXP; } @@ -728,7 +728,7 @@ perf_case_run(struct perf_case *c, enum halt halt, goto done; } - ret = fsm_runner_initialize(fsm, &runner, c->impl, vm_opts); + ret = fsm_runner_initialize(fsm, &opt, &runner, c->impl, vm_opts); if (ret != ERROR_NONE) { fsm_free(fsm); return ret; diff --git a/src/retest/runner.c b/src/retest/runner.c index 95f89aa91..ea5a54372 100644 --- a/src/retest/runner.c +++ b/src/retest/runner.c @@ -61,7 +61,10 @@ xmkstemps(char *s) } static int -print(const struct fsm *fsm, enum implementation impl, +print(const struct fsm *fsm, + const struct fsm_options *opt, + const struct fsm_hooks *hooks, + enum implementation impl, char *tmp_src) { int fd_src; @@ -76,7 +79,7 @@ print(const struct fsm *fsm, enum implementation impl, } /* the vmc codegen can emit memcmp() or strncmp() calls */ - if (impl == IMPL_VMC && (fsm_getoptions(fsm)->io == FSM_IO_PAIR || fsm_getoptions(fsm)->io == FSM_IO_STR)) { + if (impl == IMPL_VMC && (opt->io == FSM_IO_PAIR || opt->io == FSM_IO_STR)) { fprintf(f, "#include \n\n"); } @@ -84,18 +87,18 @@ print(const struct fsm *fsm, enum implementation impl, int e; switch (impl) { - case IMPL_C: e = fsm_print(f, fsm, FSM_PRINT_C); break; - case IMPL_RUST: e = fsm_print(f, fsm, FSM_PRINT_RUST); break; - case IMPL_LLVM: e = fsm_print(f, fsm, FSM_PRINT_LLVM); break; - case IMPL_VMC: e = fsm_print(f, fsm, FSM_PRINT_VMC); break; - case IMPL_GOASM: e = fsm_print(f, fsm, FSM_PRINT_AMD64_GO); break; - case IMPL_VMASM: e = fsm_print(f, fsm, FSM_PRINT_AMD64_ATT); break; - case IMPL_GO: e = fsm_print(f, fsm, FSM_PRINT_GO); break; + case IMPL_C: e = fsm_print(f, fsm, opt, hooks, FSM_PRINT_C); break; + case IMPL_RUST: e = fsm_print(f, fsm, opt, hooks, FSM_PRINT_RUST); break; + case IMPL_LLVM: e = fsm_print(f, fsm, opt, hooks, FSM_PRINT_LLVM); break; + case IMPL_VMC: e = fsm_print(f, fsm, opt, hooks, FSM_PRINT_VMC); break; + case IMPL_GOASM: e = fsm_print(f, fsm, opt, hooks, FSM_PRINT_AMD64_GO); break; + case IMPL_VMASM: e = fsm_print(f, fsm, opt, hooks, FSM_PRINT_AMD64_ATT); break; + case IMPL_GO: e = fsm_print(f, fsm, opt, hooks, FSM_PRINT_GO); break; case IMPL_VMOPS: - e = fsm_print(f, fsm, FSM_PRINT_VMOPS_H) - | fsm_print(f, fsm, FSM_PRINT_VMOPS_C) - | fsm_print(f, fsm, FSM_PRINT_VMOPS_MAIN); + e = fsm_print(f, fsm, opt, hooks, FSM_PRINT_VMOPS_H) + | fsm_print(f, fsm, opt, hooks, FSM_PRINT_VMOPS_C) + | fsm_print(f, fsm, opt, hooks, FSM_PRINT_VMOPS_MAIN); break; case IMPL_INTERPRET: @@ -285,7 +288,9 @@ compile(enum implementation impl, } static enum error_type -runner_init_compiled(struct fsm *fsm, struct fsm_runner *r, enum implementation impl) +runner_init_compiled(struct fsm *fsm, + const struct fsm_options *opt, + struct fsm_runner *r, enum implementation impl) { void *h; @@ -316,7 +321,8 @@ runner_init_compiled(struct fsm *fsm, struct fsm_runner *r, enum implementation abort(); } - if (!print(fsm, r->impl, tmp_src)) { + /* we don't override the print hooks for retest */ + if (!print(fsm, opt, NULL, r->impl, tmp_src)) { return ERROR_FILE_IO; } @@ -399,7 +405,8 @@ runner_init_compiled(struct fsm *fsm, struct fsm_runner *r, enum implementation } enum error_type -fsm_runner_initialize(struct fsm *fsm, struct fsm_runner *r, enum implementation impl, struct fsm_vm_compile_opts vm_opts) +fsm_runner_initialize(struct fsm *fsm, const struct fsm_options *opt, + struct fsm_runner *r, enum implementation impl, struct fsm_vm_compile_opts vm_opts) { static const struct fsm_runner zero; struct fsm_dfavm *vm; @@ -418,10 +425,10 @@ fsm_runner_initialize(struct fsm *fsm, struct fsm_runner *r, enum implementation case IMPL_VMOPS: case IMPL_GO: case IMPL_GOASM: - return runner_init_compiled(fsm, r, impl); + return runner_init_compiled(fsm, opt, r, impl); case IMPL_INTERPRET: - vm = fsm_vm_compile_with_options(fsm, vm_opts); + vm = fsm_vm_compile_with_options(fsm, opt, vm_opts); if (vm == NULL) { fsm_free(fsm); return ERROR_COMPILING_BYTECODE; diff --git a/src/retest/runner.h b/src/retest/runner.h index 3bd1531ab..3d53bc511 100644 --- a/src/retest/runner.h +++ b/src/retest/runner.h @@ -6,6 +6,7 @@ #include struct fsm; +struct fsm_options; struct fsm_dfavm; enum error_type { @@ -73,7 +74,8 @@ struct fsm_runner { }; enum error_type -fsm_runner_initialize(struct fsm *fsm, struct fsm_runner *r, enum implementation impl, struct fsm_vm_compile_opts vm_opts); +fsm_runner_initialize(struct fsm *fsm, const struct fsm_options *opt, + struct fsm_runner *r, enum implementation impl, struct fsm_vm_compile_opts vm_opts); void fsm_runner_finalize(struct fsm_runner *r); diff --git a/tests/aho_corasick/actest.c b/tests/aho_corasick/actest.c index b453060d0..40dcbdf4f 100644 --- a/tests/aho_corasick/actest.c +++ b/tests/aho_corasick/actest.c @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) { flags |= RE_STRINGS_ANCHOR_RIGHT; } - fsm = re_strings(NULL, &opt, (const char **)words.list, words.len, flags); + fsm = re_strings(NULL, (const char **)words.list, words.len, flags); wordlist_finalize(&words); if (fsm == NULL) { @@ -173,7 +173,7 @@ int main(int argc, char *argv[]) { exit(EXIT_FAILURE); } - fsm_print(stdout, fsm, lang); + fsm_print(stdout, fsm, &opt, NULL, lang); fsm_free(fsm); diff --git a/tests/capture/captest.c b/tests/capture/captest.c index ad2d0c21f..abfb125e0 100644 --- a/tests/capture/captest.c +++ b/tests/capture/captest.c @@ -80,7 +80,7 @@ captest_run_single(const struct captest_single_fsm_test_info *info) } #if CAPTEST_RUN_SINGLE_LOG - fsm_print(stderr, fsm, FSM_PRINT_FSM); + fsm_print(stderr, fsm, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "fsm", fsm); #endif diff --git a/tests/capture/capture3.c b/tests/capture/capture3.c index 919716e41..6dde011d6 100644 --- a/tests/capture/capture3.c +++ b/tests/capture/capture3.c @@ -83,15 +83,15 @@ int main(void) { #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "\n=== f_ab...\n"); - fsm_print(stderr, f_ab, FSM_PRINT_FSM); + fsm_print(stderr, f_ab, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### f_ab", f_ab); fprintf(stderr, "\n=== f_cde...\n"); - fsm_print(stderr, f_cde, FSM_PRINT_FSM); + fsm_print(stderr, f_cde, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### f_cde", f_cde); fprintf(stderr, "\n=== f_fghi...\n"); - fsm_print(stderr, f_fghi, FSM_PRINT_FSM); + fsm_print(stderr, f_fghi, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### f_fghi", f_fghi); #endif @@ -111,14 +111,14 @@ int main(void) { #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "=== unioned f_ab with f_cde... (CB ab: %u, cde: %u)\n", bases[0].capture, bases[1].capture); - fsm_print(stderr, f_all, FSM_PRINT_FSM); + fsm_print(stderr, f_all, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### f_all", f_all); #endif #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "=== unioned f_all with f_fghi... (CB fghi: %u), %u captures\n", bases[2].capture, fsm_countcaptures(f_all)); - fsm_print(stderr, f_all, FSM_PRINT_FSM); + fsm_print(stderr, f_all, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### f_all #2", f_all); #endif @@ -129,7 +129,7 @@ int main(void) { #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after determinise\n"); - fsm_print(stderr, f_all, FSM_PRINT_FSM); + fsm_print(stderr, f_all, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### f_all", f_all); #endif @@ -164,7 +164,7 @@ det_and_min(const char *tag, struct fsm *fsm) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after det_and_min: '%s'\n", tag); - fsm_print(stderr, fsm, FSM_PRINT_FSM); + fsm_print(stderr, fsm, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, tag, fsm); #endif diff --git a/tests/capture/capture4.c b/tests/capture/capture4.c index 5ee847770..ae27c416c 100644 --- a/tests/capture/capture4.c +++ b/tests/capture/capture4.c @@ -90,11 +90,11 @@ build_and_combine(unsigned *cb_a, unsigned *cb_b) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==================== abc \n"); - fsm_print(stderr, f_abc, FSM_PRINT_FSM); + fsm_print(stderr, f_abc, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "abc", f_abc); fprintf(stderr, "==================== ab*c \n"); - fsm_print(stderr, f_ab_c, FSM_PRINT_FSM); + fsm_print(stderr, f_ab_c, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "ab*c", f_ab_c); #endif @@ -110,7 +110,7 @@ build_and_combine(unsigned *cb_a, unsigned *cb_b) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==================== post-union \n"); - fsm_print(stderr, f_all, FSM_PRINT_FSM); + fsm_print(stderr, f_all, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "capture_actions", f_all); fprintf(stderr, "====================\n"); #endif @@ -121,7 +121,7 @@ build_and_combine(unsigned *cb_a, unsigned *cb_b) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==================== post-det \n"); - fsm_print(stderr, f_all, FSM_PRINT_FSM); + fsm_print(stderr, f_all, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "capture_actions", f_all); fprintf(stderr, "====================\n"); #endif @@ -144,7 +144,7 @@ det_and_min(const char *tag, struct fsm *fsm) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after det_and_min: '%s'\n", tag); - fsm_print(stderr, fsm, FSM_PRINT_FSM); + fsm_print(stderr, fsm, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, tag, fsm); #endif diff --git a/tests/capture/capture5.c b/tests/capture/capture5.c index f103b851e..cbcb3ee9d 100644 --- a/tests/capture/capture5.c +++ b/tests/capture/capture5.c @@ -77,7 +77,7 @@ build(void) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== built\n"); - fsm_print(stderr, fsm, FSM_PRINT_FSM); + fsm_print(stderr, fsm, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "built", fsm); #endif @@ -88,7 +88,7 @@ build(void) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after det\n"); - fsm_print(stderr, fsm, FSM_PRINT_FSM); + fsm_print(stderr, fsm, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "after det", fsm); #endif @@ -99,7 +99,7 @@ build(void) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after min\n"); - fsm_print(stderr, fsm, FSM_PRINT_FSM); + fsm_print(stderr, fsm, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "after min", fsm); #endif return fsm; diff --git a/tests/capture/capture_concat1.c b/tests/capture/capture_concat1.c index 084b666ea..23db17a25 100644 --- a/tests/capture/capture_concat1.c +++ b/tests/capture/capture_concat1.c @@ -74,7 +74,7 @@ build(unsigned *cb_a, unsigned *cb_b) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after concat: cb_ab %u, cb_cde %u\n", *cb_a, *cb_b); - fsm_print(stderr, abcde, FSM_PRINT_FSM); + fsm_print(stderr, abcde, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### after concat", abcde); @@ -87,7 +87,7 @@ build(unsigned *cb_a, unsigned *cb_b) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after determinise\n"); - fsm_print(stderr, abcde, FSM_PRINT_FSM); + fsm_print(stderr, abcde, NULL, NULL, FSM_PRINT_FSM); assert(fsm_countcaptures(abcde) == cc_abcde); diff --git a/tests/capture/capture_concat2.c b/tests/capture/capture_concat2.c index 4f8743244..b8e65025e 100644 --- a/tests/capture/capture_concat2.c +++ b/tests/capture/capture_concat2.c @@ -74,7 +74,7 @@ build(unsigned *cb_a, unsigned *cb_b) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after concat: cb_abc %u, cb_de %u\n", *cb_a, *cb_b); - fsm_print(stderr, abcde, FSM_PRINT_FSM); + fsm_print(stderr, abcde, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### after concat", abcde); @@ -87,7 +87,7 @@ build(unsigned *cb_a, unsigned *cb_b) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after determinise\n"); - fsm_print(stderr, abcde, FSM_PRINT_FSM); + fsm_print(stderr, abcde, NULL, NULL, FSM_PRINT_FSM); assert(fsm_countcaptures(abcde) == cc_abcde); diff --git a/tests/capture/capture_union1.c b/tests/capture/capture_union1.c index 704544997..8fe6fce58 100644 --- a/tests/capture/capture_union1.c +++ b/tests/capture/capture_union1.c @@ -74,7 +74,7 @@ build(unsigned *cb_a, unsigned *cb_b) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after union: cb_ab %u, cb_cde %u\n", *cb_a, *cb_b); - fsm_print(stderr, abcde, FSM_PRINT_FSM); + fsm_print(stderr, abcde, NULL, NULL, FSM_PRINT_FSM); fsm_capture_dump(stderr, "#### after union", abcde); @@ -87,7 +87,7 @@ build(unsigned *cb_a, unsigned *cb_b) #if LOG_INTERMEDIATE_FSMS fprintf(stderr, "==== after determinise\n"); - fsm_print(stderr, abcde, FSM_PRINT_FSM); + fsm_print(stderr, abcde, NULL, NULL, FSM_PRINT_FSM); assert(fsm_countcaptures(abcde) == cc_abcde); diff --git a/tests/endids/endids0.c b/tests/endids/endids0.c index 34e12f116..1f5e6f9b6 100644 --- a/tests/endids/endids0.c +++ b/tests/endids/endids0.c @@ -26,7 +26,7 @@ int main(void) size_t nend; size_t nstates, state_ind; - s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_determinise(fsm); assert(ret == 1); diff --git a/tests/endids/endids0_many_endids.c b/tests/endids/endids0_many_endids.c index 09ca8e8a3..86a66063c 100644 --- a/tests/endids/endids0_many_endids.c +++ b/tests/endids/endids0_many_endids.c @@ -28,7 +28,7 @@ int main(void) size_t i; fsm_state_t end_state; - s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_determinise(fsm); assert(ret == 1); diff --git a/tests/endids/endids10_minimise_partial_overlap.c b/tests/endids/endids10_minimise_partial_overlap.c index 3d7d9e78b..5a72d05d9 100644 --- a/tests/endids/endids10_minimise_partial_overlap.c +++ b/tests/endids/endids10_minimise_partial_overlap.c @@ -33,14 +33,14 @@ int main(void) const char *regex_ab_star_c = "^ab*c$"; const char *regex_abc = "^abc$"; - struct fsm *fsm_ab_star_c = re_comp(RE_NATIVE, fsm_sgetc, (void *)®ex_ab_star_c, NULL, NULL, 0, NULL); + struct fsm *fsm_ab_star_c = re_comp(RE_NATIVE, fsm_sgetc, (void *)®ex_ab_star_c, NULL, 0, NULL); assert(fsm_ab_star_c != NULL); if (!fsm_setendid(fsm_ab_star_c, ENDID_AB_STAR_C)) { assert(!"setendid"); } if (!fsm_determinise(fsm_ab_star_c)) { assert(!"determinise"); } if (!fsm_minimise(fsm_ab_star_c)) { assert(!"minimise"); } - struct fsm *fsm_abc = re_comp(RE_NATIVE, fsm_sgetc, (void *)®ex_abc, NULL, NULL, 0, NULL); + struct fsm *fsm_abc = re_comp(RE_NATIVE, fsm_sgetc, (void *)®ex_abc, NULL, 0, NULL); assert(fsm_abc != NULL); if (!fsm_setendid(fsm_abc, ENDID_ABC)) { assert(!"setendid"); } diff --git a/tests/endids/endids1_determinise.c b/tests/endids/endids1_determinise.c index 5b34da511..472807eed 100644 --- a/tests/endids/endids1_determinise.c +++ b/tests/endids/endids1_determinise.c @@ -25,7 +25,7 @@ int main(void) int ret; size_t nstates, state_ind; - s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm, (fsm_end_id_t) 1); assert(ret == 1); diff --git a/tests/endids/endids1_determinise_and_minimise.c b/tests/endids/endids1_determinise_and_minimise.c index a8327398a..a2feafb18 100644 --- a/tests/endids/endids1_determinise_and_minimise.c +++ b/tests/endids/endids1_determinise_and_minimise.c @@ -27,7 +27,7 @@ int main(void) int ret; size_t nstates, state_ind; - s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm, (fsm_end_id_t) 1); assert(ret == 1); diff --git a/tests/endids/endids2_union.c b/tests/endids/endids2_union.c index 72588015f..0d6182437 100644 --- a/tests/endids/endids2_union.c +++ b/tests/endids/endids2_union.c @@ -26,8 +26,8 @@ int main(void) fsm_end_id_t all_endids[2]; unsigned nstates, state_ind; - s1 = "abc"; fsm1 = re_comp(RE_NATIVE, fsm_sgetc, &s1, NULL, NULL, 0, NULL); - s2 = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s2, NULL, NULL, 0, NULL); + s1 = "abc"; fsm1 = re_comp(RE_NATIVE, fsm_sgetc, &s1, NULL, 0, NULL); + s2 = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s2, NULL, 0, NULL); assert(s1 != NULL); assert(s2 != NULL); diff --git a/tests/endids/endids2_union_many_endids.c b/tests/endids/endids2_union_many_endids.c index e152987c4..a573f1921 100644 --- a/tests/endids/endids2_union_many_endids.c +++ b/tests/endids/endids2_union_many_endids.c @@ -149,7 +149,7 @@ int main(void) strncpy(&buf[0], patterns[i], sizeof buf); bufp = &buf[0]; - new = re_comp(RE_NATIVE, fsm_sgetc, &bufp, NULL, NULL, 0, NULL); + new = re_comp(RE_NATIVE, fsm_sgetc, &bufp, NULL, 0, NULL); assert(new != NULL); ret = fsm_determinise(new); diff --git a/tests/endids/endids4.c b/tests/endids/endids4.c index a9e095193..a4530c93b 100644 --- a/tests/endids/endids4.c +++ b/tests/endids/endids4.c @@ -27,8 +27,8 @@ int main(void) fsm_end_id_t all_endids[2]; unsigned nstates, state_ind; - s1 = "abc"; fsm1 = re_comp(RE_NATIVE, fsm_sgetc, &s1, NULL, NULL, 0, NULL); - s2 = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s2, NULL, NULL, 0, NULL); + s1 = "abc"; fsm1 = re_comp(RE_NATIVE, fsm_sgetc, &s1, NULL, 0, NULL); + s2 = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s2, NULL, 0, NULL); assert(s1 != NULL); assert(s2 != NULL); diff --git a/tests/endids/endids5.c b/tests/endids/endids5.c index 923e7503d..50030ea0d 100644 --- a/tests/endids/endids5.c +++ b/tests/endids/endids5.c @@ -27,8 +27,8 @@ int main(void) fsm_end_id_t all_endids[2]; unsigned nstates, state_ind; - s1 = "(abc|def)"; fsm1 = re_comp(RE_NATIVE, fsm_sgetc, &s1, NULL, NULL, 0, NULL); - s2 = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s2, NULL, NULL, 0, NULL); + s1 = "(abc|def)"; fsm1 = re_comp(RE_NATIVE, fsm_sgetc, &s1, NULL, 0, NULL); + s2 = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s2, NULL, 0, NULL); assert(s1 != NULL); assert(s2 != NULL); diff --git a/tests/endids/endids6.c b/tests/endids/endids6.c index 37c7baced..e237c2881 100644 --- a/tests/endids/endids6.c +++ b/tests/endids/endids6.c @@ -60,14 +60,14 @@ int main(void) size_t nstates, ninfo, state_ind, info_ind, nend; int ret; - s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm, (fsm_end_id_t) 1); assert(ret == 1); { struct fsm *fsm2; - s = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm2, (fsm_end_id_t) 2); assert(ret == 1); diff --git a/tests/endids/endids7.c b/tests/endids/endids7.c index 0637b2700..3021be830 100644 --- a/tests/endids/endids7.c +++ b/tests/endids/endids7.c @@ -72,14 +72,14 @@ int main(void) size_t nstates, ninfo, state_ind, info_ind, nend; int ret; - s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm, (fsm_end_id_t) 1); assert(ret == 1); { struct fsm *fsm2; - s = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm2, (fsm_end_id_t) 2); assert(ret == 1); diff --git a/tests/endids/endids7_with_duplicates.c b/tests/endids/endids7_with_duplicates.c index 975c5c2c5..939c4b306 100644 --- a/tests/endids/endids7_with_duplicates.c +++ b/tests/endids/endids7_with_duplicates.c @@ -76,14 +76,14 @@ int main(void) size_t nstates, ninfo, state_ind, info_ind, nend; int ret; - s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm, (fsm_end_id_t) 1); assert(ret == 1); { struct fsm *fsm2; - s = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm2, (fsm_end_id_t) 2); assert(ret == 1); diff --git a/tests/endids/endids8.c b/tests/endids/endids8.c index 16db9ac8e..12b36fae0 100644 --- a/tests/endids/endids8.c +++ b/tests/endids/endids8.c @@ -27,8 +27,8 @@ int main(void) fsm_end_id_t all_ids[2]; unsigned nstates, state_ind; - s1 = "abc"; fsm1 = re_comp(RE_NATIVE, fsm_sgetc, &s1, NULL, NULL, 0, NULL); - s2 = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s2, NULL, NULL, 0, NULL); + s1 = "abc"; fsm1 = re_comp(RE_NATIVE, fsm_sgetc, &s1, NULL, 0, NULL); + s2 = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s2, NULL, 0, NULL); assert(s1 != NULL); assert(s2 != NULL); diff --git a/tests/endids/endids9.c b/tests/endids/endids9.c index 0a0d5b66e..519399973 100644 --- a/tests/endids/endids9.c +++ b/tests/endids/endids9.c @@ -37,14 +37,14 @@ int main(void) size_t nstates, ninfo, state_ind, nend; int ret; - s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "abc"; fsm = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm, (fsm_end_id_t) 1); assert(ret == 1); { struct fsm *fsm2; - s = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, NULL, 0, NULL); + s = "def"; fsm2 = re_comp(RE_NATIVE, fsm_sgetc, &s, NULL, 0, NULL); ret = fsm_setendid(fsm2, (fsm_end_id_t) 2); assert(ret == 1); diff --git a/tests/gen/gen3.c b/tests/gen/gen3.c index 56b158f41..ff9c9bd6f 100644 --- a/tests/gen/gen3.c +++ b/tests/gen/gen3.c @@ -61,7 +61,7 @@ build(void) } if (getenv("PRINT")) { - fsm_print(stderr, fsm, FSM_PRINT_FSM); + fsm_print(stderr, fsm, NULL, NULL, FSM_PRINT_FSM); } return fsm; diff --git a/tests/minimise/minimise_test_case_list.c b/tests/minimise/minimise_test_case_list.c index c3e82a236..c66f02df2 100644 --- a/tests/minimise/minimise_test_case_list.c +++ b/tests/minimise/minimise_test_case_list.c @@ -81,7 +81,7 @@ check_minimisation(const char *pattern) .offset = 0 }; - fsm = re_comp(RE_PCRE, scanner_next, &s, NULL, &opt, RE_MULTI, &err); + fsm = re_comp(RE_PCRE, scanner_next, &s, NULL, RE_MULTI, &err); assert(fsm != NULL); if (!fsm_determinise(fsm)) { return 0; @@ -110,10 +110,10 @@ check_minimisation(const char *pattern) __func__, pattern, expected_state_count, state_count_min); fprintf(stderr, "== expected:\n"); - fsm_print(stderr, oracle_min, FSM_PRINT_FSM); + fsm_print(stderr, oracle_min, &opt, NULL, FSM_PRINT_FSM); fprintf(stderr, "== got:\n"); - fsm_print(stderr, fsm, FSM_PRINT_FSM); + fsm_print(stderr, fsm, &opt, NULL, FSM_PRINT_FSM); } fsm_free(oracle_min); diff --git a/tests/re_strings/testutil.c b/tests/re_strings/testutil.c index d72a209f8..4f371f797 100644 --- a/tests/re_strings/testutil.c +++ b/tests/re_strings/testutil.c @@ -32,7 +32,7 @@ run_test(const char **strings) const int flags = 0; /* not anchored */ - struct fsm *fsm = re_strings_build(s, NULL, NULL, flags); + struct fsm *fsm = re_strings_build(s, NULL, flags); assert(fsm != NULL); /* Each literal string input should match, and the set of