From bec4510a0fb892cf6faed5d6d096b701b7626a5b Mon Sep 17 00:00:00 2001 From: llpkgc upstream Date: Tue, 7 Jul 2026 15:15:52 -0400 Subject: [PATCH] llpkgc 2026-07-07 (12b80381) Code extracted from: https://gitlab.kitware.com/utils/llpkgc.git at commit 12b80381152d003186ee3bddb200743b4ce91ffa (12b80381152d003186ee3bddb200743b4ce91ffa). --- LICENSE.rst | 28 + llpkgc.c | 205 ---- llpkgc.h | 147 +-- llpkgc__internal.c | 1069 ----------------- llpkgc__internal.h | 37 - llpkgc_dep.c | 181 +++ llpkgc_dep.h | 85 ++ llpkgc_dep__internal.c | 565 +++++++++ llpkgc_dep__internal.h | 35 + llpkgc_file.c | 338 ++++++ llpkgc_file.h | 92 ++ llpkgc_file__internal.c | 2489 +++++++++++++++++++++++++++++++++++++++ llpkgc_file__internal.h | 41 + llpkgc_frag.c | 215 ++++ llpkgc_frag.h | 83 ++ llpkgc_frag__internal.c | 674 +++++++++++ llpkgc_frag__internal.h | 36 + 17 files changed, 4867 insertions(+), 1453 deletions(-) create mode 100644 LICENSE.rst delete mode 100644 llpkgc.c delete mode 100644 llpkgc__internal.c delete mode 100644 llpkgc__internal.h create mode 100644 llpkgc_dep.c create mode 100644 llpkgc_dep.h create mode 100644 llpkgc_dep__internal.c create mode 100644 llpkgc_dep__internal.h create mode 100644 llpkgc_file.c create mode 100644 llpkgc_file.h create mode 100644 llpkgc_file__internal.c create mode 100644 llpkgc_file__internal.h create mode 100644 llpkgc_frag.c create mode 100644 llpkgc_frag.h create mode 100644 llpkgc_frag__internal.c create mode 100644 llpkgc_frag__internal.h diff --git a/LICENSE.rst b/LICENSE.rst new file mode 100644 index 0000000000..5b1e11579b --- /dev/null +++ b/LICENSE.rst @@ -0,0 +1,28 @@ +Copyright 2024-2026 Kitware, Inc. and Contributors + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Kitware, Inc. nor the names of Contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/llpkgc.c b/llpkgc.c deleted file mode 100644 index 33c9043cb9..0000000000 --- a/llpkgc.c +++ /dev/null @@ -1,205 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ - -#include -#include - -#include "llpkgc.h" - -#define CALLBACK_MAYBE(PARSER, NAME) \ - do { \ - const llpkgc_settings_t* settings; \ - settings = (const llpkgc_settings_t*) (PARSER)->settings; \ - if(settings == NULL || settings->NAME == NULL) { \ - err = 0; \ - break; \ - } \ - err = settings->NAME((PARSER)); \ - } while(0) - -#define SPAN_CALLBACK_MAYBE(PARSER, NAME, START, LEN) \ - do { \ - const llpkgc_settings_t* settings; \ - settings = (const llpkgc_settings_t*) (PARSER)->settings; \ - if(settings == NULL || settings->NAME == NULL) { \ - err = 0; \ - break; \ - } \ - err = settings->NAME((PARSER), (START), (LEN)); \ - if(err == -1) { \ - err = PCE_USER; \ - llpkgc_set_error_reason((PARSER), "Span callback error in " #NAME); \ - } \ - } while(0) - -void llpkgc_init(llpkgc_t* parser, const llpkgc_settings_t* settings) { - llpkgc__internal_init(parser); - - parser->settings = (void*) settings; -} - -void llpkgc_reset(llpkgc_t* parser) { - llpkgc_settings_t* settings = parser->settings; - void* data = parser->data; - - llpkgc__internal_init(parser); - - parser->settings = settings; - parser->data = data; -} - -void llpkgc_settings_init(llpkgc_settings_t* settings) { - memset(settings, 0, sizeof(*settings)); -} - -llpkgc_errno_t llpkgc_execute(llpkgc_t* parser, const char* data, size_t len) { - return llpkgc__internal_execute(parser, data, data + len); -} - -llpkgc_errno_t llpkgc_finish(llpkgc_t* parser) { - if(parser->error != 0) - return parser->error; - - int err; - // ToDo: Better handling of user callback errors here - if(parser->unfinished_ == 1) { - parser->reason = "Invalid EOF state"; - parser->error = PCE_UNFINISHED; - return PCE_UNFINISHED; - } else if(parser->unfinished_ == 2) { - CALLBACK_MAYBE(parser, on_value_literal_complete); - if(err != PCE_OK) { - parser->error = err; - return err; - } - CALLBACK_MAYBE(parser, on_value_complete); - if(err != PCE_OK) { - parser->error = err; - return err; - } - } else if(parser->unfinished_ == 3) { - CALLBACK_MAYBE(parser, on_value_complete); - if(err != PCE_OK) { - parser->error = err; - return err; - } - } - - CALLBACK_MAYBE(parser, on_pkgc_complete); - return err; -} - -void llpkgc_pause(llpkgc_t* parser) { - if(parser->error != PCE_OK) { - return; - } - - parser->error = PCE_PAUSED; - parser->reason = "Paused"; -} - -void llpkgc_resume(llpkgc_t* parser) { - if(parser->error != PCE_PAUSED) { - return; - } - - parser->error = 0; -} - -llpkgc_errno_t llpkgc_get_errno(const llpkgc_t* parser) { - return parser->error; -} - -const char* llpkgc_get_error_reason(const llpkgc_t* parser) { - return parser->reason; -} - -void llpkgc_set_error_reason(llpkgc_t* parser, const char* reason) { - parser->reason = reason; -} - -const char* llpkgc_get_error_pos(const llpkgc_t* parser) { - return parser->error_pos; -} - -const char* llpkgc_errno_name(llpkgc_errno_t err) { - switch(err) { - case PCE_OK: - return "PCE_OK"; - case PCE_INTERNAL: - return "PCE_INTERNAL"; - case PCE_PAUSED: - return "PCE_PAUSED"; - case PCE_USER: - return "PCE_USER"; - case PCE_UNFINISHED: - return "PCE_UNFINISHED"; - } - return "INVALID_ERRNO"; -} - -int llpkgc__line_begin(llpkgc_t* s, const char* p, const char* endp) { - int err; - s->unfinished_ = 1; - CALLBACK_MAYBE(s, on_line_begin); - return err; -} - -int llpkgc__key_span(llpkgc_t* s, const char* p, const char* endp) { - int err; - SPAN_CALLBACK_MAYBE(s, on_key, p, endp - p); - return err; -} - -int llpkgc__keyword_complete(llpkgc_t* s, const char* p, const char* endp) { - int err; - s->unfinished_ = 3; - CALLBACK_MAYBE(s, on_keyword_complete); - return err; -} - -int llpkgc__variable_complete(llpkgc_t* s, const char* p, const char* endp) { - int err; - s->unfinished_ = 3; - CALLBACK_MAYBE(s, on_variable_complete); - return err; -} - -int llpkgc__vallit_span(llpkgc_t* s, const char* p, const char* endp) { - int err; - if(s->escaped_) { - --endp; - s->escaped_ = 0; - } - s->unfinished_ = 2; - SPAN_CALLBACK_MAYBE(s, on_value_literal, p, endp - p); - return err; -} - -int llpkgc__vallit_complete(llpkgc_t* s, const char* p, const char* endp) { - int err; - s->unfinished_ = 3; - CALLBACK_MAYBE(s, on_value_literal_complete); - return err; -} - -int llpkgc__valvar_span(llpkgc_t* s, const char* p, const char* endp) { - int err; - s->unfinished_ = 1; - SPAN_CALLBACK_MAYBE(s, on_value_variable, p, endp - p); - return err; -} - -int llpkgc__valvar_complete(llpkgc_t* s, const char* p, const char* endp) { - int err; - s->unfinished_ = 3; - CALLBACK_MAYBE(s, on_value_variable_complete); - return err; -} - -int llpkgc__value_complete(llpkgc_t* s, const char* p, const char* endp) { - int err; - s->unfinished_ = 0; - CALLBACK_MAYBE(s, on_value_complete); - return err; -} diff --git a/llpkgc.h b/llpkgc.h index b7d0724e8f..f9df5e32aa 100644 --- a/llpkgc.h +++ b/llpkgc.h @@ -1,143 +1,6 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ -#ifndef INCLUDE_LLPKGC_API_H_ -#define INCLUDE_LLPKGC_API_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include - -#include "llpkgc__internal.h" - -#if defined(_MSC_VER) -#define LLPKGC_EXPORT __declspec(dllexport) -#else -#define LLPKGC_EXPORT __attribute__((visibility("default"))) -#endif - -typedef llpkgc__internal_t llpkgc_t; -typedef struct llpkgc_settings_s llpkgc_settings_t; - -typedef int (*llpkgc_data_cb)(llpkgc_t*, const char* at, size_t length); -typedef int (*llpkgc_cb)(llpkgc_t*); - -struct llpkgc_settings_s { - /* Possible return values 0, -1, PCE_USER */ - llpkgc_data_cb on_key; - llpkgc_data_cb on_value_literal; - llpkgc_data_cb on_value_variable; - - /* Possible return values 0, -1, `PCE_PAUSED` */ - llpkgc_cb on_line_begin; - llpkgc_cb on_keyword_complete; - llpkgc_cb on_variable_complete; - llpkgc_cb on_value_literal_complete; - llpkgc_cb on_value_variable_complete; - llpkgc_cb on_value_complete; - llpkgc_cb on_pkgc_complete; -}; - -enum llpkgc_errno { - PCE_OK = 0, - PCE_INTERNAL = 1, - PCE_PAUSED = 2, - PCE_USER = 3, - PCE_UNFINISHED = 4, -}; -typedef enum llpkgc_errno llpkgc_errno_t; - -/* Initialize the parser with user settings. - * - * NOTE: lifetime of `settings` has to be at least the same as the lifetime of - * the `parser` here. In practice, `settings` has to be either a static - * variable or be allocated with `malloc`, `new`, etc. - */ -LLPKGC_EXPORT -void llpkgc_init(llpkgc_t* parser, const llpkgc_settings_t* settings); - -/* Reset an already initialized parser back to the start state, preserving the - * existing callback settings and user data. - */ -LLPKGC_EXPORT -void llpkgc_reset(llpkgc_t* parser); - -/* Initialize the settings object */ -LLPKGC_EXPORT -void llpkgc_settings_init(llpkgc_settings_t* settings); - -/* Parse full or partial pc data, invoking user callbacks along the way. - * - * If any of `llpkgc_data_cb` returns errno not equal to `PCE_OK` - the parsing - * interrupts, and such errno is returned from `llpkgc_execute()`. If - * `PCE_PAUSED` was used as an errno, the execution can be resumed with - * `llpkgc_resume()` call. - * - * NOTE: if this function ever returns a non-pause type error, it will continue - * to return the same error upon each successive call up until `llpkgc_init()` - * or `llpkgc_reset()` are called. - */ -LLPKGC_EXPORT -llpkgc_errno_t llpkgc_execute(llpkgc_t* parser, const char* data, size_t len); - -/* This method should be called when the input has reached EOF - * - * This method will invoke `on_pkgc_complete()` callback if the file was - * terminated safely. Otherwise an error code will be returned. - */ -LLPKGC_EXPORT -llpkgc_errno_t llpkgc_finish(llpkgc_t* parser); - -/* Make further calls of `llpkgc_execute()` return `PCE_PAUSED` and set - * appropriate error reason. - * - * Important: do not call this from user callbacks! User callbacks must return - * `PCE_PAUSED` if pausing is required. - */ -LLPKGC_EXPORT -void llpkgc_pause(llpkgc_t* parser); - -/* Might be called to resume the execution after the pause in user's callback. - * See `llpkgc_execute()` above for details. - * - * Call this only if `llpkgc_execute()` returns `PCE_PAUSED`. - */ -LLPKGC_EXPORT -void llpkgc_resume(llpkgc_t* parser); - -/* Returns the latest return error */ -LLPKGC_EXPORT -llpkgc_errno_t llpkgc_get_errno(const llpkgc_t* parser); - -/* Returns the verbal explanation of the latest returned error. - * - * Note: User callback should set error reason when returning the error. See - * `llpkgc_set_error_reason()` for details. - */ -LLPKGC_EXPORT -const char* llpkgc_get_error_reason(const llpkgc_t* parser); - -/* Assign verbal description to the returned error. Must be called in user - * callbacks right before returning the errno. - * - * Note: `PCE_USER` error code might be useful in user callbacks. - */ -LLPKGC_EXPORT -void llpkgc_set_error_reason(llpkgc_t* parser, const char* reason); - -/* Returns the pointer to the last parsed byte before the returned error. The - * pointer is relative to the `data` argument of `llpkgc_execute()`. - * - * Note: this method might be useful for counting the number of parsed bytes. - */ -LLPKGC_EXPORT -const char* llpkgc_get_error_pos(const llpkgc_t* parser); - -/* Returns textual name of error code */ -LLPKGC_EXPORT -const char* llpkgc_errno_name(llpkgc_errno_t err); - -#ifdef __cplusplus -} /* extern "C" */ -#endif -#endif /* INCLUDE_LLPKGC_API_H_ */ +#include "llpkgc_dep.h" +#include "llpkgc_file.h" +#include "llpkgc_frag.h" diff --git a/llpkgc__internal.c b/llpkgc__internal.c deleted file mode 100644 index 2eaba127ca..0000000000 --- a/llpkgc__internal.c +++ /dev/null @@ -1,1069 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ - -/* This code was generated by llpkgc, do not edit it by hand - See: https://gitlab.kitware.com/utils/llpkgc */ - - -#include -#include -#include - -#ifdef __SSE4_2__ - #ifdef _MSC_VER - #include - #else /* !_MSC_VER */ - #include - #endif /* _MSC_VER */ -#endif /* __SSE4_2__ */ - -#ifdef _MSC_VER - #define ALIGN(n) _declspec(align(n)) -#else /* !_MSC_VER */ - #define ALIGN(n) __attribute__((aligned(n))) -#endif /* _MSC_VER */ - -#include "llpkgc__internal.h" - -typedef int (*llpkgc__internal__span_cb)( - llpkgc__internal_t*, const char*, const char*); - -enum llparse_state_e { - s_error, - s_n_llpkgc__internal__n_comment, - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete, - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_1, - s_n_llpkgc__internal__n_literal_skip_dollar, - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_2, - s_n_llpkgc__internal__n_maybe_CR, - s_n_llpkgc__internal__n_skip_escaped_LF, - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_3, - s_n_llpkgc__internal__n_maybe_LF, - s_n_llpkgc__internal__n_skip_escaped_CR, - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_4, - s_n_llpkgc__internal__n_literal_skip_hash, - s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_1, - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_5, - s_n_llpkgc__internal__n_maybe_escaped, - s_n_llpkgc__internal__n_literal, - s_n_llpkgc__internal__n_variable_skip_dollar, - s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span, - s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_2, - s_n_llpkgc__internal__n_variable_close, - s_n_llpkgc__internal__n_variable_skip_curly, - s_n_llpkgc__internal__n_invoke_llpkgc__valvar_complete, - s_n_llpkgc__internal__n_variable, - s_n_llpkgc__internal__n_span_start_llpkgc__valvar_span, - s_n_llpkgc__internal__n_maybe_variable, - s_n_llpkgc__internal__n_expect_value, - s_n_llpkgc__internal__n_expect_sep, - s_n_llpkgc__internal__n_key, - s_n_llpkgc__internal__n_span_start_llpkgc__key_span, - s_n_llpkgc__internal__n_line_start, -}; -typedef enum llparse_state_e llparse_state_t; - -int llpkgc__key_span( - llpkgc__internal_t* s, const unsigned char* p, - const unsigned char* endp); - -int llpkgc__vallit_span( - llpkgc__internal_t* s, const unsigned char* p, - const unsigned char* endp); - -int llpkgc__valvar_span( - llpkgc__internal_t* s, const unsigned char* p, - const unsigned char* endp); - -int llpkgc__line_begin( - llpkgc__internal_t* s, const unsigned char* p, - const unsigned char* endp); - -int llpkgc__keyword_complete( - llpkgc__internal_t* s, const unsigned char* p, - const unsigned char* endp); - -int llpkgc__value_complete( - llpkgc__internal_t* s, const unsigned char* p, - const unsigned char* endp); - -int llpkgc__vallit_complete( - llpkgc__internal_t* s, const unsigned char* p, - const unsigned char* endp); - -int llpkgc__internal__c_update_escaped_( - llpkgc__internal_t* state, - const unsigned char* p, - const unsigned char* endp) { - state->escaped_ = 1; - return 0; -} - -int llpkgc__valvar_complete( - llpkgc__internal_t* s, const unsigned char* p, - const unsigned char* endp); - -int llpkgc__variable_complete( - llpkgc__internal_t* s, const unsigned char* p, - const unsigned char* endp); - -int llpkgc__internal_init(llpkgc__internal_t* state) { - memset(state, 0, sizeof(*state)); - state->_current = (void*) (intptr_t) s_n_llpkgc__internal__n_line_start; - return 0; -} - -static llparse_state_t llpkgc__internal__run( - llpkgc__internal_t* state, - const unsigned char* p, - const unsigned char* endp) { - int match; - switch ((llparse_state_t) (intptr_t) state->_current) { - case s_n_llpkgc__internal__n_comment: - s_n_llpkgc__internal__n_comment: { - if (p == endp) { - return s_n_llpkgc__internal__n_comment; - } - switch (*p) { - case 10: { - p++; - goto s_n_llpkgc__internal__n_line_start; - } - case 13: { - p++; - goto s_n_llpkgc__internal__n_line_start; - } - default: { - p++; - goto s_n_llpkgc__internal__n_comment; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete: - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete: { - switch (llpkgc__vallit_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_invoke_llpkgc__value_complete_1; - default: - goto s_n_llpkgc__internal__n_error_3; - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_1: - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_1: { - switch (llpkgc__vallit_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_invoke_llpkgc__value_complete_2; - default: - goto s_n_llpkgc__internal__n_error_5; - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_literal_skip_dollar: - s_n_llpkgc__internal__n_literal_skip_dollar: { - if (p == endp) { - return s_n_llpkgc__internal__n_literal_skip_dollar; - } - p++; - goto s_n_llpkgc__internal__n_maybe_variable; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_2: - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_2: { - switch (llpkgc__vallit_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_literal_skip_dollar; - default: - goto s_n_llpkgc__internal__n_error_7; - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_maybe_CR: - s_n_llpkgc__internal__n_maybe_CR: { - if (p == endp) { - return s_n_llpkgc__internal__n_maybe_CR; - } - switch (*p) { - case 13: { - p++; - goto s_n_llpkgc__internal__n_expect_value; - } - default: { - goto s_n_llpkgc__internal__n_expect_value; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_skip_escaped_LF: - s_n_llpkgc__internal__n_skip_escaped_LF: { - if (p == endp) { - return s_n_llpkgc__internal__n_skip_escaped_LF; - } - p++; - goto s_n_llpkgc__internal__n_maybe_CR; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_3: - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_3: { - switch (llpkgc__vallit_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_skip_escaped_LF; - default: - goto s_n_llpkgc__internal__n_error_8; - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_maybe_LF: - s_n_llpkgc__internal__n_maybe_LF: { - if (p == endp) { - return s_n_llpkgc__internal__n_maybe_LF; - } - switch (*p) { - case 10: { - p++; - goto s_n_llpkgc__internal__n_expect_value; - } - default: { - goto s_n_llpkgc__internal__n_expect_value; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_skip_escaped_CR: - s_n_llpkgc__internal__n_skip_escaped_CR: { - if (p == endp) { - return s_n_llpkgc__internal__n_skip_escaped_CR; - } - p++; - goto s_n_llpkgc__internal__n_maybe_LF; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_4: - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_4: { - switch (llpkgc__vallit_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_skip_escaped_CR; - default: - goto s_n_llpkgc__internal__n_error_9; - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_literal_skip_hash: - s_n_llpkgc__internal__n_literal_skip_hash: { - if (p == endp) { - return s_n_llpkgc__internal__n_literal_skip_hash; - } - p++; - goto s_n_llpkgc__internal__n_literal; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_1: - s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_1: { - if (p == endp) { - return s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_1; - } - state->_span_pos0 = (void*) p; - state->_span_cb0 = llpkgc__vallit_span; - goto s_n_llpkgc__internal__n_literal_skip_hash; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_5: - s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_5: { - switch (llpkgc__vallit_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_1; - default: - goto s_n_llpkgc__internal__n_error_10; - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_maybe_escaped: - s_n_llpkgc__internal__n_maybe_escaped: { - if (p == endp) { - return s_n_llpkgc__internal__n_maybe_escaped; - } - switch (*p) { - case 10: { - goto s_n_llpkgc__internal__n_invoke_update_escaped_; - } - case 13: { - goto s_n_llpkgc__internal__n_invoke_update_escaped__1; - } - case '#': { - goto s_n_llpkgc__internal__n_invoke_update_escaped__2; - } - default: { - goto s_n_llpkgc__internal__n_literal; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_literal: - s_n_llpkgc__internal__n_literal: { - if (p == endp) { - return s_n_llpkgc__internal__n_literal; - } - switch (*p) { - case 10: { - goto s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span; - } - case 13: { - goto s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span; - } - case '#': { - goto s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_1; - } - case '$': { - goto s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_2; - } - case 92: { - p++; - goto s_n_llpkgc__internal__n_maybe_escaped; - } - default: { - p++; - goto s_n_llpkgc__internal__n_literal; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_variable_skip_dollar: - s_n_llpkgc__internal__n_variable_skip_dollar: { - if (p == endp) { - return s_n_llpkgc__internal__n_variable_skip_dollar; - } - p++; - goto s_n_llpkgc__internal__n_literal; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span: - s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span: { - if (p == endp) { - return s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span; - } - state->_span_pos0 = (void*) p; - state->_span_cb0 = llpkgc__vallit_span; - goto s_n_llpkgc__internal__n_variable_skip_dollar; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_2: - s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_2: { - if (p == endp) { - return s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_2; - } - state->_span_pos0 = (void*) p; - state->_span_cb0 = llpkgc__vallit_span; - goto s_n_llpkgc__internal__n_literal; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_variable_close: - s_n_llpkgc__internal__n_variable_close: { - if (p == endp) { - return s_n_llpkgc__internal__n_variable_close; - } - switch (*p) { - case 10: { - goto s_n_llpkgc__internal__n_invoke_llpkgc__value_complete; - } - case 13: { - goto s_n_llpkgc__internal__n_invoke_llpkgc__value_complete; - } - case '#': { - goto s_n_llpkgc__internal__n_invoke_llpkgc__value_complete; - } - case '$': { - p++; - goto s_n_llpkgc__internal__n_maybe_variable; - } - default: { - goto s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_2; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_variable_skip_curly: - s_n_llpkgc__internal__n_variable_skip_curly: { - if (p == endp) { - return s_n_llpkgc__internal__n_variable_skip_curly; - } - p++; - goto s_n_llpkgc__internal__n_variable_close; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_invoke_llpkgc__valvar_complete: - s_n_llpkgc__internal__n_invoke_llpkgc__valvar_complete: { - switch (llpkgc__valvar_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_variable_skip_curly; - default: - goto s_n_llpkgc__internal__n_error_11; - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_variable: - s_n_llpkgc__internal__n_variable: { - static uint8_t lookup_table[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 2, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - if (p == endp) { - return s_n_llpkgc__internal__n_variable; - } - switch (lookup_table[(uint8_t) *p]) { - case 1: { - p++; - goto s_n_llpkgc__internal__n_variable; - } - case 2: { - goto s_n_llpkgc__internal__n_span_end_llpkgc__valvar_span; - } - default: { - goto s_n_llpkgc__internal__n_error_12; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_span_start_llpkgc__valvar_span: - s_n_llpkgc__internal__n_span_start_llpkgc__valvar_span: { - if (p == endp) { - return s_n_llpkgc__internal__n_span_start_llpkgc__valvar_span; - } - state->_span_pos0 = (void*) p; - state->_span_cb0 = llpkgc__valvar_span; - goto s_n_llpkgc__internal__n_variable; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_maybe_variable: - s_n_llpkgc__internal__n_maybe_variable: { - if (p == endp) { - return s_n_llpkgc__internal__n_maybe_variable; - } - switch (*p) { - case '$': { - goto s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span; - } - case '{': { - p++; - goto s_n_llpkgc__internal__n_span_start_llpkgc__valvar_span; - } - default: { - goto s_n_llpkgc__internal__n_error_13; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_expect_value: - s_n_llpkgc__internal__n_expect_value: { - if (p == endp) { - return s_n_llpkgc__internal__n_expect_value; - } - switch (*p) { - case 9: { - p++; - goto s_n_llpkgc__internal__n_expect_value; - } - case 10: { - goto s_n_llpkgc__internal__n_invoke_llpkgc__value_complete; - } - case 13: { - goto s_n_llpkgc__internal__n_invoke_llpkgc__value_complete; - } - case ' ': { - p++; - goto s_n_llpkgc__internal__n_expect_value; - } - case '#': { - goto s_n_llpkgc__internal__n_invoke_llpkgc__value_complete; - } - case '$': { - p++; - goto s_n_llpkgc__internal__n_maybe_variable; - } - default: { - goto s_n_llpkgc__internal__n_span_start_llpkgc__vallit_span_2; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_expect_sep: - s_n_llpkgc__internal__n_expect_sep: { - if (p == endp) { - return s_n_llpkgc__internal__n_expect_sep; - } - switch (*p) { - case 9: { - p++; - goto s_n_llpkgc__internal__n_expect_sep; - } - case ' ': { - p++; - goto s_n_llpkgc__internal__n_expect_sep; - } - case ':': { - p++; - goto s_n_llpkgc__internal__n_invoke_llpkgc__keyword_complete; - } - case '=': { - p++; - goto s_n_llpkgc__internal__n_invoke_llpkgc__variable_complete; - } - default: { - goto s_n_llpkgc__internal__n_error_15; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_key: - s_n_llpkgc__internal__n_key: { - static uint8_t lookup_table[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 1, 0, 0, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - if (p == endp) { - return s_n_llpkgc__internal__n_key; - } - switch (lookup_table[(uint8_t) *p]) { - case 1: { - goto s_n_llpkgc__internal__n_span_end_llpkgc__key_span; - } - case 2: { - p++; - goto s_n_llpkgc__internal__n_key; - } - default: { - goto s_n_llpkgc__internal__n_error_16; - } - } - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_span_start_llpkgc__key_span: - s_n_llpkgc__internal__n_span_start_llpkgc__key_span: { - if (p == endp) { - return s_n_llpkgc__internal__n_span_start_llpkgc__key_span; - } - state->_span_pos0 = (void*) p; - state->_span_cb0 = llpkgc__key_span; - goto s_n_llpkgc__internal__n_key; - /* UNREACHABLE */; - abort(); - } - case s_n_llpkgc__internal__n_line_start: - s_n_llpkgc__internal__n_line_start: { - static uint8_t lookup_table[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 3, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - if (p == endp) { - return s_n_llpkgc__internal__n_line_start; - } - switch (lookup_table[(uint8_t) *p]) { - case 1: { - p++; - goto s_n_llpkgc__internal__n_line_start; - } - case 2: { - p++; - goto s_n_llpkgc__internal__n_comment; - } - case 3: { - goto s_n_llpkgc__internal__n_invoke_llpkgc__line_begin; - } - default: { - goto s_n_llpkgc__internal__n_error_17; - } - } - /* UNREACHABLE */; - abort(); - } - default: - /* UNREACHABLE */ - abort(); - } - s_n_llpkgc__internal__n_error_2: { - state->error = 0xb; - state->reason = "Value complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_invoke_llpkgc__value_complete: { - switch (llpkgc__value_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_line_start; - default: - goto s_n_llpkgc__internal__n_error_2; - } - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_4: { - state->error = 0xb; - state->reason = "Value complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_invoke_llpkgc__value_complete_1: { - switch (llpkgc__value_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_line_start; - default: - goto s_n_llpkgc__internal__n_error_4; - } - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_3: { - state->error = 0xa; - state->reason = "Literal complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span: { - const unsigned char* start; - int err; - - start = state->_span_pos0; - state->_span_pos0 = NULL; - err = llpkgc__vallit_span(state, start, p); - if (err != 0) { - state->error = err; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete; - return s_error; - } - goto s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_6: { - state->error = 0xb; - state->reason = "Value complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_invoke_llpkgc__value_complete_2: { - switch (llpkgc__value_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_comment; - default: - goto s_n_llpkgc__internal__n_error_6; - } - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_5: { - state->error = 0xa; - state->reason = "Literal complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_1: { - const unsigned char* start; - int err; - - start = state->_span_pos0; - state->_span_pos0 = NULL; - err = llpkgc__vallit_span(state, start, p); - if (err != 0) { - state->error = err; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_1; - return s_error; - } - goto s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_1; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_7: { - state->error = 0xa; - state->reason = "Literal complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_2: { - const unsigned char* start; - int err; - - start = state->_span_pos0; - state->_span_pos0 = NULL; - err = llpkgc__vallit_span(state, start, p); - if (err != 0) { - state->error = err; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_2; - return s_error; - } - goto s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_2; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_8: { - state->error = 0xa; - state->reason = "Literal complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_3: { - const unsigned char* start; - int err; - - start = state->_span_pos0; - state->_span_pos0 = NULL; - err = llpkgc__vallit_span(state, start, p); - if (err != 0) { - state->error = err; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_3; - return s_error; - } - goto s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_3; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_invoke_update_escaped_: { - switch (llpkgc__internal__c_update_escaped_(state, p, endp)) { - default: - goto s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_3; - } - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_9: { - state->error = 0xa; - state->reason = "Literal complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_4: { - const unsigned char* start; - int err; - - start = state->_span_pos0; - state->_span_pos0 = NULL; - err = llpkgc__vallit_span(state, start, p); - if (err != 0) { - state->error = err; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_4; - return s_error; - } - goto s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_4; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_invoke_update_escaped__1: { - switch (llpkgc__internal__c_update_escaped_(state, p, endp)) { - default: - goto s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_4; - } - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_10: { - state->error = 0xa; - state->reason = "Literal complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_5: { - const unsigned char* start; - int err; - - start = state->_span_pos0; - state->_span_pos0 = NULL; - err = llpkgc__vallit_span(state, start, p); - if (err != 0) { - state->error = err; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_5; - return s_error; - } - goto s_n_llpkgc__internal__n_invoke_llpkgc__vallit_complete_5; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_invoke_update_escaped__2: { - switch (llpkgc__internal__c_update_escaped_(state, p, endp)) { - default: - goto s_n_llpkgc__internal__n_span_end_llpkgc__vallit_span_5; - } - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_11: { - state->error = 0xc; - state->reason = "Variable complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_span_end_llpkgc__valvar_span: { - const unsigned char* start; - int err; - - start = state->_span_pos0; - state->_span_pos0 = NULL; - err = llpkgc__valvar_span(state, start, p); - if (err != 0) { - state->error = err; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_n_llpkgc__internal__n_invoke_llpkgc__valvar_complete; - return s_error; - } - goto s_n_llpkgc__internal__n_invoke_llpkgc__valvar_complete; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_12: { - state->error = 0xd; - state->reason = "Invalid variable character"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_13: { - state->error = 0x9; - state->reason = "Unexpected `$`"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_1: { - state->error = 0x5; - state->reason = "Keyword complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_invoke_llpkgc__keyword_complete: { - switch (llpkgc__keyword_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_expect_value; - default: - goto s_n_llpkgc__internal__n_error_1; - } - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_14: { - state->error = 0x6; - state->reason = "Variable complete error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_invoke_llpkgc__variable_complete: { - switch (llpkgc__variable_complete(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_expect_value; - default: - goto s_n_llpkgc__internal__n_error_14; - } - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_15: { - state->error = 0x7; - state->reason = "Expected seperator"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_span_end_llpkgc__key_span: { - const unsigned char* start; - int err; - - start = state->_span_pos0; - state->_span_pos0 = NULL; - err = llpkgc__key_span(state, start, p); - if (err != 0) { - state->error = err; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_n_llpkgc__internal__n_expect_sep; - return s_error; - } - goto s_n_llpkgc__internal__n_expect_sep; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_16: { - state->error = 0x4; - state->reason = "Invalid key character"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error: { - state->error = 0x63; - state->reason = "Line start error"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_invoke_llpkgc__line_begin: { - switch (llpkgc__line_begin(state, p, endp)) { - case 0: - goto s_n_llpkgc__internal__n_span_start_llpkgc__key_span; - default: - goto s_n_llpkgc__internal__n_error; - } - /* UNREACHABLE */; - abort(); - } - s_n_llpkgc__internal__n_error_17: { - state->error = 0x2; - state->reason = "Expected key"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } -} - -int llpkgc__internal_execute(llpkgc__internal_t* state, const char* p, const char* endp) { - llparse_state_t next; - - /* check lingering errors */ - if (state->error != 0) { - return state->error; - } - - /* restart spans */ - if (state->_span_pos0 != NULL) { - state->_span_pos0 = (void*) p; - } - - next = llpkgc__internal__run(state, (const unsigned char*) p, (const unsigned char*) endp); - if (next == s_error) { - return state->error; - } - state->_current = (void*) (intptr_t) next; - - /* execute spans */ - if (state->_span_pos0 != NULL) { - int error; - - error = ((llpkgc__internal__span_cb) state->_span_cb0)(state, state->_span_pos0, (const char*) endp); - if (error != 0) { - state->error = error; - state->error_pos = endp; - return error; - } - } - - return 0; -} diff --git a/llpkgc__internal.h b/llpkgc__internal.h deleted file mode 100644 index 34ec1d2547..0000000000 --- a/llpkgc__internal.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ - -/* This code was generated by llpkgc, do not edit it by hand - See: https://gitlab.kitware.com/utils/llpkgc */ - - -#ifndef INCLUDE_LLPKGC__INTERNAL_H_ -#define INCLUDE_LLPKGC__INTERNAL_H_ -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef struct llpkgc__internal_s llpkgc__internal_t; -struct llpkgc__internal_s { - int32_t _index; - void* _span_pos0; - void* _span_cb0; - int32_t error; - const char* reason; - const char* error_pos; - void* data; - void* _current; - void* settings; - uint8_t unfinished_; - uint8_t escaped_; -}; - -int llpkgc__internal_init(llpkgc__internal_t* s); -int llpkgc__internal_execute(llpkgc__internal_t* s, const char* p, const char* endp); - -#ifdef __cplusplus -} /* extern "C" */ -#endif -#endif /* INCLUDE_LLPKGC__INTERNAL_H_ */ diff --git a/llpkgc_dep.c b/llpkgc_dep.c new file mode 100644 index 0000000000..c48dc43029 --- /dev/null +++ b/llpkgc_dep.c @@ -0,0 +1,181 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ + +#include +#include +#include + +#include "llpkgc_dep.h" + +#define CALLBACK_MAYBE(PARSER, NAME) \ + do { \ + const llpkgc_dep_settings_t* settings; \ + settings = \ + (const llpkgc_dep_settings_t*) (PARSER)->llpkgc_dep__settings; \ + if(settings == NULL || settings->NAME == NULL) { \ + err = 0; \ + break; \ + } \ + err = settings->NAME((PARSER)); \ + } while(0) + +#define SPAN_CALLBACK_MAYBE(PARSER, NAME, START, LEN) \ + do { \ + const llpkgc_dep_settings_t* settings; \ + settings = \ + (const llpkgc_dep_settings_t*) (PARSER)->llpkgc_dep__settings; \ + if(settings == NULL || settings->NAME == NULL) { \ + err = 0; \ + break; \ + } \ + err = settings->NAME((PARSER), (START), (LEN)); \ + if(err == -1) { \ + err = PDEP_USER; \ + llpkgc_dep_set_error_reason((PARSER), "Span callback error in " #NAME); \ + } \ + } while(0) + +enum llpkgc_dep_state { + PDEP_START = 0, + PDEP_DEP_NAME = 1, + PDEP_DEP_OP = 2, + PDEP_AFTER_OP = 3, + PDEP_DEP_VERSION = 4, +}; + +void llpkgc_dep_init(llpkgc_dep_t* parser, + const llpkgc_dep_settings_t* settings) { + llpkgc_dep__internal_init(parser); + parser->llpkgc_dep__settings = (void*) settings; +} + +void llpkgc_dep_reset(llpkgc_dep_t* parser) { + llpkgc_dep_settings_t* settings = parser->llpkgc_dep__settings; + void* data = parser->data; + llpkgc_dep__internal_init(parser); + parser->llpkgc_dep__settings = settings; + parser->data = data; +} + +void llpkgc_dep_settings_init(llpkgc_dep_settings_t* settings) { + memset(settings, 0, sizeof(*settings)); +} + +llpkgc_dep_errno_t llpkgc_dep_execute(llpkgc_dep_t* parser, const char* data, + size_t len) { + return llpkgc_dep__internal_execute(parser, data, data + len); +} + +llpkgc_dep_errno_t llpkgc_dep_finish(llpkgc_dep_t* parser) { + int err = PDEP_OK; + + if(parser->error != 0) { + return parser->error; + } + + switch(parser->llpkgc_dep__state) { + case PDEP_DEP_NAME: + CALLBACK_MAYBE(parser, on_dep_complete); + if(err != PDEP_OK) { + parser->error = err; + return err; + } + break; + + case PDEP_DEP_OP: + case PDEP_AFTER_OP: + case PDEP_DEP_VERSION: + CALLBACK_MAYBE(parser, on_dep_complete); + if(err != PDEP_OK) { + parser->error = err; + return err; + } + break; + + case PDEP_START: + break; + } + + CALLBACK_MAYBE(parser, on_dep_list_complete); + if(err != PDEP_OK) { + parser->error = err; + return err; + } + + return PDEP_OK; +} + +void llpkgc_dep_pause(llpkgc_dep_t* parser) { + if(parser->error != PDEP_OK) { + return; + } + parser->error = PDEP_PAUSED; + parser->reason = "Paused"; +} + +void llpkgc_dep_resume(llpkgc_dep_t* parser) { + if(parser->error != PDEP_PAUSED) { + return; + } + parser->error = 0; +} + +llpkgc_dep_errno_t llpkgc_dep_get_errno(const llpkgc_dep_t* parser) { + return parser->error; +} + +const char* llpkgc_dep_get_error_reason(const llpkgc_dep_t* parser) { + return parser->reason; +} + +void llpkgc_dep_set_error_reason(llpkgc_dep_t* parser, const char* reason) { + parser->reason = reason; +} + +const char* llpkgc_dep_get_error_pos(const llpkgc_dep_t* parser) { + return parser->error_pos; +} + +const char* llpkgc_dep_errno_name(llpkgc_dep_errno_t err) { + switch(err) { + case PDEP_OK: + return "PDEP_OK"; + case PDEP_INTERNAL: + return "PDEP_INTERNAL"; + case PDEP_PAUSED: + return "PDEP_PAUSED"; + case PDEP_USER: + return "PDEP_USER"; + case PDEP_UNFINISHED: + return "PDEP_UNFINISHED"; + } + return "INVALID_ERRNO"; +} + +int llpkgc_dep__dep_name(llpkgc_dep_t* s, const char* p, + const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_dep_name, p, endp - p); + return err; +} + +int llpkgc_dep__dep_op(llpkgc_dep_t* s, const char* p, + const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_dep_op, p, endp - p); + return err; +} + +int llpkgc_dep__dep_version(llpkgc_dep_t* s, const char* p, + const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_dep_version, p, endp - p); + return err; +} + +int llpkgc_dep__dep_complete(llpkgc_dep_t* s, const char* p, + const char* endp) { + int err; + CALLBACK_MAYBE(s, on_dep_complete); + return err; +} diff --git a/llpkgc_dep.h b/llpkgc_dep.h new file mode 100644 index 0000000000..18a3aa8be3 --- /dev/null +++ b/llpkgc_dep.h @@ -0,0 +1,85 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ + +#ifndef INCLUDE_LLPKGC_DEP_API_H_ +#define INCLUDE_LLPKGC_DEP_API_H_ +#ifdef __cplusplus +extern "C" { +#endif +#include + +#include "llpkgc_dep__internal.h" + +#if defined(_MSC_VER) +#define LLPKGC_DEP_EXPORT __declspec(dllexport) +#else +#define LLPKGC_DEP_EXPORT __attribute__((visibility("default"))) +#endif + +typedef llpkgc_dep__internal_t llpkgc_dep_t; +typedef struct llpkgc_dep_settings_s llpkgc_dep_settings_t; + +typedef int ( + *llpkgc_dep_data_cb)(llpkgc_dep_t*, const char* at, size_t length); +typedef int (*llpkgc_dep_cb)(llpkgc_dep_t*); + +struct llpkgc_dep_settings_s { + llpkgc_dep_data_cb on_dep_name; + llpkgc_dep_data_cb on_dep_op; + llpkgc_dep_data_cb on_dep_version; + + llpkgc_dep_cb on_dep_complete; + llpkgc_dep_cb on_dep_list_complete; +}; + +enum llpkgc_dep_errno { + PDEP_INTERNAL = -1, + PDEP_OK = 0, + PDEP_PAUSED = 1, + PDEP_USER = 2, + PDEP_UNFINISHED = 3, +}; +typedef enum llpkgc_dep_errno llpkgc_dep_errno_t; + +LLPKGC_DEP_EXPORT +void llpkgc_dep_init(llpkgc_dep_t* parser, + const llpkgc_dep_settings_t* settings); + +LLPKGC_DEP_EXPORT +void llpkgc_dep_reset(llpkgc_dep_t* parser); + +LLPKGC_DEP_EXPORT +void llpkgc_dep_settings_init(llpkgc_dep_settings_t* settings); + +LLPKGC_DEP_EXPORT +llpkgc_dep_errno_t llpkgc_dep_execute(llpkgc_dep_t* parser, const char* data, + size_t len); + +LLPKGC_DEP_EXPORT +llpkgc_dep_errno_t llpkgc_dep_finish(llpkgc_dep_t* parser); + +LLPKGC_DEP_EXPORT +void llpkgc_dep_pause(llpkgc_dep_t* parser); + +LLPKGC_DEP_EXPORT +void llpkgc_dep_resume(llpkgc_dep_t* parser); + +LLPKGC_DEP_EXPORT +llpkgc_dep_errno_t llpkgc_dep_get_errno(const llpkgc_dep_t* parser); + +LLPKGC_DEP_EXPORT +const char* llpkgc_dep_get_error_reason(const llpkgc_dep_t* parser); + +LLPKGC_DEP_EXPORT +void llpkgc_dep_set_error_reason(llpkgc_dep_t* parser, const char* reason); + +LLPKGC_DEP_EXPORT +const char* llpkgc_dep_get_error_pos(const llpkgc_dep_t* parser); + +LLPKGC_DEP_EXPORT +const char* llpkgc_dep_errno_name(llpkgc_dep_errno_t err); + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* INCLUDE_LLPKGC_DEP_API_H_ */ diff --git a/llpkgc_dep__internal.c b/llpkgc_dep__internal.c new file mode 100644 index 0000000000..eb27e9428f --- /dev/null +++ b/llpkgc_dep__internal.c @@ -0,0 +1,565 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ +/* This code was generated by llpkgc, do not edit it by hand + See: https://gitlab.kitware.com/utils/llpkgc */ + + +#include +#include +#include + +#ifdef __SSE4_2__ + #ifdef _MSC_VER + #include + #else /* !_MSC_VER */ + #include + #endif /* _MSC_VER */ +#endif /* __SSE4_2__ */ + +#if defined(__ARM_NEON__) || defined(__ARM_NEON) + #include +#endif /* __ARM_NEON__ */ + +#ifdef __wasm__ + #include +#endif /* __wasm__ */ + +#ifdef _MSC_VER + #define ALIGN(n) _declspec(align(n)) + #define UNREACHABLE __assume(0) +#else /* !_MSC_VER */ + #define ALIGN(n) __attribute__((aligned(n))) + #define UNREACHABLE __builtin_unreachable() +#endif /* _MSC_VER */ + +#include "llpkgc_dep__internal.h" + +typedef int (*llpkgc_dep__internal__span_cb)( + llpkgc_dep__internal_t*, const char*, const char*); + +enum llparse_state_e { + s_error, + s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete, + s_n_llpkgc_dep__internal__n_pkgc_dep_dep_version, + s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_version, + s_n_llpkgc_dep__internal__n_pkgc_dep_after_op, + s_n_llpkgc_dep__internal__n_pkgc_dep_dep_op, + s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_op, + s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_1, + s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws, + s_n_llpkgc_dep__internal__n_pkgc_dep_dep_name, + s_n_llpkgc_dep__internal__n_pkgc_dep_first_dep_name, + s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_name, + s_n_llpkgc_dep__internal__n_pkgc_dep_start, +}; +typedef enum llparse_state_e llparse_state_t; + +int llpkgc_dep__dep_name( + llpkgc_dep__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_dep__dep_op( + llpkgc_dep__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_dep__dep_version( + llpkgc_dep__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_dep__internal__c_update_llpkgc_dep__state( + llpkgc_dep__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_dep__state = 1; + return 0; +} + +int llpkgc_dep__internal__c_update_llpkgc_dep__state_1( + llpkgc_dep__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_dep__state = 2; + return 0; +} + +int llpkgc_dep__internal__c_update_llpkgc_dep__state_2( + llpkgc_dep__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_dep__state = 3; + return 0; +} + +int llpkgc_dep__dep_complete( + llpkgc_dep__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_dep__internal__c_update_llpkgc_dep__state_3( + llpkgc_dep__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_dep__state = 0; + return 0; +} + +int llpkgc_dep__internal__c_update_llpkgc_dep__state_4( + llpkgc_dep__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_dep__state = 4; + return 0; +} + +int llpkgc_dep__internal_init(llpkgc_dep__internal_t* state) { + memset(state, 0, sizeof(*state)); + state->_current = (void*) (intptr_t) s_n_llpkgc_dep__internal__n_pkgc_dep_start; + return 0; +} + +static llparse_state_t llpkgc_dep__internal__run( + llpkgc_dep__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + int match; + switch ((llparse_state_t) (intptr_t) state->_current) { + case s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete: + s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete: { + switch (llpkgc_dep__dep_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_3; + default: + goto s_n_llpkgc_dep__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_pkgc_dep_dep_version: + s_n_llpkgc_dep__internal__n_pkgc_dep_dep_version: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_pkgc_dep_dep_version; + } + switch (*p) { + case 9: { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_version; + } + case ' ': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_version; + } + case ',': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_version; + } + default: { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_dep_version; + } + } + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_version: + s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_version: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_version; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_dep__dep_version; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_dep_version; + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_pkgc_dep_after_op: + s_n_llpkgc_dep__internal__n_pkgc_dep_after_op: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_pkgc_dep_after_op; + } + switch (*p) { + case 9: { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_after_op; + } + case ' ': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_after_op; + } + case ',': { + goto s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete; + } + default: { + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_4; + } + } + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_pkgc_dep_dep_op: + s_n_llpkgc_dep__internal__n_pkgc_dep_dep_op: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_pkgc_dep_dep_op; + } + switch (*p) { + case '!': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_dep_op; + } + case '<': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_dep_op; + } + case '=': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_dep_op; + } + case '>': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_dep_op; + } + default: { + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_2; + } + } + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_op: + s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_op: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_op; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_dep__dep_op; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_dep_op; + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_1: + s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_1: { + switch (llpkgc_dep__internal__c_update_llpkgc_dep__state_1(state, p, endp)) { + default: + goto s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_op; + } + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws: + s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws; + } + switch (*p) { + case 9: { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws; + } + case ' ': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws; + } + case '!': { + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_1; + } + case '<': { + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_1; + } + case '=': { + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_1; + } + case '>': { + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_1; + } + default: { + goto s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete; + } + } + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_pkgc_dep_dep_name: + s_n_llpkgc_dep__internal__n_pkgc_dep_dep_name: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_pkgc_dep_dep_name; + } + switch (*p) { + case 9: { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_2; + } + case ' ': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_2; + } + case '!': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_3; + } + case ',': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_4; + } + case '<': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_3; + } + case '=': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_3; + } + case '>': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_3; + } + default: { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_dep_name; + } + } + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_pkgc_dep_first_dep_name: + s_n_llpkgc_dep__internal__n_pkgc_dep_first_dep_name: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_pkgc_dep_first_dep_name; + } + switch (*p) { + case 9: { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name; + } + case ' ': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name; + } + case '!': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_first_dep_name; + } + case ',': { + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_1; + } + case '<': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_first_dep_name; + } + case '=': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_first_dep_name; + } + case '>': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_first_dep_name; + } + default: { + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_5; + } + } + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_name: + s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_name: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_name; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_dep__dep_name; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_first_dep_name; + UNREACHABLE; + } + case s_n_llpkgc_dep__internal__n_pkgc_dep_start: + s_n_llpkgc_dep__internal__n_pkgc_dep_start: { + if (p == endp) { + return s_n_llpkgc_dep__internal__n_pkgc_dep_start; + } + switch (*p) { + case 9: { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_start; + } + case ' ': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_start; + } + case ',': { + p++; + goto s_n_llpkgc_dep__internal__n_pkgc_dep_start; + } + default: { + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state; + } + } + UNREACHABLE; + } + default: + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_3: { + switch (llpkgc_dep__internal__c_update_llpkgc_dep__state_3(state, p, endp)) { + default: + goto s_n_llpkgc_dep__internal__n_pkgc_dep_start; + } + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_error: { + state->error = 0x1; + state->reason = "Dep complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_version: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_dep__dep_version(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete; + return s_error; + } + goto s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete; + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_4: { + switch (llpkgc_dep__internal__c_update_llpkgc_dep__state_4(state, p, endp)) { + default: + goto s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_version; + } + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_op: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_dep__dep_op(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_dep__internal__n_pkgc_dep_after_op; + return s_error; + } + goto s_n_llpkgc_dep__internal__n_pkgc_dep_after_op; + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_2: { + switch (llpkgc_dep__internal__c_update_llpkgc_dep__state_2(state, p, endp)) { + default: + goto s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_op; + } + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_dep__dep_name(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws; + return s_error; + } + goto s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws; + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_1: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_dep__dep_name(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete; + return s_error; + } + goto s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete; + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_2: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_dep__dep_name(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws; + return s_error; + } + goto s_n_llpkgc_dep__internal__n_pkgc_dep_name_ws; + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_3: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_dep__dep_name(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_1; + return s_error; + } + goto s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_1; + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_span_end_llpkgc_dep__dep_name_4: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_dep__dep_name(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete; + return s_error; + } + goto s_n_llpkgc_dep__internal__n_invoke_llpkgc_dep__dep_complete; + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state_5: { + switch (llpkgc_dep__internal__c_update_llpkgc_dep__state(state, p, endp)) { + default: + goto s_n_llpkgc_dep__internal__n_pkgc_dep_dep_name; + } + UNREACHABLE; + } + s_n_llpkgc_dep__internal__n_invoke_update_llpkgc_dep__state: { + switch (llpkgc_dep__internal__c_update_llpkgc_dep__state(state, p, endp)) { + default: + goto s_n_llpkgc_dep__internal__n_span_start_llpkgc_dep__dep_name; + } + UNREACHABLE; + } +} + +int llpkgc_dep__internal_execute(llpkgc_dep__internal_t* state, const char* p, const char* endp) { + llparse_state_t next; + + /* check lingering errors */ + if (state->error != 0) { + return state->error; + } + + /* restart spans */ + if (state->_span_pos0 != NULL) { + state->_span_pos0 = (void*) p; + } + + next = llpkgc_dep__internal__run(state, (const unsigned char*) p, (const unsigned char*) endp); + if (next == s_error) { + return state->error; + } + state->_current = (void*) (intptr_t) next; + + /* execute spans */ + if (state->_span_pos0 != NULL) { + int error; + + error = ((llpkgc_dep__internal__span_cb) state->_span_cb0)(state, state->_span_pos0, (const char*) endp); + if (error != 0) { + state->error = error; + state->error_pos = endp; + return error; + } + } + + return 0; +} diff --git a/llpkgc_dep__internal.h b/llpkgc_dep__internal.h new file mode 100644 index 0000000000..d3bb8ea7b5 --- /dev/null +++ b/llpkgc_dep__internal.h @@ -0,0 +1,35 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ +/* This code was generated by llpkgc, do not edit it by hand + See: https://gitlab.kitware.com/utils/llpkgc */ + + +#ifndef INCLUDE_LLPKGC_DEP__INTERNAL_H_ +#define INCLUDE_LLPKGC_DEP__INTERNAL_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct llpkgc_dep__internal_s llpkgc_dep__internal_t; +struct llpkgc_dep__internal_s { + int32_t _index; + void* _span_pos0; + void* _span_cb0; + int32_t error; + const char* reason; + const char* error_pos; + void* data; + void* _current; + void* llpkgc_dep__settings; + uint8_t llpkgc_dep__state; +}; + +int llpkgc_dep__internal_init(llpkgc_dep__internal_t* s); +int llpkgc_dep__internal_execute(llpkgc_dep__internal_t* s, const char* p, const char* endp); + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* INCLUDE_LLPKGC_DEP__INTERNAL_H_ */ diff --git a/llpkgc_file.c b/llpkgc_file.c new file mode 100644 index 0000000000..f56429d5fa --- /dev/null +++ b/llpkgc_file.c @@ -0,0 +1,338 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ + +#include +#include +#include + +#include "llpkgc_file.h" + +#define CALLBACK_MAYBE(PARSER, NAME) \ + do { \ + const llpkgc_file_settings_t* settings; \ + settings = \ + (const llpkgc_file_settings_t*) (PARSER)->llpkgc_file__settings; \ + if(settings == NULL || settings->NAME == NULL) { \ + err = 0; \ + break; \ + } \ + err = settings->NAME((PARSER)); \ + } while(0) + +#define SPAN_CALLBACK_MAYBE(PARSER, NAME, START, LEN) \ + do { \ + const llpkgc_file_settings_t* settings; \ + settings = \ + (const llpkgc_file_settings_t*) (PARSER)->llpkgc_file__settings; \ + if(settings == NULL || settings->NAME == NULL) { \ + err = 0; \ + break; \ + } \ + err = settings->NAME((PARSER), (START), (LEN)); \ + if(err == -1) { \ + err = PFCE_USER; \ + llpkgc_file_set_error_reason((PARSER), "Span callback error in " #NAME); \ + } \ + } while(0) + +enum llpkgc_file_unfinished_state { + PFUS_NONE = 0, + PFUS_IDENT = 1, + PFUS_BAREWORDS = 2, + PFUS_EXPECT_VALUE = 3, + PFUS_VALUE = 4, + PFUS_VALUE_LITERAL = 5, + PFUS_VALUE_SUBSTITUTION = 6, +}; + +void llpkgc_file_init(llpkgc_file_t* parser, + const llpkgc_file_settings_t* settings) { + llpkgc_file__internal_init(parser); + + parser->llpkgc_file__settings = (void*) settings; +} + +void llpkgc_file_reset(llpkgc_file_t* parser) { + llpkgc_file_settings_t* settings = parser->llpkgc_file__settings; + void* data = parser->data; + + llpkgc_file__internal_init(parser); + + parser->llpkgc_file__settings = settings; + parser->data = data; +} + +void llpkgc_file_settings_init(llpkgc_file_settings_t* settings) { + memset(settings, 0, sizeof(*settings)); +} + +llpkgc_file_errno_t llpkgc_file_execute(llpkgc_file_t* parser, const char* data, + size_t len) { + return llpkgc_file__internal_execute(parser, data, data + len); +} + +int llpkgc_file__line_begin(llpkgc_file_t* s, const char* p, const char* endp); +int llpkgc_file__ident_span(llpkgc_file_t* s, const char* p, const char* endp); + +llpkgc_file_errno_t llpkgc_file_finish(llpkgc_file_t* parser) { + int err = PFCE_OK; + + if(parser->error == PFCE_LOOKAHEAD) { + if(parser->error_pos == NULL) { + parser->error = PFCE_INTERNAL; + parser->reason = "Missing lookahead error position"; + return parser->error; + } + + parser->llpkgc_file__eof = 1; + llpkgc_file_resume(parser); + err = llpkgc_file_execute(parser, parser->error_pos, 1); + parser->llpkgc_file__eof = 0; + + if(err != PFCE_OK) { + return err; + } + + parser->llpkgc_file__lookahead = 0; + } else if(parser->error != 0) { + return parser->error; + } + + switch(parser->llpkgc_file__unfinished) { + case PFUS_IDENT: + case PFUS_BAREWORDS: + CALLBACK_MAYBE(parser, on_barewords_complete); + if(err != PFCE_OK) { + parser->error = err; + return err; + } + + CALLBACK_MAYBE(parser, on_value_complete); + if(err != PFCE_OK) { + parser->error = err; + return err; + } + break; + + case PFUS_EXPECT_VALUE: + case PFUS_VALUE: + CALLBACK_MAYBE(parser, on_value_complete); + if(err != PFCE_OK) { + parser->error = err; + return err; + } + break; + + case PFUS_VALUE_LITERAL: + CALLBACK_MAYBE(parser, on_value_literal_complete); + if(err != PFCE_OK) { + parser->error = err; + return err; + } + + CALLBACK_MAYBE(parser, on_value_complete); + if(err != PFCE_OK) { + parser->error = err; + return err; + } + break; + + case PFUS_VALUE_SUBSTITUTION: + parser->reason = "Invalid EOF state"; + parser->error = PFCE_UNFINISHED; + return PFCE_UNFINISHED; + + case PFUS_NONE: + break; + } + + CALLBACK_MAYBE(parser, on_pkgc_complete); + return err; +} + +void llpkgc_file_pause(llpkgc_file_t* parser) { + if(parser->error != PFCE_OK) { + return; + } + + parser->error = PFCE_PAUSED; + parser->reason = "Paused"; +} + +void llpkgc_file_resume(llpkgc_file_t* parser) { + if(parser->error != PFCE_PAUSED && parser->error != PFCE_LOOKAHEAD) { + return; + } + + parser->error = 0; +} + +llpkgc_file_errno_t llpkgc_file_get_errno(const llpkgc_file_t* parser) { + return parser->error; +} + +const char* llpkgc_file_get_error_reason(const llpkgc_file_t* parser) { + return parser->reason; +} + +void llpkgc_file_set_error_reason(llpkgc_file_t* parser, const char* reason) { + parser->reason = reason; +} + +const char* llpkgc_file_get_error_pos(const llpkgc_file_t* parser) { + return parser->error_pos; +} + +const char* llpkgc_file_errno_name(llpkgc_file_errno_t err) { + switch(err) { + case PFCE_OK: + return "PFCE_OK"; + case PFCE_INTERNAL: + return "PFCE_INTERNAL"; + case PFCE_PAUSED: + return "PFCE_PAUSED"; + case PFCE_USER: + return "PFCE_USER"; + case PFCE_UNFINISHED: + return "PFCE_UNFINISHED"; + case PFCE_LOOKAHEAD: + return "PFCE_LOOKAHEAD"; + } + return "INVALID_ERRNO"; +} + +int llpkgc_file__lookahead(llpkgc_file_t* s, const char* p, const char* endp) { + if(p == endp) { + llpkgc_file_set_error_reason(s, "Invalid lookahead state"); + return PFCE_INTERNAL; + } + + if(p + 1 == endp) { + if(s->llpkgc_file__eof != 0) { + s->llpkgc_file__lookahead = 0; + return 3; + } + + s->llpkgc_file__lookahead = (uint8_t) *p; + return PFCE_LOOKAHEAD; + } + + s->llpkgc_file__lookahead = 0; + + if(*p != '$') { + llpkgc_file_set_error_reason(s, "Invalid lookahead state"); + return PFCE_INTERNAL; + } + + switch(p[1]) { + case '{': + return 1; + case '$': + return 2; + default: + return 0; + } +} + +int llpkgc_file__lookahead_backslash(llpkgc_file_t* s, const char* p, + const char* endp) { + if(p == endp) { + llpkgc_file_set_error_reason(s, "Invalid lookahead state"); + return PFCE_INTERNAL; + } + + if(p + 1 == endp) { + if(s->llpkgc_file__eof != 0) { + s->llpkgc_file__lookahead = 0; + return 4; + } + + s->llpkgc_file__lookahead = (uint8_t) *p; + return 5; + } + + s->llpkgc_file__lookahead = 0; + + if(*p != '\\') { + llpkgc_file_set_error_reason(s, "Invalid lookahead state"); + return PFCE_INTERNAL; + } + + switch(p[1]) { + case '\r': + case '\n': + return 1; + case '#': + return 2; + case '\\': + return 3; + default: + return 0; + } +} + +int llpkgc_file__line_begin(llpkgc_file_t* s, const char* p, const char* endp) { + int err; + CALLBACK_MAYBE(s, on_line_begin); + return err; +} + +int llpkgc_file__ident_span(llpkgc_file_t* s, const char* p, const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_ident, p, endp - p); + return err; +} + +int llpkgc_file__prop_decl_complete(llpkgc_file_t* s, const char* p, + const char* endp) { + int err; + CALLBACK_MAYBE(s, on_property_complete); + return err; +} + +int llpkgc_file__var_decl_complete(llpkgc_file_t* s, const char* p, + const char* endp) { + int err; + CALLBACK_MAYBE(s, on_variable_complete); + return err; +} + +int llpkgc_file__barewords_decl_complete(llpkgc_file_t* s, const char* p, + const char* endp) { + int err; + CALLBACK_MAYBE(s, on_barewords_complete); + return err; +} + +int llpkgc_file__lit_span(llpkgc_file_t* s, const char* p, const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_value_literal, p, endp - p); + return err; +} + +int llpkgc_file__lit_complete(llpkgc_file_t* s, const char* p, + const char* endp) { + int err; + CALLBACK_MAYBE(s, on_value_literal_complete); + return err; +} + +int llpkgc_file__sub_span(llpkgc_file_t* s, const char* p, const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_value_substitution, p, endp - p); + return err; +} + +int llpkgc_file__sub_complete(llpkgc_file_t* s, const char* p, + const char* endp) { + int err; + CALLBACK_MAYBE(s, on_value_substitution_complete); + return err; +} + +int llpkgc_file__val_complete(llpkgc_file_t* s, const char* p, + const char* endp) { + int err; + CALLBACK_MAYBE(s, on_value_complete); + return err; +} diff --git a/llpkgc_file.h b/llpkgc_file.h new file mode 100644 index 0000000000..c282fc4a86 --- /dev/null +++ b/llpkgc_file.h @@ -0,0 +1,92 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ + +#ifndef INCLUDE_LLPKGC_FILE_API_H_ +#define INCLUDE_LLPKGC_FILE_API_H_ +#ifdef __cplusplus +extern "C" { +#endif +#include + +#include "llpkgc_file__internal.h" + +#if defined(_MSC_VER) +#define LLPKGC_FILE_EXPORT __declspec(dllexport) +#else +#define LLPKGC_FILE_EXPORT __attribute__((visibility("default"))) +#endif + +typedef llpkgc_file__internal_t llpkgc_file_t; +typedef struct llpkgc_file_settings_s llpkgc_file_settings_t; + +typedef int ( + *llpkgc_file_data_cb)(llpkgc_file_t*, const char* at, size_t length); +typedef int (*llpkgc_file_cb)(llpkgc_file_t*); + +struct llpkgc_file_settings_s { + llpkgc_file_data_cb on_ident; + llpkgc_file_data_cb on_value_literal; + llpkgc_file_data_cb on_value_substitution; + + llpkgc_file_cb on_line_begin; + llpkgc_file_cb on_property_complete; + llpkgc_file_cb on_variable_complete; + llpkgc_file_cb on_barewords_complete; + llpkgc_file_cb on_value_literal_complete; + llpkgc_file_cb on_value_substitution_complete; + llpkgc_file_cb on_value_complete; + llpkgc_file_cb on_pkgc_complete; +}; + +enum llpkgc_file_errno { + PFCE_INTERNAL = -1, + PFCE_OK = 0, + PFCE_PAUSED = 1, + PFCE_USER = 2, + PFCE_UNFINISHED = 3, + PFCE_LOOKAHEAD = 4, +}; +typedef enum llpkgc_file_errno llpkgc_file_errno_t; + +LLPKGC_FILE_EXPORT +void llpkgc_file_init(llpkgc_file_t* parser, + const llpkgc_file_settings_t* settings); + +LLPKGC_FILE_EXPORT +void llpkgc_file_reset(llpkgc_file_t* parser); + +LLPKGC_FILE_EXPORT +void llpkgc_file_settings_init(llpkgc_file_settings_t* settings); + +LLPKGC_FILE_EXPORT +llpkgc_file_errno_t llpkgc_file_execute(llpkgc_file_t* parser, const char* data, + size_t len); + +LLPKGC_FILE_EXPORT +llpkgc_file_errno_t llpkgc_file_finish(llpkgc_file_t* parser); + +LLPKGC_FILE_EXPORT +void llpkgc_file_pause(llpkgc_file_t* parser); + +LLPKGC_FILE_EXPORT +void llpkgc_file_resume(llpkgc_file_t* parser); + +LLPKGC_FILE_EXPORT +llpkgc_file_errno_t llpkgc_file_get_errno(const llpkgc_file_t* parser); + +LLPKGC_FILE_EXPORT +const char* llpkgc_file_get_error_reason(const llpkgc_file_t* parser); + +LLPKGC_FILE_EXPORT +void llpkgc_file_set_error_reason(llpkgc_file_t* parser, const char* reason); + +LLPKGC_FILE_EXPORT +const char* llpkgc_file_get_error_pos(const llpkgc_file_t* parser); + +LLPKGC_FILE_EXPORT +const char* llpkgc_file_errno_name(llpkgc_file_errno_t err); + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* INCLUDE_LLPKGC_FILE_API_H_ */ diff --git a/llpkgc_file__internal.c b/llpkgc_file__internal.c new file mode 100644 index 0000000000..0198f45681 --- /dev/null +++ b/llpkgc_file__internal.c @@ -0,0 +1,2489 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ +/* This code was generated by llpkgc, do not edit it by hand + See: https://gitlab.kitware.com/utils/llpkgc */ + + +#include +#include +#include + +#ifdef __SSE4_2__ + #ifdef _MSC_VER + #include + #else /* !_MSC_VER */ + #include + #endif /* _MSC_VER */ +#endif /* __SSE4_2__ */ + +#if defined(__ARM_NEON__) || defined(__ARM_NEON) + #include +#endif /* __ARM_NEON__ */ + +#ifdef __wasm__ + #include +#endif /* __wasm__ */ + +#ifdef _MSC_VER + #define ALIGN(n) _declspec(align(n)) + #define UNREACHABLE __assume(0) +#else /* !_MSC_VER */ + #define ALIGN(n) __attribute__((aligned(n))) + #define UNREACHABLE __builtin_unreachable() +#endif /* _MSC_VER */ + +#include "llpkgc_file__internal.h" + +typedef int (*llpkgc_file__internal__span_cb)( + llpkgc_file__internal_t*, const char*, const char*); + +static const unsigned char llparse_blob0[] = { + '\\', '\\' +}; +static const unsigned char llparse_blob1[] = { + '$', '{' +}; +static const unsigned char llparse_blob2[] = { + '\\', '\\' +}; +static const unsigned char llparse_blob3[] = { + '\\', '\\' +}; + +enum llparse_match_status_e { + kMatchComplete, + kMatchPause, + kMatchMismatch +}; +typedef enum llparse_match_status_e llparse_match_status_t; + +struct llparse_match_s { + llparse_match_status_t status; + const unsigned char* current; +}; +typedef struct llparse_match_s llparse_match_t; + +static llparse_match_t llparse__match_sequence_id( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp, + const unsigned char* seq, uint32_t seq_len) { + uint32_t index; + llparse_match_t res; + + index = s->_index; + for (; p != endp; p++) { + unsigned char current; + + current = *p; + if (current == seq[index]) { + if (++index == seq_len) { + res.status = kMatchComplete; + goto reset; + } + } else { + res.status = kMatchMismatch; + goto reset; + } + } + s->_index = index; + res.status = kMatchPause; + res.current = p; + return res; +reset: + s->_index = 0; + res.current = p; + return res; +} + +enum llparse_state_e { + s_error, + s_n_llpkgc_file__internal__n_pkgc_file_comment, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__barewords_decl_complete, + s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_literal, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_1, + s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_cr, + s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_lf, + s_n_llpkgc_file__internal__n_pkgc_file_barewords_line_end, + s_n_llpkgc_file__internal__n_pkgc_file_barewords_continue_line, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_2, + s_n_llpkgc_file__internal__n_pkgc_file_barewords_escaped_comment, + s_n_llpkgc_file__internal__n_pkgc_file_barewords_double_backslash, + s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_eof, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_1, + s_n_llpkgc_file__internal__n_pkgc_file_barewords, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span, + s_n_llpkgc_file__internal__n_pkgc_file_expect_ident_escaped_comment, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_3, + s_n_llpkgc_file__internal__n_pkgc_file_start_barewords_backslash_eof, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_4, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete, + s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_literal, + s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled_literal, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_1, + s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_2, + s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_eof, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_2, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_2, + s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_cr, + s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_lf, + s_n_llpkgc_file__internal__n_pkgc_file_line_end, + s_n_llpkgc_file__internal__n_pkgc_file_continue_line, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_3, + s_n_llpkgc_file__internal__n_pkgc_file_value_escaped_comment, + s_n_llpkgc_file__internal__n_pkgc_file_double_backslash, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_4, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_3, + s_n_llpkgc_file__internal__n_pkgc_file_value_backslash_eof, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_5, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_2, + s_n_llpkgc_file__internal__n_pkgc_file_value, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__sub_complete, + s_n_llpkgc_file__internal__n_pkgc_file_substitution, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__sub_span, + s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_substitution, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_1, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_4, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_5, + s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_eof, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_1, + s_n_llpkgc_file__internal__n_pkgc_file_backslash_literal, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_6, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_7, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_8, + s_n_llpkgc_file__internal__n_pkgc_file_value_literal_backslash_eof, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_3, + s_n_llpkgc_file__internal__n_pkgc_file_value_literal, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_6, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_7, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_8, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_4, + s_n_llpkgc_file__internal__n_pkgc_file_expect_value, + s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator_backslash_literal, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_6, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_7, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_5, + s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator, + s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_literal, + s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_cr, + s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_lf, + s_n_llpkgc_file__internal__n_pkgc_file_ident_line_end, + s_n_llpkgc_file__internal__n_pkgc_file_ident_continue_line, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_8, + s_n_llpkgc_file__internal__n_pkgc_file_ident_escaped_comment, + s_n_llpkgc_file__internal__n_pkgc_file_ident_double_backslash, + s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_eof, + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_6, + s_n_llpkgc_file__internal__n_pkgc_file_ident, + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_5, + s_n_llpkgc_file__internal__n_pkgc_file_expect_ident, +}; +typedef enum llparse_state_e llparse_state_t; + +int llpkgc_file__ident_span( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__sub_span( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__lit_span( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__lookahead_backslash( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__internal__c_update_llpkgc_file__unfinished( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__unfinished = 2; + return 0; +} + +int llpkgc_file__barewords_decl_complete( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__val_complete( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__internal__c_update_llpkgc_file__unfinished_1( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__unfinished = 0; + return 0; +} + +int llpkgc_file__internal__c_update_llpkgc_file__unfinished_4( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__unfinished = 1; + return 0; +} + +int llpkgc_file__prop_decl_complete( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__internal__c_update_llpkgc_file__unfinished_5( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__unfinished = 3; + return 0; +} + +int llpkgc_file__lookahead( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__internal__c_update_llpkgc_file__unfinished_6( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__unfinished = 5; + return 0; +} + +int llpkgc_file__lit_complete( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__internal__c_update_llpkgc_file__unfinished_7( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__unfinished = 6; + return 0; +} + +int llpkgc_file__sub_complete( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__internal__c_update_llpkgc_file__unfinished_8( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__unfinished = 4; + return 0; +} + +int llpkgc_file__internal__c_update_llpkgc_file__value_resume( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__value_resume = 1; + return 0; +} + +int llpkgc_file__internal__c_update_llpkgc_file__line_resume( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__line_resume = 1; + return 0; +} + +int llpkgc_file__internal__c_load_llpkgc_file__line_resume( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + return state->llpkgc_file__line_resume; +} + +int llpkgc_file__internal__c_load_llpkgc_file__value_resume( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + return state->llpkgc_file__value_resume; +} + +int llpkgc_file__internal__c_update_llpkgc_file__text_resume( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__text_resume = 0; + return 0; +} + +int llpkgc_file__internal__c_load_llpkgc_file__text_resume( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + return state->llpkgc_file__text_resume; +} + +int llpkgc_file__internal__c_update_llpkgc_file__value_resume_2( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__value_resume = 0; + return 0; +} + +int llpkgc_file__var_decl_complete( + llpkgc_file__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_file__internal__c_update_llpkgc_file__line_resume_3( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_file__line_resume = 0; + return 0; +} + +int llpkgc_file__internal_init(llpkgc_file__internal_t* state) { + memset(state, 0, sizeof(*state)); + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + return 0; +} + +static llparse_state_t llpkgc_file__internal__run( + llpkgc_file__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + int match; + switch ((llparse_state_t) (intptr_t) state->_current) { + case s_n_llpkgc_file__internal__n_pkgc_file_comment: + s_n_llpkgc_file__internal__n_pkgc_file_comment: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_comment; + } + switch (*p) { + case 10: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + } + case 13: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + } + default: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_comment; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__barewords_decl_complete: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__barewords_decl_complete: { + switch (llpkgc_file__barewords_decl_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + default: + goto s_n_llpkgc_file__internal__n_error_1; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_literal: + s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_literal: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_literal; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_1: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_1: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_1; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__ident_span; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_cr: + s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_cr: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_cr; + } + switch (*p) { + case 13: { + p++; + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_1; + } + default: { + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_1; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_lf: + s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_lf: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_lf; + } + switch (*p) { + case 10: { + p++; + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_1; + } + default: { + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_1; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_barewords_line_end: + s_n_llpkgc_file__internal__n_pkgc_file_barewords_line_end: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords_line_end; + } + switch (*p) { + case 10: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_cr; + } + case 13: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_maybe_lf; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_barewords_continue_line: + s_n_llpkgc_file__internal__n_pkgc_file_barewords_continue_line: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords_continue_line; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_line_end; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_2: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_2: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_2; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__ident_span; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_barewords_escaped_comment: + s_n_llpkgc_file__internal__n_pkgc_file_barewords_escaped_comment: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords_escaped_comment; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_2; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_barewords_double_backslash: + s_n_llpkgc_file__internal__n_pkgc_file_barewords_double_backslash: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords_double_backslash; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob0, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + } + case kMatchPause: { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords_double_backslash; + } + case kMatchMismatch: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_eof: + s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_eof: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_eof; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_1: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_1: { + switch (llpkgc_file__lookahead_backslash(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_literal; + case 1: + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_1; + case 2: + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_2; + case 3: + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_double_backslash; + case 4: + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_backslash_eof; + case 5: + goto s_n_llpkgc_file__internal__n_pause; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_barewords: + s_n_llpkgc_file__internal__n_pkgc_file_barewords: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_barewords; + } + switch (*p) { + case 10: { + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span; + } + case 13: { + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span; + } + case '#': { + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span; + } + case 92: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_1; + } + default: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__ident_span; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_expect_ident_escaped_comment: + s_n_llpkgc_file__internal__n_pkgc_file_expect_ident_escaped_comment: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_expect_ident_escaped_comment; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_3: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_3: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_3; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__ident_span; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_double_backslash; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_start_barewords_backslash_eof: + s_n_llpkgc_file__internal__n_pkgc_file_start_barewords_backslash_eof: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_start_barewords_backslash_eof; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_4: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_4: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_4; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__ident_span; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_start_barewords_backslash_eof; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash: { + switch (llpkgc_file__lookahead_backslash(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished; + case 1: + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + case 2: + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_ident_escaped_comment; + case 3: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_2; + case 4: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_3; + case 5: + goto s_n_llpkgc_file__internal__n_pause_1; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete: { + switch (llpkgc_file__lit_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + default: + goto s_n_llpkgc_file__internal__n_error_4; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_literal: + s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_literal: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_literal; + } + switch (*p) { + case '$': { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_literal; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled_literal: + s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled_literal: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled_literal; + } + switch (*p) { + case '$': { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_literal; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_1: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_1: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_1; + } + state->_span_pos1 = (void*) p; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled_literal; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled: + s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled; + } + switch (*p) { + case '$': { + p++; + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_1; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_2: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_2: { + switch (llpkgc_file__lit_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + default: + goto s_n_llpkgc_file__internal__n_error_7; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_eof: + s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_eof: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_eof; + } + switch (*p) { + case '$': { + p++; + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_2; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_2: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_2: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_2; + } + state->_span_pos1 = (void*) p; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_eof; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_2: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_2: { + switch (llpkgc_file__lookahead(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_6; + case 1: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_substitution; + case 2: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled; + case 3: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_9; + case 4: + goto s_n_llpkgc_file__internal__n_pause_2; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_cr: + s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_cr: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_cr; + } + switch (*p) { + case 13: { + p++; + goto s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__line_resume; + } + default: { + goto s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__line_resume; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_lf: + s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_lf: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_lf; + } + switch (*p) { + case 10: { + p++; + goto s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__line_resume; + } + default: { + goto s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__line_resume; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_line_end: + s_n_llpkgc_file__internal__n_pkgc_file_line_end: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_line_end; + } + switch (*p) { + case 10: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_cr; + } + case 13: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_line_maybe_lf; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_continue_line: + s_n_llpkgc_file__internal__n_pkgc_file_continue_line: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_continue_line; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_line_end; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_3: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_3: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_3; + } + state->_span_pos1 = (void*) p; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_literal; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_escaped_comment: + s_n_llpkgc_file__internal__n_pkgc_file_value_escaped_comment: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_escaped_comment; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_10; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_double_backslash: + s_n_llpkgc_file__internal__n_pkgc_file_double_backslash: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_double_backslash; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob2, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__text_resume; + } + case kMatchPause: { + return s_n_llpkgc_file__internal__n_pkgc_file_double_backslash; + } + case kMatchMismatch: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_4: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_4: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_4; + } + state->_span_pos1 = (void*) p; + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__text_resume; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_3: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_3: { + switch (llpkgc_file__lit_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + default: + goto s_n_llpkgc_file__internal__n_error_8; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_backslash_eof: + s_n_llpkgc_file__internal__n_pkgc_file_value_backslash_eof: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_backslash_eof; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_3; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_5: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_5: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_5; + } + state->_span_pos1 = (void*) p; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_backslash_eof; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_2: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_2: { + switch (llpkgc_file__lookahead_backslash(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_6; + case 1: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__value_resume; + case 2: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_escaped_comment; + case 3: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_4; + case 4: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_11; + case 5: + goto s_n_llpkgc_file__internal__n_pause_3; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value: + s_n_llpkgc_file__internal__n_pkgc_file_value: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value; + } + switch (*p) { + case 10: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + } + case 13: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + } + case '#': { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + } + case '$': { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_2; + } + case 92: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_2; + } + default: { + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_10; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__sub_complete: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__sub_complete: { + switch (llpkgc_file__sub_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_8; + default: + goto s_n_llpkgc_file__internal__n_error_6; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_substitution: + s_n_llpkgc_file__internal__n_pkgc_file_substitution: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_substitution; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_substitution; + } + case 2: { + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__sub_span; + } + default: { + goto s_n_llpkgc_file__internal__n_error_9; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__sub_span: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__sub_span: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__sub_span; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__sub_span; + goto s_n_llpkgc_file__internal__n_pkgc_file_substitution; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_substitution: + s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_substitution: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_substitution; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob1, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_7; + } + case kMatchPause: { + return s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_substitution; + } + case kMatchMismatch: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_1: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_1: { + switch (llpkgc_file__lit_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_substitution; + default: + goto s_n_llpkgc_file__internal__n_error_5; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_4: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_4: { + switch (llpkgc_file__lit_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled; + default: + goto s_n_llpkgc_file__internal__n_error_10; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_5: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_5: { + switch (llpkgc_file__lit_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + default: + goto s_n_llpkgc_file__internal__n_error_11; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_eof: + s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_eof: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_eof; + } + switch (*p) { + case '$': { + p++; + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_5; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_1: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_1: { + switch (llpkgc_file__lookahead(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_literal; + case 1: + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_1; + case 2: + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_4; + case 3: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_literal_dollar_eof; + case 4: + goto s_n_llpkgc_file__internal__n_pause_4; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_backslash_literal: + s_n_llpkgc_file__internal__n_pkgc_file_backslash_literal: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_backslash_literal; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__text_resume; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_6: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_6: { + switch (llpkgc_file__lit_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__value_resume_1; + default: + goto s_n_llpkgc_file__internal__n_error_12; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_7: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_7: { + switch (llpkgc_file__lit_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_escaped_comment; + default: + goto s_n_llpkgc_file__internal__n_error_13; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_8: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_8: { + switch (llpkgc_file__lit_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + default: + goto s_n_llpkgc_file__internal__n_error_14; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_literal_backslash_eof: + s_n_llpkgc_file__internal__n_pkgc_file_value_literal_backslash_eof: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_literal_backslash_eof; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_8; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_3: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_3: { + switch (llpkgc_file__lookahead_backslash(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__text_resume_1; + case 1: + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_6; + case 2: + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_7; + case 3: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__text_resume_2; + case 4: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_literal_backslash_eof; + case 5: + goto s_n_llpkgc_file__internal__n_pause_5; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_value_literal: + s_n_llpkgc_file__internal__n_pkgc_file_value_literal: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_value_literal; + } + switch (*p) { + case 10: { + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span; + } + case 13: { + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span; + } + case '#': { + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span; + } + case '$': { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_1; + } + case 92: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_3; + } + default: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_literal; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span; + } + state->_span_pos1 = (void*) p; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_literal; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_6: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_6: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_6; + } + state->_span_pos1 = (void*) p; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_eof; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead: { + switch (llpkgc_file__lookahead(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_6; + case 1: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_substitution; + case 2: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_dollar_doubled; + case 3: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_12; + case 4: + goto s_n_llpkgc_file__internal__n_pause_6; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_7: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_7: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_7; + } + state->_span_pos1 = (void*) p; + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__text_resume_3; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_8: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_8: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_8; + } + state->_span_pos1 = (void*) p; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_value_backslash_eof; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_4: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_4: { + switch (llpkgc_file__lookahead_backslash(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_6; + case 1: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__value_resume_2; + case 2: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_escaped_comment; + case 3: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_7; + case 4: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_13; + case 5: + goto s_n_llpkgc_file__internal__n_pause_7; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_expect_value: + s_n_llpkgc_file__internal__n_pkgc_file_expect_value: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_expect_value; + } + switch (*p) { + case 10: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + } + case 13: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + } + case '#': { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete; + } + case '$': { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead; + } + case 92: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_4; + } + default: { + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_10; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator_backslash_literal: + s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator_backslash_literal: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator_backslash_literal; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_6: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_6: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_6; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__ident_span; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_double_backslash; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_7: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_7: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_7; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__ident_span; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_start_barewords_backslash_eof; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_5: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_5: { + switch (llpkgc_file__lookahead_backslash(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator_backslash_literal; + case 1: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__line_resume_3; + case 2: + goto s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator_backslash_literal; + case 3: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_14; + case 4: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_15; + case 5: + goto s_n_llpkgc_file__internal__n_pause_8; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator: + s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator; + } + switch (*p) { + case 9: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator; + } + case 10: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__barewords_decl_complete; + } + case 13: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__barewords_decl_complete; + } + case ' ': { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator; + } + case '#': { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__barewords_decl_complete; + } + case ':': { + p++; + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__prop_decl_complete; + } + case '=': { + p++; + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__var_decl_complete; + } + case 92: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_5; + } + default: { + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_literal: + s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_literal: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_literal; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_cr: + s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_cr: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_cr; + } + switch (*p) { + case 13: { + p++; + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_5; + } + default: { + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_5; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_lf: + s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_lf: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_lf; + } + switch (*p) { + case 10: { + p++; + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_5; + } + default: { + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_5; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_ident_line_end: + s_n_llpkgc_file__internal__n_pkgc_file_ident_line_end: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_ident_line_end; + } + switch (*p) { + case 10: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_cr; + } + case 13: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_ident_maybe_lf; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_ident_continue_line: + s_n_llpkgc_file__internal__n_pkgc_file_ident_continue_line: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_ident_continue_line; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_ident_line_end; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_8: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_8: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_8; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__ident_span; + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_ident_escaped_comment: + s_n_llpkgc_file__internal__n_pkgc_file_ident_escaped_comment: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_ident_escaped_comment; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_8; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_ident_double_backslash: + s_n_llpkgc_file__internal__n_pkgc_file_ident_double_backslash: { + llparse_match_t match_seq; + + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_ident_double_backslash; + } + match_seq = llparse__match_sequence_id(state, p, endp, llparse_blob3, 2); + p = match_seq.current; + switch (match_seq.status) { + case kMatchComplete: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + } + case kMatchPause: { + return s_n_llpkgc_file__internal__n_pkgc_file_ident_double_backslash; + } + case kMatchMismatch: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_eof: + s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_eof: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_eof; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span; + } + default: { + goto s_n_llpkgc_file__internal__n_error; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_6: + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_6: { + switch (llpkgc_file__lookahead_backslash(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_literal; + case 1: + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_4; + case 2: + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_5; + case 3: + goto s_n_llpkgc_file__internal__n_pkgc_file_ident_double_backslash; + case 4: + goto s_n_llpkgc_file__internal__n_pkgc_file_ident_backslash_eof; + case 5: + goto s_n_llpkgc_file__internal__n_pause_9; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_ident: + s_n_llpkgc_file__internal__n_pkgc_file_ident: { + static uint8_t lookup_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0, 0, 1, 0, 0, + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 4, 0, 0, 3, + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_ident; + } + switch (lookup_table[(uint8_t) *p]) { + case 1: { + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_3; + } + case 2: { + goto s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span; + } + case 3: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_ident; + } + case 4: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_6; + } + default: { + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords; + } + } + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_5: + s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_5: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_5; + } + state->_span_pos0 = (void*) p; + state->_span_cb0 = llpkgc_file__ident_span; + goto s_n_llpkgc_file__internal__n_pkgc_file_ident; + UNREACHABLE; + } + case s_n_llpkgc_file__internal__n_pkgc_file_expect_ident: + s_n_llpkgc_file__internal__n_pkgc_file_expect_ident: { + if (p == endp) { + return s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + } + switch (*p) { + case 9: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + } + case 10: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + } + case 13: { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + } + case ' ': { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + } + case '#': { + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_comment; + } + case 92: { + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash; + } + default: { + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_4; + } + } + UNREACHABLE; + } + default: + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_1: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_1(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_ident; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_2: { + state->error = 0xa; + state->reason = "Value complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__val_complete: { + switch (llpkgc_file__val_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_1; + default: + goto s_n_llpkgc_file__internal__n_error_2; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_1: { + state->error = 0x9; + state->reason = "Barewords complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_file__ident_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__barewords_decl_complete; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__barewords_decl_complete; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error: { + state->error = 0xe; + state->reason = "Lookahead error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_1: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_file__ident_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_pkgc_file_barewords_continue_line; + return s_error; + } + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_continue_line; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_2: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_file__ident_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_pkgc_file_barewords_escaped_comment; + return s_error; + } + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_barewords_escaped_comment; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_1; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_2: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_3; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_3: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_4; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause_1: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_4: { + state->error = 0xb; + state->reason = "Value literal complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span: { + const unsigned char* start; + int err; + + start = state->_span_pos1; + state->_span_pos1 = NULL; + err = llpkgc_file__lit_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_7: { + state->error = 0xb; + state->reason = "Value literal complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_2: { + const unsigned char* start; + int err; + + start = state->_span_pos1; + state->_span_pos1 = NULL; + err = llpkgc_file__lit_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_2; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_2; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_9: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_6(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_2; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause_2: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_2; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__value_resume: { + switch (llpkgc_file__internal__c_load_llpkgc_file__value_resume(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_value; + case 1: + goto s_n_llpkgc_file__internal__n_pkgc_file_value; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__line_resume: { + switch (llpkgc_file__internal__c_load_llpkgc_file__line_resume(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator; + case 1: + goto s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__value_resume; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__line_resume: { + switch (llpkgc_file__internal__c_update_llpkgc_file__line_resume(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_continue_line; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__value_resume: { + switch (llpkgc_file__internal__c_update_llpkgc_file__value_resume(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__line_resume; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_10: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_6(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_3; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_load_llpkgc_file__text_resume: { + switch (llpkgc_file__internal__c_load_llpkgc_file__text_resume(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_pkgc_file_value_literal; + default: + goto s_n_llpkgc_file__internal__n_error; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__text_resume: { + switch (llpkgc_file__internal__c_update_llpkgc_file__text_resume(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_double_backslash; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_8: { + state->error = 0xb; + state->reason = "Value literal complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_3: { + const unsigned char* start; + int err; + + start = state->_span_pos1; + state->_span_pos1 = NULL; + err = llpkgc_file__lit_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_3; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_3; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_11: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_6(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_5; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause_3: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_2; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_8: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_8(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_value; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_6: { + state->error = 0xc; + state->reason = "Value substitution complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__sub_span: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_file__sub_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__sub_complete; + return s_error; + } + p++; + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__sub_complete; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_9: { + state->error = 0xd; + state->reason = "Invalid variable substitution character"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_7: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_7(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__sub_span; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_5: { + state->error = 0xb; + state->reason = "Value literal complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_1: { + const unsigned char* start; + int err; + + start = state->_span_pos1; + state->_span_pos1 = NULL; + err = llpkgc_file__lit_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_1; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_1; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_10: { + state->error = 0xb; + state->reason = "Value literal complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_4: { + const unsigned char* start; + int err; + + start = state->_span_pos1; + state->_span_pos1 = NULL; + err = llpkgc_file__lit_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_4; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_4; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_11: { + state->error = 0xb; + state->reason = "Value literal complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_5: { + const unsigned char* start; + int err; + + start = state->_span_pos1; + state->_span_pos1 = NULL; + err = llpkgc_file__lit_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_5; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_5; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause_4: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_1; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__text_resume_1: { + switch (llpkgc_file__internal__c_update_llpkgc_file__text_resume(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_backslash_literal; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__line_resume_1: { + switch (llpkgc_file__internal__c_update_llpkgc_file__line_resume(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_continue_line; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__value_resume_1: { + switch (llpkgc_file__internal__c_update_llpkgc_file__value_resume(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__line_resume_1; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_12: { + state->error = 0xb; + state->reason = "Value literal complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_6: { + const unsigned char* start; + int err; + + start = state->_span_pos1; + state->_span_pos1 = NULL; + err = llpkgc_file__lit_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_6; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_6; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_13: { + state->error = 0xb; + state->reason = "Value literal complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_7: { + const unsigned char* start; + int err; + + start = state->_span_pos1; + state->_span_pos1 = NULL; + err = llpkgc_file__lit_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_7; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_7; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__text_resume_2: { + switch (llpkgc_file__internal__c_update_llpkgc_file__text_resume(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_double_backslash; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_14: { + state->error = 0xb; + state->reason = "Value literal complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__lit_span_8: { + const unsigned char* start; + int err; + + start = state->_span_pos1; + state->_span_pos1 = NULL; + err = llpkgc_file__lit_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_8; + return s_error; + } + goto s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lit_complete_8; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause_5: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_3; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_6: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_6(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_12: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_6(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_6; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause_6: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__line_resume_2: { + switch (llpkgc_file__internal__c_update_llpkgc_file__line_resume(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_continue_line; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__value_resume_2: { + switch (llpkgc_file__internal__c_update_llpkgc_file__value_resume_2(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__line_resume_2; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__text_resume_3: { + switch (llpkgc_file__internal__c_update_llpkgc_file__text_resume(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_double_backslash; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_13: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_6(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__lit_span_8; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause_7: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_4; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_5: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_5(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_expect_value; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_3: { + state->error = 0x7; + state->reason = "Property complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__prop_decl_complete: { + switch (llpkgc_file__prop_decl_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_5; + default: + goto s_n_llpkgc_file__internal__n_error_3; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_error_15: { + state->error = 0x8; + state->reason = "Variable complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_llpkgc_file__var_decl_complete: { + switch (llpkgc_file__var_decl_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_5; + default: + goto s_n_llpkgc_file__internal__n_error_15; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__line_resume_3: { + switch (llpkgc_file__internal__c_update_llpkgc_file__line_resume_3(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_pkgc_file_continue_line; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_14: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_6; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_15: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_7; + } + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause_8: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_5; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_3: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_file__ident_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator; + return s_error; + } + goto s_n_llpkgc_file__internal__n_pkgc_file_maybe_separator; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_4: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_file__ident_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_pkgc_file_ident_continue_line; + return s_error; + } + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_ident_continue_line; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_span_end_llpkgc_file__ident_span_5: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_file__ident_span(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) (p + 1); + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_pkgc_file_ident_escaped_comment; + return s_error; + } + p++; + goto s_n_llpkgc_file__internal__n_pkgc_file_ident_escaped_comment; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_pause_9: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_file__internal__n_invoke_llpkgc_file__lookahead_backslash_6; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_file__internal__n_invoke_update_llpkgc_file__unfinished_4: { + switch (llpkgc_file__internal__c_update_llpkgc_file__unfinished_4(state, p, endp)) { + default: + goto s_n_llpkgc_file__internal__n_span_start_llpkgc_file__ident_span_5; + } + UNREACHABLE; + } +} + +int llpkgc_file__internal_execute(llpkgc_file__internal_t* state, const char* p, const char* endp) { + llparse_state_t next; + + /* check lingering errors */ + if (state->error != 0) { + return state->error; + } + + /* restart spans */ + if (state->_span_pos0 != NULL) { + state->_span_pos0 = (void*) p; + } + if (state->_span_pos1 != NULL) { + state->_span_pos1 = (void*) p; + } + + next = llpkgc_file__internal__run(state, (const unsigned char*) p, (const unsigned char*) endp); + if (next == s_error) { + return state->error; + } + state->_current = (void*) (intptr_t) next; + + /* execute spans */ + if (state->_span_pos0 != NULL) { + int error; + + error = ((llpkgc_file__internal__span_cb) state->_span_cb0)(state, state->_span_pos0, (const char*) endp); + if (error != 0) { + state->error = error; + state->error_pos = endp; + return error; + } + } + if (state->_span_pos1 != NULL) { + int error; + + error = llpkgc_file__lit_span(state, state->_span_pos1, (const char*) endp); + if (error != 0) { + state->error = error; + state->error_pos = endp; + return error; + } + } + + return 0; +} diff --git a/llpkgc_file__internal.h b/llpkgc_file__internal.h new file mode 100644 index 0000000000..8b6347791a --- /dev/null +++ b/llpkgc_file__internal.h @@ -0,0 +1,41 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ +/* This code was generated by llpkgc, do not edit it by hand + See: https://gitlab.kitware.com/utils/llpkgc */ + + +#ifndef INCLUDE_LLPKGC_FILE__INTERNAL_H_ +#define INCLUDE_LLPKGC_FILE__INTERNAL_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct llpkgc_file__internal_s llpkgc_file__internal_t; +struct llpkgc_file__internal_s { + int32_t _index; + void* _span_pos0; + void* _span_cb0; + void* _span_pos1; + int32_t error; + const char* reason; + const char* error_pos; + void* data; + void* _current; + void* llpkgc_file__settings; + uint8_t llpkgc_file__unfinished; + uint8_t llpkgc_file__lookahead; + uint8_t llpkgc_file__eof; + uint8_t llpkgc_file__value_resume; + uint8_t llpkgc_file__line_resume; + uint8_t llpkgc_file__text_resume; +}; + +int llpkgc_file__internal_init(llpkgc_file__internal_t* s); +int llpkgc_file__internal_execute(llpkgc_file__internal_t* s, const char* p, const char* endp); + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* INCLUDE_LLPKGC_FILE__INTERNAL_H_ */ diff --git a/llpkgc_frag.c b/llpkgc_frag.c new file mode 100644 index 0000000000..cab2b1a959 --- /dev/null +++ b/llpkgc_frag.c @@ -0,0 +1,215 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ + +#include +#include +#include + +#include "llpkgc_frag.h" + +#define CALLBACK_MAYBE(PARSER, NAME) \ + do { \ + const llpkgc_frag_settings_t* settings; \ + settings = \ + (const llpkgc_frag_settings_t*) (PARSER)->llpkgc_frag__settings; \ + if(settings == NULL || settings->NAME == NULL) { \ + err = 0; \ + break; \ + } \ + err = settings->NAME((PARSER)); \ + } while(0) + +#define SPAN_CALLBACK_MAYBE(PARSER, NAME, START, LEN) \ + do { \ + const llpkgc_frag_settings_t* settings; \ + settings = \ + (const llpkgc_frag_settings_t*) (PARSER)->llpkgc_frag__settings; \ + if(settings == NULL || settings->NAME == NULL) { \ + err = 0; \ + break; \ + } \ + err = settings->NAME((PARSER), (START), (LEN)); \ + if(err == -1) { \ + err = PFFE_USER; \ + llpkgc_frag_set_error_reason((PARSER), "Span callback error in " #NAME); \ + } \ + } while(0) + +enum llpkgc_frag_state { + PFFS_START = 0, + PFFS_UNQUOTED = 1, + PFFS_DOUBLE_QUOTED = 2, + PFFS_SINGLE_QUOTED = 3, +}; + +void llpkgc_frag_init(llpkgc_frag_t* parser, + const llpkgc_frag_settings_t* settings) { + llpkgc_frag__internal_init(parser); + parser->llpkgc_frag__settings = (void*) settings; +} + +void llpkgc_frag_reset(llpkgc_frag_t* parser) { + llpkgc_frag_settings_t* settings = parser->llpkgc_frag__settings; + void* data = parser->data; + llpkgc_frag__internal_init(parser); + parser->llpkgc_frag__settings = settings; + parser->data = data; +} + +void llpkgc_frag_settings_init(llpkgc_frag_settings_t* settings) { + memset(settings, 0, sizeof(*settings)); +} + +llpkgc_frag_errno_t llpkgc_frag_execute(llpkgc_frag_t* parser, const char* data, + size_t len) { + return llpkgc_frag__internal_execute(parser, data, data + len); +} + +llpkgc_frag_errno_t llpkgc_frag_finish(llpkgc_frag_t* parser) { + int err = PFFE_OK; + + if(parser->error == PFFE_LOOKAHEAD) { + if(parser->error_pos == NULL) { + parser->error = PFFE_INTERNAL; + parser->reason = "Missing lookahead error position"; + return parser->error; + } + + parser->llpkgc_frag__eof = 1; + llpkgc_frag_resume(parser); + err = llpkgc_frag_execute(parser, parser->error_pos, 1); + parser->llpkgc_frag__eof = 0; + + if(err != PFFE_OK) { + return err; + } + + parser->llpkgc_frag__lookahead = 0; + } else if(parser->error != 0) { + return parser->error; + } + + switch(parser->llpkgc_frag__state) { + case PFFS_UNQUOTED: + CALLBACK_MAYBE(parser, on_frag_complete); + if(err != PFFE_OK) { + parser->error = err; + return err; + } + break; + + case PFFS_DOUBLE_QUOTED: + case PFFS_SINGLE_QUOTED: + parser->reason = "Unterminated quote at end of input"; + parser->error = PFFE_UNFINISHED; + return PFFE_UNFINISHED; + + case PFFS_START: + break; + } + + CALLBACK_MAYBE(parser, on_fraglist_complete); + if(err != PFFE_OK) { + parser->error = err; + return err; + } + + return PFFE_OK; +} + +void llpkgc_frag_pause(llpkgc_frag_t* parser) { + if(parser->error != PFFE_OK) { + return; + } + parser->error = PFFE_PAUSED; + parser->reason = "Paused"; +} + +void llpkgc_frag_resume(llpkgc_frag_t* parser) { + if(parser->error != PFFE_PAUSED && parser->error != PFFE_LOOKAHEAD) { + return; + } + parser->error = 0; +} + +llpkgc_frag_errno_t llpkgc_frag_get_errno(const llpkgc_frag_t* parser) { + return parser->error; +} + +const char* llpkgc_frag_get_error_reason(const llpkgc_frag_t* parser) { + return parser->reason; +} + +void llpkgc_frag_set_error_reason(llpkgc_frag_t* parser, const char* reason) { + parser->reason = reason; +} + +const char* llpkgc_frag_get_error_pos(const llpkgc_frag_t* parser) { + return parser->error_pos; +} + +const char* llpkgc_frag_errno_name(llpkgc_frag_errno_t err) { + switch(err) { + case PFFE_OK: + return "PFFE_OK"; + case PFFE_INTERNAL: + return "PFFE_INTERNAL"; + case PFFE_PAUSED: + return "PFFE_PAUSED"; + case PFFE_USER: + return "PFFE_USER"; + case PFFE_UNFINISHED: + return "PFFE_UNFINISHED"; + case PFFE_LOOKAHEAD: + return "PFFE_LOOKAHEAD"; + } + return "INVALID_ERRNO"; +} + +int llpkgc_frag__lookahead_dq_backslash(llpkgc_frag_t* s, const char* p, + const char* endp) { + if(p == endp) { + llpkgc_frag_set_error_reason(s, "Invalid lookahead state"); + return PFFE_INTERNAL; + } + + if(p + 1 == endp) { + if(s->llpkgc_frag__eof != 0) { + s->llpkgc_frag__lookahead = 0; + return 1; + } + s->llpkgc_frag__lookahead = (uint8_t) *p; + return PFFE_LOOKAHEAD; + } + + s->llpkgc_frag__lookahead = 0; + + if(*p != '\\') { + llpkgc_frag_set_error_reason(s, "Invalid lookahead state"); + return PFFE_INTERNAL; + } + + switch(p[1]) { + case '$': + case '`': + case '"': + case '\\': + return 0; + default: + return 1; + } +} + +int llpkgc_frag__fragment_text(llpkgc_frag_t* s, const char* p, + const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_fragment_text, p, endp - p); + return err; +} + +int llpkgc_frag__frag_complete(llpkgc_frag_t* s, const char* p, + const char* endp) { + int err; + CALLBACK_MAYBE(s, on_frag_complete); + return err; +} diff --git a/llpkgc_frag.h b/llpkgc_frag.h new file mode 100644 index 0000000000..7210a5baa6 --- /dev/null +++ b/llpkgc_frag.h @@ -0,0 +1,83 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ + +#ifndef INCLUDE_LLPKGC_FRAG_API_H_ +#define INCLUDE_LLPKGC_FRAG_API_H_ +#ifdef __cplusplus +extern "C" { +#endif +#include + +#include "llpkgc_frag__internal.h" + +#if defined(_MSC_VER) +#define LLPKGC_FRAG_EXPORT __declspec(dllexport) +#else +#define LLPKGC_FRAG_EXPORT __attribute__((visibility("default"))) +#endif + +typedef llpkgc_frag__internal_t llpkgc_frag_t; +typedef struct llpkgc_frag_settings_s llpkgc_frag_settings_t; + +typedef int ( + *llpkgc_frag_data_cb)(llpkgc_frag_t*, const char* at, size_t length); +typedef int (*llpkgc_frag_cb)(llpkgc_frag_t*); + +struct llpkgc_frag_settings_s { + llpkgc_frag_data_cb on_fragment_text; + llpkgc_frag_cb on_frag_complete; + llpkgc_frag_cb on_fraglist_complete; +}; + +enum llpkgc_frag_errno { + PFFE_INTERNAL = -1, + PFFE_OK = 0, + PFFE_PAUSED = 1, + PFFE_USER = 2, + PFFE_UNFINISHED = 3, + PFFE_LOOKAHEAD = 4, +}; +typedef enum llpkgc_frag_errno llpkgc_frag_errno_t; + +LLPKGC_FRAG_EXPORT +void llpkgc_frag_init(llpkgc_frag_t* parser, + const llpkgc_frag_settings_t* settings); + +LLPKGC_FRAG_EXPORT +void llpkgc_frag_reset(llpkgc_frag_t* parser); + +LLPKGC_FRAG_EXPORT +void llpkgc_frag_settings_init(llpkgc_frag_settings_t* settings); + +LLPKGC_FRAG_EXPORT +llpkgc_frag_errno_t llpkgc_frag_execute(llpkgc_frag_t* parser, const char* data, + size_t len); + +LLPKGC_FRAG_EXPORT +llpkgc_frag_errno_t llpkgc_frag_finish(llpkgc_frag_t* parser); + +LLPKGC_FRAG_EXPORT +void llpkgc_frag_pause(llpkgc_frag_t* parser); + +LLPKGC_FRAG_EXPORT +void llpkgc_frag_resume(llpkgc_frag_t* parser); + +LLPKGC_FRAG_EXPORT +llpkgc_frag_errno_t llpkgc_frag_get_errno(const llpkgc_frag_t* parser); + +LLPKGC_FRAG_EXPORT +const char* llpkgc_frag_get_error_reason(const llpkgc_frag_t* parser); + +LLPKGC_FRAG_EXPORT +void llpkgc_frag_set_error_reason(llpkgc_frag_t* parser, const char* reason); + +LLPKGC_FRAG_EXPORT +const char* llpkgc_frag_get_error_pos(const llpkgc_frag_t* parser); + +LLPKGC_FRAG_EXPORT +const char* llpkgc_frag_errno_name(llpkgc_frag_errno_t err); + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* INCLUDE_LLPKGC_FRAG_API_H_ */ diff --git a/llpkgc_frag__internal.c b/llpkgc_frag__internal.c new file mode 100644 index 0000000000..b74d61182a --- /dev/null +++ b/llpkgc_frag__internal.c @@ -0,0 +1,674 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ +/* This code was generated by llpkgc, do not edit it by hand + See: https://gitlab.kitware.com/utils/llpkgc */ + + +#include +#include +#include + +#ifdef __SSE4_2__ + #ifdef _MSC_VER + #include + #else /* !_MSC_VER */ + #include + #endif /* _MSC_VER */ +#endif /* __SSE4_2__ */ + +#if defined(__ARM_NEON__) || defined(__ARM_NEON) + #include +#endif /* __ARM_NEON__ */ + +#ifdef __wasm__ + #include +#endif /* __wasm__ */ + +#ifdef _MSC_VER + #define ALIGN(n) _declspec(align(n)) + #define UNREACHABLE __assume(0) +#else /* !_MSC_VER */ + #define ALIGN(n) __attribute__((aligned(n))) + #define UNREACHABLE __builtin_unreachable() +#endif /* _MSC_VER */ + +#include "llpkgc_frag__internal.h" + +typedef int (*llpkgc_frag__internal__span_cb)( + llpkgc_frag__internal_t*, const char*, const char*); + +enum llparse_state_e { + s_error, + s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__frag_complete, + s_n_llpkgc_frag__internal__n_pkgc_frag_consume_dq, + s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_sq, + s_n_llpkgc_frag__internal__n_pkgc_frag_sq, + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_1, + s_n_llpkgc_frag__internal__n_pkgc_frag_consume_sq, + s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_escaped_char, + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_3, + s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_skip_backslash, + s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted, + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_2, + s_n_llpkgc_frag__internal__n_pkgc_frag_after_quote, + s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_dq, + s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special_skip, + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_4, + s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special, + s_n_llpkgc_frag__internal__n_pkgc_frag_dq_keep_backslash, + s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__lookahead_dq_backslash, + s_n_llpkgc_frag__internal__n_pkgc_frag_dq, + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text, + s_n_llpkgc_frag__internal__n_pkgc_frag_start, +}; +typedef enum llparse_state_e llparse_state_t; + +int llpkgc_frag__fragment_text( + llpkgc_frag__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_frag__internal__c_update_llpkgc_frag__state( + llpkgc_frag__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_frag__state = 2; + return 0; +} + +int llpkgc_frag__internal__c_update_llpkgc_frag__state_1( + llpkgc_frag__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_frag__state = 1; + return 0; +} + +int llpkgc_frag__frag_complete( + llpkgc_frag__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_frag__internal__c_update_llpkgc_frag__state_2( + llpkgc_frag__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_frag__state = 0; + return 0; +} + +int llpkgc_frag__internal__c_update_llpkgc_frag__state_3( + llpkgc_frag__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + state->llpkgc_frag__state = 3; + return 0; +} + +int llpkgc_frag__lookahead_dq_backslash( + llpkgc_frag__internal_t* s, const unsigned char* p, + const unsigned char* endp); + +int llpkgc_frag__internal_init(llpkgc_frag__internal_t* state) { + memset(state, 0, sizeof(*state)); + state->_current = (void*) (intptr_t) s_n_llpkgc_frag__internal__n_pkgc_frag_start; + return 0; +} + +static llparse_state_t llpkgc_frag__internal__run( + llpkgc_frag__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + int match; + switch ((llparse_state_t) (intptr_t) state->_current) { + case s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__frag_complete: + s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__frag_complete: { + switch (llpkgc_frag__frag_complete(state, p, endp)) { + case 0: + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_2; + default: + goto s_n_llpkgc_frag__internal__n_error; + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_consume_dq: + s_n_llpkgc_frag__internal__n_pkgc_frag_consume_dq: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_consume_dq; + } + switch (*p) { + case '"': { + p++; + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state; + } + default: { + goto s_n_llpkgc_frag__internal__n_error_1; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_sq: + s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_sq: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_sq; + } + switch (*p) { + case 39: { + p++; + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_1; + } + default: { + goto s_n_llpkgc_frag__internal__n_error_1; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_sq: + s_n_llpkgc_frag__internal__n_pkgc_frag_sq: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_sq; + } + switch (*p) { + case 39: { + goto s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_1; + } + default: { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_sq; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_1: + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_1: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_1; + } + state->_span_pos0 = (void*) p; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_sq; + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_consume_sq: + s_n_llpkgc_frag__internal__n_pkgc_frag_consume_sq: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_consume_sq; + } + switch (*p) { + case 39: { + p++; + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_3; + } + default: { + goto s_n_llpkgc_frag__internal__n_error_1; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_escaped_char: + s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_escaped_char: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_escaped_char; + } + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted; + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_3: + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_3: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_3; + } + state->_span_pos0 = (void*) p; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_escaped_char; + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_skip_backslash: + s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_skip_backslash: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_skip_backslash; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_3; + } + default: { + goto s_n_llpkgc_frag__internal__n_error_2; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted: + s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted; + } + switch (*p) { + case 9: { + goto s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_2; + } + case ' ': { + goto s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_2; + } + case '"': { + goto s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_3; + } + case 39: { + goto s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_4; + } + case 92: { + goto s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_5; + } + default: { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_2: + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_2: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_2; + } + state->_span_pos0 = (void*) p; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted; + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_after_quote: + s_n_llpkgc_frag__internal__n_pkgc_frag_after_quote: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_after_quote; + } + switch (*p) { + case 9: { + goto s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__frag_complete; + } + case ' ': { + goto s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__frag_complete; + } + case '"': { + goto s_n_llpkgc_frag__internal__n_pkgc_frag_consume_dq; + } + case 39: { + goto s_n_llpkgc_frag__internal__n_pkgc_frag_consume_sq; + } + case 92: { + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_4; + } + default: { + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_4; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_dq: + s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_dq: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_dq; + } + switch (*p) { + case '"': { + p++; + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_1; + } + default: { + goto s_n_llpkgc_frag__internal__n_error_1; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special_skip: + s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special_skip: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special_skip; + } + switch (*p) { + case '"': { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq; + } + case '$': { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq; + } + case 92: { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq; + } + case '`': { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq; + } + default: { + goto s_n_llpkgc_frag__internal__n_error_2; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_4: + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_4: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_4; + } + state->_span_pos0 = (void*) p; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special_skip; + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special: + s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_4; + } + default: { + goto s_n_llpkgc_frag__internal__n_error_2; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_dq_keep_backslash: + s_n_llpkgc_frag__internal__n_pkgc_frag_dq_keep_backslash: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_dq_keep_backslash; + } + switch (*p) { + case 92: { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq; + } + default: { + goto s_n_llpkgc_frag__internal__n_error_2; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__lookahead_dq_backslash: + s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__lookahead_dq_backslash: { + switch (llpkgc_frag__lookahead_dq_backslash(state, p, endp)) { + case 0: + goto s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_6; + case 1: + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq_keep_backslash; + case 4: + goto s_n_llpkgc_frag__internal__n_pause; + default: + goto s_n_llpkgc_frag__internal__n_error_2; + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_dq: + s_n_llpkgc_frag__internal__n_pkgc_frag_dq: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_dq; + } + switch (*p) { + case '"': { + goto s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text; + } + case 92: { + goto s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__lookahead_dq_backslash; + } + default: { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq; + } + } + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text: + s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text; + } + state->_span_pos0 = (void*) p; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq; + UNREACHABLE; + } + case s_n_llpkgc_frag__internal__n_pkgc_frag_start: + s_n_llpkgc_frag__internal__n_pkgc_frag_start: { + if (p == endp) { + return s_n_llpkgc_frag__internal__n_pkgc_frag_start; + } + switch (*p) { + case 9: { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_start; + } + case ' ': { + p++; + goto s_n_llpkgc_frag__internal__n_pkgc_frag_start; + } + case '"': { + p++; + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state; + } + case 39: { + p++; + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_3; + } + default: { + goto s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_4; + } + } + UNREACHABLE; + } + default: + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_2: { + switch (llpkgc_frag__internal__c_update_llpkgc_frag__state_2(state, p, endp)) { + default: + goto s_n_llpkgc_frag__internal__n_pkgc_frag_start; + } + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_error: { + state->error = 0x1; + state->reason = "Fragment complete error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_error_1: { + state->error = 0x1; + state->reason = "Fragment parse error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_1: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_frag__fragment_text(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_sq; + return s_error; + } + goto s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_sq; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_3: { + switch (llpkgc_frag__internal__c_update_llpkgc_frag__state_3(state, p, endp)) { + default: + goto s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_1; + } + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_2: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_frag__fragment_text(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__frag_complete; + return s_error; + } + goto s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__frag_complete; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_3: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_frag__fragment_text(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_frag__internal__n_pkgc_frag_consume_dq; + return s_error; + } + goto s_n_llpkgc_frag__internal__n_pkgc_frag_consume_dq; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_4: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_frag__fragment_text(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_frag__internal__n_pkgc_frag_consume_sq; + return s_error; + } + goto s_n_llpkgc_frag__internal__n_pkgc_frag_consume_sq; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_error_2: { + state->error = 0x3; + state->reason = "Lookahead error"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_5: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_frag__fragment_text(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_skip_backslash; + return s_error; + } + goto s_n_llpkgc_frag__internal__n_pkgc_frag_unquoted_skip_backslash; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_4: { + switch (llpkgc_frag__internal__c_update_llpkgc_frag__state_1(state, p, endp)) { + default: + goto s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text_2; + } + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state_1: { + switch (llpkgc_frag__internal__c_update_llpkgc_frag__state_1(state, p, endp)) { + default: + goto s_n_llpkgc_frag__internal__n_pkgc_frag_after_quote; + } + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_frag__fragment_text(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_dq; + return s_error; + } + goto s_n_llpkgc_frag__internal__n_pkgc_frag_consume_closing_dq; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_span_end_llpkgc_frag__fragment_text_6: { + const unsigned char* start; + int err; + + start = state->_span_pos0; + state->_span_pos0 = NULL; + err = llpkgc_frag__fragment_text(state, start, p); + if (err != 0) { + state->error = err; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special; + return s_error; + } + goto s_n_llpkgc_frag__internal__n_pkgc_frag_dq_special; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_pause: { + state->error = 0x4; + state->reason = "Lookahead required"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_n_llpkgc_frag__internal__n_invoke_llpkgc_frag__lookahead_dq_backslash; + return s_error; + UNREACHABLE; + } + s_n_llpkgc_frag__internal__n_invoke_update_llpkgc_frag__state: { + switch (llpkgc_frag__internal__c_update_llpkgc_frag__state(state, p, endp)) { + default: + goto s_n_llpkgc_frag__internal__n_span_start_llpkgc_frag__fragment_text; + } + UNREACHABLE; + } +} + +int llpkgc_frag__internal_execute(llpkgc_frag__internal_t* state, const char* p, const char* endp) { + llparse_state_t next; + + /* check lingering errors */ + if (state->error != 0) { + return state->error; + } + + /* restart spans */ + if (state->_span_pos0 != NULL) { + state->_span_pos0 = (void*) p; + } + + next = llpkgc_frag__internal__run(state, (const unsigned char*) p, (const unsigned char*) endp); + if (next == s_error) { + return state->error; + } + state->_current = (void*) (intptr_t) next; + + /* execute spans */ + if (state->_span_pos0 != NULL) { + int error; + + error = llpkgc_frag__fragment_text(state, state->_span_pos0, (const char*) endp); + if (error != 0) { + state->error = error; + state->error_pos = endp; + return error; + } + } + + return 0; +} diff --git a/llpkgc_frag__internal.h b/llpkgc_frag__internal.h new file mode 100644 index 0000000000..cd21219292 --- /dev/null +++ b/llpkgc_frag__internal.h @@ -0,0 +1,36 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See accompanying file LICENSE.rst for details. */ +/* This code was generated by llpkgc, do not edit it by hand + See: https://gitlab.kitware.com/utils/llpkgc */ + + +#ifndef INCLUDE_LLPKGC_FRAG__INTERNAL_H_ +#define INCLUDE_LLPKGC_FRAG__INTERNAL_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct llpkgc_frag__internal_s llpkgc_frag__internal_t; +struct llpkgc_frag__internal_s { + int32_t _index; + void* _span_pos0; + int32_t error; + const char* reason; + const char* error_pos; + void* data; + void* _current; + void* llpkgc_frag__settings; + uint8_t llpkgc_frag__state; + uint8_t llpkgc_frag__eof; + uint8_t llpkgc_frag__lookahead; +}; + +int llpkgc_frag__internal_init(llpkgc_frag__internal_t* s); +int llpkgc_frag__internal_execute(llpkgc_frag__internal_t* s, const char* p, const char* endp); + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* INCLUDE_LLPKGC_FRAG__INTERNAL_H_ */