/* 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 <stdlib.h>
#include <stdint.h>
#include <string.h>

#ifdef __SSE4_2__
 #ifdef _MSC_VER
  #include <nmmintrin.h>
 #else  /* !_MSC_VER */
  #include <x86intrin.h>
 #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;
}
