basic support for builtins
authorMichael Wallner <mike@php.net>
Tue, 6 Nov 2018 16:33:35 +0000 (17:33 +0100)
committerMichael Wallner <mike@php.net>
Tue, 4 Dec 2018 11:13:48 +0000 (12:13 +0100)
49 files changed:
.gitignore
.travis.yml
Makefile.frag
TODO
config.m4
m4/psi/psi.m4
php_psi.h
php_psi_posix.h.in
psi.d/stdlib.psi
scripts/gen_travis_yml.php
src/builtin.c [new file with mode: 0644]
src/builtin.h [new file with mode: 0644]
src/calc.h
src/context.c
src/context.h
src/cpp.c
src/cpp.h
src/cpp_tokiter.c
src/data.c
src/data.h
src/error.c
src/error.h
src/module.c
src/parser.c
src/parser.h
src/parser.re [deleted file]
src/parser_proc.c
src/parser_proc.h
src/parser_proc_grammar.y
src/parser_scan.c [new file with mode: 0644]
src/parser_scan.re [new file with mode: 0644]
src/types/const.c
src/types/cpp_exp.c
src/types/cpp_macro_call.c
src/types/cpp_macro_call.h
src/types/decl.c
src/types/decl_arg.c
src/types/decl_extvar.c
src/types/decl_extvar.h
src/types/impl_def_val.c
src/types/impl_val.h
src/types/num_exp.c
src/types/num_exp.h
src/types/number.c
src/types/number.h
src/validate.h
tests/parser/cpp002.phpt [new file with mode: 0644]
tests/parser/cpp003.phpt [new file with mode: 0644]
tests/parser/cpp003/prescan.psi [new file with mode: 0644]

index ce94c07..320a3eb 100644 (file)
@@ -63,3 +63,4 @@ tests/*/*.sh
 /php_psi_posix.h
 /types/
 /calc/
+*.bak
index db53c03..7fe182c 100644 (file)
@@ -25,8 +25,8 @@ before_install:
  - touch src/parser_proc_grammar.y
  - touch src/parser_proc.c
  - touch src/parser_proc.h
- - touch src/parser.re
- - touch src/parser.c
+ - touch src/parser_scan.re
+ - touch src/parser_scan.c
  - touch src/parser.h
 
 install:
index 5a7a877..589785d 100644 (file)
@@ -18,9 +18,9 @@ $(PHP_PSI_SRCDIR)/src/parser_proc.c: $(PHP_PSI_SRCDIR)/src/parser_proc_grammar.y
        # trickery needed for relative #line directives
        cd $(PHP_PSI_SRCDIR) && bison -Wall -v -d -o $(patsubst $(PHP_PSI_SRCDIR)/%,%,$@) $(patsubst $(PHP_PSI_SRCDIR)/%,%,$<)
 
-$(PHP_PSI_SRCDIR)/src/parser.re: $(PHP_PSI_SRCDIR)/src/parser_proc.h
+$(PHP_PSI_SRCDIR)/src/parser_scan.re: $(PHP_PSI_SRCDIR)/src/parser_proc.h
        touch $@
-$(PHP_PSI_SRCDIR)/src/parser.c: $(PHP_PSI_SRCDIR)/src/parser.re
+$(PHP_PSI_SRCDIR)/src/parser_scan.c: $(PHP_PSI_SRCDIR)/src/parser_scan.re
        # trickery needed for relative #line directives
        cd $(PHP_PSI_SRCDIR) && $(RE2C) -o $(patsubst $(PHP_PSI_SRCDIR)/%,%,$@) $(patsubst $(PHP_PSI_SRCDIR)/%,%,$<)
 
@@ -31,7 +31,7 @@ $(PHP_PSI_SRCDIR)/src/calc.h: | $(PHP_PSI_SRCDIR)/src/calc/basic.h $(PHP_PSI_SRC
 
 .PHONY: psi-generated
 psi-generated: $(PHP_PSI_GENERATED)
-       
+
 
 PHP_PSI_DEPEND = $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(PHP_PSI_SOURCES:.c=.dep))
 
@@ -82,7 +82,7 @@ psi-watch:
        -while inotifywait -q -e modify -r $(PHP_PSI_SRCDIR); do $(MAKE); done
 
 install-headers: psi-build-headers
-clean: psi-clean-headers psi-clean-aux
+clean: psi-clean-headers
 ifneq ($(PSI_DEPS),)
 clean: psi-clean-depend
 endif
diff --git a/TODO b/TODO
index 3e6e55a..e029536 100644 (file)
--- a/TODO
+++ b/TODO
@@ -7,3 +7,14 @@
 * improve varargs support, currently it's impossible to map e.g. curl_easy_setopt
 * impl_var.name: remove leading '$'
 * really solve the array/pointer problem
+
+* variadic macros
+* predefined macros
+   * __COUNTER__               counter starting from 0, incremented each time expanded
+   * __BASE_FILE__             current PSI file
+   * __INCLUDE_LEVEL__ include level
+   * __TIMESTAMP__             lmod of current source file
+* builtins
+* int128
+* very small real numbers
+* cache tokens of files and copy tokens if used for further processing
index d621ffc..1a6fbec 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -55,12 +55,13 @@ if test "$PHP_PSI" != no; then
        AC_MSG_RESULT([$PHP_PSI_SRCDIR])
        AC_MSG_CHECKING([psi build dir])
        AC_MSG_RESULT([$PHP_PSI_BUILDDIR])
-       
+
        PSI_CHECK_LIBJIT
        PSI_CHECK_LIBFFI
 
        AC_FUNC_FNMATCH
        AC_FUNC_MMAP
+       AC_CHECK_FUNCS([mknodat eaccess])
 
        PSI_CONFIG_INIT
        PSI_CHECK_STD_TYPES
@@ -83,15 +84,15 @@ if test "$PHP_PSI" != no; then
                src/calc/unary.h src/calc/cmp.h src/calc/oper.h \
                `(cd $PHP_PSI_SRCDIR/src && ls *.h types/*.h)` \
        "
-       # parser* should come first
+       # parser_* should come first
        PHP_PSI_SOURCES=" \
-               src/parser_proc.c src/parser.c \
+               src/parser_proc.c src/parser_scan.c \
                `(cd $PHP_PSI_SRCDIR && ls src/*.c src/types/*.c \
-                       | $EGREP -v '^src/parser' \
+                       | $EGREP -v '^src/parser_' \
                )` \
        "
        PHP_PSI_GENERATED=" \
-               src/parser_proc.c src/parser.c \
+               src/parser_proc.c src/parser_scan.c \
                src/calc/basic.h src/calc/bin.h src/calc/bool.h src/calc/cast.h \
                src/calc/unary.h src/calc/cmp.h src/calc/oper.h \
        "
index f292c3e..bb8254b 100644 (file)
@@ -12,7 +12,7 @@ AC_DEFUN(PSI_CONFIG_INIT, [
        AC_PROG_AWK
        
        AC_MSG_CHECKING(for preprocessor defaults)
-       psi_cpp_predef=`$CPP -Wp,-dM $CPPFLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 - </dev/null`
+       psi_cpp_predef=`$CPP -Wp,-dM $CPPFLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U__BLOCKS__ - </dev/null`
        psi_cpp_search=`$CPP -Wp,-v $CPPFLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 - </dev/null 2>&1 >/dev/null \
                | $AWK '
                        /include.*search.*start/ { 
index 91f3030..01582c5 100644 (file)
--- a/php_psi.h
+++ b/php_psi.h
@@ -47,7 +47,7 @@ extern zend_module_entry psi_module_entry;
 
 static inline int psi_check_env(const char *var) {
        char *set = getenv(var);
-       return (set && *set && '0' != *set);
+       return (set && *set && (*set != '0' || set[1]));
 }
 
 typedef struct psi_object {
index bc2d356..a0527c5 100644 (file)
@@ -61,7 +61,9 @@ static struct psi_func_redir {
        {"fstatat", (psi_func_ptr) fstatat},
        {"lstat", (psi_func_ptr) lstat},
        {"mknod", (psi_func_ptr) mknod},
+#ifdef HAVE_MKNODAT
        {"mknodat", (psi_func_ptr) mknodat},
+#endif
        {"stat", (psi_func_ptr) stat},
        {0}
 };
index bf67899..70b1c65 100644 (file)
@@ -1,4 +1,6 @@
+#ifdef linux
 lib "crypt";
+#endif
 
 #include <stdlib.h>
 
@@ -19,7 +21,7 @@ function psi\ldiv(int $numerator, int $denominator) : array {
        let numerator = intval($numerator);
        let denominator = intval($denominator);
        pre_assert denominator != 0;
-       return ldiv(numerator, denominator) 
+       return ldiv(numerator, denominator)
                as to_array(ldiv, to_int(quot), to_int(rem));
 }
 
@@ -27,14 +29,14 @@ function psi\lldiv(int $numerator, int $denominator) : array {
        let numerator = intval($numerator);
        let denominator = intval($denominator);
        pre_assert denominator != 0;
-       return lldiv(numerator, denominator) 
+       return lldiv(numerator, denominator)
                as to_array(lldiv, to_int(quot), to_int(rem));
 }
 
 function psi\strtold(string $str, string &$end = null) : float {
        let nptr = strval($str);
        let endptr = &NULL;
-       return strtold(nptr, endptr) 
+       return strtold(nptr, endptr)
                as to_float(strtold);
        set $end = to_string(*endptr);
 }
@@ -62,4 +64,4 @@ function psi\realloc(object $obj, int $size) : object {
        let size = intval($size);
        pre_assert size >= 0;
        return realloc(ptr, size) as to_object(realloc);
-} 
+}
index 5de7ab9..8b4185b 100755 (executable)
@@ -39,8 +39,8 @@ before_install:
  - touch src/parser_proc_grammar.y
  - touch src/parser_proc.c
  - touch src/parser_proc.h
- - touch src/parser.re
- - touch src/parser.c
+ - touch src/parser_scan.re
+ - touch src/parser_scan.c
  - touch src/parser.h
 
 install:
diff --git a/src/builtin.c b/src/builtin.c
new file mode 100644 (file)
index 0000000..e4e2e9b
--- /dev/null
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ Copyright (c) 2018, Michael Wallner <mike@php.net>.
+ All rights reserved.
+
+ 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.
+
+ 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 OWNER 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.
+*******************************************************************************/
+
+#include "php_psi_stdinc.h"
+
+#include "php_psi.h"
+#include "builtin.h"
+#include "parser.h"
+#include "cpp.h"
+
+#include <stdarg.h>
+
+HashTable psi_builtins;
+
+static bool has_include(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res);
+static bool has_include_next(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res);
+static bool builtin_constant_p(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res);
+static bool COUNTER__(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res);
+
+static inline struct psi_plist *builtin_sig(token_t typ, ...)
+{
+       struct psi_plist *sig;
+       size_t n = 0;
+       va_list args;
+
+       if (typ == (token_t) - 1) {
+               return NULL;
+       }
+
+       sig  = psi_plist_init((psi_plist_dtor) psi_token_free);
+       va_start(args, typ);
+       while (typ) {
+               char a = 'a' + n++;
+               struct psi_token *arg;
+
+               arg = psi_token_init(typ, &a, 1, 0, 0, zend_empty_string);
+               sig = psi_plist_add(sig, &arg);
+               typ = va_arg(args, token_t);
+       }
+       va_end(args);
+
+       return sig;
+}
+
+static void free_builtin(zval *p)
+{
+       struct psi_builtin *b = Z_PTR_P(p);
+
+       if (b) {
+               zend_string_release(b->name);
+               psi_cpp_macro_decl_free(&b->decl);
+               pefree(b, 1);
+       }
+}
+
+PHP_MINIT_FUNCTION(psi_builtin)
+{
+#define PSI_BUILTIN(builtin, ...) do { \
+       struct psi_builtin entry; \
+       struct psi_plist *sig = builtin_sig(__VA_ARGS__, 0); \
+       struct psi_cpp_macro_decl *decl = psi_cpp_macro_decl_init(sig, NULL, NULL); \
+       decl->token = psi_token_init(PSI_T_NAME, "__" #builtin, sizeof("__" #builtin)-1, \
+               0, 0, zend_empty_string); \
+       entry.name = zend_string_copy(decl->token->text); \
+       entry.func = &builtin; \
+       entry.decl = decl; \
+       zend_hash_add_mem(&psi_builtins, entry.name, &entry, sizeof(entry)); \
+} while(0)
+
+       zend_hash_init(&psi_builtins, 0, NULL, free_builtin, 1);
+       PSI_BUILTIN(has_include, PSI_T_CPP_HEADER);
+       PSI_BUILTIN(has_include_next, PSI_T_CPP_HEADER);
+       PSI_BUILTIN(builtin_constant_p, PSI_T_NAME);
+       PSI_BUILTIN(COUNTER__, -1);
+
+       return SUCCESS;
+}
+
+PHP_MSHUTDOWN_FUNCTION(psi_builtin)
+{
+       zend_hash_destroy(&psi_builtins);
+       return SUCCESS;
+}
+
+bool psi_builtin_exists(zend_string *name)
+{
+       return zend_hash_exists(&psi_builtins, name);
+}
+
+struct psi_builtin *psi_builtin_get(zend_string *name)
+{
+       return zend_hash_find_ptr(&psi_builtins, name);
+}
+
+static bool has_include(struct psi_cpp *cpp, struct psi_token *target,
+               struct psi_plist **args, struct psi_plist **res)
+{
+       struct psi_plist *arg = args[0];
+       struct psi_token *tok;
+
+       switch (psi_plist_count(arg)) {
+       case 1:
+               if (psi_plist_get(arg, 0, &tok)) {
+                       const char *cpp_search = cpp->search;
+                       bool has = psi_cpp_has_include(cpp, tok, 0, NULL);
+                       cpp->search = cpp_search;
+                       return has;
+               }
+               /* no break */
+       default:
+               cpp->parser->error(PSI_DATA(cpp->parser), target, PSI_WARNING,
+                               "Erroneous usage of builtin __%s", __FUNCTION__);
+       }
+       return false;
+}
+
+static bool has_include_next(struct psi_cpp *cpp, struct psi_token *target,
+               struct psi_plist **args, struct psi_plist **res)
+{
+       struct psi_plist *arg = args[0];
+       struct psi_token *tok;
+
+       switch (psi_plist_count(arg)) {
+       case 1:
+               if (psi_plist_get(arg, 0, &tok)) {
+                       const char *cpp_search = cpp->search;
+                       bool has = psi_cpp_has_include(cpp, tok, PSI_CPP_INCLUDE_NEXT, NULL);
+                       cpp->search = cpp_search;
+                       return has;
+               }
+               /* no break */
+       default:
+               cpp->parser->error(PSI_DATA(cpp->parser), target, PSI_WARNING,
+                               "Erroneous usage of builtin __%s", __FUNCTION__);
+       }
+       return false;
+}
+
+static bool builtin_constant_p(struct psi_cpp *cpp, struct psi_token *target,
+               struct psi_plist **args, struct psi_plist **res_ptr)
+{
+       /* we want functions, not macros for e.g. htonl() */
+       return false;
+}
+
+static bool COUNTER__(struct psi_cpp *cpp, struct psi_token *target,
+               struct psi_plist **args, struct psi_plist **res)
+{
+       struct psi_token *tok;
+       char buf[0x20];
+       size_t len = sprintf(buf, "%u", cpp->counter++);
+
+       tok = psi_token_init(PSI_T_NUMBER, buf, len, target->col, target->line, target->file);
+       *res = psi_plist_init((psi_plist_dtor) psi_token_free);
+       *res = psi_plist_add(*res, &tok);
+
+       return true;
+}
diff --git a/src/builtin.h b/src/builtin.h
new file mode 100644 (file)
index 0000000..13b8c83
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ Copyright (c) 2018, Michael Wallner <mike@php.net>.
+ All rights reserved.
+
+ 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.
+
+ 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 OWNER 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.
+*******************************************************************************/
+
+#ifndef PSI_BUILTIN_H
+#define PSI_BUILTIN_H
+
+struct psi_cpp;
+struct psi_plist;
+struct psi_token;
+
+struct psi_builtin {
+       zend_string *name;
+       bool (*func)(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args_list, struct psi_plist **res);
+       struct psi_cpp_macro_decl *decl;
+};
+
+bool psi_builtin_exists(zend_string *name);
+struct psi_builtin *psi_builtin_get(zend_string *name);
+
+#endif /* PSI_BUILTIN_H */
index 21ece7b..0c2678c 100644 (file)
@@ -30,7 +30,7 @@
 #include "types/impl_val.h"
 
 #define PRIfval ".13gF"
-#define PRIdval ".53lg"
+#define PRIdval ".53g"
 #define PRIldval ".64LgL"
 
 typedef token_t (*psi_calc)(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res);
index 1d5e230..be8bae9 100644 (file)
@@ -98,7 +98,9 @@ PHP_MINIT_FUNCTION(psi_context)
 PHP_MSHUTDOWN_FUNCTION(psi_context)
 {
        if (psi_check_env("PSI_DUMP")) {
-               psi_context_dump(PSI_G(context), STDOUT_FILENO);
+               struct psi_dump dump = {{.hn = stdout}, (psi_dump_cb) fprintf};
+
+               psi_context_dump(&dump, PSI_G(context));
        }
 
        psi_context_free(&PSI_G(context));
@@ -148,7 +150,7 @@ static bool psi_context_add(struct psi_context *C, struct psi_parser *P)
        D = psi_data_exchange(&C->data[C->count++], PSI_DATA(P));
 
        psi_validate_scope_ctor(&scope);
-       scope.defs = &P->preproc->defs;
+       scope.cpp = P->preproc;
        valid = psi_validate(&scope, PSI_DATA(C), D);
        psi_validate_scope_dtor(&scope);
 
@@ -234,7 +236,7 @@ zend_function_entry *psi_context_compile(struct psi_context *C)
 
                        zc.name = zend_string_copy(c->name);
 
-                       switch (c->type->type) {
+                       switch (c->type ? c->type->type : c->val->type) {
                        case PSI_T_BOOL:
                                ZVAL_BOOL(&zc.value, c->val->ival.zend.bval);
                                break;
@@ -376,15 +378,21 @@ void psi_context_free(struct psi_context **C)
        }
 }
 
-void psi_context_dump(struct psi_context *C, int fd)
+void psi_context_dump(struct psi_dump *dump, struct psi_context *C)
 {
        size_t i;
 
-       dprintf(fd, "// psi.engine=%s\n// %lu files\n",
+       PSI_DUMP(dump, "// psi.engine=%s\n// %lu files\n",
                        (char *) C->ops->query(C, PSI_CONTEXT_QUERY_SELF, NULL),
                        C->count);
 
-       for (i = 0; i < C->count; ++i) {
-               psi_data_dump(fd, &C->data[i]);
+       psi_data_dump(dump, PSI_DATA(C));
+
+#if 0
+       if (C->flags & PSI_DEBUG) {
+               for (i = 0; i < C->count; ++i) {
+                       psi_data_dump(fd, &C->data[i]);
+               }
        }
+#endif
 }
index 73d13cd..248efbb 100644 (file)
@@ -75,7 +75,7 @@ struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_o
 void psi_context_build(struct psi_context *C, const char *path);
 zend_function_entry *psi_context_compile(struct psi_context *C);
 ZEND_RESULT_CODE psi_context_call(struct psi_context *C, zend_execute_data *execute_data, zval *return_value, struct psi_impl *impl);
-void psi_context_dump(struct psi_context *C, int fd);
+void psi_context_dump(struct psi_dump *dump, struct psi_context *C);
 void psi_context_dtor(struct psi_context *C);
 void psi_context_free(struct psi_context **C);
 
index e01c3e6..4982c78 100644 (file)
--- a/src/cpp.c
+++ b/src/cpp.c
@@ -46,7 +46,7 @@ PHP_MINIT_FUNCTION(psi_cpp)
        PSI_G(search_path) = pemalloc(strlen(PSI_G(directory)) + strlen(psi_cpp_search) + 1 + 1, 1);
        sprintf(PSI_G(search_path), "%s:%s", PSI_G(directory), psi_cpp_search);
 
-       if (!psi_parser_init(&parser, NULL, 0)) {
+       if (!psi_parser_init(&parser, psi_error_wrapper, PSI_SILENT)) {
                return FAILURE;
        }
 
@@ -108,13 +108,18 @@ struct psi_cpp *psi_cpp_init(struct psi_parser *P)
        return cpp;
 }
 
-#if PSI_CPP_DEBUG
+static char *include_flavor[] = {
+               "include",
+               "include next",
+               "include once"
+};
+
+#if PSI_CPP_DEBUG > 1
 static int dump_def(zval *p)
 {
        struct psi_cpp_macro_decl *decl = Z_PTR_P(p);
 
        if (decl) {
-               fflush(stderr);
                dprintf(2, "PSI: CPP decl -> #define ");
                psi_cpp_macro_decl_dump(2, decl);
                dprintf(2, "\n");
@@ -128,7 +133,7 @@ void psi_cpp_free(struct psi_cpp **cpp_ptr)
        if (*cpp_ptr) {
                struct psi_cpp *cpp = *cpp_ptr;
 
-#if PSI_CPP_DEBUG
+#if PSI_CPP_DEBUG > 1
                zend_hash_apply(&cpp->defs, dump_def);
 #endif
                *cpp_ptr = NULL;
@@ -251,7 +256,7 @@ static bool psi_cpp_stage2(struct psi_cpp *cpp)
                        }
                } else if (current->type == PSI_T_EOL) {
 #if PSI_CPP_DEBUG
-                       fprintf(stderr, "PSI: CPP do_expansion=true, PSI_T_EOL\n");
+                       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP do_expansion=true, PSI_T_EOL\n");
 #endif
                        is_eol = true;
                        skip_all = false;
@@ -267,7 +272,7 @@ static bool psi_cpp_stage2(struct psi_cpp *cpp)
                                switch (current->type) {
                                case PSI_T_DEFINE:
 #if PSI_CPP_DEBUG
-                                       fprintf(stderr, "PSI: CPP do_expansion=false, PSI_T_DEFINE, skip_all\n");
+                                       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP do_expansion=false, PSI_T_DEFINE, skip_all\n");
 #endif
                                        do_expansion = false;
                                        skip_all = true;
@@ -279,7 +284,7 @@ static bool psi_cpp_stage2(struct psi_cpp *cpp)
                                case PSI_T_IFNDEF:
                                case PSI_T_UNDEF:
 #if PSI_CPP_DEBUG
-                                       fprintf(stderr, "PSI: CPP do_expansion=false, PSI_T_{IF{,N},UN}DEF\n");
+                                       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP do_expansion=false, PSI_T_{IF{,N},UN}DEF\n");
 #endif
                                        do_expansion = false;
                                        break;
@@ -291,7 +296,7 @@ static bool psi_cpp_stage2(struct psi_cpp *cpp)
                                                } else {
                                                        do_expansion = true;
 #if PSI_CPP_DEBUG
-                                                       fprintf(stderr, "PSI: CPP do_expansion=true, PSI_T_LPAREN, !skip_all, !skip_paren\n");
+                                                       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP do_expansion=true, PSI_T_LPAREN, !skip_all, !skip_paren\n");
 #endif
                                                }
                                        }
@@ -301,7 +306,7 @@ static bool psi_cpp_stage2(struct psi_cpp *cpp)
                                default:
                                        do_expansion = !skip_all;
 #if PSI_CPP_DEBUG
-                                       fprintf(stderr, "PSI: CPP do_expansion=%s, <- !skip_all\n", do_expansion?"true":"false");
+                                       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP do_expansion=%s, <- !skip_all\n", do_expansion?"true":"false");
 #endif
                                }
                        }
@@ -310,8 +315,8 @@ static bool psi_cpp_stage2(struct psi_cpp *cpp)
                if (cpp->skip) {
                        if (!do_cpp) {
 #if PSI_CPP_DEBUG
-                               fprintf(stderr, "PSI: CPP skip ");
-                               psi_token_dump(2, current);
+                               PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP skip ");
+                               PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, current);
 #endif
                                psi_cpp_tokiter_del_cur(cpp, true);
                                continue;
@@ -352,7 +357,7 @@ static bool psi_cpp_stage2(struct psi_cpp *cpp)
                        }
 
 #if PSI_CPP_DEBUG > 1
-                       psi_cpp_tokiter_dump(2, cpp);
+                       PSI_DEBUG_DUMP(cpp->parser, psi_cpp_tokiter_dump, cpp);
 #endif
 
                        continue;
@@ -370,7 +375,7 @@ static bool psi_cpp_stage2(struct psi_cpp *cpp)
 bool psi_cpp_process(struct psi_cpp *cpp, struct psi_plist **tokens)
 {
        bool parsed = false;
-       struct psi_cpp temp = *cpp;
+       struct psi_cpp temp = *cpp;     cpp->level = temp.level;
 
        cpp->tokens.iter = *tokens;
        cpp->tokens.next = NULL;
@@ -390,8 +395,11 @@ bool psi_cpp_process(struct psi_cpp *cpp, struct psi_plist **tokens)
        if (temp.tokens.iter) {
                cpp->tokens.iter = temp.tokens.iter;
                cpp->tokens.next = temp.tokens.next;
-               cpp->index = temp.index;
        }
+       cpp->index = temp.index;
+       cpp->skip = temp.skip;
+       cpp->level = temp.level;
+       cpp->seen = temp.seen;
 
        return parsed;
 }
@@ -401,18 +409,21 @@ bool psi_cpp_defined(struct psi_cpp *cpp, struct psi_token *tok)
        bool defined;
 
        if (tok->type == PSI_T_NAME) {
-               defined = zend_hash_exists(&cpp->defs, tok->text);
+               defined = zend_hash_exists(&cpp->defs, tok->text)
+                               || psi_builtin_exists(tok->text);
        } else {
                defined = false;
        }
 
 #if PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP defined -> %s ", defined ? "true" : "false");
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP defined -> %s ", defined ? "true" : "false");
        if (defined) {
                struct psi_cpp_macro_decl *macro = zend_hash_find_ptr(&cpp->defs, tok->text);
-               fprintf(stderr, " @ %s:%u ", macro->token->file->val, macro->token->line);
+               if (macro) {
+                       PSI_DEBUG_PRINT(cpp->parser, " @ %s:%u ", macro->token->file->val, macro->token->line);
+               }
        }
-       psi_token_dump(2, tok);
+       PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, tok);
 #endif
 
        return defined;
@@ -430,12 +441,12 @@ void psi_cpp_define(struct psi_cpp *cpp, struct psi_cpp_macro_decl *decl)
        }
 #if PSI_CPP_DEBUG
        if (decl->exp) {
-               fprintf(stderr, "PSI: CPP MACRO num_exp -> %s ", decl->token->text->val);
+               PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP MACRO num_exp -> ");
        } else {
-               fprintf(stderr, "PSI: CPP MACRO decl    -> %s ", decl->token->text->val);
+               PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP MACRO decl    -> ");
        }
-       psi_cpp_macro_decl_dump(2, decl);
-       fprintf(stderr, "\n");
+       PSI_DEBUG_DUMP(cpp->parser, psi_cpp_macro_decl_dump, decl);
+       PSI_DEBUG_PRINT(cpp->parser, "\n");
 #endif
        zend_hash_update_ptr(&cpp->defs, decl->token->text, decl);
 }
@@ -449,93 +460,105 @@ bool psi_cpp_if(struct psi_cpp *cpp, struct psi_cpp_exp *exp)
 {
        struct psi_validate_scope scope = {0};
 
-       scope.defs = &cpp->defs;
+       scope.cpp = cpp;
        if (!psi_num_exp_validate(PSI_DATA(cpp->parser), exp->data.num, &scope)) {
                return false;
        }
-       if (!psi_num_exp_get_long(exp->data.num, NULL, &cpp->defs)) {
+       if (!psi_num_exp_get_long(exp->data.num, NULL, cpp)) {
                return false;
        }
        return true;
 }
 
-static inline bool try_include(struct psi_cpp *cpp, const char *path, bool *parsed)
+bool psi_cpp_include(struct psi_cpp *cpp, const struct psi_token *file, unsigned flags)
 {
+       bool parsed = false;
+       char path[PATH_MAX];
+       struct psi_plist *tokens;
        struct psi_parser_input *include;
 
-       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP include trying %s\n", path);
-
-       include = psi_parser_open_file(cpp->parser, path, false);
-       if (include) {
-               struct psi_plist *tokens;
-
-               PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP include scanning %s\n", path);
-
-               tokens = psi_parser_scan(cpp->parser, include);
-               if (tokens) {
-                       *parsed = psi_cpp_process(cpp, &tokens);
-
-                       if (*parsed) {
-                               size_t num_tokens = psi_plist_count(tokens);
+       if (!psi_cpp_has_include(cpp, file, flags, path)) {
+               return false;
+       }
 
-                               ++cpp->expanded;
-                               psi_cpp_tokiter_add_range(cpp, num_tokens, psi_plist_eles(tokens));
-                               free(tokens);
-                       } else {
-                               psi_plist_free(tokens);
-                       }
+       if (flags & PSI_CPP_INCLUDE_ONCE) {
+               if (zend_hash_str_exists(&cpp->once, path, strlen(path))) {
+                       return true;
                }
-               psi_parser_input_free(&include);
+       }
+
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP %s opening %s\n",
+                       include_flavor[flags], path);
 
-               zend_hash_str_add_empty_element(&cpp->once, path, strlen(path));
-               return true;
+       include = psi_parser_open_file(cpp->parser, path, false);
+       if (!include) {
+               return false;
        }
-       return false;
-}
 
-static inline void include_path(const struct psi_token *file, char **path)
-{
-       if (file->text->val[0] == '/') {
-               *path = file->text->val;
-       } else {
-               char *dir;
-               size_t len;
+       zend_hash_str_add_empty_element(&cpp->once, path, strlen(path));
 
-               strncpy(*path, file->file->val, PATH_MAX);
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP include scanning %s\n", path);
 
-               dir = dirname(*path);
-               len = strlen(dir);
+       tokens = psi_parser_scan(cpp->parser, include);
+       psi_parser_input_free(&include);
 
-               assert(len + file->text->len + 1 < PATH_MAX);
+       if (!tokens) {
+               return false;
+       }
 
-               memmove(*path, dir, len);
-               (*path)[len] = '/';
-               memcpy(&(*path)[len + 1], file->text->val, file->text->len + 1);
+       parsed = psi_cpp_process(cpp, &tokens);
+       if (!parsed) {
+               psi_plist_free(tokens);
+               return false;
        }
+
+       psi_cpp_tokiter_add_range(cpp, psi_plist_count(tokens), psi_plist_eles(tokens));
+       free(tokens);
+
+       ++cpp->expanded;
+       return true;
 }
 
-bool psi_cpp_include(struct psi_cpp *cpp, const struct psi_token *file, unsigned flags)
+#ifndef HAVE_EACCESS
+#      define eaccess access
+#endif
+bool psi_cpp_has_include(struct psi_cpp *cpp, const struct psi_token *file, unsigned flags, char *path)
 {
-       bool parsed = false;
+       char temp[PATH_MAX];
+
+       if (!path) {
+               path = temp;
+       }
 
        if (file->type == PSI_T_QUOTED_STRING && (!(flags & PSI_CPP_INCLUDE_NEXT) || file->text->val[0] == '/')) {
                /* first try as is, full or relative path */
-               char temp[PATH_MAX], *path = temp;
+               if (file->text->val[0] == '/') {
+                       path = file->text->val;
+               } else {
+                       char *dir;
+                       size_t len;
 
-               include_path(file, &path);
+                       strncpy(path, file->file->val, PATH_MAX);
 
-               if ((flags & PSI_CPP_INCLUDE_ONCE) && zend_hash_str_exists(&cpp->once, path, strlen(path))) {
-                       return true;
+                       dir = dirname(path);
+                       len = strlen(dir);
+
+                       assert(len + file->text->len + 1 < PATH_MAX);
+
+                       memmove(path, dir, len);
+                       path[len] = '/';
+                       memcpy(&(path)[len + 1], file->text->val, file->text->len + 1);
                }
-               if (try_include(cpp, path, &parsed)) {
-                       /* found */
-                       return parsed;
+
+               PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP %s trying %s\n",
+                               include_flavor[flags], path);
+               if (0 == eaccess(path, R_OK)) {
+                       return true;
                }
        }
 
        /* look through search paths */
        if (file->text->val[0] != '/') {
-               char path[PATH_MAX];
                const char *sep;
                int p_len;
 
@@ -559,12 +582,11 @@ bool psi_cpp_include(struct psi_cpp *cpp, const struct psi_token *file, unsigned
                        d_len = sep ? sep - cpp->search : strlen(cpp->search);
 
                        if (PATH_MAX > (p_len = snprintf(path, PATH_MAX, "%.*s/%.*s", d_len, cpp->search, (int) file->text->len, file->text->val))) {
-                               if ((flags & PSI_CPP_INCLUDE_ONCE) && zend_hash_str_exists(&cpp->once, path, p_len)) {
-                                       return true;
-                               }
-                               if (try_include(cpp, path, &parsed)) {
-                                       break;
-                               }
+                               PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP %s trying %s\n",
+                                               include_flavor[flags], path);
+                               if (0 == eaccess(path, R_OK)) {
+                                        return true;
+                                }
                        }
 
                        if (sep) {
@@ -573,5 +595,5 @@ bool psi_cpp_include(struct psi_cpp *cpp, const struct psi_token *file, unsigned
                } while (sep);
        }
 
-       return parsed;
+       return false;
 }
index ae607c5..ed766e3 100644 (file)
--- a/src/cpp.h
+++ b/src/cpp.h
@@ -29,7 +29,7 @@
 #include "data.h"
 
 #ifndef PSI_CPP_DEBUG
-# define PSI_CPP_DEBUG 0
+# define PSI_CPP_DEBUG 1
 #endif
 
 struct psi_cpp {
@@ -46,6 +46,7 @@ struct psi_cpp {
        unsigned skip;
        unsigned seen;
        unsigned expanded;
+       unsigned counter;
 };
 
 struct psi_cpp *psi_cpp_init(struct psi_parser *parser);
@@ -61,6 +62,7 @@ bool psi_cpp_undef(struct psi_cpp *cpp, struct psi_token *tok);
 #define PSI_CPP_INCLUDE_NEXT 0x1
 #define PSI_CPP_INCLUDE_ONCE 0x2
 
+bool psi_cpp_has_include(struct psi_cpp *cpp, const struct psi_token *file, unsigned flags, char *path);
 bool psi_cpp_include(struct psi_cpp *cpp, const struct psi_token *file, unsigned flags);
 
 void psi_cpp_tokiter_reset(struct psi_cpp *cpp);
index 5611d3a..c2bcb95 100644 (file)
@@ -56,15 +56,18 @@ void psi_cpp_tokiter_dump(int fd, struct psi_cpp *cpp)
 void psi_cpp_tokiter_reset(struct psi_cpp *cpp)
 {
 #if PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP reset -> iter.count=%zu, next.count=%zu\n",
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP reset -> iter.count=%zu, next.count=%zu\n",
                        psi_plist_count(cpp->tokens.iter),
                        psi_plist_count(cpp->tokens.next));
 #      if PSI_CPP_DEBUG > 1
-       psi_cpp_tokiter_dump(2, cpp);
+       PSI_DEBUG_DUMP(cpp->parser, psi_cpp_tokiter_dump, cpp);
 #      endif
 #endif
        cpp->index = 0;
        cpp->expanded = 0;
+       cpp->skip = 0;
+       cpp->seen = 0;
+       cpp->level = 0;
 
        if (cpp->tokens.next) {
                free(cpp->tokens.iter);
@@ -108,9 +111,9 @@ bool psi_cpp_tokiter_add_cur(struct psi_cpp *cpp)
                        cpp->tokens.next = tokens;
 
 #if PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP add_cur -> index=%zu, iter.count=%zu, next.count=%zu  ",
-                       cpp->index, psi_plist_count(cpp->tokens.iter), psi_plist_count(cpp->tokens.next));
-       psi_token_dump(2, cur);
+                       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP add_cur -> index=%zu, iter.count=%zu, next.count=%zu     ",
+                                       cpp->index, psi_plist_count(cpp->tokens.iter), psi_plist_count(cpp->tokens.next));
+                       PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, cur);
 #endif
 
                        return true;
@@ -130,9 +133,9 @@ bool psi_cpp_tokiter_add(struct psi_cpp *cpp, struct psi_token *tok)
        cpp->tokens.next = tokens;
 
 #if PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP add -> index=%zu, iter.count=%zu, next.count=%zu      ",
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP add -> index=%zu, iter.count=%zu, next.count=%zu ",
                        cpp->index, psi_plist_count(cpp->tokens.iter), psi_plist_count(cpp->tokens.next));
-       psi_token_dump(2, tok);
+       PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, tok);
 #endif
 
        return true;
@@ -154,7 +157,7 @@ bool psi_cpp_tokiter_add_range(struct psi_cpp *cpp, size_t num_eles, void **eles
        cpp->tokens.next = tokens;
 
 #if PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP add_range -> index=%zu, num_eles=%zu, iter.count=%zu, next.count=%zu\n",
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP add_range -> index=%zu, num_eles=%zu, iter.count=%zu, next.count=%zu\n",
                        cpp->index, num_eles, psi_plist_count(cpp->tokens.iter), psi_plist_count(cpp->tokens.next));
 #endif
 
@@ -165,7 +168,7 @@ bool psi_cpp_tokiter_add_range(struct psi_cpp *cpp, size_t num_eles, void **eles
 void psi_cpp_tokiter_next(struct psi_cpp *cpp)
 {
 #if 0 && PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP next -> index=%zu -> index=%zu\n",
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP next -> index=%zu -> index=%zu\n",
                        cpp->index, cpp->index+1);
 #endif
        ++cpp->index;
@@ -174,7 +177,7 @@ void psi_cpp_tokiter_next(struct psi_cpp *cpp)
 bool psi_cpp_tokiter_valid(struct psi_cpp *cpp)
 {
 #if 0 && PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP valid -> index=%zu -> %d\n",
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP valid -> index=%zu -> %d\n",
                        cpp->index, cpp->index < psi_plist_count(cpp->tokens.iter));
 #endif
        return cpp->index < psi_plist_count(cpp->tokens.iter);
@@ -185,8 +188,8 @@ bool psi_cpp_tokiter_del_prev(struct psi_cpp *cpp, bool free_token)
        struct psi_token *cur = NULL;
 
 #if PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP del_prev -> index=%zu, iter.count=%zu, next.count\n",
-                       cpp->index, psi_plist_count(cpp->tokens.iter));
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP del_prev -> index=%zu, iter.count=%zu, next.count=%zu\n",
+                       cpp->index, psi_plist_count(cpp->tokens.iter), psi_plist_count(cpp->tokens.next));
 #endif
 
        if (psi_plist_pop(cpp->tokens.next, NULL) && psi_plist_get(cpp->tokens.iter, cpp->index - 1, &cur)) {
@@ -204,13 +207,13 @@ bool psi_cpp_tokiter_del_cur(struct psi_cpp *cpp, bool free_token)
        struct psi_token *cur = NULL;
 
 #if PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP del_cur -> index=%zu, iter.count=%zu, next.count=%zu  ",
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP del_cur -> index=%zu, iter.count=%zu, next.count=%zu     ",
                        cpp->index, psi_plist_count(cpp->tokens.iter), psi_plist_count(cpp->tokens.next));
 #endif
 
        if (psi_plist_get(cpp->tokens.iter, cpp->index, &cur)) {
 #if PSI_CPP_DEBUG
-               psi_token_dump(2, cur);
+               PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, cur);
 #endif
                psi_plist_unset(cpp->tokens.iter, cpp->index);
                if (free_token && cur) {
@@ -229,7 +232,7 @@ bool psi_cpp_tokiter_del_range(struct psi_cpp *cpp, size_t offset, size_t num_el
        size_t i;
 
 #if PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP del_range -> index=%zu, offset=%zu, num_eles=%zu, iter.count=%zu, next.count=%zu\n",
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP del_range -> index=%zu, offset=%zu, num_eles=%zu, iter.count=%zu, next.count=%zu\n",
                        cpp->index, offset, num_eles, psi_plist_count(cpp->tokens.iter), psi_plist_count(cpp->tokens.next));
 #endif
 
@@ -238,8 +241,8 @@ bool psi_cpp_tokiter_del_range(struct psi_cpp *cpp, size_t offset, size_t num_el
                        return false;
                }
 #if PSI_CPP_DEBUG
-               fprintf(stderr, "PSI: CPP del_range ->  ");
-               psi_token_dump(2, ptr);
+               PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP del_range ->     ");
+               PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, ptr);
 #endif
                psi_plist_unset(cpp->tokens.iter, i);
                if (free_tokens && ptr) {
@@ -266,7 +269,7 @@ bool psi_cpp_tokiter_ins_range(struct psi_cpp *cpp, size_t num_eles, void **eles
        cpp->tokens.iter = tokens;
 
 #if PSI_CPP_DEBUG
-       fprintf(stderr, "PSI: CPP ins_range -> index=%zu, num_eles=%zu, iter.count=%zu, next.count=%zu\n",
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP ins_range -> index=%zu, num_eles=%zu, iter.count=%zu, next.count=%zu\n",
                        cpp->index, num_eles, psi_plist_count(cpp->tokens.iter), psi_plist_count(cpp->tokens.next));
 #endif
 
@@ -284,67 +287,100 @@ bool psi_cpp_tokiter_defined(struct psi_cpp *cpp)
        return false;
 }
 
-static size_t psi_cpp_tokiter_expand_tokens(struct psi_cpp *cpp,
+static inline size_t psi_cpp_tokiter_expand_tokens(struct psi_cpp *cpp,
                struct psi_token *target, struct psi_plist *tokens)
 {
-       if (tokens && psi_plist_count(tokens)) {
-               size_t i = 0, n = 0;
-               bool stringify = false, paste = false;
-               struct psi_token *tok, **exp_tokens = pecalloc(psi_plist_count(tokens), sizeof(*exp_tokens), 1);
+       size_t i = 0, n = 0;
+       bool stringify = false, paste = false;
+       struct psi_token *tok;
+       struct psi_plist *exp;
 
-               while (psi_plist_get(tokens, i++, &tok)) {
-                       struct psi_token *new_tok;
+       if (!psi_plist_count(tokens)) {
+               return 0;
+       }
 
-                       if (tok->type == PSI_T_EOL) {
-                               continue;
-                       }
-                       if (tok->type == PSI_T_HASH) {
-                               stringify = true;
-                               continue;
-                       }
-                       if (tok->type == PSI_T_CPP_PASTE) {
-                               paste = true;
-                               continue;
-                       }
+       exp = psi_plist_init(NULL);
+       while (psi_plist_get(tokens, i++, &tok)) {
+               struct psi_token *new_tok;
+
+               if (tok->type == PSI_T_EOL) {
+                       continue;
+               }
+               if (tok->type == PSI_T_HASH) {
+                       stringify = true;
+                       continue;
+               }
+               if (tok->type == PSI_T_CPP_PASTE) {
+                       paste = true;
+                       continue;
+               }
 
-                       if (paste && n > 0 && exp_tokens[n - 1]) {
-                               struct psi_token *tmp_tok, *old_tok = exp_tokens[n - 1];
+               if (paste && psi_plist_count(exp)) {
+                       struct psi_token *old_tok;
+                       struct psi_parser_input *toscan;
 
-                               tmp_tok = psi_token_init(old_tok->type, "", 0,
-                                               target->col, target->line,
-                                               target->file ? target->file : zend_empty_string);
+                       psi_plist_pop(exp, &old_tok);
+                       new_tok = psi_token_cat(NULL, 2, old_tok, tok);
 
-                               new_tok = psi_token_cat(NULL, 3, tmp_tok, old_tok, tok);
-                               psi_token_free(&old_tok);
-                               psi_token_free(&tmp_tok);
+                       /* reclassify token(s) */
+                       if ((toscan = psi_parser_open_string(cpp->parser, new_tok->text->val, new_tok->text->len))) {
+                               struct psi_plist *scanned;
 
-                               exp_tokens[n - 1] = new_tok;
-                       } else {
-                               new_tok = psi_token_init(stringify ? PSI_T_QUOTED_STRING : tok->type,
-                                               tok->text->val, tok->text->len, target->col, target->line,
-                                               target->file ?: zend_empty_string);
+                               scanned = psi_parser_scan(cpp->parser, toscan);
+                               if (psi_plist_count(scanned)) {
+                                       size_t i = 0;
+                                       struct psi_token *tmp_tok;
+
+                                       exp = psi_plist_add_r(exp, psi_plist_count(scanned), psi_plist_eles(scanned));
 
-                               exp_tokens[n++] = new_tok;
+                                       /* fix meta info */
+                                       while (psi_plist_get(scanned, i++, &tmp_tok)) {
+                                               zend_string_release(tmp_tok->file);
+                                               tmp_tok->file = zend_string_copy(new_tok->file);
+                                               tmp_tok->line = new_tok->line;
+                                               tmp_tok->col = new_tok->col;
+                                       }
+
+                                       psi_token_free(&new_tok);
+                                       psi_plist_top(scanned, &new_tok);
+                               } else {
+                                       exp = psi_plist_add(exp, &new_tok);
+                               }
+                               if (scanned) {
+                                       free(scanned);
+                               }
+                               psi_parser_input_free(&toscan);
+                       } else {
+                               exp = psi_plist_add(exp, &new_tok);
                        }
 
-#if PSI_CPP_DEBUG
-                       fprintf(stderr, "PSI: CPP expand > ");
-                       psi_token_dump(2, tok);
-#endif
+                       psi_token_free(&old_tok);
+               } else {
+                       new_tok = psi_token_init(stringify ? PSI_T_QUOTED_STRING : tok->type,
+                                       tok->text->val, tok->text->len, target->col, target->line,
+                                       target->file ?: zend_empty_string);
 
-                       paste = false;
-                       stringify = false;
+                       exp = psi_plist_add(exp, &new_tok);
                }
-               psi_cpp_tokiter_ins_range(cpp, n, (void *) exp_tokens);
-               free(exp_tokens);
 
-               return n;
-       } else {
-               return 0;
+#if PSI_CPP_DEBUG
+               PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP expand > ");
+               PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, new_tok);
+#endif
+
+               paste = false;
+               stringify = false;
        }
+
+       n = psi_plist_count(exp);
+       psi_cpp_tokiter_ins_range(cpp, n, psi_plist_eles(exp));
+       free(exp);
+
+       return n;
 }
 
-static void psi_cpp_tokiter_free_call_tokens(struct psi_plist **arg_tokens_list, size_t arg_count, bool free_tokens)
+static inline void psi_cpp_tokiter_free_call_tokens(
+               struct psi_plist **arg_tokens_list, size_t arg_count, bool free_tokens)
 {
        size_t i;
 
@@ -363,10 +399,10 @@ static void psi_cpp_tokiter_free_call_tokens(struct psi_plist **arg_tokens_list,
        free(arg_tokens_list);
 }
 
-static struct psi_plist **psi_cpp_tokiter_read_call_tokens(
+static inline struct psi_plist **psi_cpp_tokiter_read_call_tokens(
                struct psi_cpp *cpp, size_t arg_count)
 {
-       size_t arg_index = 0, lparens = 1, rparens = 0;
+       size_t arg_index = 0, lparens = 1, rparens = 0, start = psi_cpp_tokiter_index(cpp);
        struct psi_plist **arg_tokens = pecalloc(arg_count, sizeof(*arg_tokens), 1);
        struct psi_plist *free_tokens = psi_plist_init((psi_plist_dtor) psi_token_free);
        struct psi_token *tok;
@@ -424,7 +460,10 @@ static struct psi_plist **psi_cpp_tokiter_read_call_tokens(
                }
        }
 
+       /* ditch arg tokens */
+       psi_cpp_tokiter_del_range(cpp, start, psi_cpp_tokiter_index(cpp) - start + 1, false);
        psi_plist_free(free_tokens);
+
        return arg_tokens;
 
 fail:
@@ -432,23 +471,31 @@ fail:
        return NULL;
 }
 
-static void psi_cpp_tokiter_expand_call_tokens(struct psi_cpp *cpp,
+static inline void psi_cpp_tokiter_expand_call_tokens(struct psi_cpp *cpp,
                struct psi_token *target, struct psi_cpp_macro_decl *macro,
                struct psi_plist **arg_tokens_list)
 {
        size_t i;
        struct psi_token *tok;
        struct psi_plist *tokens = psi_plist_init(NULL);
+       bool prescan = true;
 
        for (i = 0; psi_plist_get(macro->tokens, i, &tok); ++i) {
                struct psi_plist *arg_tokens = NULL;
 
-               if (tok->type == PSI_T_NAME) {
+               if (tok->type == PSI_T_HASH || tok->type == PSI_T_CPP_PASTE) {
+                       prescan = false;
+               } else if (tok->type == PSI_T_NAME) {
                        size_t s;
                        struct psi_token *arg_name;
 
                        for (s = 0; psi_plist_get(macro->sig, s, &arg_name); ++s) {
                                if (zend_string_equals(arg_name->text, tok->text)) {
+                                       if (prescan) {
+                                               bool processed = psi_cpp_process(cpp, &arg_tokens_list[s]);
+
+                                               assert(processed);
+                                       }
                                        arg_tokens = arg_tokens_list[s];
                                        break;
                                }
@@ -466,36 +513,92 @@ static void psi_cpp_tokiter_expand_call_tokens(struct psi_cpp *cpp,
        psi_plist_free(tokens);
 }
 
-static bool psi_cpp_tokiter_expand_call(struct psi_cpp *cpp,
+static inline bool psi_cpp_tokiter_expand_call(struct psi_cpp *cpp,
                struct psi_token *target, struct psi_cpp_macro_decl *macro)
 {
        /* function-like macro
         * #define FOO(a,b) a>b // macro->sig == {a, b}, macro->tokens = {a, >, b}
         * # if FOO(1,2) // expands to if 1 > 2
         */
-       size_t start = psi_cpp_tokiter_index(cpp);
+       size_t start = psi_cpp_tokiter_index(cpp), argc = psi_plist_count(macro->sig);
        struct psi_plist **arg_tokens_list;
 
+
        /* read in tokens, until we have balanced parens */
-       arg_tokens_list = psi_cpp_tokiter_read_call_tokens(cpp, psi_plist_count(macro->sig));
+       arg_tokens_list = psi_cpp_tokiter_read_call_tokens(cpp, argc);
        if (!arg_tokens_list) {
                psi_cpp_tokiter_seek(cpp, start);
                return false;
        }
 
-       /* ditch arg tokens */
-       psi_cpp_tokiter_del_range(cpp, start, psi_cpp_tokiter_index(cpp) - start + 1, false);
-
        /* insert and expand macro tokens */
        psi_cpp_tokiter_expand_call_tokens(cpp, target, macro, arg_tokens_list);
-       psi_cpp_tokiter_free_call_tokens(arg_tokens_list, psi_plist_count(macro->sig), true);
+       psi_cpp_tokiter_free_call_tokens(arg_tokens_list, argc, true);
 
        psi_token_free(&target);
        ++cpp->expanded;
        return true;
 }
 
-static bool psi_cpp_tokiter_expand_def(struct psi_cpp *cpp,
+static inline void psi_cpp_tokiter_expand_builtin_tokens(struct psi_cpp *cpp,
+               struct psi_token *target, struct psi_builtin *builtin,
+               struct psi_plist **arg_tokens_list)
+{
+       size_t s;
+       struct psi_plist *res = NULL;
+       size_t argc = psi_plist_count(builtin->decl->sig);
+
+       /* prescan */
+       for (s = 0; s < argc; ++s) {
+               bool processed = psi_cpp_process(cpp, &arg_tokens_list[s]);
+               assert(processed);
+       }
+
+       /* insert and expand macro tokens */
+       if (!builtin->func(cpp, target, arg_tokens_list, &res)) {
+               struct psi_token *zero = psi_token_init(PSI_T_NUMBER, "0", 1,
+                               target->col, target->line, target->file);
+               psi_cpp_tokiter_ins_range(cpp, 1, (void *) &zero);
+       } else if (!res) {
+               struct psi_token *one = psi_token_init(PSI_T_NUMBER, "1", 1,
+                               target->col, target->line, target->file);
+               psi_cpp_tokiter_ins_range(cpp, 1, (void *) &one);
+       } else {
+               psi_cpp_tokiter_expand_tokens(cpp, target, res);
+               psi_plist_free(res);
+       }
+}
+
+static inline bool psi_cpp_tokiter_expand_builtin(struct psi_cpp *cpp,
+               struct psi_token *target, struct psi_builtin *builtin)
+{
+       size_t start = psi_cpp_tokiter_index(cpp), argc = 0;
+       struct psi_plist **arg_tokens_list = NULL;
+
+       if (builtin->decl->sig) {
+               argc = psi_plist_count(builtin->decl->sig);
+               /* read in tokens, until we have balanced parens */
+               arg_tokens_list = psi_cpp_tokiter_read_call_tokens(cpp, argc);
+               if (!arg_tokens_list) {
+                       psi_cpp_tokiter_seek(cpp, start);
+                       return false;
+               }
+       } else {
+               psi_cpp_tokiter_next(cpp);
+       }
+
+       psi_cpp_tokiter_expand_builtin_tokens(cpp, target, builtin, arg_tokens_list);
+       if (arg_tokens_list) {
+               psi_cpp_tokiter_free_call_tokens(arg_tokens_list, argc, true);
+       }
+
+       psi_token_free(&target);
+       ++cpp->expanded;
+       return true;
+}
+
+
+static inline bool psi_cpp_tokiter_expand_def(struct psi_cpp *cpp,
                struct psi_token *target, struct psi_cpp_macro_decl *macro)
 {
        /* delete current token from stream */
@@ -514,35 +617,56 @@ static inline int psi_cpp_tokiter_expand_cmp(struct psi_token *t,
        if (psi_plist_count(m->tokens) == 1) {
                struct psi_token *r;
 
-               psi_plist_get(m->tokens, 0, &r);
-
-               return !zend_string_equals(r->text, t->text);
+               if (psi_plist_get(m->tokens, 0, &r) && r->text) {
+                       return !zend_string_equals(r->text, t->text);
+               }
        }
        return -1;
 }
 
+static inline bool psi_cpp_tokiter_expand_decl(struct psi_cpp *cpp,
+               struct psi_token *target, struct psi_cpp_macro_decl *macro)
+{
+       if (!macro) {
+               return false;
+       }
+
+       /* don't expand itself */
+       if (macro->token == target) {
+               return false;
+       }
+
+       if (macro->sig) {
+               return psi_cpp_tokiter_expand_call(cpp, target, macro);
+       } else if (psi_cpp_tokiter_expand_cmp(target, macro)) {
+               return psi_cpp_tokiter_expand_def(cpp, target, macro);
+       } else {
+               return false;
+       }
+}
+
 bool psi_cpp_tokiter_expand(struct psi_cpp *cpp)
 {
-       if (psi_cpp_tokiter_valid(cpp)) {
-               struct psi_token *current = psi_cpp_tokiter_current(cpp);
+       struct psi_token *current;
 
-               if (current) {
-                       struct psi_cpp_macro_decl *macro = zend_hash_find_ptr(
-                                       &cpp->defs, current->text);
+       if (!psi_cpp_tokiter_valid(cpp)) {
+               return false;
+       }
 
-                       /* don't expand itself */
-                       if (macro && macro->token != current) {
+       current = psi_cpp_tokiter_current(cpp);
+       if (!current) {
+               return false;
+       }
 #if PSI_CPP_DEBUG
-                               fprintf(stderr, "PSI: CPP expand < ");
-                               psi_token_dump(2, current);
+       PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP expand < ");
+       PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, current);
 #endif
-                               if (macro->sig) {
-                                       return psi_cpp_tokiter_expand_call(cpp, current, macro);
-                               } else if (psi_cpp_tokiter_expand_cmp(current, macro)) {
-                                       return psi_cpp_tokiter_expand_def(cpp, current, macro);
-                               }
-                       }
-               }
+
+       if (psi_builtin_exists(current->text)) {
+               return psi_cpp_tokiter_expand_builtin(cpp, current,
+                               psi_builtin_get(current->text));
+       } else {
+               return psi_cpp_tokiter_expand_decl(cpp, current,
+                               zend_hash_find_ptr(&cpp->defs, current->text));
        }
-       return false;
 }
index b1fbc49..0fb9816 100644 (file)
 #include "data.h"
 
 #include "php_globals.h"
+#include "php_network.h"
 
 #include <dlfcn.h>
 #include <ctype.h>
 
+static void psi_data_ctor_internal(struct psi_data *data,
+               psi_error_cb error, unsigned flags)
+{
+       data->error = error;
+       data->flags = flags;
+
+       if (data->flags & PSI_DEBUG) {
+               char *debug = getenv("PSI_DEBUG");
+
+               if (debug) {
+                       int fd = -1;
+                       char *addr = strstr(debug, "://");
+
+                       if (addr) {
+                               addr += 3;
+                       }
+                       if (addr && *addr) {
+                               struct sockaddr_storage sa = {0};
+                               socklen_t ss = 0;
+                               int rc = php_network_parse_network_address_with_port(addr,
+                                               strlen(addr), (struct sockaddr *) &sa, &ss);
+
+                               if (SUCCESS == rc) {
+                                       int styp = strncmp(debug, "udp:", 4)
+                                                       ? SOCK_STREAM
+                                                       : SOCK_DGRAM;
+                                       int sfam = sa.ss_family == AF_INET6
+                                                       ? ((struct sockaddr_in6 *) &sa)->sin6_family
+                                                       : ((struct sockaddr_in *) &sa)->sin_family;
+
+                                       fd = socket(sfam, styp, 0);
+
+                                       if (fd > 0 && 0 != connect(fd, (struct sockaddr *) &sa, ss)) {
+                                               perror(debug);
+                                               close(fd);
+                                               fd = -1;
+                                       }
+                               }
+                       } else if (!strcmp(debug, "stdout")) {
+                               fd = STDOUT_FILENO;
+                       } else if (!strcmp(debug, "stderr")) {
+                               fd = STDERR_FILENO;
+                       } else if (!(fd = atoi(debug))) {
+                               fd = open(debug, O_WRONLY|O_APPEND|O_CREAT|O_CLOEXEC, 0664);
+                       }
+
+                       if (fd > 0) {
+                               data->debug_fd = fd;
+                       } else {
+                               data->debug_fd = STDERR_FILENO;
+                       }
+               }
+       }
+}
+
 struct psi_data *psi_data_ctor_with_dtors(struct psi_data *data,
                psi_error_cb error, unsigned flags)
 {
@@ -38,8 +94,8 @@ struct psi_data *psi_data_ctor_with_dtors(struct psi_data *data,
                data = pecalloc(1, sizeof(*data), 1);
        }
 
-       data->error = error;
-       data->flags = flags;
+       psi_data_ctor_internal(data, error, flags);
+
        if (!data->file.libnames) {
                data->file.libnames = psi_plist_init((psi_plist_dtor) psi_names_free);
        }
@@ -81,8 +137,7 @@ struct psi_data *psi_data_ctor(struct psi_data *data, psi_error_cb error,
                data = pecalloc(1, sizeof(*data), 1);
        }
 
-       data->error = error;
-       data->flags = flags;
+       psi_data_ctor_internal(data, error, flags);
 
        if (!data->file.libnames) {
                data->file.libnames = psi_plist_init(NULL);
@@ -130,6 +185,9 @@ struct psi_data *psi_data_exchange(struct psi_data *dest, struct psi_data *src)
 
 void psi_data_dtor(struct psi_data *data)
 {
+       if (data->debug_fd) {
+               close(data->debug_fd);
+       }
        if (data->consts) {
                psi_plist_free(data->consts);
        }
@@ -158,27 +216,27 @@ void psi_data_dtor(struct psi_data *data)
        psi_decl_file_dtor(&data->file);
 }
 
-void psi_data_dump(int fd, struct psi_data *D)
+void psi_data_dump(struct psi_dump *dump, struct psi_data *D)
 {
        size_t i = 0;
        char *libname;
 
        if (D->file.filename) {
-               dprintf(fd, "// filename=%s (%u errors)\n", D->file.filename->val, D->errors);
+               PSI_DUMP(dump, "// filename=%s (%u errors)\n", D->file.filename->val, D->errors);
        }
        while (psi_plist_get(D->file.libnames, i++, &libname)) {
-               dprintf(fd, "lib \"%s\";\n", libname);
+               PSI_DUMP(dump, "lib \"%s\";\n", libname);
        }
        if (psi_plist_count(D->types)) {
                size_t i = 0;
                struct psi_decl_arg *def;
 
                while (psi_plist_get(D->types, i++, &def)) {
-                       dprintf(fd, "typedef ");
-                       psi_decl_arg_dump(fd, def, 0);
-                       dprintf(fd, ";\n");
+                       PSI_DUMP(dump, "typedef ");
+                       psi_decl_arg_dump(dump, def, 0);
+                       PSI_DUMP(dump, ";\n");
                }
-               dprintf(fd, "\n");
+               PSI_DUMP(dump, "\n");
        }
        if (psi_plist_count(D->unions)) {
                size_t i = 0;
@@ -187,10 +245,10 @@ void psi_data_dump(int fd, struct psi_data *D)
                while (psi_plist_get(D->unions, i++, &unn)) {
                        if (!psi_decl_type_is_anon(unn->name, "union")) {
                                psi_decl_union_dump(fd, unn);
-                               dprintf(fd, "\n");
+                               PSI_DUMP(dump, "\n");
                        }
                }
-               dprintf(fd, "\n");
+               PSI_DUMP(dump, "\n");
        }
        if (psi_plist_count(D->structs)) {
                size_t i = 0;
@@ -198,11 +256,11 @@ void psi_data_dump(int fd, struct psi_data *D)
 
                while (psi_plist_get(D->structs, i++, &strct)) {
                        if (!psi_decl_type_is_anon(strct->name, "struct")) {
-                               psi_decl_struct_dump(fd, strct);
-                               dprintf(fd, "\n");
+                               psi_decl_struct_dump(dump, strct);
+                               PSI_DUMP(dump, "\n");
                        }
                }
-               dprintf(fd, "\n");
+               PSI_DUMP(dump, "\n");
        }
        if (psi_plist_count(D->enums)) {
                size_t i = 0;
@@ -210,21 +268,21 @@ void psi_data_dump(int fd, struct psi_data *D)
 
                while (psi_plist_get(D->enums, i++, &enm)) {
                        if (!psi_decl_type_is_anon(enm->name, "enum")) {
-                               psi_decl_enum_dump(fd, enm, 0);
-                               dprintf(fd, "\n");
+                               psi_decl_enum_dump(dump, enm, 0);
+                               PSI_DUMP(dump, "\n");
                        }
                }
-               dprintf(fd, "\n");
+               PSI_DUMP(dump, "\n");
        }
        if (psi_plist_count(D->consts)) {
                size_t i = 0;
                struct psi_const *c;
 
                while (psi_plist_get(D->consts, i++, &c)) {
-                       psi_const_dump(fd, c);
-                       dprintf(fd, "\n");
+                       psi_const_dump(dump, c);
+                       PSI_DUMP(dump, "\n");
                }
-               dprintf(fd, "\n");
+               PSI_DUMP(dump, "\n");
        }
        if (psi_plist_count(D->decls)) {
                size_t i = 0;
@@ -232,33 +290,33 @@ void psi_data_dump(int fd, struct psi_data *D)
 
                while (psi_plist_get(D->decls, i++, &decl)) {
                        if (decl->extvar) {
-                               dprintf(fd, "/* extvar accessor\n");
+                               PSI_DUMP(dump, "/* extvar accessor\n");
                        }
-                       psi_decl_dump(fd, decl);
-                       dprintf(fd, "\n");
+                       psi_decl_dump(dump, decl);
+                       PSI_DUMP(dump, "\n");
                        if (decl->extvar) {
-                               dprintf(fd, "   extvar accessor */\n");
+                               PSI_DUMP(dump, "   extvar accessor */\n");
                        }
                }
-               dprintf(fd, "\n");
+               PSI_DUMP(dump, "\n");
        }
        if (psi_plist_count(D->vars)) {
                size_t i = 0;
                struct psi_decl_extvar *evar;
 
                while (psi_plist_get(D->vars, i++, &evar)) {
-                       psi_decl_extvar_dump(fd, evar);
+                       psi_decl_extvar_dump(dump, evar);
                }
-               dprintf(fd, "\n");
+               PSI_DUMP(dump, "\n");
        }
        if (psi_plist_count(D->impls)) {
                size_t i = 0;
                struct psi_impl *impl;
 
                while (psi_plist_get(D->impls, i++, &impl)) {
-                       psi_impl_dump(fd, impl);
-                       dprintf(fd, "\n");
+                       psi_impl_dump(dump, impl);
+                       PSI_DUMP(dump, "\n");
                }
-               dprintf(fd, "\n");
+               PSI_DUMP(dump, "\n");
        }
 }
index 964b468..1d8414f 100644 (file)
 #define PSI_SILENT 0x2
 
 #include <stdarg.h>
+#include <dlfcn.h>
 
-#define PSI_DEBUG_PRINT(ctx, msg, ...) do { \
+#ifndef RTLD_NEXT
+# define RTLD_NEXT ((void *) -1l)
+#endif
+#ifndef RTLD_DEFAULT
+# define RTLD_DEFAULT ((void *) 0)
+#endif
+
+static inline void *psi_dlsym(struct psi_plist *dllist, const char *name, const char *redir)
+{
+       void *dl, *sym = NULL;
+       const char *test = redir ?: name;
+
+again:
+       if (dllist) {
+               size_t i = 0;
+
+               while (!sym && psi_plist_get(dllist, i++, &dl)) {
+                       sym = dlsym(dl, test);
+               }
+       }
+       if (!sym) {
+               sym = dlsym(RTLD_DEFAULT, test);
+       }
+       if (!sym && test == redir) {
+               test = name;
+               goto again;
+       }
+
+       return sym;
+}
+
+#define PSI_DEBUG_PRINT(ctx, ...) do { \
        if ((ctx) && (PSI_DATA(ctx)->flags & PSI_DEBUG)) { \
-               fprintf(stderr, msg, __VA_ARGS__); \
+               dprintf(PSI_DATA(ctx)->debug_fd, __VA_ARGS__); \
        } \
 } while(0)
+#define PSI_DEBUG_PRINTV(ctx, msg, argv) do { \
+       if ((ctx) && (PSI_DATA(ctx)->flags & PSI_DEBUG)) { \
+               vdprintf(PSI_DATA(ctx)->debug_fd, msg, argv); \
+       } \
+} while(0)
+#define PSI_DEBUG_DUMP(ctx, dump_func, ...) do { \
+       if ((ctx) && (PSI_DATA(ctx)->flags & PSI_DEBUG)) { \
+               dump_func(PSI_DATA(ctx)->debug_fd, __VA_ARGS__); \
+       } \
+} while (0)
 
+union psi_dump_arg {
+       void *hn;
+       int fd;
+};
+typedef void (*psi_dump_cb)(union psi_dump_arg, const char *msg, ...);
+struct psi_dump {
+       union psi_dump_arg ctx;
+       psi_dump_cb fun;
+};
+#define PSI_DUMP(dump, ...) (dump)->fun((dump)->ctx, __VA_ARGS__)
 
 #define PSI_DATA(D) ((struct psi_data *) (D))
 
        psi_error_cb error; \
        char last_error[0x1000]; \
        unsigned errors; \
-       unsigned flags
+       unsigned flags; \
+       int debug_fd
 
 struct psi_data {
        PSI_DATA_MEMBERS;
index 486867b..af336a2 100644 (file)
@@ -71,6 +71,7 @@ void psi_error_wrapper(struct psi_data *context, struct psi_token *t, int type,
 
        va_start(argv, msg);
        psi_verror(type, fn, ln, msg, argv);
+       PSI_DEBUG_PRINTV(context, msg, argv);
        va_end(argv);
 
        if (context) {
index c155d39..ebbd60b 100644 (file)
@@ -41,4 +41,9 @@ void psi_error_wrapper(struct psi_data *context, struct psi_token *t, int type,
 void psi_error(int type, const char *fn, unsigned ln, const char *msg, ...);
 void psi_verror(int type, const char *fn, unsigned ln, const char *msg, va_list argv);
 
+union psi_debug_ctx {
+       FILE *stdio;
+       int socket;
+};
+
 #endif /* PSI_ERROR_H */
index 9de278f..0edd74f 100644 (file)
@@ -217,7 +217,7 @@ static PHP_FUNCTION(psi_validate)
        psi_parser_parse(&P, I);
        psi_data_ctor(&D, P.error, P.flags);
        psi_validate_scope_ctor(&S);
-       S.defs = &P.preproc->defs;
+       S.cpp = P.preproc;
 
        RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)));
 
@@ -269,7 +269,7 @@ static PHP_FUNCTION(psi_validate_string)
        psi_parser_parse(&P, I);
        psi_data_ctor(&D, P.error, P.flags);
        psi_validate_scope_ctor(&S);
-       S.defs = &P.preproc->defs;
+       S.cpp = P.preproc;
 
        RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)));
 
@@ -286,6 +286,7 @@ static PHP_FUNCTION(psi_validate_string)
 }
 
 PHP_MINIT_FUNCTION(psi_cpp);
+PHP_MINIT_FUNCTION(psi_builtin);
 PHP_MINIT_FUNCTION(psi_context);
 static PHP_MINIT_FUNCTION(psi)
 {
@@ -305,6 +306,9 @@ static PHP_MINIT_FUNCTION(psi)
        psi_object_handlers.free_obj = psi_object_free;
        psi_object_handlers.clone_obj = NULL;
 
+       if (SUCCESS != PHP_MINIT(psi_builtin)(type, module_number)) {
+               return FAILURE;
+       }
        if (SUCCESS != PHP_MINIT(psi_cpp)(type, module_number)) {
                return FAILURE;
        }
@@ -316,11 +320,13 @@ static PHP_MINIT_FUNCTION(psi)
 }
 
 PHP_MSHUTDOWN_FUNCTION(psi_cpp);
+PHP_MSHUTDOWN_FUNCTION(psi_builtin);
 PHP_MSHUTDOWN_FUNCTION(psi_context);
 static PHP_MSHUTDOWN_FUNCTION(psi)
 {
        PHP_MSHUTDOWN(psi_context)(type, module_number);
        PHP_MSHUTDOWN(psi_cpp)(type, module_number);
+       PHP_MSHUTDOWN(psi_builtin)(type, module_number);
 
        UNREGISTER_INI_ENTRIES();
 
index 50bfa31..e747ed2 100644 (file)
@@ -1,5 +1,3 @@
-/* Generated by re2c 1.1.1 on Fri Nov  2 10:19:25 2018 */
-#line 1 "src/parser.re"
 /*******************************************************************************
  Copyright (c) 2016, Michael Wallner <mike@php.net>.
  All rights reserved.
 
 #include "parser.h"
 
-#define YYMAXFILL 15
-
-#ifndef YYMAXFILL
-# define YYMAXFILL 256
-#endif
-
 struct psi_parser *psi_parser_init(struct psi_parser *P, psi_error_cb error, unsigned flags)
 {
        if (!P) {
@@ -70,11 +62,11 @@ struct psi_parser_input *psi_parser_open_file(struct psi_parser *P, const char *
                return NULL;
        }
 
-       if (!(fb = pemalloc(sizeof(*fb) + sb.st_size + YYMAXFILL, 1))) {
+       if (!(fb = pemalloc(sizeof(*fb) + sb.st_size + psi_parser_maxfill(), 1))) {
                if (report_errors) {
                        P->error(PSI_DATA(P), NULL, PSI_WARNING,
                                        "Could not allocate %zu bytes for reading '%s': %s",
-                                       sb.st_size + YYMAXFILL, filename, strerror(errno));
+                                       sb.st_size + psi_parser_maxfill(), filename, strerror(errno));
                }
                return NULL;
        }
@@ -95,10 +87,13 @@ struct psi_parser_input *psi_parser_open_file(struct psi_parser *P, const char *
                if (report_errors) {
                        P->error(PSI_DATA(P), NULL, PSI_WARNING,
                                        "Could not read %zu bytes from '%s': %s",
-                                       sb.st_size + YYMAXFILL, filename, strerror(errno));
+                                       sb.st_size + psi_parser_maxfill(), filename, strerror(errno));
                }
                return NULL;
        }
+       fclose(fp);
+
+       memset(fb->buffer + sb.st_size, 0, psi_parser_maxfill());
 
        fb->length = sb.st_size;
        fb->file = zend_string_init_interned(filename, strlen(filename), 1);
@@ -110,15 +105,15 @@ struct psi_parser_input *psi_parser_open_string(struct psi_parser *P, const char
 {
        struct psi_parser_input *sb;
 
-       if (!(sb = pemalloc(sizeof(*sb) + length + YYMAXFILL, 1))) {
+       if (!(sb = pemalloc(sizeof(*sb) + length + psi_parser_maxfill(), 1))) {
                P->error(PSI_DATA(P), NULL, PSI_WARNING,
                                "Could not allocate %zu bytes: %s",
-                               length + YYMAXFILL, strerror(errno));
+                               length + psi_parser_maxfill(), strerror(errno));
                return NULL;
        }
 
        memcpy(sb->buffer, string, length);
-       memset(sb->buffer + length, 0, YYMAXFILL);
+       memset(sb->buffer + length, 0, psi_parser_maxfill());
 
        sb->length = length;
        sb->file = zend_string_init_interned("<stdin>", strlen("<stdin>"), 1);
@@ -142,6 +137,38 @@ bool psi_parser_process(struct psi_parser *P, struct psi_plist *tokens, size_t *
        return true;
 }
 
+static inline zend_string *macro_to_constant(struct psi_parser *parser,
+               zend_string *name, struct psi_validate_scope *scope)
+{
+       smart_str str = {0};
+
+       size_t i = 0;
+       struct psi_token *tok;
+
+       smart_str_append_printf(&str, "\nconst psi\\%s = ", name->val);
+       if (scope->macro->exp) {
+               impl_val res = {0};
+               token_t typ = psi_num_exp_exec(scope->macro->exp, &res, NULL, scope->cpp);
+
+               switch (typ) {
+               CASE_IMPLVAL_NUM_PRINTF(smart_str_append_printf, &str, res);
+               default:
+                       assert(0);
+               }
+       } else while (psi_plist_get(scope->macro->tokens, i++, &tok)) {
+               if (tok->type == PSI_T_QUOTED_STRING) {
+                       smart_str_appendc(&str, '"');
+               }
+               smart_str_append(&str, tok->text);
+               if (tok->type == PSI_T_QUOTED_STRING) {
+                       smart_str_appendc(&str, '"');
+               }
+               smart_str_appendc(&str, ' ');
+       }
+       smart_str_appendl(&str, ";\n", 2);
+       return smart_str_extract(&str);
+}
+
 void psi_parser_postprocess(struct psi_parser *P)
 {
        unsigned flags;
@@ -149,64 +176,57 @@ void psi_parser_postprocess(struct psi_parser *P)
        struct psi_validate_scope scope = {0};
 
        psi_validate_scope_ctor(&scope);
-       scope.defs = &P->preproc->defs;
+       scope.cpp = P->preproc;
 
        flags = P->flags;
-       P->flags |= PSI_SILENT;
+       //P->flags |= PSI_SILENT;
 
-       /* register const macros */
        ZEND_HASH_FOREACH_STR_KEY_PTR(&P->preproc->defs, name, scope.macro)
        {
-               if (scope.macro->sig) {
-               } else if (scope.macro->exp) {
-                       if (psi_num_exp_validate(PSI_DATA(P), scope.macro->exp, &scope)) {
-                               struct psi_impl_type *type;
-                               struct psi_impl_def_val *def;
-                               struct psi_const *cnst;
-                               struct psi_num_exp *num;
-                               smart_str ns_name = {0};
-                               zend_string *name_str, *type_str;
+               bool parsed;
+               size_t processed = 0;
+               struct psi_plist *scanned, *preproc;
+               struct psi_parser_input *I;
+               zend_string *cnst;
 
-                               smart_str_appendl_ex(&ns_name, ZEND_STRL("psi\\"), 1);
-                               smart_str_append_ex(&ns_name, name, 1);
-                               name_str = smart_str_extract(&ns_name);
-                               type_str = zend_string_init_interned(ZEND_STRL("<eval number>"), 1);
+               if (scope.macro->sig) {
+                       continue;
+               } else if (!scope.macro->exp) {
+                       struct psi_token *tok;
+                       if (psi_plist_count(scope.macro->tokens) != 1) {
+                               continue;
+                       } else if (!psi_plist_get(scope.macro->tokens, 0, &tok)) {
+                               continue;
+                       } else if (tok->type != PSI_T_QUOTED_STRING) {
+                               continue;
+                       }
+               } else if (!psi_num_exp_validate(PSI_DATA(P), scope.macro->exp, &scope)) {
+                       continue;
+               }
 
-                               num = psi_num_exp_copy(scope.macro->exp);
-                               def = psi_impl_def_val_init(PSI_T_NUMBER, num);
-                               type = psi_impl_type_init(PSI_T_NUMBER, type_str);
-                               cnst = psi_const_init(type, name_str, def);
-                               P->consts = psi_plist_add(P->consts, &cnst);
-                               zend_string_release(name_str);
-                               zend_string_release(type_str);
-                       }
-               } else {
-                       if (psi_plist_count(scope.macro->tokens) == 1) {
-                               struct psi_token *t;
+               cnst = macro_to_constant(P, name, &scope);
+               if (!cnst) {
+                       continue;
+               }
 
-                               if (psi_plist_get(scope.macro->tokens, 0, &t)) {
-                                       if (t->type == PSI_T_QUOTED_STRING) {
-                                               struct psi_impl_type *type;
-                                               struct psi_impl_def_val *def;
-                                               struct psi_const *cnst;
-                                               smart_str ns_name = {0};
-                                               zend_string *name_str, *type_str;
+               I = psi_parser_open_string(P, ZSTR_VAL(cnst), ZSTR_LEN(cnst));
+               zend_string_release(cnst);
 
-                                               smart_str_appendl_ex(&ns_name, ZEND_STRL("psi\\"), 1);
-                                               smart_str_append_ex(&ns_name, name, 1);
-                                               name_str = smart_str_extract(&ns_name);
-                                               type_str = zend_string_init_interned(ZEND_STRL("string"), 1);
+               if (!(scanned = psi_parser_scan(P, I))) {
+                       psi_parser_input_free(&I);
+                       continue;
+               }
+               psi_parser_input_free(&I);
 
-                                               type = psi_impl_type_init(PSI_T_STRING, type_str);
-                                               def = psi_impl_def_val_init(PSI_T_QUOTED_STRING, t->text);
-                                               cnst = psi_const_init(type, name_str, def);
-                                               P->consts = psi_plist_add(P->consts, &cnst);
-                                               zend_string_release(name_str);
-                                               zend_string_release(type_str);
-                                       }
-                               }
-                       }
+               if (!(preproc = psi_parser_preprocess(P, &scanned))) {
+                       psi_plist_free(scanned);
+                       continue;
                }
+
+               parsed = psi_parser_process(P, preproc, &processed);
+               PSI_DEBUG_PRINT(PSI_DATA(P), "PSI: processed=%zu success=%d\n",
+                               processed, (int) parsed);
+               psi_plist_free(preproc);
        }
        ZEND_HASH_FOREACH_END();
 
@@ -257,9982 +277,3 @@ void psi_parser_free(struct psi_parser **P)
        }
 }
 
-#define NEWLINE() \
-       eol = cur; \
-       ++I->lines
-
-#define NEWTOKEN(t) \
-       if (t == PSI_T_COMMENT || t == PSI_T_WHITESPACE) { \
-               token = psi_token_init(t, "", 0, tok - eol + 1, I->lines, I->file); \
-       } else { \
-               token = psi_token_init(t, tok, cur - tok, tok - eol + 1, I->lines, I->file); \
-       } \
-       tokens = psi_plist_add(tokens, &token); \
-       if (P->flags & PSI_DEBUG) { \
-               fprintf(stderr, "PSI< "); \
-               psi_token_dump(2, token); \
-       }
-
-
-
-
-struct psi_plist *psi_parser_scan(struct psi_parser *P, struct psi_parser_input *I)
-{
-       struct psi_plist *tokens;
-       struct psi_token *token;
-       const char *tok, *cur, *lim, *mrk, *eol, *ctxmrk;
-       unsigned parens;
-       bool escaped;
-       token_t char_width;
-
-       PSI_DEBUG_PRINT(P, "PSI: scanning %s\n", I->file->val);
-
-       tok = mrk = eol = cur = I->buffer;
-       lim = I->buffer + I->length;
-       I->lines = 1;
-       tokens = psi_plist_init((psi_plist_dtor) psi_token_free);
-
-       start: ;
-               char_width = 1;
-               ctxmrk = NULL;
-               tok = cur;
-
-               (void) ctxmrk;
-
-               
-#line 304 "src/parser.c"
-               {
-                       unsigned char yych;
-                       unsigned int yyaccept = 0;
-                       if ((lim - cur) < 15) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\v':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case '@':
-                       case '`':
-                       case 0x7F:      goto yy2;
-                       case '\t':
-                       case '\f':
-                       case ' ':       goto yy4;
-                       case '\n':
-                       case '\r':      goto yy7;
-                       case '!':       goto yy9;
-                       case '"':       goto yy11;
-                       case '#':       goto yy13;
-                       case '$':       goto yy15;
-                       case '%':       goto yy16;
-                       case '&':       goto yy18;
-                       case '\'':      goto yy20;
-                       case '(':       goto yy22;
-                       case ')':       goto yy24;
-                       case '*':       goto yy26;
-                       case '+':       goto yy28;
-                       case ',':       goto yy30;
-                       case '-':       goto yy32;
-                       case '.':       goto yy34;
-                       case '/':       goto yy36;
-                       case '0':       goto yy38;
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':       goto yy40;
-                       case ':':       goto yy42;
-                       case ';':       goto yy44;
-                       case '<':       goto yy46;
-                       case '=':       goto yy48;
-                       case '>':       goto yy50;
-                       case '?':       goto yy52;
-                       case 'A':
-                       case 'a':       goto yy54;
-                       case 'B':       goto yy56;
-                       case 'C':       goto yy57;
-                       case 'D':       goto yy58;
-                       case 'E':       goto yy59;
-                       case 'F':       goto yy60;
-                       case 'I':       goto yy63;
-                       case 'L':       goto yy64;
-                       case 'M':
-                       case 'm':       goto yy65;
-                       case 'N':
-                       case 'n':       goto yy66;
-                       case 'O':
-                       case 'o':       goto yy67;
-                       case 'P':       goto yy68;
-                       case 'R':
-                       case 'r':       goto yy69;
-                       case 'S':       goto yy70;
-                       case 'T':       goto yy71;
-                       case 'U':       goto yy72;
-                       case 'W':
-                       case 'w':       goto yy73;
-                       case 'Z':
-                       case 'z':       goto yy74;
-                       case '[':       goto yy75;
-                       case '\\':      goto yy77;
-                       case ']':       goto yy79;
-                       case '^':       goto yy81;
-                       case '_':       goto yy83;
-                       case 'b':       goto yy84;
-                       case 'c':       goto yy85;
-                       case 'd':       goto yy86;
-                       case 'e':       goto yy87;
-                       case 'f':       goto yy88;
-                       case 'i':       goto yy89;
-                       case 'l':       goto yy90;
-                       case 'p':       goto yy91;
-                       case 's':       goto yy92;
-                       case 't':       goto yy93;
-                       case 'u':       goto yy94;
-                       case 'v':       goto yy95;
-                       case '{':       goto yy96;
-                       case '|':       goto yy98;
-                       case '}':       goto yy100;
-                       case '~':       goto yy102;
-                       default:        goto yy61;
-                       }
-yy2:
-                       ++cur;
-yy3:
-#line 469 "src/parser.re"
-                       { NEWTOKEN(-2); goto error; }
-#line 431 "src/parser.c"
-yy4:
-                       ++cur;
-                       if (lim <= cur) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case '\t':
-                       case '\f':
-                       case ' ':       goto yy4;
-                       default:        goto yy6;
-                       }
-yy6:
-#line 468 "src/parser.re"
-                       { NEWTOKEN(PSI_T_WHITESPACE); goto start; }
-#line 445 "src/parser.c"
-yy7:
-                       ++cur;
-#line 467 "src/parser.re"
-                       { NEWTOKEN(PSI_T_EOL); NEWLINE(); goto start; }
-#line 450 "src/parser.c"
-yy9:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '=':       goto yy104;
-                       default:        goto yy10;
-                       }
-yy10:
-#line 370 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NOT); goto start; }
-#line 460 "src/parser.c"
-yy11:
-                       ++cur;
-#line 343 "src/parser.re"
-                       { escaped = false; tok += 1; goto string; }
-#line 465 "src/parser.c"
-yy13:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '#':       goto yy106;
-                       default:        goto yy14;
-                       }
-yy14:
-#line 353 "src/parser.re"
-                       { NEWTOKEN(PSI_T_HASH); goto start; }
-#line 475 "src/parser.c"
-yy15:
-                       yych = *++cur;
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case '\\':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy3;
-                       default:        goto yy108;
-                       }
-yy16:
-                       ++cur;
-#line 371 "src/parser.re"
-                       { NEWTOKEN(PSI_T_MODULO); goto start; }
-#line 550 "src/parser.c"
-yy18:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '&':       goto yy111;
-                       default:        goto yy19;
-                       }
-yy19:
-#line 372 "src/parser.re"
-                       { NEWTOKEN(PSI_T_AMPERSAND); goto start; }
-#line 560 "src/parser.c"
-yy20:
-                       ++cur;
-#line 342 "src/parser.re"
-                       { escaped = false; tok += 1; goto character; }
-#line 565 "src/parser.c"
-yy22:
-                       ++cur;
-#line 354 "src/parser.re"
-                       { NEWTOKEN(PSI_T_LPAREN); goto start; }
-#line 570 "src/parser.c"
-yy24:
-                       ++cur;
-#line 355 "src/parser.re"
-                       { NEWTOKEN(PSI_T_RPAREN); goto start; }
-#line 575 "src/parser.c"
-yy26:
-                       ++cur;
-#line 368 "src/parser.re"
-                       { NEWTOKEN(PSI_T_ASTERISK); goto start; }
-#line 580 "src/parser.c"
-yy28:
-                       yyaccept = 0;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '.':       goto yy113;
-                       case '0':       goto yy38;
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':       goto yy40;
-                       default:        goto yy29;
-                       }
-yy29:
-#line 373 "src/parser.re"
-                       { NEWTOKEN(PSI_T_PLUS); goto start; }
-#line 601 "src/parser.c"
-yy30:
-                       ++cur;
-#line 357 "src/parser.re"
-                       { NEWTOKEN(PSI_T_COMMA); goto start; }
-#line 606 "src/parser.c"
-yy32:
-                       yyaccept = 1;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '.':       goto yy113;
-                       case '0':       goto yy38;
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':       goto yy40;
-                       default:        goto yy33;
-                       }
-yy33:
-#line 374 "src/parser.re"
-                       { NEWTOKEN(PSI_T_MINUS); goto start; }
-#line 627 "src/parser.c"
-yy34:
-                       yyaccept = 2;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '.':       goto yy115;
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':       goto yy116;
-                       default:        goto yy35;
-                       }
-yy35:
-#line 385 "src/parser.re"
-                       { NEWTOKEN(PSI_T_PERIOD); goto start; }
-#line 648 "src/parser.c"
-yy36:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '*':       goto yy119;
-                       case '/':       goto yy121;
-                       default:        goto yy37;
-                       }
-yy37:
-#line 375 "src/parser.re"
-                       { NEWTOKEN(PSI_T_SLASH); goto start; }
-#line 659 "src/parser.c"
-yy38:
-                       yyaccept = 3;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '.':       goto yy123;
-                       case 'E':
-                       case 'e':       goto yy127;
-                       case 'X':
-                       case 'x':       goto yy132;
-                       default:        goto yy126;
-                       }
-yy39:
-#line 329 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT; goto start; }
-#line 674 "src/parser.c"
-yy40:
-                       yyaccept = 3;
-                       mrk = ++cur;
-                       if ((lim - cur) < 3) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case '.':       goto yy123;
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':       goto yy40;
-                       case 'E':
-                       case 'e':       goto yy127;
-                       case 'L':
-                       case 'l':       goto yy128;
-                       case 'U':
-                       case 'u':       goto yy130;
-                       default:        goto yy39;
-                       }
-yy42:
-                       ++cur;
-#line 358 "src/parser.re"
-                       { NEWTOKEN(PSI_T_COLON); goto start; }
-#line 704 "src/parser.c"
-yy44:
-                       ++cur;
-#line 356 "src/parser.re"
-                       { NEWTOKEN(PSI_T_EOS); goto start; }
-#line 709 "src/parser.c"
-yy46:
-                       yyaccept = 4;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '-':
-                       case '.':
-                       case '/':
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':
-                       case 'A':
-                       case 'B':
-                       case 'C':
-                       case 'D':
-                       case 'E':
-                       case 'F':
-                       case 'G':
-                       case 'H':
-                       case 'I':
-                       case 'J':
-                       case 'K':
-                       case 'L':
-                       case 'M':
-                       case 'N':
-                       case 'O':
-                       case 'P':
-                       case 'Q':
-                       case 'R':
-                       case 'S':
-                       case 'T':
-                       case 'U':
-                       case 'V':
-                       case 'W':
-                       case 'X':
-                       case 'Y':
-                       case 'Z':
-                       case '_':
-                       case 'a':
-                       case 'b':
-                       case 'c':
-                       case 'd':
-                       case 'e':
-                       case 'f':
-                       case 'g':
-                       case 'h':
-                       case 'i':
-                       case 'j':
-                       case 'k':
-                       case 'l':
-                       case 'm':
-                       case 'n':
-                       case 'o':
-                       case 'p':
-                       case 'q':
-                       case 'r':
-                       case 's':
-                       case 't':
-                       case 'u':
-                       case 'v':
-                       case 'w':
-                       case 'x':
-                       case 'y':
-                       case 'z':       goto yy133;
-                       case '<':       goto yy135;
-                       case '=':       goto yy137;
-                       default:        goto yy47;
-                       }
-yy47:
-#line 383 "src/parser.re"
-                       { NEWTOKEN(PSI_T_LCHEVR); goto start; }
-#line 787 "src/parser.c"
-yy48:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '=':       goto yy139;
-                       default:        goto yy49;
-                       }
-yy49:
-#line 367 "src/parser.re"
-                       { NEWTOKEN(PSI_T_EQUALS); goto start; }
-#line 797 "src/parser.c"
-yy50:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '=':       goto yy141;
-                       case '>':       goto yy143;
-                       default:        goto yy51;
-                       }
-yy51:
-#line 384 "src/parser.re"
-                       { NEWTOKEN(PSI_T_RCHEVR); goto start; }
-#line 808 "src/parser.c"
-yy52:
-                       ++cur;
-#line 387 "src/parser.re"
-                       { NEWTOKEN(PSI_T_IIF); goto start; }
-#line 813 "src/parser.c"
-yy54:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'R':
-                       case 'r':       goto yy145;
-                       case 'S':
-                       case 's':       goto yy146;
-                       default:        goto yy62;
-                       }
-yy55:
-#line 462 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NAME); goto start; }
-#line 827 "src/parser.c"
-yy56:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'O':
-                       case 'o':       goto yy149;
-                       default:        goto yy62;
-                       }
-yy57:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy150;
-                       case 'O':
-                       case 'o':       goto yy151;
-                       default:        goto yy62;
-                       }
-yy58:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy152;
-                       default:        goto yy62;
-                       }
-yy59:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy153;
-                       case 'N':
-                       case 'n':       goto yy154;
-                       case 'R':
-                       case 'r':       goto yy155;
-                       default:        goto yy62;
-                       }
-yy60:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy156;
-                       case 'L':
-                       case 'l':       goto yy157;
-                       case 'R':
-                       case 'r':       goto yy158;
-                       case 'U':
-                       case 'u':       goto yy159;
-                       default:        goto yy62;
-                       }
-yy61:
-                       yyaccept = 5;
-                       mrk = ++cur;
-                       if (lim <= cur) if (cur >= lim) goto done;;
-                       yych = *cur;
-yy62:
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy55;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy63:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'F':
-                       case 'f':       goto yy160;
-                       case 'N':
-                       case 'n':       goto yy162;
-                       default:        goto yy62;
-                       }
-yy64:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '"':
-                       case '\'':      goto yy163;
-                       case 'E':
-                       case 'e':       goto yy165;
-                       case 'I':
-                       case 'i':       goto yy166;
-                       default:        goto yy62;
-                       }
-yy65:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'I':
-                       case 'i':       goto yy167;
-                       default:        goto yy62;
-                       }
-yy66:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'U':
-                       case 'u':       goto yy168;
-                       default:        goto yy62;
-                       }
-yy67:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'B':
-                       case 'b':       goto yy169;
-                       default:        goto yy62;
-                       }
-yy68:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy170;
-                       case 'O':
-                       case 'o':       goto yy171;
-                       case 'R':
-                       case 'r':       goto yy172;
-                       default:        goto yy62;
-                       }
-yy69:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy173;
-                       default:        goto yy62;
-                       }
-yy70:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy174;
-                       case 'T':
-                       case 't':       goto yy175;
-                       default:        goto yy62;
-                       }
-yy71:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy176;
-                       case 'O':
-                       case 'o':       goto yy177;
-                       case 'R':
-                       case 'r':       goto yy178;
-                       default:        goto yy62;
-                       }
-yy72:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '"':
-                       case '\'':      goto yy179;
-                       case 'N':
-                       case 'n':       goto yy181;
-                       default:        goto yy62;
-                       }
-yy73:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy182;
-                       default:        goto yy62;
-                       }
-yy74:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'V':
-                       case 'v':       goto yy183;
-                       default:        goto yy62;
-                       }
-yy75:
-                       ++cur;
-#line 361 "src/parser.re"
-                       { NEWTOKEN(PSI_T_LBRACKET); goto start; }
-#line 1072 "src/parser.c"
-yy77:
-                       yych = *++cur;
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case '\\':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy78;
-                       default:        goto yy184;
-                       }
-yy78:
-#line 376 "src/parser.re"
-                       { NEWTOKEN(PSI_T_BSLASH); goto start; }
-#line 1156 "src/parser.c"
-yy79:
-                       ++cur;
-#line 362 "src/parser.re"
-                       { NEWTOKEN(PSI_T_RBRACKET); goto start; }
-#line 1161 "src/parser.c"
-yy81:
-                       ++cur;
-#line 378 "src/parser.re"
-                       { NEWTOKEN(PSI_T_CARET); goto start; }
-#line 1166 "src/parser.c"
-yy83:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '_':       goto yy187;
-                       default:        goto yy62;
-                       }
-yy84:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'O':       goto yy149;
-                       case 'o':       goto yy188;
-                       default:        goto yy62;
-                       }
-yy85:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy150;
-                       case 'O':       goto yy151;
-                       case 'h':       goto yy189;
-                       case 'o':       goto yy190;
-                       default:        goto yy62;
-                       }
-yy86:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy152;
-                       case 'o':       goto yy191;
-                       default:        goto yy62;
-                       }
-yy87:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy153;
-                       case 'N':       goto yy154;
-                       case 'R':
-                       case 'r':       goto yy155;
-                       case 'n':       goto yy192;
-                       default:        goto yy62;
-                       }
-yy88:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy156;
-                       case 'L':       goto yy157;
-                       case 'R':
-                       case 'r':       goto yy158;
-                       case 'U':
-                       case 'u':       goto yy159;
-                       case 'l':       goto yy193;
-                       default:        goto yy62;
-                       }
-yy89:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'F':
-                       case 'f':       goto yy160;
-                       case 'N':       goto yy162;
-                       case 'n':       goto yy194;
-                       default:        goto yy62;
-                       }
-yy90:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy165;
-                       case 'I':       goto yy166;
-                       case 'i':       goto yy195;
-                       case 'o':       goto yy196;
-                       default:        goto yy62;
-                       }
-yy91:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy170;
-                       case 'O':
-                       case 'o':       goto yy171;
-                       case 'R':       goto yy172;
-                       case 'r':       goto yy197;
-                       default:        goto yy62;
-                       }
-yy92:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy174;
-                       case 'T':       goto yy175;
-                       case 'h':       goto yy198;
-                       case 'i':       goto yy199;
-                       case 't':       goto yy200;
-                       default:        goto yy62;
-                       }
-yy93:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy176;
-                       case 'O':
-                       case 'o':       goto yy177;
-                       case 'R':
-                       case 'r':       goto yy178;
-                       case 'y':       goto yy201;
-                       default:        goto yy62;
-                       }
-yy94:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '"':
-                       case '\'':      goto yy202;
-                       case '8':       goto yy204;
-                       case 'N':       goto yy181;
-                       case 'n':       goto yy205;
-                       default:        goto yy62;
-                       }
-yy95:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'o':       goto yy206;
-                       default:        goto yy62;
-                       }
-yy96:
-                       ++cur;
-#line 359 "src/parser.re"
-                       { NEWTOKEN(PSI_T_LBRACE); goto start; }
-#line 1308 "src/parser.c"
-yy98:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '|':       goto yy207;
-                       default:        goto yy99;
-                       }
-yy99:
-#line 377 "src/parser.re"
-                       { NEWTOKEN(PSI_T_PIPE); goto start; }
-#line 1318 "src/parser.c"
-yy100:
-                       ++cur;
-#line 360 "src/parser.re"
-                       { NEWTOKEN(PSI_T_RBRACE); goto start; }
-#line 1323 "src/parser.c"
-yy102:
-                       ++cur;
-#line 369 "src/parser.re"
-                       { NEWTOKEN(PSI_T_TILDE); goto start; }
-#line 1328 "src/parser.c"
-yy104:
-                       ++cur;
-#line 363 "src/parser.re"
-                       { NEWTOKEN(PSI_T_CMP_NE); goto start; }
-#line 1333 "src/parser.c"
-yy106:
-                       ++cur;
-#line 352 "src/parser.re"
-                       { NEWTOKEN(PSI_T_CPP_PASTE); goto start; }
-#line 1338 "src/parser.c"
-yy108:
-                       ++cur;
-                       if (lim <= cur) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case '\\':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy110;
-                       default:        goto yy108;
-                       }
-yy110:
-#line 464 "src/parser.re"
-                       { NEWTOKEN(PSI_T_DOLLAR_NAME); goto start; }
-#line 1414 "src/parser.c"
-yy111:
-                       ++cur;
-#line 365 "src/parser.re"
-                       { NEWTOKEN(PSI_T_AND); goto start; }
-#line 1419 "src/parser.c"
-yy113:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':       goto yy116;
-                       default:        goto yy114;
-                       }
-yy114:
-                       cur = mrk;
-                       switch (yyaccept) {
-                       case 0:         goto yy29;
-                       case 1:         goto yy33;
-                       case 2:         goto yy35;
-                       case 3:         goto yy39;
-                       case 4:         goto yy47;
-                       case 5:         goto yy55;
-                       case 6:         goto yy118;
-                       case 7:         goto yy129;
-                       case 8:         goto yy147;
-                       case 9:         goto yy161;
-                       case 10:        goto yy186;
-                       case 11:        goto yy242;
-                       case 12:        goto yy244;
-                       case 13:        goto yy253;
-                       case 14:        goto yy273;
-                       case 15:        goto yy305;
-                       case 16:        goto yy307;
-                       case 17:        goto yy313;
-                       case 18:        goto yy321;
-                       case 19:        goto yy333;
-                       case 20:        goto yy341;
-                       case 21:        goto yy345;
-                       case 22:        goto yy352;
-                       case 23:        goto yy354;
-                       case 24:        goto yy358;
-                       case 25:        goto yy361;
-                       case 26:        goto yy363;
-                       case 27:        goto yy373;
-                       case 28:        goto yy376;
-                       case 29:        goto yy383;
-                       case 30:        goto yy386;
-                       case 31:        goto yy388;
-                       case 32:        goto yy390;
-                       case 33:        goto yy394;
-                       case 34:        goto yy399;
-                       case 35:        goto yy417;
-                       case 36:        goto yy425;
-                       case 37:        goto yy428;
-                       case 38:        goto yy431;
-                       case 39:        goto yy437;
-                       case 40:        goto yy441;
-                       case 41:        goto yy446;
-                       case 42:        goto yy448;
-                       case 43:        goto yy452;
-                       case 44:        goto yy455;
-                       case 45:        goto yy457;
-                       case 46:        goto yy459;
-                       case 47:        goto yy464;
-                       case 48:        goto yy466;
-                       case 49:        goto yy468;
-                       case 50:        goto yy470;
-                       case 51:        goto yy472;
-                       case 52:        goto yy477;
-                       case 53:        goto yy487;
-                       case 54:        goto yy489;
-                       case 55:        goto yy491;
-                       case 56:        goto yy493;
-                       case 57:        goto yy495;
-                       case 58:        goto yy500;
-                       case 59:        goto yy504;
-                       case 60:        goto yy508;
-                       case 61:        goto yy510;
-                       case 62:        goto yy515;
-                       case 63:        goto yy520;
-                       case 64:        goto yy522;
-                       case 65:        goto yy530;
-                       case 66:        goto yy534;
-                       case 67:        goto yy536;
-                       case 68:        goto yy538;
-                       case 69:        goto yy540;
-                       case 70:        goto yy545;
-                       case 71:        goto yy547;
-                       case 72:        goto yy553;
-                       case 73:        goto yy558;
-                       case 74:        goto yy560;
-                       case 75:        goto yy565;
-                       case 76:        goto yy567;
-                       case 77:        goto yy575;
-                       case 78:        goto yy579;
-                       case 79:        goto yy583;
-                       case 80:        goto yy587;
-                       case 81:        goto yy589;
-                       default:        goto yy594;
-                       }
-yy115:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '.':       goto yy209;
-                       default:        goto yy114;
-                       }
-yy116:
-                       yyaccept = 6;
-                       mrk = ++cur;
-                       if ((lim - cur) < 2) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':       goto yy116;
-                       case 'D':
-                       case 'd':       goto yy211;
-                       case 'F':
-                       case 'f':       goto yy212;
-                       case 'L':
-                       case 'l':       goto yy214;
-                       default:        goto yy118;
-                       }
-yy118:
-#line 335 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT; goto start; }
-#line 1555 "src/parser.c"
-yy119:
-                       ++cur;
-#line 349 "src/parser.re"
-                       { goto comment; }
-#line 1560 "src/parser.c"
-yy121:
-                       ++cur;
-#line 350 "src/parser.re"
-                       { goto comment_sl; }
-#line 1565 "src/parser.c"
-yy123:
-                       yyaccept = 6;
-                       mrk = ++cur;
-                       if ((lim - cur) < 3) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':       goto yy123;
-                       case 'D':
-                       case 'd':       goto yy211;
-                       case 'E':
-                       case 'e':       goto yy127;
-                       case 'F':
-                       case 'f':       goto yy212;
-                       case 'L':
-                       case 'l':       goto yy214;
-                       default:        goto yy118;
-                       }
-yy125:
-                       ++cur;
-                       if ((lim - cur) < 3) if (cur >= lim) goto done;;
-                       yych = *cur;
-yy126:
-                       switch (yych) {
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':       goto yy125;
-                       case 'L':
-                       case 'l':       goto yy128;
-                       case 'U':
-                       case 'u':       goto yy130;
-                       default:        goto yy39;
-                       }
-yy127:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '+':
-                       case '-':       goto yy113;
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':       goto yy116;
-                       default:        goto yy114;
-                       }
-yy128:
-                       yyaccept = 7;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy216;
-                       case 'U':
-                       case 'u':       goto yy217;
-                       default:        goto yy129;
-                       }
-yy129:
-                       cur -= 1;
-#line 331 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_L; cur += 1; goto start; }
-#line 1643 "src/parser.c"
-yy130:
-                       yych = *++cur;
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy219;
-                       default:        goto yy131;
-                       }
-yy131:
-                       cur -= 1;
-#line 330 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_U; cur += 1; goto start; }
-#line 1655 "src/parser.c"
-yy132:
-                       yych = *++cur;
-                       switch (yych) {
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':
-                       case 'A':
-                       case 'B':
-                       case 'C':
-                       case 'D':
-                       case 'E':
-                       case 'F':
-                       case 'a':
-                       case 'b':
-                       case 'c':
-                       case 'd':
-                       case 'e':
-                       case 'f':       goto yy220;
-                       default:        goto yy114;
-                       }
-yy133:
-                       ++cur;
-                       if (lim <= cur) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case '-':
-                       case '.':
-                       case '/':
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':
-                       case 'A':
-                       case 'B':
-                       case 'C':
-                       case 'D':
-                       case 'E':
-                       case 'F':
-                       case 'G':
-                       case 'H':
-                       case 'I':
-                       case 'J':
-                       case 'K':
-                       case 'L':
-                       case 'M':
-                       case 'N':
-                       case 'O':
-                       case 'P':
-                       case 'Q':
-                       case 'R':
-                       case 'S':
-                       case 'T':
-                       case 'U':
-                       case 'V':
-                       case 'W':
-                       case 'X':
-                       case 'Y':
-                       case 'Z':
-                       case '_':
-                       case 'a':
-                       case 'b':
-                       case 'c':
-                       case 'd':
-                       case 'e':
-                       case 'f':
-                       case 'g':
-                       case 'h':
-                       case 'i':
-                       case 'j':
-                       case 'k':
-                       case 'l':
-                       case 'm':
-                       case 'n':
-                       case 'o':
-                       case 'p':
-                       case 'q':
-                       case 'r':
-                       case 's':
-                       case 't':
-                       case 'u':
-                       case 'v':
-                       case 'w':
-                       case 'x':
-                       case 'y':
-                       case 'z':       goto yy133;
-                       case '>':       goto yy222;
-                       default:        goto yy114;
-                       }
-yy135:
-                       ++cur;
-#line 379 "src/parser.re"
-                       { NEWTOKEN(PSI_T_LSHIFT); goto start; }
-#line 1761 "src/parser.c"
-yy137:
-                       ++cur;
-#line 381 "src/parser.re"
-                       { NEWTOKEN(PSI_T_CMP_LE); goto start; }
-#line 1766 "src/parser.c"
-yy139:
-                       ++cur;
-#line 364 "src/parser.re"
-                       { NEWTOKEN(PSI_T_CMP_EQ); goto start; }
-#line 1771 "src/parser.c"
-yy141:
-                       ++cur;
-#line 382 "src/parser.re"
-                       { NEWTOKEN(PSI_T_CMP_GE); goto start; }
-#line 1776 "src/parser.c"
-yy143:
-                       ++cur;
-#line 380 "src/parser.re"
-                       { NEWTOKEN(PSI_T_RSHIFT); goto start; }
-#line 1781 "src/parser.c"
-yy145:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'R':
-                       case 'r':       goto yy224;
-                       default:        goto yy62;
-                       }
-yy146:
-                       yyaccept = 8;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy147;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy147:
-#line 442 "src/parser.re"
-                       { NEWTOKEN(PSI_T_AS); goto start; }
-#line 1864 "src/parser.c"
-yy148:
-                       ++cur;
-                       if (lim <= cur) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case '\\':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy114;
-                       default:        goto yy184;
-                       }
-yy149:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'O':
-                       case 'o':       goto yy225;
-                       default:        goto yy62;
-                       }
-yy150:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy226;
-                       default:        goto yy62;
-                       }
-yy151:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'U':
-                       case 'u':       goto yy227;
-                       default:        goto yy62;
-                       }
-yy152:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'F':
-                       case 'f':       goto yy228;
-                       default:        goto yy62;
-                       }
-yy153:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'I':
-                       case 'i':       goto yy229;
-                       case 'S':
-                       case 's':       goto yy230;
-                       default:        goto yy62;
-                       }
-yy154:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'D':
-                       case 'd':       goto yy231;
-                       default:        goto yy62;
-                       }
-yy155:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'R':
-                       case 'r':       goto yy232;
-                       default:        goto yy62;
-                       }
-yy156:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy233;
-                       default:        goto yy62;
-                       }
-yy157:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'O':
-                       case 'o':       goto yy234;
-                       default:        goto yy62;
-                       }
-yy158:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy235;
-                       default:        goto yy62;
-                       }
-yy159:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'N':
-                       case 'n':       goto yy236;
-                       default:        goto yy62;
-                       }
-yy160:
-                       yyaccept = 9;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy161;
-                       case 'D':
-                       case 'd':       goto yy237;
-                       case 'N':
-                       case 'n':       goto yy238;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy161:
-#line 412 "src/parser.re"
-                       { NEWTOKEN(PSI_T_IF); goto start; }
-#line 2115 "src/parser.c"
-yy162:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'C':
-                       case 'c':       goto yy239;
-                       case 'T':
-                       case 't':       goto yy240;
-                       default:        goto yy62;
-                       }
-yy163:
-                       ++cur;
-                       cur -= 1;
-#line 347 "src/parser.re"
-                       { char_width = sizeof(wchar_t)/8; }
-#line 2131 "src/parser.c"
-yy165:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'T':
-                       case 't':       goto yy241;
-                       default:        goto yy62;
-                       }
-yy166:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'B':
-                       case 'b':       goto yy243;
-                       default:        goto yy62;
-                       }
-yy167:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'X':
-                       case 'x':       goto yy245;
-                       default:        goto yy62;
-                       }
-yy168:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy246;
-                       default:        goto yy62;
-                       }
-yy169:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'J':
-                       case 'j':       goto yy247;
-                       default:        goto yy62;
-                       }
-yy170:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'T':
-                       case 't':       goto yy248;
-                       default:        goto yy62;
-                       }
-yy171:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'S':
-                       case 's':       goto yy249;
-                       default:        goto yy62;
-                       }
-yy172:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy250;
-                       default:        goto yy62;
-                       }
-yy173:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'T':
-                       case 't':       goto yy251;
-                       default:        goto yy62;
-                       }
-yy174:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'T':
-                       case 't':       goto yy252;
-                       default:        goto yy62;
-                       }
-yy175:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy254;
-                       case 'R':
-                       case 'r':       goto yy255;
-                       default:        goto yy62;
-                       }
-yy176:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'M':
-                       case 'm':       goto yy256;
-                       default:        goto yy62;
-                       }
-yy177:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '_':       goto yy257;
-                       default:        goto yy62;
-                       }
-yy178:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'U':
-                       case 'u':       goto yy258;
-                       default:        goto yy62;
-                       }
-yy179:
-                       ++cur;
-                       cur -= 1;
-#line 346 "src/parser.re"
-                       { char_width = 4; }
-#line 2250 "src/parser.c"
-yy181:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'D':
-                       case 'd':       goto yy259;
-                       default:        goto yy62;
-                       }
-yy182:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'R':
-                       case 'r':       goto yy260;
-                       default:        goto yy62;
-                       }
-yy183:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy261;
-                       default:        goto yy62;
-                       }
-yy184:
-                       yyaccept = 10;
-                       mrk = ++cur;
-                       if (lim <= cur) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy186;
-                       case '\\':      goto yy148;
-                       default:        goto yy184;
-                       }
-yy186:
-#line 463 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NSNAME); goto start; }
-#line 2351 "src/parser.c"
-yy187:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'a':       goto yy262;
-                       case 'e':       goto yy263;
-                       case 'i':       goto yy264;
-                       case 'r':       goto yy265;
-                       default:        goto yy62;
-                       }
-yy188:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'O':       goto yy225;
-                       case 'o':       goto yy266;
-                       default:        goto yy62;
-                       }
-yy189:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'a':       goto yy267;
-                       default:        goto yy62;
-                       }
-yy190:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'U':
-                       case 'u':       goto yy227;
-                       case 'n':       goto yy268;
-                       default:        goto yy62;
-                       }
-yy191:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'u':       goto yy269;
-                       default:        goto yy62;
-                       }
-yy192:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'D':
-                       case 'd':       goto yy231;
-                       case 'u':       goto yy270;
-                       default:        goto yy62;
-                       }
-yy193:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'O':       goto yy234;
-                       case 'o':       goto yy271;
-                       default:        goto yy62;
-                       }
-yy194:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'C':
-                       case 'c':       goto yy239;
-                       case 'T':       goto yy240;
-                       case 't':       goto yy272;
-                       default:        goto yy62;
-                       }
-yy195:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'B':
-                       case 'b':       goto yy243;
-                       case 'n':       goto yy274;
-                       default:        goto yy62;
-                       }
-yy196:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'n':       goto yy275;
-                       default:        goto yy62;
-                       }
-yy197:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy250;
-                       case 'a':       goto yy276;
-                       default:        goto yy62;
-                       }
-yy198:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'o':       goto yy277;
-                       default:        goto yy62;
-                       }
-yy199:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'g':       goto yy278;
-                       case 'z':       goto yy279;
-                       default:        goto yy62;
-                       }
-yy200:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy254;
-                       case 'R':       goto yy255;
-                       case 'r':       goto yy280;
-                       default:        goto yy62;
-                       }
-yy201:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'p':       goto yy281;
-                       default:        goto yy62;
-                       }
-yy202:
-                       ++cur;
-                       cur -= 1;
-#line 345 "src/parser.re"
-                       { char_width = 2; }
-#line 2482 "src/parser.c"
-yy204:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '"':       goto yy282;
-                       default:        goto yy62;
-                       }
-yy205:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'D':
-                       case 'd':       goto yy259;
-                       case 'i':       goto yy284;
-                       case 's':       goto yy285;
-                       default:        goto yy62;
-                       }
-yy206:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'i':       goto yy286;
-                       case 'l':       goto yy287;
-                       default:        goto yy62;
-                       }
-yy207:
-                       ++cur;
-#line 366 "src/parser.re"
-                       { NEWTOKEN(PSI_T_OR); goto start; }
-#line 2512 "src/parser.c"
-yy209:
-                       ++cur;
-#line 386 "src/parser.re"
-                       { NEWTOKEN(PSI_T_ELLIPSIS); goto start; }
-#line 2517 "src/parser.c"
-yy211:
-                       yych = *++cur;
-                       switch (yych) {
-                       case 'D':
-                       case 'd':       goto yy288;
-                       case 'F':
-                       case 'f':       goto yy290;
-                       case 'L':
-                       case 'l':       goto yy292;
-                       default:        goto yy114;
-                       }
-yy212:
-                       ++cur;
-                       cur -= 1;
-#line 336 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_F; cur += 1; goto start; }
-#line 2534 "src/parser.c"
-yy214:
-                       ++cur;
-                       cur -= 1;
-#line 337 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_L; cur += 1; goto start; }
-#line 2540 "src/parser.c"
-yy216:
-                       yych = *++cur;
-                       switch (yych) {
-                       case 'U':
-                       case 'u':       goto yy294;
-                       default:        goto yy114;
-                       }
-yy217:
-                       ++cur;
-yy218:
-                       cur -= 2;
-#line 332 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_UL; cur += 2; goto start; }
-#line 2554 "src/parser.c"
-yy219:
-                       yych = *++cur;
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy294;
-                       default:        goto yy218;
-                       }
-yy220:
-                       yyaccept = 3;
-                       mrk = ++cur;
-                       if ((lim - cur) < 3) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case '.':       goto yy296;
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':
-                       case 'A':
-                       case 'B':
-                       case 'C':
-                       case 'D':
-                       case 'E':
-                       case 'F':
-                       case 'a':
-                       case 'b':
-                       case 'c':
-                       case 'd':
-                       case 'e':
-                       case 'f':       goto yy220;
-                       case 'L':
-                       case 'l':       goto yy128;
-                       case 'P':
-                       case 'p':       goto yy127;
-                       case 'U':
-                       case 'u':       goto yy130;
-                       default:        goto yy39;
-                       }
-yy222:
-                       ++cur;
-#line 465 "src/parser.re"
-                       { tok += 1; cur -= 1; NEWTOKEN(PSI_T_CPP_HEADER); cur += 1; goto start; }
-#line 2603 "src/parser.c"
-yy224:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy298;
-                       case 'V':
-                       case 'v':       goto yy299;
-                       default:        goto yy62;
-                       }
-yy225:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy300;
-                       default:        goto yy62;
-                       }
-yy226:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy301;
-                       default:        goto yy62;
-                       }
-yy227:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'N':
-                       case 'n':       goto yy302;
-                       default:        goto yy62;
-                       }
-yy228:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'I':
-                       case 'i':       goto yy303;
-                       default:        goto yy62;
-                       }
-yy229:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'F':
-                       case 'f':       goto yy304;
-                       default:        goto yy62;
-                       }
-yy230:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy306;
-                       default:        goto yy62;
-                       }
-yy231:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'I':
-                       case 'i':       goto yy308;
-                       default:        goto yy62;
-                       }
-yy232:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'O':
-                       case 'o':       goto yy309;
-                       default:        goto yy62;
-                       }
-yy233:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'S':
-                       case 's':       goto yy310;
-                       default:        goto yy62;
-                       }
-yy234:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy311;
-                       default:        goto yy62;
-                       }
-yy235:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy312;
-                       default:        goto yy62;
-                       }
-yy236:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'C':
-                       case 'c':       goto yy314;
-                       default:        goto yy62;
-                       }
-yy237:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy315;
-                       default:        goto yy62;
-                       }
-yy238:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'D':
-                       case 'd':       goto yy316;
-                       default:        goto yy62;
-                       }
-yy239:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy317;
-                       default:        goto yy62;
-                       }
-yy240:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'V':
-                       case 'v':       goto yy318;
-                       default:        goto yy62;
-                       }
-yy241:
-                       yyaccept = 11;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy242;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy242:
-#line 437 "src/parser.re"
-                       { NEWTOKEN(PSI_T_LET); goto start; }
-#line 2816 "src/parser.c"
-yy243:
-                       yyaccept = 12;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy244;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy244:
-#line 436 "src/parser.re"
-                       { NEWTOKEN(PSI_T_LIB); goto start; }
-#line 2891 "src/parser.c"
-yy245:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy319;
-                       default:        goto yy62;
-                       }
-yy246:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy320;
-                       default:        goto yy62;
-                       }
-yy247:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy322;
-                       case 'V':
-                       case 'v':       goto yy323;
-                       default:        goto yy62;
-                       }
-yy248:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'H':
-                       case 'h':       goto yy324;
-                       default:        goto yy62;
-                       }
-yy249:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'T':
-                       case 't':       goto yy325;
-                       default:        goto yy62;
-                       }
-yy250:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '_':       goto yy326;
-                       default:        goto yy62;
-                       }
-yy251:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'U':
-                       case 'u':       goto yy327;
-                       default:        goto yy62;
-                       }
-yy252:
-                       yyaccept = 13;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy253;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy253:
-#line 438 "src/parser.re"
-                       { NEWTOKEN(PSI_T_SET); goto start; }
-#line 3023 "src/parser.c"
-yy254:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'T':
-                       case 't':       goto yy328;
-                       default:        goto yy62;
-                       }
-yy255:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'I':
-                       case 'i':       goto yy329;
-                       case 'L':
-                       case 'l':       goto yy330;
-                       case 'V':
-                       case 'v':       goto yy331;
-                       default:        goto yy62;
-                       }
-yy256:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'P':
-                       case 'p':       goto yy332;
-                       default:        goto yy62;
-                       }
-yy257:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy334;
-                       case 'B':
-                       case 'b':       goto yy335;
-                       case 'F':
-                       case 'f':       goto yy336;
-                       case 'I':
-                       case 'i':       goto yy337;
-                       case 'O':
-                       case 'o':       goto yy338;
-                       case 'S':
-                       case 's':       goto yy339;
-                       default:        goto yy62;
-                       }
-yy258:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy340;
-                       default:        goto yy62;
-                       }
-yy259:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy342;
-                       default:        goto yy62;
-                       }
-yy260:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'N':
-                       case 'n':       goto yy343;
-                       default:        goto yy62;
-                       }
-yy261:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy344;
-                       default:        goto yy62;
-                       }
-yy262:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 's':       goto yy346;
-                       case 't':       goto yy347;
-                       default:        goto yy62;
-                       }
-yy263:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'x':       goto yy348;
-                       default:        goto yy62;
-                       }
-yy264:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'n':       goto yy349;
-                       default:        goto yy62;
-                       }
-yy265:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'e':       goto yy350;
-                       default:        goto yy62;
-                       }
-yy266:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':       goto yy300;
-                       case 'l':       goto yy351;
-                       default:        goto yy62;
-                       }
-yy267:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'r':       goto yy353;
-                       default:        goto yy62;
-                       }
-yy268:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 's':       goto yy355;
-                       default:        goto yy62;
-                       }
-yy269:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'b':       goto yy356;
-                       default:        goto yy62;
-                       }
-yy270:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'm':       goto yy357;
-                       default:        goto yy62;
-                       }
-yy271:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':       goto yy311;
-                       case 'a':       goto yy359;
-                       default:        goto yy62;
-                       }
-yy272:
-                       yyaccept = 14;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy273;
-                       case 'V':
-                       case 'v':       goto yy318;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy273:
-#line 406 "src/parser.re"
-                       { NEWTOKEN(PSI_T_INT); goto start; }
-#line 3251 "src/parser.c"
-yy274:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'e':       goto yy360;
-                       default:        goto yy62;
-                       }
-yy275:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'g':       goto yy362;
-                       default:        goto yy62;
-                       }
-yy276:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'g':       goto yy364;
-                       default:        goto yy62;
-                       }
-yy277:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'r':       goto yy365;
-                       default:        goto yy62;
-                       }
-yy278:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'n':       goto yy366;
-                       default:        goto yy62;
-                       }
-yy279:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'e':       goto yy367;
-                       default:        goto yy62;
-                       }
-yy280:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'I':
-                       case 'i':       goto yy329;
-                       case 'L':
-                       case 'l':       goto yy330;
-                       case 'V':
-                       case 'v':       goto yy331;
-                       case 'u':       goto yy368;
-                       default:        goto yy62;
-                       }
-yy281:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'e':       goto yy369;
-                       default:        goto yy62;
-                       }
-yy282:
-                       ++cur;
-                       cur -= 1;
-#line 344 "src/parser.re"
-                       { char_width = 1; }
-#line 3319 "src/parser.c"
-yy284:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'o':       goto yy370;
-                       default:        goto yy62;
-                       }
-yy285:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'i':       goto yy371;
-                       default:        goto yy62;
-                       }
-yy286:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'd':       goto yy372;
-                       default:        goto yy62;
-                       }
-yy287:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'a':       goto yy374;
-                       default:        goto yy62;
-                       }
-yy288:
-                       ++cur;
-                       cur -= 2;
-#line 339 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_DD; cur += 2; goto start; }
-#line 3353 "src/parser.c"
-yy290:
-                       ++cur;
-                       cur -= 2;
-#line 338 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_DF; cur += 2; goto start; }
-#line 3359 "src/parser.c"
-yy292:
-                       ++cur;
-                       cur -= 2;
-#line 340 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_DL; cur += 2; goto start; }
-#line 3365 "src/parser.c"
-yy294:
-                       ++cur;
-                       cur -= 3;
-#line 333 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_ULL; cur += 3; goto start; }
-#line 3371 "src/parser.c"
-yy296:
-                       ++cur;
-                       if ((lim - cur) < 3) if (cur >= lim) goto done;;
-                       yych = *cur;
-                       switch (yych) {
-                       case '0':
-                       case '1':
-                       case '2':
-                       case '3':
-                       case '4':
-                       case '5':
-                       case '6':
-                       case '7':
-                       case '8':
-                       case '9':
-                       case 'A':
-                       case 'B':
-                       case 'C':
-                       case 'D':
-                       case 'E':
-                       case 'F':
-                       case 'a':
-                       case 'b':
-                       case 'c':
-                       case 'd':
-                       case 'e':
-                       case 'f':       goto yy296;
-                       case 'P':
-                       case 'p':       goto yy127;
-                       default:        goto yy114;
-                       }
-yy298:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'Y':
-                       case 'y':       goto yy375;
-                       default:        goto yy62;
-                       }
-yy299:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy377;
-                       default:        goto yy62;
-                       }
-yy300:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'V':
-                       case 'v':       goto yy378;
-                       default:        goto yy62;
-                       }
-yy301:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy379;
-                       case 'B':
-                       case 'b':       goto yy380;
-                       case 'O':
-                       case 'o':       goto yy381;
-                       default:        goto yy62;
-                       }
-yy302:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'T':
-                       case 't':       goto yy382;
-                       default:        goto yy62;
-                       }
-yy303:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'N':
-                       case 'n':       goto yy384;
-                       default:        goto yy62;
-                       }
-yy304:
-                       yyaccept = 15;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy305;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy305:
-#line 416 "src/parser.re"
-                       { NEWTOKEN(PSI_T_ELIF); goto start; }
-#line 3529 "src/parser.c"
-yy306:
-                       yyaccept = 16;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy307;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy307:
-#line 415 "src/parser.re"
-                       { NEWTOKEN(PSI_T_ELSE); goto start; }
-#line 3604 "src/parser.c"
-yy308:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'F':
-                       case 'f':       goto yy385;
-                       default:        goto yy62;
-                       }
-yy309:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'R':
-                       case 'r':       goto yy387;
-                       default:        goto yy62;
-                       }
-yy310:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy389;
-                       default:        goto yy62;
-                       }
-yy311:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'T':
-                       case 't':       goto yy391;
-                       default:        goto yy62;
-                       }
-yy312:
-                       yyaccept = 17;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy313;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy313:
-#line 443 "src/parser.re"
-                       { NEWTOKEN(PSI_T_FREE); goto start; }
-#line 3711 "src/parser.c"
-yy314:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'T':
-                       case 't':       goto yy392;
-                       default:        goto yy62;
-                       }
-yy315:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'F':
-                       case 'f':       goto yy393;
-                       default:        goto yy62;
-                       }
-yy316:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy395;
-                       default:        goto yy62;
-                       }
-yy317:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'U':
-                       case 'u':       goto yy396;
-                       default:        goto yy62;
-                       }
-yy318:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy397;
-                       default:        goto yy62;
-                       }
-yy319:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'D':
-                       case 'd':       goto yy398;
-                       default:        goto yy62;
-                       }
-yy320:
-                       yyaccept = 18;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy321;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy321:
-#line 427 "src/parser.re"
-                       { NEWTOKEN(PSI_T_NULL); goto start; }
-#line 3834 "src/parser.c"
-yy322:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'C':
-                       case 'c':       goto yy400;
-                       default:        goto yy62;
-                       }
-yy323:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy401;
-                       default:        goto yy62;
-                       }
-yy324:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'V':
-                       case 'v':       goto yy402;
-                       default:        goto yy62;
-                       }
-yy325:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case '_':       goto yy403;
-                       default:        goto yy62;
-                       }
-yy326:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy404;
-                       default:        goto yy62;
-                       }
-yy327:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'R':
-                       case 'r':       goto yy405;
-                       default:        goto yy62;
-                       }
-yy328:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'I':
-                       case 'i':       goto yy406;
-                       default:        goto yy62;
-                       }
-yy329:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'N':
-                       case 'n':       goto yy407;
-                       default:        goto yy62;
-                       }
-yy330:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'E':
-                       case 'e':       goto yy408;
-                       default:        goto yy62;
-                       }
-yy331:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'A':
-                       case 'a':       goto yy409;
-                       default:        goto yy62;
-                       }
-yy332:
-                       yyaccept = 19;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 0x00:
-                       case 0x01:
-                       case 0x02:
-                       case 0x03:
-                       case 0x04:
-                       case 0x05:
-                       case 0x06:
-                       case 0x07:
-                       case 0x08:
-                       case '\t':
-                       case '\n':
-                       case '\v':
-                       case '\f':
-                       case '\r':
-                       case 0x0E:
-                       case 0x0F:
-                       case 0x10:
-                       case 0x11:
-                       case 0x12:
-                       case 0x13:
-                       case 0x14:
-                       case 0x15:
-                       case 0x16:
-                       case 0x17:
-                       case 0x18:
-                       case 0x19:
-                       case 0x1A:
-                       case 0x1B:
-                       case 0x1C:
-                       case 0x1D:
-                       case 0x1E:
-                       case 0x1F:
-                       case ' ':
-                       case '!':
-                       case '"':
-                       case '#':
-                       case '$':
-                       case '%':
-                       case '&':
-                       case '\'':
-                       case '(':
-                       case ')':
-                       case '*':
-                       case '+':
-                       case ',':
-                       case '-':
-                       case '.':
-                       case '/':
-                       case ':':
-                       case ';':
-                       case '<':
-                       case '=':
-                       case '>':
-                       case '?':
-                       case '@':
-                       case '[':
-                       case ']':
-                       case '^':
-                       case '`':
-                       case '{':
-                       case '|':
-                       case '}':
-                       case '~':
-                       case 0x7F:      goto yy333;
-                       case '\\':      goto yy148;
-                       default:        goto yy61;
-                       }
-yy333:
-#line 444 "src/parser.re"
-                       { NEWTOKEN(PSI_T_TEMP); goto start; }
-#line 3988 "src/parser.c"
-yy334:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'R':
-                       case 'r':       goto yy410;
-                       default:        goto yy62;
-                       }
-yy335:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'O':
-                       case 'o':       goto yy411;
-                       default:        goto yy62;
-                       }
-yy336:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'L':
-                       case 'l':       goto yy412;
-                       default:        goto yy62;
-                       }
-yy337:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'N':
-                       case 'n':       goto yy413;
-                       default:        goto yy62;
-                       }
-yy338:
-                       yyaccept = 5;
-                       yych = *(mrk = ++cur);
-                       switch (yych) {
-                       case 'B':
-                       case 'b':       goto yy414;
-                       default:        goto yy62;
-  &