From 0824e52aa0cceb1843ecfab07921f8617cbf8313 Mon Sep 17 00:00:00 2001 From: xensik Date: Wed, 26 Jan 2022 12:08:28 +0100 Subject: [PATCH] new lexer and update headers --- gen/h1/Makefile | 7 +- gen/h1/lexer.lpp | 240 - gen/h1/parser.ypp | 22 +- gen/h2/Makefile | 7 +- gen/h2/lexer.lpp | 240 - gen/h2/parser.ypp | 22 +- gen/iw5/Makefile | 7 +- gen/iw5/lexer.lpp | 239 - gen/iw5/parser.ypp | 22 +- gen/iw6/Makefile | 7 +- gen/iw6/lexer.lpp | 239 - gen/iw6/parser.ypp | 22 +- gen/iw7/Makefile | 7 +- gen/iw7/lexer.lpp | 239 - gen/iw7/parser.ypp | 22 +- gen/iw8/Makefile | 7 +- gen/iw8/lexer.lpp | 242 - gen/iw8/parser.ypp | 22 +- gen/s1/Makefile | 7 +- gen/s1/lexer.lpp | 240 - gen/s1/parser.ypp | 22 +- gen/s2/Makefile | 7 +- gen/s2/lexer.lpp | 240 - gen/s2/parser.ypp | 22 +- gen/s4/Makefile | 7 +- gen/s4/lexer.lpp | 242 - gen/s4/parser.ypp | 22 +- src/experimental/iw5_console/stdafx.cpp | 2 +- src/experimental/iw5_console/stdafx.hpp | 2 +- .../iw5_console/xsk/iw5_console.cpp | 2 +- .../iw5_console/xsk/iw5_console.hpp | 2 +- src/experimental/iw6_console/stdafx.cpp | 2 +- src/experimental/iw6_console/stdafx.hpp | 2 +- .../iw6_console/xsk/iw6_console.cpp | 2 +- .../iw6_console/xsk/iw6_console.hpp | 2 +- src/experimental/s1_console/stdafx.cpp | 2 +- src/experimental/s1_console/stdafx.hpp | 2 +- .../s1_console/xsk/s1_console.cpp | 2 +- .../s1_console/xsk/s1_console.hpp | 2 +- src/experimental/t4/stdafx.cpp | 2 +- src/experimental/t4/stdafx.hpp | 2 +- src/experimental/t4/xsk/t4.cpp | 2 +- src/experimental/t4/xsk/t4.hpp | 2 +- src/experimental/t5/stdafx.cpp | 2 +- src/experimental/t5/stdafx.hpp | 2 +- src/experimental/t5/xsk/t5.cpp | 2 +- src/experimental/t5/xsk/t5.hpp | 2 +- src/h1/stdafx.cpp | 2 +- src/h1/stdafx.hpp | 2 +- src/h1/xsk/assembler.cpp | 2 +- src/h1/xsk/assembler.hpp | 2 +- src/h1/xsk/compiler.cpp | 31 +- src/h1/xsk/compiler.hpp | 3 +- src/h1/xsk/decompiler.cpp | 2 +- src/h1/xsk/decompiler.hpp | 2 +- src/h1/xsk/disassembler.cpp | 2 +- src/h1/xsk/disassembler.hpp | 2 +- src/h1/xsk/h1.cpp | 2 +- src/h1/xsk/h1.hpp | 2 +- src/h1/xsk/lexer.cpp | 3934 ++++------------ src/h1/xsk/lexer.hpp | 790 +--- src/h1/xsk/parser.cpp | 931 ++-- src/h1/xsk/parser.hpp | 16 +- src/h1/xsk/resolver.cpp | 31 +- src/h1/xsk/resolver.hpp | 4 +- src/h2/stdafx.cpp | 2 +- src/h2/stdafx.hpp | 2 +- src/h2/xsk/assembler.cpp | 2 +- src/h2/xsk/assembler.hpp | 2 +- src/h2/xsk/compiler.cpp | 31 +- src/h2/xsk/compiler.hpp | 3 +- src/h2/xsk/decompiler.cpp | 2 +- src/h2/xsk/decompiler.hpp | 2 +- src/h2/xsk/disassembler.cpp | 2 +- src/h2/xsk/disassembler.hpp | 2 +- src/h2/xsk/h2.cpp | 2 +- src/h2/xsk/h2.hpp | 2 +- src/h2/xsk/lexer.cpp | 3934 ++++------------ src/h2/xsk/lexer.hpp | 788 +--- src/h2/xsk/parser.cpp | 931 ++-- src/h2/xsk/parser.hpp | 16 +- src/h2/xsk/resolver.cpp | 31 +- src/h2/xsk/resolver.hpp | 4 +- src/iw5/stdafx.cpp | 2 +- src/iw5/stdafx.hpp | 2 +- src/iw5/xsk/assembler.cpp | 2 +- src/iw5/xsk/assembler.hpp | 2 +- src/iw5/xsk/compiler.cpp | 31 +- src/iw5/xsk/compiler.hpp | 3 +- src/iw5/xsk/decompiler.cpp | 2 +- src/iw5/xsk/decompiler.hpp | 2 +- src/iw5/xsk/disassembler.cpp | 2 +- src/iw5/xsk/disassembler.hpp | 2 +- src/iw5/xsk/iw5.cpp | 2 +- src/iw5/xsk/iw5.hpp | 2 +- src/iw5/xsk/lexer.cpp | 3920 ++++------------ src/iw5/xsk/lexer.hpp | 790 +--- src/iw5/xsk/parser.cpp | 919 ++-- src/iw5/xsk/parser.hpp | 16 +- src/iw5/xsk/resolver.cpp | 31 +- src/iw5/xsk/resolver.hpp | 4 +- src/iw6/stdafx.cpp | 2 +- src/iw6/stdafx.hpp | 2 +- src/iw6/xsk/assembler.cpp | 2 +- src/iw6/xsk/assembler.hpp | 2 +- src/iw6/xsk/compiler.cpp | 31 +- src/iw6/xsk/compiler.hpp | 3 +- src/iw6/xsk/decompiler.cpp | 2 +- src/iw6/xsk/decompiler.hpp | 2 +- src/iw6/xsk/disassembler.cpp | 2 +- src/iw6/xsk/disassembler.hpp | 2 +- src/iw6/xsk/iw6.cpp | 2 +- src/iw6/xsk/iw6.hpp | 2 +- src/iw6/xsk/lexer.cpp | 3920 ++++------------ src/iw6/xsk/lexer.hpp | 790 +--- src/iw6/xsk/parser.cpp | 919 ++-- src/iw6/xsk/parser.hpp | 16 +- src/iw6/xsk/resolver.cpp | 31 +- src/iw6/xsk/resolver.hpp | 4 +- src/iw7/stdafx.cpp | 2 +- src/iw7/stdafx.hpp | 2 +- src/iw7/xsk/assembler.cpp | 2 +- src/iw7/xsk/assembler.hpp | 2 +- src/iw7/xsk/compiler.cpp | 31 +- src/iw7/xsk/compiler.hpp | 3 +- src/iw7/xsk/decompiler.cpp | 2 +- src/iw7/xsk/decompiler.hpp | 2 +- src/iw7/xsk/disassembler.cpp | 2 +- src/iw7/xsk/disassembler.hpp | 2 +- src/iw7/xsk/iw7.cpp | 2 +- src/iw7/xsk/iw7.hpp | 2 +- src/iw7/xsk/lexer.cpp | 3920 ++++------------ src/iw7/xsk/lexer.hpp | 790 +--- src/iw7/xsk/parser.cpp | 919 ++-- src/iw7/xsk/parser.hpp | 16 +- src/iw7/xsk/resolver.cpp | 31 +- src/iw7/xsk/resolver.hpp | 4 +- src/iw8/stdafx.cpp | 2 +- src/iw8/stdafx.hpp | 2 +- src/iw8/xsk/assembler.cpp | 2 +- src/iw8/xsk/assembler.hpp | 2 +- src/iw8/xsk/compiler.cpp | 31 +- src/iw8/xsk/compiler.hpp | 3 +- src/iw8/xsk/decompiler.cpp | 2 +- src/iw8/xsk/decompiler.hpp | 2 +- src/iw8/xsk/disassembler.cpp | 2 +- src/iw8/xsk/disassembler.hpp | 2 +- src/iw8/xsk/iw8.cpp | 2 +- src/iw8/xsk/iw8.hpp | 2 +- src/iw8/xsk/lexer.cpp | 3949 ++++------------- src/iw8/xsk/lexer.hpp | 790 +--- src/iw8/xsk/parser.cpp | 949 ++-- src/iw8/xsk/parser.hpp | 16 +- src/iw8/xsk/resolver.cpp | 31 +- src/iw8/xsk/resolver.hpp | 4 +- src/s1/stdafx.cpp | 2 +- src/s1/stdafx.hpp | 2 +- src/s1/xsk/assembler.cpp | 2 +- src/s1/xsk/assembler.hpp | 2 +- src/s1/xsk/compiler.cpp | 31 +- src/s1/xsk/compiler.hpp | 3 +- src/s1/xsk/decompiler.cpp | 2 +- src/s1/xsk/decompiler.hpp | 2 +- src/s1/xsk/disassembler.cpp | 2 +- src/s1/xsk/disassembler.hpp | 2 +- src/s1/xsk/lexer.cpp | 3934 ++++------------ src/s1/xsk/lexer.hpp | 790 +--- src/s1/xsk/parser.cpp | 931 ++-- src/s1/xsk/parser.hpp | 16 +- src/s1/xsk/resolver.cpp | 31 +- src/s1/xsk/resolver.hpp | 4 +- src/s1/xsk/s1.cpp | 2 +- src/s1/xsk/s1.hpp | 2 +- src/s2/stdafx.cpp | 2 +- src/s2/stdafx.hpp | 2 +- src/s2/xsk/assembler.cpp | 2 +- src/s2/xsk/assembler.hpp | 2 +- src/s2/xsk/compiler.cpp | 31 +- src/s2/xsk/compiler.hpp | 3 +- src/s2/xsk/decompiler.cpp | 2 +- src/s2/xsk/decompiler.hpp | 2 +- src/s2/xsk/disassembler.cpp | 2 +- src/s2/xsk/disassembler.hpp | 2 +- src/s2/xsk/lexer.cpp | 3934 ++++------------ src/s2/xsk/lexer.hpp | 790 +--- src/s2/xsk/parser.cpp | 931 ++-- src/s2/xsk/parser.hpp | 16 +- src/s2/xsk/resolver.cpp | 31 +- src/s2/xsk/resolver.hpp | 4 +- src/s2/xsk/s2.cpp | 2 +- src/s2/xsk/s2.hpp | 2 +- src/s4/stdafx.cpp | 2 +- src/s4/stdafx.hpp | 2 +- src/s4/xsk/assembler.cpp | 2 +- src/s4/xsk/assembler.hpp | 2 +- src/s4/xsk/compiler.cpp | 31 +- src/s4/xsk/compiler.hpp | 3 +- src/s4/xsk/decompiler.cpp | 2 +- src/s4/xsk/decompiler.hpp | 2 +- src/s4/xsk/disassembler.cpp | 2 +- src/s4/xsk/disassembler.hpp | 2 +- src/s4/xsk/lexer.cpp | 3948 ++++------------ src/s4/xsk/lexer.hpp | 790 +--- src/s4/xsk/parser.cpp | 949 ++-- src/s4/xsk/parser.hpp | 16 +- src/s4/xsk/resolver.cpp | 31 +- src/s4/xsk/resolver.hpp | 4 +- src/s4/xsk/s4.cpp | 2 +- src/s4/xsk/s4.hpp | 2 +- src/tool/stdafx.cpp | 2 +- src/tool/stdafx.hpp | 2 +- src/tool/xsk/main.cpp | 2 +- src/utils/stdafx.cpp | 2 +- src/utils/stdafx.hpp | 2 +- src/utils/xsk/gsc/asset.cpp | 2 +- src/utils/xsk/gsc/asset.hpp | 2 +- src/utils/xsk/gsc/block.cpp | 2 +- src/utils/xsk/gsc/block.hpp | 2 +- src/utils/xsk/gsc/interfaces/assembler.hpp | 2 +- src/utils/xsk/gsc/interfaces/compiler.hpp | 2 +- src/utils/xsk/gsc/interfaces/decompiler.hpp | 2 +- src/utils/xsk/gsc/interfaces/disassembler.hpp | 2 +- src/utils/xsk/gsc/interfaces/exception.hpp | 2 +- src/utils/xsk/gsc/location.hpp | 2 +- src/utils/xsk/gsc/nodetree.cpp | 2 +- src/utils/xsk/gsc/nodetree.hpp | 2 +- src/utils/xsk/gsc/types.cpp | 10 +- src/utils/xsk/gsc/types.hpp | 23 +- src/utils/xsk/utils.hpp | 2 +- src/utils/xsk/utils/byte_buffer.cpp | 2 +- src/utils/xsk/utils/byte_buffer.hpp | 2 +- src/utils/xsk/utils/compression.cpp | 2 +- src/utils/xsk/utils/compression.hpp | 2 +- src/utils/xsk/utils/file.cpp | 2 +- src/utils/xsk/utils/file.hpp | 2 +- src/utils/xsk/utils/string.cpp | 2 +- src/utils/xsk/utils/string.hpp | 2 +- 237 files changed, 14009 insertions(+), 40363 deletions(-) delete mode 100644 gen/h1/lexer.lpp delete mode 100644 gen/h2/lexer.lpp delete mode 100644 gen/iw5/lexer.lpp delete mode 100644 gen/iw6/lexer.lpp delete mode 100644 gen/iw7/lexer.lpp delete mode 100644 gen/iw8/lexer.lpp delete mode 100644 gen/s1/lexer.lpp delete mode 100644 gen/s2/lexer.lpp delete mode 100644 gen/s4/lexer.lpp diff --git a/gen/h1/Makefile b/gen/h1/Makefile index 344068b1..2e7b3a33 100644 --- a/gen/h1/Makefile +++ b/gen/h1/Makefile @@ -3,10 +3,7 @@ generate: H1 clean: rm -rf ./parser.hpp rm -rf ./parser.cpp - rm -rf ./lexer.hpp - rm -rf ./lexer.cpp -H1: lexer.lpp parser.ypp - flex lexer.lpp +H1: parser.ypp bison parser.ypp -Wcounterexamples - mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/h1/xsk/ + mv parser.hpp parser.cpp ../../src/h1/xsk/ diff --git a/gen/h1/lexer.lpp b/gen/h1/lexer.lpp deleted file mode 100644 index 0580b0d6..00000000 --- a/gen/h1/lexer.lpp +++ /dev/null @@ -1,240 +0,0 @@ -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ - -%option outfile="lexer.cpp" -%option header-file="lexer.hpp" -%option prefix="h1_" -%option reentrant -%option noyywrap batch nounput noinput -%option never-interactive -%option nounistd - -%top{ -#include "stdafx.hpp" -#include "h1.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void h1_push_header(xsk::gsc::context* ctx, const std::string& file); -void h1_pop_header(xsk::gsc::context* ctx); -} - -%{ -#define YY_USER_ACTION ctx->loc.columns(yyleng); -%} - -RGX_PATH ([_A-Za-z0-9]+\\)+[_A-Za-z0-9]+ -RGX_IDENTIFIER [_A-Za-z][_A-Za-z0-9]* -RGX_STRING \"(?:\\.|[^\"])*?\"|\'(?:\\.|[^\'])*?\' -RGX_COLOR_S #[0-9a-fA-F]{3} -RGX_COLOR_L #[0-9a-fA-F]{6} -RGX_FLT_DEC [0-9]+\.(?:[0-9]*)?f?|\.[0-9]+f? -RGX_INT_OCT 0[1-7][0-7]* -RGX_INT_BIN 0[bB][01]+ -RGX_INT_HEX 0[xX][0-9a-fA-F]+ -RGX_INT_DEC [0-9]+ -RGX_DEFAULT (.|\n) - -%x COMMENT_STATE -%x DEV_OFF_STATE -%s DEV_ON_STATE - -%% - -%{ - ctx->loc.step(); -%} - -[ \t\r] { ctx->loc.step(); } -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } - -"//".* - -"/*" { BEGIN(COMMENT_STATE); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"*/" { BEGIN(INITIAL); } -<> { throw h1::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } -"*/" { throw h1::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - -"/#" { throw h1::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } -"#/" { BEGIN(INITIAL); return h1::parser::make_DEVEND(ctx->loc); } -<> { throw h1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - -"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return h1::parser::make_DEVBEGIN(ctx->loc); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"#/" { BEGIN(INITIAL); } -<> { throw h1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } -"#/" { throw h1::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - -"#inline" { return h1::parser::make_INLINE(ctx->loc); } -"#include" { return h1::parser::make_INCLUDE(ctx->loc); } -"#using_animtree" { return h1::parser::make_USINGTREE(ctx->loc); } -"#animtree" { return h1::parser::make_ANIMTREE(ctx->loc); } -"endon" { return h1::parser::make_ENDON(ctx->loc); } -"notify" { return h1::parser::make_NOTIFY(ctx->loc); } -"wait" { return h1::parser::make_WAIT(ctx->loc); } -"waittill" { return h1::parser::make_WAITTILL(ctx->loc); } -"waittillmatch" { return h1::parser::make_WAITTILLMATCH(ctx->loc); } -"waittillframeend" { return h1::parser::make_WAITTILLFRAMEEND(ctx->loc); } -"waitframe" { return h1::parser::make_WAITFRAME(ctx->loc); } -"if" { return h1::parser::make_IF(ctx->loc); } -"else" { return h1::parser::make_ELSE(ctx->loc); } -"do" { return h1::parser::make_DO(ctx->loc); } -"while" { return h1::parser::make_WHILE(ctx->loc); } -"for" { return h1::parser::make_FOR(ctx->loc); } -"foreach" { return h1::parser::make_FOREACH(ctx->loc); } -"in" { return h1::parser::make_IN(ctx->loc); } -"switch" { return h1::parser::make_SWITCH(ctx->loc); } -"case" { return h1::parser::make_CASE(ctx->loc); } -"default" { return h1::parser::make_DEFAULT(ctx->loc); } -"break" { return h1::parser::make_BREAK(ctx->loc); } -"continue" { return h1::parser::make_CONTINUE(ctx->loc); } -"return" { return h1::parser::make_RETURN(ctx->loc); } -"breakpoint" { return h1::parser::make_BREAKPOINT(ctx->loc); } -"prof_begin" { return h1::parser::make_PROFBEGIN(ctx->loc); } -"prof_end" { return h1::parser::make_PROFEND(ctx->loc); } -"thread" { return h1::parser::make_THREAD(ctx->loc); } -"childthread" { return h1::parser::make_CHILDTHREAD(ctx->loc); } -"thisthread" { return h1::parser::make_THISTHREAD(ctx->loc); } -"call" { return h1::parser::make_CALL(ctx->loc); } -"true" { return h1::parser::make_TRUE(ctx->loc); } -"false" { return h1::parser::make_FALSE(ctx->loc); } -"undefined" { return h1::parser::make_UNDEFINED(ctx->loc); } -".size" { return h1::parser::make_SIZE(ctx->loc); } -"game" { return h1::parser::make_GAME(ctx->loc); } -"self" { return h1::parser::make_SELF(ctx->loc); } -"anim" { return h1::parser::make_ANIM(ctx->loc); } -"level" { return h1::parser::make_LEVEL(ctx->loc); } -\( { return h1::parser::make_LPAREN(ctx->loc); } -\) { return h1::parser::make_RPAREN(ctx->loc); } -\{ { return h1::parser::make_LBRACE(ctx->loc); } -\} { return h1::parser::make_RBRACE(ctx->loc); } -\[ { return h1::parser::make_LBRACKET(ctx->loc); } -\] { return h1::parser::make_RBRACKET(ctx->loc); } -\, { return h1::parser::make_COMMA(ctx->loc); } -\. { return h1::parser::make_DOT(ctx->loc); } -\:\: { return h1::parser::make_DOUBLECOLON(ctx->loc); } -\: { return h1::parser::make_COLON(ctx->loc); } -\; { return h1::parser::make_SEMICOLON(ctx->loc); } -\? { return h1::parser::make_QMARK(ctx->loc); } -\+\+ { return h1::parser::make_INCREMENT(ctx->loc); } -\-\- { return h1::parser::make_DECREMENT(ctx->loc); } -\<\<\= { return h1::parser::make_ASSIGN_LSHIFT(ctx->loc); } -\>\>\= { return h1::parser::make_ASSIGN_RSHIFT(ctx->loc); } -\<\< { return h1::parser::make_LSHIFT(ctx->loc); } -\>\> { return h1::parser::make_RSHIFT(ctx->loc); } -\|\| { return h1::parser::make_OR(ctx->loc); } -\&\& { return h1::parser::make_AND(ctx->loc); } -\=\= { return h1::parser::make_EQUALITY(ctx->loc); } -\!\= { return h1::parser::make_INEQUALITY(ctx->loc); } -\<\= { return h1::parser::make_LESS_EQUAL(ctx->loc); } -\>\= { return h1::parser::make_GREATER_EQUAL(ctx->loc); } -\< { return h1::parser::make_LESS(ctx->loc); } -\> { return h1::parser::make_GREATER(ctx->loc); } -\+\= { return h1::parser::make_ASSIGN_ADD(ctx->loc); } -\-\= { return h1::parser::make_ASSIGN_SUB(ctx->loc); } -\*\= { return h1::parser::make_ASSIGN_MUL(ctx->loc); } -\/\= { return h1::parser::make_ASSIGN_DIV(ctx->loc); } -\%\= { return h1::parser::make_ASSIGN_MOD(ctx->loc); } -\|\= { return h1::parser::make_ASSIGN_BW_OR(ctx->loc); } -\&\= { return h1::parser::make_ASSIGN_BW_AND(ctx->loc); } -\^\= { return h1::parser::make_ASSIGN_BW_EXOR(ctx->loc); } -\= { return h1::parser::make_ASSIGN(ctx->loc); } -\+ { return h1::parser::make_ADD(ctx->loc); } -\- { return h1::parser::make_SUB(ctx->loc); } -\* { return h1::parser::make_MUL(ctx->loc); } -\/ { return h1::parser::make_DIV(ctx->loc); } -\% { return h1::parser::make_MOD(ctx->loc); } -\! { return h1::parser::make_NOT(ctx->loc); } -\~ { return h1::parser::make_COMPLEMENT(ctx->loc); } -\| { return h1::parser::make_BITWISE_OR(ctx->loc); } -\& { return h1::parser::make_BITWISE_AND(ctx->loc); } -\^ { return h1::parser::make_BITWISE_EXOR(ctx->loc); } -{RGX_PATH} { return h1::parser::make_PATH(xsk::gsc::h1::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -{RGX_IDENTIFIER} { return h1::parser::make_IDENTIFIER(xsk::gsc::h1::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -\&{RGX_STRING} { return h1::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_STRING} { return h1::parser::make_STRING(std::string(yytext), ctx->loc); } -{RGX_COLOR_S} { return h1::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_COLOR_L} { return h1::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_FLT_DEC} { return h1::parser::make_FLOAT(std::string(yytext), ctx->loc); } -{RGX_INT_OCT} { return h1::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } -{RGX_INT_BIN} { return h1::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } -{RGX_INT_HEX} { return h1::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } -{RGX_INT_DEC} { return h1::parser::make_INTEGER(std::string(yytext), ctx->loc); } -<> { if(ctx->header_top > 0) h1_pop_header(ctx); else return h1::parser::make_H1EOF(ctx->loc); } -<*>{RGX_DEFAULT} { throw h1::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - -%% - -void h1_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void h1_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} diff --git a/gen/h1/parser.ypp b/gen/h1/parser.ypp index 97b14818..3296677f 100644 --- a/gen/h1/parser.ypp +++ b/gen/h1/parser.ypp @@ -1,4 +1,4 @@ -/* Copyright 2021 xensik. All rights reserved. +/* Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,21 +19,15 @@ %define parse.trace %define parse.error detailed %define parse.lac full - %locations - -%lex-param { yyscan_t yyscanner } -%lex-param { xsk::gsc::context* ctx } - -%parse-param { yyscan_t yyscanner } -%parse-param { xsk::gsc::context* ctx } +%lex-param { xsk::gsc::h1::lexer& lexer } +%parse-param { xsk::gsc::h1::lexer& lexer } %parse-param { xsk::gsc::ast::program::ptr& ast } %code requires { #include "h1.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::h1::parser::symbol_type H1lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::h1 { class lexer; } } %code top @@ -42,7 +36,7 @@ typedef void *yyscan_t; #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::h1::parser::symbol_type H1lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::h1::parser::symbol_type H1lex(xsk::gsc::h1::lexer& lexer); } %token DEVBEGIN "/#" @@ -268,7 +262,7 @@ program ; inline - : INLINE expr_path SEMICOLON { h1_push_header(ctx, $2->value); } + : INLINE expr_path SEMICOLON { lexer.push_header($2->value); } ; include @@ -286,7 +280,7 @@ declaration decl_usingtree : USINGTREE LPAREN expr_string RPAREN SEMICOLON - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } ; decl_constant @@ -296,7 +290,7 @@ decl_constant decl_thread : expr_identifier LPAREN expr_parameters RPAREN stmt_block - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } ; stmt diff --git a/gen/h2/Makefile b/gen/h2/Makefile index 04be2d76..9781465d 100644 --- a/gen/h2/Makefile +++ b/gen/h2/Makefile @@ -3,10 +3,7 @@ generate: H2 clean: rm -rf ./parser.hpp rm -rf ./parser.cpp - rm -rf ./lexer.hpp - rm -rf ./lexer.cpp -H2: lexer.lpp parser.ypp - flex lexer.lpp +H2: parser.ypp bison parser.ypp -Wcounterexamples - mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/h2/xsk/ + mv parser.hpp parser.cpp ../../src/h2/xsk/ diff --git a/gen/h2/lexer.lpp b/gen/h2/lexer.lpp deleted file mode 100644 index 43c8ef91..00000000 --- a/gen/h2/lexer.lpp +++ /dev/null @@ -1,240 +0,0 @@ -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ - -%option outfile="lexer.cpp" -%option header-file="lexer.hpp" -%option prefix="h2_" -%option reentrant -%option noyywrap batch nounput noinput -%option never-interactive -%option nounistd - -%top{ -#include "stdafx.hpp" -#include "h2.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void h2_push_header(xsk::gsc::context* ctx, const std::string& file); -void h2_pop_header(xsk::gsc::context* ctx); -} - -%{ -#define YY_USER_ACTION ctx->loc.columns(yyleng); -%} - -RGX_PATH ([_A-Za-z0-9]+\\)+[_A-Za-z0-9]+ -RGX_IDENTIFIER [_A-Za-z][_A-Za-z0-9]* -RGX_STRING \"(?:\\.|[^\"])*?\"|\'(?:\\.|[^\'])*?\' -RGX_COLOR_S #[0-9a-fA-F]{3} -RGX_COLOR_L #[0-9a-fA-F]{6} -RGX_FLT_DEC [0-9]+\.(?:[0-9]*)?f?|\.[0-9]+f? -RGX_INT_OCT 0[1-7][0-7]* -RGX_INT_BIN 0[bB][01]+ -RGX_INT_HEX 0[xX][0-9a-fA-F]+ -RGX_INT_DEC [0-9]+ -RGX_DEFAULT (.|\n) - -%x COMMENT_STATE -%x DEV_OFF_STATE -%s DEV_ON_STATE - -%% - -%{ - ctx->loc.step(); -%} - -[ \t\r] { ctx->loc.step(); } -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } - -"//".* - -"/*" { BEGIN(COMMENT_STATE); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"*/" { BEGIN(INITIAL); } -<> { throw h2::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } -"*/" { throw h2::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - -"/#" { throw h2::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } -"#/" { BEGIN(INITIAL); return h2::parser::make_DEVEND(ctx->loc); } -<> { throw h2::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - -"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return h2::parser::make_DEVBEGIN(ctx->loc); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"#/" { BEGIN(INITIAL); } -<> { throw h2::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } -"#/" { throw h2::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - -"#inline" { return h2::parser::make_INLINE(ctx->loc); } -"#include" { return h2::parser::make_INCLUDE(ctx->loc); } -"#using_animtree" { return h2::parser::make_USINGTREE(ctx->loc); } -"#animtree" { return h2::parser::make_ANIMTREE(ctx->loc); } -"endon" { return h2::parser::make_ENDON(ctx->loc); } -"notify" { return h2::parser::make_NOTIFY(ctx->loc); } -"wait" { return h2::parser::make_WAIT(ctx->loc); } -"waittill" { return h2::parser::make_WAITTILL(ctx->loc); } -"waittillmatch" { return h2::parser::make_WAITTILLMATCH(ctx->loc); } -"waittillframeend" { return h2::parser::make_WAITTILLFRAMEEND(ctx->loc); } -"waitframe" { return h2::parser::make_WAITFRAME(ctx->loc); } -"if" { return h2::parser::make_IF(ctx->loc); } -"else" { return h2::parser::make_ELSE(ctx->loc); } -"do" { return h2::parser::make_DO(ctx->loc); } -"while" { return h2::parser::make_WHILE(ctx->loc); } -"for" { return h2::parser::make_FOR(ctx->loc); } -"foreach" { return h2::parser::make_FOREACH(ctx->loc); } -"in" { return h2::parser::make_IN(ctx->loc); } -"switch" { return h2::parser::make_SWITCH(ctx->loc); } -"case" { return h2::parser::make_CASE(ctx->loc); } -"default" { return h2::parser::make_DEFAULT(ctx->loc); } -"break" { return h2::parser::make_BREAK(ctx->loc); } -"continue" { return h2::parser::make_CONTINUE(ctx->loc); } -"return" { return h2::parser::make_RETURN(ctx->loc); } -"breakpoint" { return h2::parser::make_BREAKPOINT(ctx->loc); } -"prof_begin" { return h2::parser::make_PROFBEGIN(ctx->loc); } -"prof_end" { return h2::parser::make_PROFEND(ctx->loc); } -"thread" { return h2::parser::make_THREAD(ctx->loc); } -"childthread" { return h2::parser::make_CHILDTHREAD(ctx->loc); } -"thisthread" { return h2::parser::make_THISTHREAD(ctx->loc); } -"call" { return h2::parser::make_CALL(ctx->loc); } -"true" { return h2::parser::make_TRUE(ctx->loc); } -"false" { return h2::parser::make_FALSE(ctx->loc); } -"undefined" { return h2::parser::make_UNDEFINED(ctx->loc); } -".size" { return h2::parser::make_SIZE(ctx->loc); } -"game" { return h2::parser::make_GAME(ctx->loc); } -"self" { return h2::parser::make_SELF(ctx->loc); } -"anim" { return h2::parser::make_ANIM(ctx->loc); } -"level" { return h2::parser::make_LEVEL(ctx->loc); } -\( { return h2::parser::make_LPAREN(ctx->loc); } -\) { return h2::parser::make_RPAREN(ctx->loc); } -\{ { return h2::parser::make_LBRACE(ctx->loc); } -\} { return h2::parser::make_RBRACE(ctx->loc); } -\[ { return h2::parser::make_LBRACKET(ctx->loc); } -\] { return h2::parser::make_RBRACKET(ctx->loc); } -\, { return h2::parser::make_COMMA(ctx->loc); } -\. { return h2::parser::make_DOT(ctx->loc); } -\:\: { return h2::parser::make_DOUBLECOLON(ctx->loc); } -\: { return h2::parser::make_COLON(ctx->loc); } -\; { return h2::parser::make_SEMICOLON(ctx->loc); } -\? { return h2::parser::make_QMARK(ctx->loc); } -\+\+ { return h2::parser::make_INCREMENT(ctx->loc); } -\-\- { return h2::parser::make_DECREMENT(ctx->loc); } -\<\<\= { return h2::parser::make_ASSIGN_LSHIFT(ctx->loc); } -\>\>\= { return h2::parser::make_ASSIGN_RSHIFT(ctx->loc); } -\<\< { return h2::parser::make_LSHIFT(ctx->loc); } -\>\> { return h2::parser::make_RSHIFT(ctx->loc); } -\|\| { return h2::parser::make_OR(ctx->loc); } -\&\& { return h2::parser::make_AND(ctx->loc); } -\=\= { return h2::parser::make_EQUALITY(ctx->loc); } -\!\= { return h2::parser::make_INEQUALITY(ctx->loc); } -\<\= { return h2::parser::make_LESS_EQUAL(ctx->loc); } -\>\= { return h2::parser::make_GREATER_EQUAL(ctx->loc); } -\< { return h2::parser::make_LESS(ctx->loc); } -\> { return h2::parser::make_GREATER(ctx->loc); } -\+\= { return h2::parser::make_ASSIGN_ADD(ctx->loc); } -\-\= { return h2::parser::make_ASSIGN_SUB(ctx->loc); } -\*\= { return h2::parser::make_ASSIGN_MUL(ctx->loc); } -\/\= { return h2::parser::make_ASSIGN_DIV(ctx->loc); } -\%\= { return h2::parser::make_ASSIGN_MOD(ctx->loc); } -\|\= { return h2::parser::make_ASSIGN_BW_OR(ctx->loc); } -\&\= { return h2::parser::make_ASSIGN_BW_AND(ctx->loc); } -\^\= { return h2::parser::make_ASSIGN_BW_EXOR(ctx->loc); } -\= { return h2::parser::make_ASSIGN(ctx->loc); } -\+ { return h2::parser::make_ADD(ctx->loc); } -\- { return h2::parser::make_SUB(ctx->loc); } -\* { return h2::parser::make_MUL(ctx->loc); } -\/ { return h2::parser::make_DIV(ctx->loc); } -\% { return h2::parser::make_MOD(ctx->loc); } -\! { return h2::parser::make_NOT(ctx->loc); } -\~ { return h2::parser::make_COMPLEMENT(ctx->loc); } -\| { return h2::parser::make_BITWISE_OR(ctx->loc); } -\& { return h2::parser::make_BITWISE_AND(ctx->loc); } -\^ { return h2::parser::make_BITWISE_EXOR(ctx->loc); } -{RGX_PATH} { return h2::parser::make_PATH(xsk::gsc::h2::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -{RGX_IDENTIFIER} { return h2::parser::make_IDENTIFIER(xsk::gsc::h2::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -\&{RGX_STRING} { return h2::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_STRING} { return h2::parser::make_STRING(std::string(yytext), ctx->loc); } -{RGX_COLOR_S} { return h2::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_COLOR_L} { return h2::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_FLT_DEC} { return h2::parser::make_FLOAT(std::string(yytext), ctx->loc); } -{RGX_INT_OCT} { return h2::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } -{RGX_INT_BIN} { return h2::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } -{RGX_INT_HEX} { return h2::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } -{RGX_INT_DEC} { return h2::parser::make_INTEGER(std::string(yytext), ctx->loc); } -<> { if(ctx->header_top > 0) h2_pop_header(ctx); else return h2::parser::make_H2EOF(ctx->loc); } -<*>{RGX_DEFAULT} { throw h2::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - -%% - -void h2_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void h2_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} diff --git a/gen/h2/parser.ypp b/gen/h2/parser.ypp index a31df172..cf204d50 100644 --- a/gen/h2/parser.ypp +++ b/gen/h2/parser.ypp @@ -1,4 +1,4 @@ -/* Copyright 2021 xensik. All rights reserved. +/* Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,21 +19,15 @@ %define parse.trace %define parse.error detailed %define parse.lac full - %locations - -%lex-param { yyscan_t yyscanner } -%lex-param { xsk::gsc::context* ctx } - -%parse-param { yyscan_t yyscanner } -%parse-param { xsk::gsc::context* ctx } +%lex-param { xsk::gsc::h2::lexer& lexer } +%parse-param { xsk::gsc::h2::lexer& lexer } %parse-param { xsk::gsc::ast::program::ptr& ast } %code requires { #include "h2.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::h2::parser::symbol_type H2lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::h2 { class lexer; } } %code top @@ -42,7 +36,7 @@ typedef void *yyscan_t; #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::h2::parser::symbol_type H2lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::h2::parser::symbol_type H2lex(xsk::gsc::h2::lexer& lexer); } %token DEVBEGIN "/#" @@ -268,7 +262,7 @@ program ; inline - : INLINE expr_path SEMICOLON { h2_push_header(ctx, $2->value); } + : INLINE expr_path SEMICOLON { lexer.push_header($2->value); } ; include @@ -286,7 +280,7 @@ declaration decl_usingtree : USINGTREE LPAREN expr_string RPAREN SEMICOLON - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } ; decl_constant @@ -296,7 +290,7 @@ decl_constant decl_thread : expr_identifier LPAREN expr_parameters RPAREN stmt_block - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } ; stmt diff --git a/gen/iw5/Makefile b/gen/iw5/Makefile index 86e83f69..2fe7b3a1 100644 --- a/gen/iw5/Makefile +++ b/gen/iw5/Makefile @@ -3,10 +3,7 @@ generate: IW5 clean: rm -rf ./parser.hpp rm -rf ./parser.cpp - rm -rf ./lexer.hpp - rm -rf ./lexer.cpp -IW5: lexer.lpp parser.ypp - flex lexer.lpp +IW5: parser.ypp bison parser.ypp -Wcounterexamples - mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/iw5/xsk/ + mv parser.hpp parser.cpp ../../src/iw5/xsk/ diff --git a/gen/iw5/lexer.lpp b/gen/iw5/lexer.lpp deleted file mode 100644 index b62bee82..00000000 --- a/gen/iw5/lexer.lpp +++ /dev/null @@ -1,239 +0,0 @@ -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ - -%option outfile="lexer.cpp" -%option header-file="lexer.hpp" -%option prefix="iw5_" -%option reentrant -%option noyywrap batch nounput noinput -%option never-interactive -%option nounistd - -%top{ -#include "stdafx.hpp" -#include "iw5.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw5_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw5_pop_header(xsk::gsc::context* ctx); -} - -%{ -#define YY_USER_ACTION ctx->loc.columns(yyleng); -%} - -RGX_PATH ([_A-Za-z0-9]+\\)+[_A-Za-z0-9]+ -RGX_IDENTIFIER [_A-Za-z][_A-Za-z0-9]* -RGX_STRING \"(?:\\.|[^\"])*?\"|\'(?:\\.|[^\'])*?\' -RGX_COLOR_S #[0-9a-fA-F]{3} -RGX_COLOR_L #[0-9a-fA-F]{6} -RGX_FLT_DEC [0-9]+\.(?:[0-9]*)?f?|\.[0-9]+f? -RGX_INT_OCT 0[1-7][0-7]* -RGX_INT_BIN 0[bB][01]+ -RGX_INT_HEX 0[xX][0-9a-fA-F]+ -RGX_INT_DEC [0-9]+ -RGX_DEFAULT (.|\n) - -%x COMMENT_STATE -%x DEV_OFF_STATE -%s DEV_ON_STATE - -%% - -%{ - ctx->loc.step(); -%} - -[ \t\r] { ctx->loc.step(); } -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } - -"//".* - -"/*" { BEGIN(COMMENT_STATE); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"*/" { BEGIN(INITIAL); } -<> { throw iw5::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } -"*/" { throw iw5::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - -"/#" { throw iw5::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } -"#/" { BEGIN(INITIAL); return iw5::parser::make_DEVEND(ctx->loc); } -<> { throw iw5::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - -"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return iw5::parser::make_DEVBEGIN(ctx->loc); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"#/" { BEGIN(INITIAL); } -<> { throw iw5::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } -"#/" { throw iw5::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - -"#inline" { return iw5::parser::make_INLINE(ctx->loc); } -"#include" { return iw5::parser::make_INCLUDE(ctx->loc); } -"#using_animtree" { return iw5::parser::make_USINGTREE(ctx->loc); } -"#animtree" { return iw5::parser::make_ANIMTREE(ctx->loc); } -"endon" { return iw5::parser::make_ENDON(ctx->loc); } -"notify" { return iw5::parser::make_NOTIFY(ctx->loc); } -"wait" { return iw5::parser::make_WAIT(ctx->loc); } -"waittill" { return iw5::parser::make_WAITTILL(ctx->loc); } -"waittillmatch" { return iw5::parser::make_WAITTILLMATCH(ctx->loc); } -"waittillframeend" { return iw5::parser::make_WAITTILLFRAMEEND(ctx->loc); } -"if" { return iw5::parser::make_IF(ctx->loc); } -"else" { return iw5::parser::make_ELSE(ctx->loc); } -"do" { return iw5::parser::make_DO(ctx->loc); } -"while" { return iw5::parser::make_WHILE(ctx->loc); } -"for" { return iw5::parser::make_FOR(ctx->loc); } -"foreach" { return iw5::parser::make_FOREACH(ctx->loc); } -"in" { return iw5::parser::make_IN(ctx->loc); } -"switch" { return iw5::parser::make_SWITCH(ctx->loc); } -"case" { return iw5::parser::make_CASE(ctx->loc); } -"default" { return iw5::parser::make_DEFAULT(ctx->loc); } -"break" { return iw5::parser::make_BREAK(ctx->loc); } -"continue" { return iw5::parser::make_CONTINUE(ctx->loc); } -"return" { return iw5::parser::make_RETURN(ctx->loc); } -"breakpoint" { return iw5::parser::make_BREAKPOINT(ctx->loc); } -"prof_begin" { return iw5::parser::make_PROFBEGIN(ctx->loc); } -"prof_end" { return iw5::parser::make_PROFEND(ctx->loc); } -"thread" { return iw5::parser::make_THREAD(ctx->loc); } -"childthread" { return iw5::parser::make_CHILDTHREAD(ctx->loc); } -"thisthread" { return iw5::parser::make_THISTHREAD(ctx->loc); } -"call" { return iw5::parser::make_CALL(ctx->loc); } -"true" { return iw5::parser::make_TRUE(ctx->loc); } -"false" { return iw5::parser::make_FALSE(ctx->loc); } -"undefined" { return iw5::parser::make_UNDEFINED(ctx->loc); } -".size" { return iw5::parser::make_SIZE(ctx->loc); } -"game" { return iw5::parser::make_GAME(ctx->loc); } -"self" { return iw5::parser::make_SELF(ctx->loc); } -"anim" { return iw5::parser::make_ANIM(ctx->loc); } -"level" { return iw5::parser::make_LEVEL(ctx->loc); } -\( { return iw5::parser::make_LPAREN(ctx->loc); } -\) { return iw5::parser::make_RPAREN(ctx->loc); } -\{ { return iw5::parser::make_LBRACE(ctx->loc); } -\} { return iw5::parser::make_RBRACE(ctx->loc); } -\[ { return iw5::parser::make_LBRACKET(ctx->loc); } -\] { return iw5::parser::make_RBRACKET(ctx->loc); } -\, { return iw5::parser::make_COMMA(ctx->loc); } -\. { return iw5::parser::make_DOT(ctx->loc); } -\:\: { return iw5::parser::make_DOUBLECOLON(ctx->loc); } -\: { return iw5::parser::make_COLON(ctx->loc); } -\; { return iw5::parser::make_SEMICOLON(ctx->loc); } -\? { return iw5::parser::make_QMARK(ctx->loc); } -\+\+ { return iw5::parser::make_INCREMENT(ctx->loc); } -\-\- { return iw5::parser::make_DECREMENT(ctx->loc); } -\<\<\= { return iw5::parser::make_ASSIGN_LSHIFT(ctx->loc); } -\>\>\= { return iw5::parser::make_ASSIGN_RSHIFT(ctx->loc); } -\<\< { return iw5::parser::make_LSHIFT(ctx->loc); } -\>\> { return iw5::parser::make_RSHIFT(ctx->loc); } -\|\| { return iw5::parser::make_OR(ctx->loc); } -\&\& { return iw5::parser::make_AND(ctx->loc); } -\=\= { return iw5::parser::make_EQUALITY(ctx->loc); } -\!\= { return iw5::parser::make_INEQUALITY(ctx->loc); } -\<\= { return iw5::parser::make_LESS_EQUAL(ctx->loc); } -\>\= { return iw5::parser::make_GREATER_EQUAL(ctx->loc); } -\< { return iw5::parser::make_LESS(ctx->loc); } -\> { return iw5::parser::make_GREATER(ctx->loc); } -\+\= { return iw5::parser::make_ASSIGN_ADD(ctx->loc); } -\-\= { return iw5::parser::make_ASSIGN_SUB(ctx->loc); } -\*\= { return iw5::parser::make_ASSIGN_MUL(ctx->loc); } -\/\= { return iw5::parser::make_ASSIGN_DIV(ctx->loc); } -\%\= { return iw5::parser::make_ASSIGN_MOD(ctx->loc); } -\|\= { return iw5::parser::make_ASSIGN_BW_OR(ctx->loc); } -\&\= { return iw5::parser::make_ASSIGN_BW_AND(ctx->loc); } -\^\= { return iw5::parser::make_ASSIGN_BW_EXOR(ctx->loc); } -\= { return iw5::parser::make_ASSIGN(ctx->loc); } -\+ { return iw5::parser::make_ADD(ctx->loc); } -\- { return iw5::parser::make_SUB(ctx->loc); } -\* { return iw5::parser::make_MUL(ctx->loc); } -\/ { return iw5::parser::make_DIV(ctx->loc); } -\% { return iw5::parser::make_MOD(ctx->loc); } -\! { return iw5::parser::make_NOT(ctx->loc); } -\~ { return iw5::parser::make_COMPLEMENT(ctx->loc); } -\| { return iw5::parser::make_BITWISE_OR(ctx->loc); } -\& { return iw5::parser::make_BITWISE_AND(ctx->loc); } -\^ { return iw5::parser::make_BITWISE_EXOR(ctx->loc); } -{RGX_PATH} { return iw5::parser::make_PATH(xsk::gsc::iw5::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -{RGX_IDENTIFIER} { return iw5::parser::make_IDENTIFIER(xsk::gsc::iw5::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -\&{RGX_STRING} { return iw5::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_STRING} { return iw5::parser::make_STRING(std::string(yytext), ctx->loc); } -{RGX_COLOR_S} { return iw5::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_COLOR_L} { return iw5::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_FLT_DEC} { return iw5::parser::make_FLOAT(std::string(yytext), ctx->loc); } -{RGX_INT_OCT} { return iw5::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } -{RGX_INT_BIN} { return iw5::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } -{RGX_INT_HEX} { return iw5::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } -{RGX_INT_DEC} { return iw5::parser::make_INTEGER(std::string(yytext), ctx->loc); } -<> { if(ctx->header_top > 0) iw5_pop_header(ctx); else return iw5::parser::make_IW5EOF(ctx->loc); } -<*>{RGX_DEFAULT} { throw iw5::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - -%% - -void iw5_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void iw5_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} diff --git a/gen/iw5/parser.ypp b/gen/iw5/parser.ypp index e7e02f09..0c8d504f 100644 --- a/gen/iw5/parser.ypp +++ b/gen/iw5/parser.ypp @@ -1,4 +1,4 @@ -/* Copyright 2021 xensik. All rights reserved. +/* Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,21 +19,15 @@ %define parse.trace %define parse.error detailed %define parse.lac full - %locations - -%lex-param { yyscan_t yyscanner } -%lex-param { xsk::gsc::context* ctx } - -%parse-param { yyscan_t yyscanner } -%parse-param { xsk::gsc::context* ctx } +%lex-param { xsk::gsc::iw5::lexer& lexer } +%parse-param { xsk::gsc::iw5::lexer& lexer } %parse-param { xsk::gsc::ast::program::ptr& ast } %code requires { #include "iw5.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::iw5 { class lexer; } } %code top @@ -42,7 +36,7 @@ typedef void *yyscan_t; #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::iw5::parser::symbol_type IW5lex(xsk::gsc::iw5::lexer& lexer); } %token DEVBEGIN "/#" @@ -266,7 +260,7 @@ program ; inline - : INLINE expr_path SEMICOLON { iw5_push_header(ctx, $2->value); } + : INLINE expr_path SEMICOLON { lexer.push_header($2->value); } ; include @@ -284,7 +278,7 @@ declaration decl_usingtree : USINGTREE LPAREN expr_string RPAREN SEMICOLON - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } ; decl_constant @@ -294,7 +288,7 @@ decl_constant decl_thread : expr_identifier LPAREN expr_parameters RPAREN stmt_block - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } ; stmt diff --git a/gen/iw6/Makefile b/gen/iw6/Makefile index ec92ac6a..9af53533 100644 --- a/gen/iw6/Makefile +++ b/gen/iw6/Makefile @@ -3,10 +3,7 @@ generate: IW6 clean: rm -rf ./parser.hpp rm -rf ./parser.cpp - rm -rf ./lexer.hpp - rm -rf ./lexer.cpp -IW6: lexer.lpp parser.ypp - flex lexer.lpp +IW6: parser.ypp bison parser.ypp -Wcounterexamples - mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/iw6/xsk/ + mv parser.hpp parser.cpp ../../src/iw6/xsk/ diff --git a/gen/iw6/lexer.lpp b/gen/iw6/lexer.lpp deleted file mode 100644 index dd1e2066..00000000 --- a/gen/iw6/lexer.lpp +++ /dev/null @@ -1,239 +0,0 @@ -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ - -%option outfile="lexer.cpp" -%option header-file="lexer.hpp" -%option prefix="iw6_" -%option reentrant -%option noyywrap batch nounput noinput -%option never-interactive -%option nounistd - -%top{ -#include "stdafx.hpp" -#include "iw6.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw6_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw6_pop_header(xsk::gsc::context* ctx); -} - -%{ -#define YY_USER_ACTION ctx->loc.columns(yyleng); -%} - -RGX_PATH ([_A-Za-z0-9]+\\)+[_A-Za-z0-9]+ -RGX_IDENTIFIER [_A-Za-z][_A-Za-z0-9]* -RGX_STRING \"(?:\\.|[^\"])*?\"|\'(?:\\.|[^\'])*?\' -RGX_COLOR_S #[0-9a-fA-F]{3} -RGX_COLOR_L #[0-9a-fA-F]{6} -RGX_FLT_DEC [0-9]+\.(?:[0-9]*)?f?|\.[0-9]+f? -RGX_INT_OCT 0[1-7][0-7]* -RGX_INT_BIN 0[bB][01]+ -RGX_INT_HEX 0[xX][0-9a-fA-F]+ -RGX_INT_DEC [0-9]+ -RGX_DEFAULT (.|\n) - -%x COMMENT_STATE -%x DEV_OFF_STATE -%s DEV_ON_STATE - -%% - -%{ - ctx->loc.step(); -%} - -[ \t\r] { ctx->loc.step(); } -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } - -"//".* - -"/*" { BEGIN(COMMENT_STATE); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"*/" { BEGIN(INITIAL); } -<> { throw iw6::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } -"*/" { throw iw6::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - -"/#" { throw iw6::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } -"#/" { BEGIN(INITIAL); return iw6::parser::make_DEVEND(ctx->loc); } -<> { throw iw6::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - -"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return iw6::parser::make_DEVBEGIN(ctx->loc); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"#/" { BEGIN(INITIAL); } -<> { throw iw6::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } -"#/" { throw iw6::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - -"#inline" { return iw6::parser::make_INLINE(ctx->loc); } -"#include" { return iw6::parser::make_INCLUDE(ctx->loc); } -"#using_animtree" { return iw6::parser::make_USINGTREE(ctx->loc); } -"#animtree" { return iw6::parser::make_ANIMTREE(ctx->loc); } -"endon" { return iw6::parser::make_ENDON(ctx->loc); } -"notify" { return iw6::parser::make_NOTIFY(ctx->loc); } -"wait" { return iw6::parser::make_WAIT(ctx->loc); } -"waittill" { return iw6::parser::make_WAITTILL(ctx->loc); } -"waittillmatch" { return iw6::parser::make_WAITTILLMATCH(ctx->loc); } -"waittillframeend" { return iw6::parser::make_WAITTILLFRAMEEND(ctx->loc); } -"if" { return iw6::parser::make_IF(ctx->loc); } -"else" { return iw6::parser::make_ELSE(ctx->loc); } -"do" { return iw6::parser::make_DO(ctx->loc); } -"while" { return iw6::parser::make_WHILE(ctx->loc); } -"for" { return iw6::parser::make_FOR(ctx->loc); } -"foreach" { return iw6::parser::make_FOREACH(ctx->loc); } -"in" { return iw6::parser::make_IN(ctx->loc); } -"switch" { return iw6::parser::make_SWITCH(ctx->loc); } -"case" { return iw6::parser::make_CASE(ctx->loc); } -"default" { return iw6::parser::make_DEFAULT(ctx->loc); } -"break" { return iw6::parser::make_BREAK(ctx->loc); } -"continue" { return iw6::parser::make_CONTINUE(ctx->loc); } -"return" { return iw6::parser::make_RETURN(ctx->loc); } -"breakpoint" { return iw6::parser::make_BREAKPOINT(ctx->loc); } -"prof_begin" { return iw6::parser::make_PROFBEGIN(ctx->loc); } -"prof_end" { return iw6::parser::make_PROFEND(ctx->loc); } -"thread" { return iw6::parser::make_THREAD(ctx->loc); } -"childthread" { return iw6::parser::make_CHILDTHREAD(ctx->loc); } -"thisthread" { return iw6::parser::make_THISTHREAD(ctx->loc); } -"call" { return iw6::parser::make_CALL(ctx->loc); } -"true" { return iw6::parser::make_TRUE(ctx->loc); } -"false" { return iw6::parser::make_FALSE(ctx->loc); } -"undefined" { return iw6::parser::make_UNDEFINED(ctx->loc); } -".size" { return iw6::parser::make_SIZE(ctx->loc); } -"game" { return iw6::parser::make_GAME(ctx->loc); } -"self" { return iw6::parser::make_SELF(ctx->loc); } -"anim" { return iw6::parser::make_ANIM(ctx->loc); } -"level" { return iw6::parser::make_LEVEL(ctx->loc); } -\( { return iw6::parser::make_LPAREN(ctx->loc); } -\) { return iw6::parser::make_RPAREN(ctx->loc); } -\{ { return iw6::parser::make_LBRACE(ctx->loc); } -\} { return iw6::parser::make_RBRACE(ctx->loc); } -\[ { return iw6::parser::make_LBRACKET(ctx->loc); } -\] { return iw6::parser::make_RBRACKET(ctx->loc); } -\, { return iw6::parser::make_COMMA(ctx->loc); } -\. { return iw6::parser::make_DOT(ctx->loc); } -\:\: { return iw6::parser::make_DOUBLECOLON(ctx->loc); } -\: { return iw6::parser::make_COLON(ctx->loc); } -\; { return iw6::parser::make_SEMICOLON(ctx->loc); } -\? { return iw6::parser::make_QMARK(ctx->loc); } -\+\+ { return iw6::parser::make_INCREMENT(ctx->loc); } -\-\- { return iw6::parser::make_DECREMENT(ctx->loc); } -\<\<\= { return iw6::parser::make_ASSIGN_LSHIFT(ctx->loc); } -\>\>\= { return iw6::parser::make_ASSIGN_RSHIFT(ctx->loc); } -\<\< { return iw6::parser::make_LSHIFT(ctx->loc); } -\>\> { return iw6::parser::make_RSHIFT(ctx->loc); } -\|\| { return iw6::parser::make_OR(ctx->loc); } -\&\& { return iw6::parser::make_AND(ctx->loc); } -\=\= { return iw6::parser::make_EQUALITY(ctx->loc); } -\!\= { return iw6::parser::make_INEQUALITY(ctx->loc); } -\<\= { return iw6::parser::make_LESS_EQUAL(ctx->loc); } -\>\= { return iw6::parser::make_GREATER_EQUAL(ctx->loc); } -\< { return iw6::parser::make_LESS(ctx->loc); } -\> { return iw6::parser::make_GREATER(ctx->loc); } -\+\= { return iw6::parser::make_ASSIGN_ADD(ctx->loc); } -\-\= { return iw6::parser::make_ASSIGN_SUB(ctx->loc); } -\*\= { return iw6::parser::make_ASSIGN_MUL(ctx->loc); } -\/\= { return iw6::parser::make_ASSIGN_DIV(ctx->loc); } -\%\= { return iw6::parser::make_ASSIGN_MOD(ctx->loc); } -\|\= { return iw6::parser::make_ASSIGN_BW_OR(ctx->loc); } -\&\= { return iw6::parser::make_ASSIGN_BW_AND(ctx->loc); } -\^\= { return iw6::parser::make_ASSIGN_BW_EXOR(ctx->loc); } -\= { return iw6::parser::make_ASSIGN(ctx->loc); } -\+ { return iw6::parser::make_ADD(ctx->loc); } -\- { return iw6::parser::make_SUB(ctx->loc); } -\* { return iw6::parser::make_MUL(ctx->loc); } -\/ { return iw6::parser::make_DIV(ctx->loc); } -\% { return iw6::parser::make_MOD(ctx->loc); } -\! { return iw6::parser::make_NOT(ctx->loc); } -\~ { return iw6::parser::make_COMPLEMENT(ctx->loc); } -\| { return iw6::parser::make_BITWISE_OR(ctx->loc); } -\& { return iw6::parser::make_BITWISE_AND(ctx->loc); } -\^ { return iw6::parser::make_BITWISE_EXOR(ctx->loc); } -{RGX_PATH} { return iw6::parser::make_PATH(xsk::gsc::iw6::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -{RGX_IDENTIFIER} { return iw6::parser::make_IDENTIFIER(xsk::gsc::iw6::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -\&{RGX_STRING} { return iw6::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_STRING} { return iw6::parser::make_STRING(std::string(yytext), ctx->loc); } -{RGX_COLOR_S} { return iw6::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_COLOR_L} { return iw6::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_FLT_DEC} { return iw6::parser::make_FLOAT(std::string(yytext), ctx->loc); } -{RGX_INT_OCT} { return iw6::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } -{RGX_INT_BIN} { return iw6::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } -{RGX_INT_HEX} { return iw6::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } -{RGX_INT_DEC} { return iw6::parser::make_INTEGER(std::string(yytext), ctx->loc); } -<> { if(ctx->header_top > 0) iw6_pop_header(ctx); else return iw6::parser::make_IW6EOF(ctx->loc); } -<*>{RGX_DEFAULT} { throw iw6::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - -%% - -void iw6_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void iw6_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} diff --git a/gen/iw6/parser.ypp b/gen/iw6/parser.ypp index f4286d3d..ec0e424e 100644 --- a/gen/iw6/parser.ypp +++ b/gen/iw6/parser.ypp @@ -1,4 +1,4 @@ -/* Copyright 2021 xensik. All rights reserved. +/* Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,21 +19,15 @@ %define parse.trace %define parse.error detailed %define parse.lac full - %locations - -%lex-param { yyscan_t yyscanner } -%lex-param { xsk::gsc::context* ctx } - -%parse-param { yyscan_t yyscanner } -%parse-param { xsk::gsc::context* ctx } +%lex-param { xsk::gsc::iw6::lexer& lexer } +%parse-param { xsk::gsc::iw6::lexer& lexer } %parse-param { xsk::gsc::ast::program::ptr& ast } %code requires { #include "iw6.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::iw6::parser::symbol_type IW6lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::iw6 { class lexer; } } %code top @@ -42,7 +36,7 @@ typedef void *yyscan_t; #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::iw6::parser::symbol_type IW6lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::iw6::parser::symbol_type IW6lex(xsk::gsc::iw6::lexer& lexer); } %token DEVBEGIN "/#" @@ -266,7 +260,7 @@ program ; inline - : INLINE expr_path SEMICOLON { iw6_push_header(ctx, $2->value); } + : INLINE expr_path SEMICOLON { lexer.push_header($2->value); } ; include @@ -284,7 +278,7 @@ declaration decl_usingtree : USINGTREE LPAREN expr_string RPAREN SEMICOLON - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } ; decl_constant @@ -294,7 +288,7 @@ decl_constant decl_thread : expr_identifier LPAREN expr_parameters RPAREN stmt_block - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } ; stmt diff --git a/gen/iw7/Makefile b/gen/iw7/Makefile index 0f32a238..4800d2a1 100644 --- a/gen/iw7/Makefile +++ b/gen/iw7/Makefile @@ -3,10 +3,7 @@ generate: IW7 clean: rm -rf ./parser.hpp rm -rf ./parser.cpp - rm -rf ./lexer.hpp - rm -rf ./lexer.cpp -IW7: lexer.lpp parser.ypp - flex lexer.lpp +IW7: parser.ypp bison parser.ypp -Wcounterexamples - mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/iw7/xsk/ + mv parser.hpp parser.cpp ../../src/iw7/xsk/ diff --git a/gen/iw7/lexer.lpp b/gen/iw7/lexer.lpp deleted file mode 100644 index fdcc2a66..00000000 --- a/gen/iw7/lexer.lpp +++ /dev/null @@ -1,239 +0,0 @@ -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ - -%option outfile="lexer.cpp" -%option header-file="lexer.hpp" -%option prefix="iw7_" -%option reentrant -%option noyywrap batch nounput noinput -%option never-interactive -%option nounistd - -%top{ -#include "stdafx.hpp" -#include "iw7.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw7_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw7_pop_header(xsk::gsc::context* ctx); -} - -%{ -#define YY_USER_ACTION ctx->loc.columns(yyleng); -%} - -RGX_PATH ([_A-Za-z0-9]+\\)+[_A-Za-z0-9]+ -RGX_IDENTIFIER [_A-Za-z][_A-Za-z0-9]* -RGX_STRING \"(?:\\.|[^\"])*?\"|\'(?:\\.|[^\'])*?\' -RGX_COLOR_S #[0-9a-fA-F]{3} -RGX_COLOR_L #[0-9a-fA-F]{6} -RGX_FLT_DEC [0-9]+\.(?:[0-9]*)?f?|\.[0-9]+f? -RGX_INT_OCT 0[1-7][0-7]* -RGX_INT_BIN 0[bB][01]+ -RGX_INT_HEX 0[xX][0-9a-fA-F]+ -RGX_INT_DEC [0-9]+ -RGX_DEFAULT (.|\n) - -%x COMMENT_STATE -%x DEV_OFF_STATE -%s DEV_ON_STATE - -%% - -%{ - ctx->loc.step(); -%} - -[ \t\r] { ctx->loc.step(); } -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } - -"//".* - -"/*" { BEGIN(COMMENT_STATE); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"*/" { BEGIN(INITIAL); } -<> { throw iw7::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } -"*/" { throw iw7::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - -"/#" { throw iw7::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } -"#/" { BEGIN(INITIAL); return iw7::parser::make_DEVEND(ctx->loc); } -<> { throw iw7::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - -"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return iw7::parser::make_DEVBEGIN(ctx->loc); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"#/" { BEGIN(INITIAL); } -<> { throw iw7::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } -"#/" { throw iw7::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - -"#inline" { return iw7::parser::make_INLINE(ctx->loc); } -"#include" { return iw7::parser::make_INCLUDE(ctx->loc); } -"#using_animtree" { return iw7::parser::make_USINGTREE(ctx->loc); } -"#animtree" { return iw7::parser::make_ANIMTREE(ctx->loc); } -"endon" { return iw7::parser::make_ENDON(ctx->loc); } -"notify" { return iw7::parser::make_NOTIFY(ctx->loc); } -"wait" { return iw7::parser::make_WAIT(ctx->loc); } -"waittill" { return iw7::parser::make_WAITTILL(ctx->loc); } -"waittillmatch" { return iw7::parser::make_WAITTILLMATCH(ctx->loc); } -"waittillframeend" { return iw7::parser::make_WAITTILLFRAMEEND(ctx->loc); } -"if" { return iw7::parser::make_IF(ctx->loc); } -"else" { return iw7::parser::make_ELSE(ctx->loc); } -"do" { return iw7::parser::make_DO(ctx->loc); } -"while" { return iw7::parser::make_WHILE(ctx->loc); } -"for" { return iw7::parser::make_FOR(ctx->loc); } -"foreach" { return iw7::parser::make_FOREACH(ctx->loc); } -"in" { return iw7::parser::make_IN(ctx->loc); } -"switch" { return iw7::parser::make_SWITCH(ctx->loc); } -"case" { return iw7::parser::make_CASE(ctx->loc); } -"default" { return iw7::parser::make_DEFAULT(ctx->loc); } -"break" { return iw7::parser::make_BREAK(ctx->loc); } -"continue" { return iw7::parser::make_CONTINUE(ctx->loc); } -"return" { return iw7::parser::make_RETURN(ctx->loc); } -"breakpoint" { return iw7::parser::make_BREAKPOINT(ctx->loc); } -"prof_begin" { return iw7::parser::make_PROFBEGIN(ctx->loc); } -"prof_end" { return iw7::parser::make_PROFEND(ctx->loc); } -"thread" { return iw7::parser::make_THREAD(ctx->loc); } -"childthread" { return iw7::parser::make_CHILDTHREAD(ctx->loc); } -"thisthread" { return iw7::parser::make_THISTHREAD(ctx->loc); } -"call" { return iw7::parser::make_CALL(ctx->loc); } -"true" { return iw7::parser::make_TRUE(ctx->loc); } -"false" { return iw7::parser::make_FALSE(ctx->loc); } -"undefined" { return iw7::parser::make_UNDEFINED(ctx->loc); } -".size" { return iw7::parser::make_SIZE(ctx->loc); } -"game" { return iw7::parser::make_GAME(ctx->loc); } -"self" { return iw7::parser::make_SELF(ctx->loc); } -"anim" { return iw7::parser::make_ANIM(ctx->loc); } -"level" { return iw7::parser::make_LEVEL(ctx->loc); } -\( { return iw7::parser::make_LPAREN(ctx->loc); } -\) { return iw7::parser::make_RPAREN(ctx->loc); } -\{ { return iw7::parser::make_LBRACE(ctx->loc); } -\} { return iw7::parser::make_RBRACE(ctx->loc); } -\[ { return iw7::parser::make_LBRACKET(ctx->loc); } -\] { return iw7::parser::make_RBRACKET(ctx->loc); } -\, { return iw7::parser::make_COMMA(ctx->loc); } -\. { return iw7::parser::make_DOT(ctx->loc); } -\:\: { return iw7::parser::make_DOUBLECOLON(ctx->loc); } -\: { return iw7::parser::make_COLON(ctx->loc); } -\; { return iw7::parser::make_SEMICOLON(ctx->loc); } -\? { return iw7::parser::make_QMARK(ctx->loc); } -\+\+ { return iw7::parser::make_INCREMENT(ctx->loc); } -\-\- { return iw7::parser::make_DECREMENT(ctx->loc); } -\<\<\= { return iw7::parser::make_ASSIGN_LSHIFT(ctx->loc); } -\>\>\= { return iw7::parser::make_ASSIGN_RSHIFT(ctx->loc); } -\<\< { return iw7::parser::make_LSHIFT(ctx->loc); } -\>\> { return iw7::parser::make_RSHIFT(ctx->loc); } -\|\| { return iw7::parser::make_OR(ctx->loc); } -\&\& { return iw7::parser::make_AND(ctx->loc); } -\=\= { return iw7::parser::make_EQUALITY(ctx->loc); } -\!\= { return iw7::parser::make_INEQUALITY(ctx->loc); } -\<\= { return iw7::parser::make_LESS_EQUAL(ctx->loc); } -\>\= { return iw7::parser::make_GREATER_EQUAL(ctx->loc); } -\< { return iw7::parser::make_LESS(ctx->loc); } -\> { return iw7::parser::make_GREATER(ctx->loc); } -\+\= { return iw7::parser::make_ASSIGN_ADD(ctx->loc); } -\-\= { return iw7::parser::make_ASSIGN_SUB(ctx->loc); } -\*\= { return iw7::parser::make_ASSIGN_MUL(ctx->loc); } -\/\= { return iw7::parser::make_ASSIGN_DIV(ctx->loc); } -\%\= { return iw7::parser::make_ASSIGN_MOD(ctx->loc); } -\|\= { return iw7::parser::make_ASSIGN_BW_OR(ctx->loc); } -\&\= { return iw7::parser::make_ASSIGN_BW_AND(ctx->loc); } -\^\= { return iw7::parser::make_ASSIGN_BW_EXOR(ctx->loc); } -\= { return iw7::parser::make_ASSIGN(ctx->loc); } -\+ { return iw7::parser::make_ADD(ctx->loc); } -\- { return iw7::parser::make_SUB(ctx->loc); } -\* { return iw7::parser::make_MUL(ctx->loc); } -\/ { return iw7::parser::make_DIV(ctx->loc); } -\% { return iw7::parser::make_MOD(ctx->loc); } -\! { return iw7::parser::make_NOT(ctx->loc); } -\~ { return iw7::parser::make_COMPLEMENT(ctx->loc); } -\| { return iw7::parser::make_BITWISE_OR(ctx->loc); } -\& { return iw7::parser::make_BITWISE_AND(ctx->loc); } -\^ { return iw7::parser::make_BITWISE_EXOR(ctx->loc); } -{RGX_PATH} { return iw7::parser::make_PATH(xsk::gsc::iw7::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -{RGX_IDENTIFIER} { return iw7::parser::make_IDENTIFIER(xsk::gsc::iw7::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -\&{RGX_STRING} { return iw7::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_STRING} { return iw7::parser::make_STRING(std::string(yytext), ctx->loc); } -{RGX_COLOR_S} { return iw7::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_COLOR_L} { return iw7::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_FLT_DEC} { return iw7::parser::make_FLOAT(std::string(yytext), ctx->loc); } -{RGX_INT_OCT} { return iw7::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } -{RGX_INT_BIN} { return iw7::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } -{RGX_INT_HEX} { return iw7::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } -{RGX_INT_DEC} { return iw7::parser::make_INTEGER(std::string(yytext), ctx->loc); } -<> { if(ctx->header_top > 0) iw7_pop_header(ctx); else return iw7::parser::make_IW7EOF(ctx->loc); } -<*>{RGX_DEFAULT} { throw iw7::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - -%% - -void iw7_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void iw7_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} diff --git a/gen/iw7/parser.ypp b/gen/iw7/parser.ypp index 595e0e53..665504f3 100644 --- a/gen/iw7/parser.ypp +++ b/gen/iw7/parser.ypp @@ -1,4 +1,4 @@ -/* Copyright 2021 xensik. All rights reserved. +/* Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,21 +19,15 @@ %define parse.trace %define parse.error detailed %define parse.lac full - %locations - -%lex-param { yyscan_t yyscanner } -%lex-param { xsk::gsc::context* ctx } - -%parse-param { yyscan_t yyscanner } -%parse-param { xsk::gsc::context* ctx } +%lex-param { xsk::gsc::iw7::lexer& lexer } +%parse-param { xsk::gsc::iw7::lexer& lexer } %parse-param { xsk::gsc::ast::program::ptr& ast } %code requires { #include "iw7.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::iw7::parser::symbol_type IW7lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::iw7 { class lexer; } } %code top @@ -42,7 +36,7 @@ typedef void *yyscan_t; #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::iw7::parser::symbol_type IW7lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::iw7::parser::symbol_type IW7lex(xsk::gsc::iw7::lexer& lexer); } %token DEVBEGIN "/#" @@ -266,7 +260,7 @@ program ; inline - : INLINE expr_path SEMICOLON { iw7_push_header(ctx, $2->value); } + : INLINE expr_path SEMICOLON { lexer.push_header($2->value); } ; include @@ -284,7 +278,7 @@ declaration decl_usingtree : USINGTREE LPAREN expr_string RPAREN SEMICOLON - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } ; decl_constant @@ -294,7 +288,7 @@ decl_constant decl_thread : expr_identifier LPAREN expr_parameters RPAREN stmt_block - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } ; stmt diff --git a/gen/iw8/Makefile b/gen/iw8/Makefile index b3556ba5..639b0170 100644 --- a/gen/iw8/Makefile +++ b/gen/iw8/Makefile @@ -3,10 +3,7 @@ generate: IW8 clean: rm -rf ./parser.hpp rm -rf ./parser.cpp - rm -rf ./lexer.hpp - rm -rf ./lexer.cpp -IW8: lexer.lpp parser.ypp - flex lexer.lpp +IW8: parser.ypp bison parser.ypp -Wcounterexamples - mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/iw8/xsk/ + mv parser.hpp parser.cpp ../../src/iw8/xsk/ diff --git a/gen/iw8/lexer.lpp b/gen/iw8/lexer.lpp deleted file mode 100644 index a606d534..00000000 --- a/gen/iw8/lexer.lpp +++ /dev/null @@ -1,242 +0,0 @@ -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ - -%option outfile="lexer.cpp" -%option header-file="lexer.hpp" -%option prefix="iw8_" -%option reentrant -%option noyywrap batch nounput noinput -%option never-interactive -%option nounistd - -%top{ -#include "stdafx.hpp" -#include "iw8.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw8_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw8_pop_header(xsk::gsc::context* ctx); -} - -%{ -#define YY_USER_ACTION ctx->loc.columns(yyleng); -%} - -RGX_PATH ([_A-Za-z0-9]+\\)+[_A-Za-z0-9]+ -RGX_IDENTIFIER [_A-Za-z][_A-Za-z0-9]* -RGX_STRING \"(?:\\.|[^\"])*?\"|\'(?:\\.|[^\'])*?\' -RGX_COLOR_S #[0-9a-fA-F]{3} -RGX_COLOR_L #[0-9a-fA-F]{6} -RGX_FLT_DEC [0-9]+\.(?:[0-9]*)?f?|\.[0-9]+f? -RGX_INT_OCT 0[1-7][0-7]* -RGX_INT_BIN 0[bB][01]+ -RGX_INT_HEX 0[xX][0-9a-fA-F]+ -RGX_INT_DEC [0-9]+ -RGX_DEFAULT (.|\n) - -%x COMMENT_STATE -%x DEV_OFF_STATE -%s DEV_ON_STATE - -%% - -%{ - ctx->loc.step(); -%} - -[ \t\r] { ctx->loc.step(); } -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } - -"//".* - -"/*" { BEGIN(COMMENT_STATE); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"*/" { BEGIN(INITIAL); } -<> { throw iw8::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } -"*/" { throw iw8::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - -"/#" { throw iw8::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } -"#/" { BEGIN(INITIAL); return iw8::parser::make_DEVEND(ctx->loc); } -<> { throw iw8::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - -"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return iw8::parser::make_DEVBEGIN(ctx->loc); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"#/" { BEGIN(INITIAL); } -<> { throw iw8::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } -"#/" { throw iw8::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - -"#inline" { return iw8::parser::make_INLINE(ctx->loc); } -"#include" { return iw8::parser::make_INCLUDE(ctx->loc); } -"#using_animtree" { return iw8::parser::make_USINGTREE(ctx->loc); } -"#animtree" { return iw8::parser::make_ANIMTREE(ctx->loc); } -"endon" { return iw8::parser::make_ENDON(ctx->loc); } -"notify" { return iw8::parser::make_NOTIFY(ctx->loc); } -"wait" { return iw8::parser::make_WAIT(ctx->loc); } -"waittill" { return iw8::parser::make_WAITTILL(ctx->loc); } -"waittillmatch" { return iw8::parser::make_WAITTILLMATCH(ctx->loc); } -"waittillframeend" { return iw8::parser::make_WAITTILLFRAMEEND(ctx->loc); } -"waitframe" { return iw8::parser::make_WAITFRAME(ctx->loc); } -"if" { return iw8::parser::make_IF(ctx->loc); } -"else" { return iw8::parser::make_ELSE(ctx->loc); } -"do" { return iw8::parser::make_DO(ctx->loc); } -"while" { return iw8::parser::make_WHILE(ctx->loc); } -"for" { return iw8::parser::make_FOR(ctx->loc); } -"foreach" { return iw8::parser::make_FOREACH(ctx->loc); } -"in" { return iw8::parser::make_IN(ctx->loc); } -"switch" { return iw8::parser::make_SWITCH(ctx->loc); } -"case" { return iw8::parser::make_CASE(ctx->loc); } -"default" { return iw8::parser::make_DEFAULT(ctx->loc); } -"break" { return iw8::parser::make_BREAK(ctx->loc); } -"continue" { return iw8::parser::make_CONTINUE(ctx->loc); } -"return" { return iw8::parser::make_RETURN(ctx->loc); } -"breakpoint" { return iw8::parser::make_BREAKPOINT(ctx->loc); } -"prof_begin" { return iw8::parser::make_PROFBEGIN(ctx->loc); } -"prof_end" { return iw8::parser::make_PROFEND(ctx->loc); } -"thread" { return iw8::parser::make_THREAD(ctx->loc); } -"childthread" { return iw8::parser::make_CHILDTHREAD(ctx->loc); } -"thisthread" { return iw8::parser::make_THISTHREAD(ctx->loc); } -"call" { return iw8::parser::make_CALL(ctx->loc); } -"true" { return iw8::parser::make_TRUE(ctx->loc); } -"false" { return iw8::parser::make_FALSE(ctx->loc); } -"undefined" { return iw8::parser::make_UNDEFINED(ctx->loc); } -".size" { return iw8::parser::make_SIZE(ctx->loc); } -"game" { return iw8::parser::make_GAME(ctx->loc); } -"self" { return iw8::parser::make_SELF(ctx->loc); } -"anim" { return iw8::parser::make_ANIM(ctx->loc); } -"level" { return iw8::parser::make_LEVEL(ctx->loc); } -(?i:isdefined) { return iw8::parser::make_ISDEFINED(ctx->loc); } -(?i:istrue) { return iw8::parser::make_ISTRUE(ctx->loc); } -\( { return iw8::parser::make_LPAREN(ctx->loc); } -\) { return iw8::parser::make_RPAREN(ctx->loc); } -\{ { return iw8::parser::make_LBRACE(ctx->loc); } -\} { return iw8::parser::make_RBRACE(ctx->loc); } -\[ { return iw8::parser::make_LBRACKET(ctx->loc); } -\] { return iw8::parser::make_RBRACKET(ctx->loc); } -\, { return iw8::parser::make_COMMA(ctx->loc); } -\. { return iw8::parser::make_DOT(ctx->loc); } -\:\: { return iw8::parser::make_DOUBLECOLON(ctx->loc); } -\: { return iw8::parser::make_COLON(ctx->loc); } -\; { return iw8::parser::make_SEMICOLON(ctx->loc); } -\? { return iw8::parser::make_QMARK(ctx->loc); } -\+\+ { return iw8::parser::make_INCREMENT(ctx->loc); } -\-\- { return iw8::parser::make_DECREMENT(ctx->loc); } -\<\<\= { return iw8::parser::make_ASSIGN_LSHIFT(ctx->loc); } -\>\>\= { return iw8::parser::make_ASSIGN_RSHIFT(ctx->loc); } -\<\< { return iw8::parser::make_LSHIFT(ctx->loc); } -\>\> { return iw8::parser::make_RSHIFT(ctx->loc); } -\|\| { return iw8::parser::make_OR(ctx->loc); } -\&\& { return iw8::parser::make_AND(ctx->loc); } -\=\= { return iw8::parser::make_EQUALITY(ctx->loc); } -\!\= { return iw8::parser::make_INEQUALITY(ctx->loc); } -\<\= { return iw8::parser::make_LESS_EQUAL(ctx->loc); } -\>\= { return iw8::parser::make_GREATER_EQUAL(ctx->loc); } -\< { return iw8::parser::make_LESS(ctx->loc); } -\> { return iw8::parser::make_GREATER(ctx->loc); } -\+\= { return iw8::parser::make_ASSIGN_ADD(ctx->loc); } -\-\= { return iw8::parser::make_ASSIGN_SUB(ctx->loc); } -\*\= { return iw8::parser::make_ASSIGN_MUL(ctx->loc); } -\/\= { return iw8::parser::make_ASSIGN_DIV(ctx->loc); } -\%\= { return iw8::parser::make_ASSIGN_MOD(ctx->loc); } -\|\= { return iw8::parser::make_ASSIGN_BW_OR(ctx->loc); } -\&\= { return iw8::parser::make_ASSIGN_BW_AND(ctx->loc); } -\^\= { return iw8::parser::make_ASSIGN_BW_EXOR(ctx->loc); } -\= { return iw8::parser::make_ASSIGN(ctx->loc); } -\+ { return iw8::parser::make_ADD(ctx->loc); } -\- { return iw8::parser::make_SUB(ctx->loc); } -\* { return iw8::parser::make_MUL(ctx->loc); } -\/ { return iw8::parser::make_DIV(ctx->loc); } -\% { return iw8::parser::make_MOD(ctx->loc); } -\! { return iw8::parser::make_NOT(ctx->loc); } -\~ { return iw8::parser::make_COMPLEMENT(ctx->loc); } -\| { return iw8::parser::make_BITWISE_OR(ctx->loc); } -\& { return iw8::parser::make_BITWISE_AND(ctx->loc); } -\^ { return iw8::parser::make_BITWISE_EXOR(ctx->loc); } -{RGX_PATH} { return iw8::parser::make_PATH(xsk::gsc::iw8::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -{RGX_IDENTIFIER} { return iw8::parser::make_IDENTIFIER(xsk::gsc::iw8::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -\&{RGX_STRING} { return iw8::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_STRING} { return iw8::parser::make_STRING(std::string(yytext), ctx->loc); } -{RGX_COLOR_S} { return iw8::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_COLOR_L} { return iw8::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_FLT_DEC} { return iw8::parser::make_FLOAT(std::string(yytext), ctx->loc); } -{RGX_INT_OCT} { return iw8::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } -{RGX_INT_BIN} { return iw8::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } -{RGX_INT_HEX} { return iw8::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } -{RGX_INT_DEC} { return iw8::parser::make_INTEGER(std::string(yytext), ctx->loc); } -<> { if(ctx->header_top > 0) iw8_pop_header(ctx); else return iw8::parser::make_IW8EOF(ctx->loc); } -<*>{RGX_DEFAULT} { throw iw8::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - -%% - -void iw8_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void iw8_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} diff --git a/gen/iw8/parser.ypp b/gen/iw8/parser.ypp index 35819996..4a06432b 100644 --- a/gen/iw8/parser.ypp +++ b/gen/iw8/parser.ypp @@ -1,4 +1,4 @@ -/* Copyright 2021 xensik. All rights reserved. +/* Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,21 +19,15 @@ %define parse.trace %define parse.error detailed %define parse.lac full - %locations - -%lex-param { yyscan_t yyscanner } -%lex-param { xsk::gsc::context* ctx } - -%parse-param { yyscan_t yyscanner } -%parse-param { xsk::gsc::context* ctx } +%lex-param { xsk::gsc::iw8::lexer& lexer } +%parse-param { xsk::gsc::iw8::lexer& lexer } %parse-param { xsk::gsc::ast::program::ptr& ast } %code requires { #include "iw8.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::iw8::parser::symbol_type IW8lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::iw8 { class lexer; } } %code top @@ -42,7 +36,7 @@ typedef void *yyscan_t; #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::iw8::parser::symbol_type IW8lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::iw8::parser::symbol_type IW8lex(xsk::gsc::iw8::lexer& lexer); } %token DEVBEGIN "/#" @@ -272,7 +266,7 @@ program ; inline - : INLINE expr_path SEMICOLON { iw8_push_header(ctx, $2->value); } + : INLINE expr_path SEMICOLON { lexer.push_header($2->value); } ; include @@ -290,7 +284,7 @@ declaration decl_usingtree : USINGTREE LPAREN expr_string RPAREN SEMICOLON - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } ; decl_constant @@ -300,7 +294,7 @@ decl_constant decl_thread : expr_identifier LPAREN expr_parameters RPAREN stmt_block - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } ; stmt diff --git a/gen/s1/Makefile b/gen/s1/Makefile index 384f64ef..c7c9fdf6 100644 --- a/gen/s1/Makefile +++ b/gen/s1/Makefile @@ -3,10 +3,7 @@ generate: S1 clean: rm -rf ./parser.hpp rm -rf ./parser.cpp - rm -rf ./lexer.hpp - rm -rf ./lexer.cpp -S1: lexer.lpp parser.ypp - flex lexer.lpp +S1: parser.ypp bison parser.ypp -Wcounterexamples - mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/s1/xsk/ + mv parser.hpp parser.cpp ../../src/s1/xsk/ diff --git a/gen/s1/lexer.lpp b/gen/s1/lexer.lpp deleted file mode 100644 index 0e954065..00000000 --- a/gen/s1/lexer.lpp +++ /dev/null @@ -1,240 +0,0 @@ -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ - -%option outfile="lexer.cpp" -%option header-file="lexer.hpp" -%option prefix="s1_" -%option reentrant -%option noyywrap batch nounput noinput -%option never-interactive -%option nounistd - -%top{ -#include "stdafx.hpp" -#include "s1.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void s1_push_header(xsk::gsc::context* ctx, const std::string& file); -void s1_pop_header(xsk::gsc::context* ctx); -} - -%{ -#define YY_USER_ACTION ctx->loc.columns(yyleng); -%} - -RGX_PATH ([_A-Za-z0-9]+\\)+[_A-Za-z0-9]+ -RGX_IDENTIFIER [_A-Za-z][_A-Za-z0-9]* -RGX_STRING \"(?:\\.|[^\"])*?\"|\'(?:\\.|[^\'])*?\' -RGX_COLOR_S #[0-9a-fA-F]{3} -RGX_COLOR_L #[0-9a-fA-F]{6} -RGX_FLT_DEC [0-9]+\.(?:[0-9]*)?f?|\.[0-9]+f? -RGX_INT_OCT 0[1-7][0-7]* -RGX_INT_BIN 0[bB][01]+ -RGX_INT_HEX 0[xX][0-9a-fA-F]+ -RGX_INT_DEC [0-9]+ -RGX_DEFAULT (.|\n) - -%x COMMENT_STATE -%x DEV_OFF_STATE -%s DEV_ON_STATE - -%% - -%{ - ctx->loc.step(); -%} - -[ \t\r] { ctx->loc.step(); } -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } - -"//".* - -"/*" { BEGIN(COMMENT_STATE); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"*/" { BEGIN(INITIAL); } -<> { throw s1::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } -"*/" { throw s1::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - -"/#" { throw s1::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } -"#/" { BEGIN(INITIAL); return s1::parser::make_DEVEND(ctx->loc); } -<> { throw s1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - -"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return s1::parser::make_DEVBEGIN(ctx->loc); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"#/" { BEGIN(INITIAL); } -<> { throw s1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } -"#/" { throw s1::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - -"#inline" { return s1::parser::make_INLINE(ctx->loc); } -"#include" { return s1::parser::make_INCLUDE(ctx->loc); } -"#using_animtree" { return s1::parser::make_USINGTREE(ctx->loc); } -"#animtree" { return s1::parser::make_ANIMTREE(ctx->loc); } -"endon" { return s1::parser::make_ENDON(ctx->loc); } -"notify" { return s1::parser::make_NOTIFY(ctx->loc); } -"wait" { return s1::parser::make_WAIT(ctx->loc); } -"waittill" { return s1::parser::make_WAITTILL(ctx->loc); } -"waittillmatch" { return s1::parser::make_WAITTILLMATCH(ctx->loc); } -"waittillframeend" { return s1::parser::make_WAITTILLFRAMEEND(ctx->loc); } -"waitframe" { return s1::parser::make_WAITFRAME(ctx->loc); } -"if" { return s1::parser::make_IF(ctx->loc); } -"else" { return s1::parser::make_ELSE(ctx->loc); } -"do" { return s1::parser::make_DO(ctx->loc); } -"while" { return s1::parser::make_WHILE(ctx->loc); } -"for" { return s1::parser::make_FOR(ctx->loc); } -"foreach" { return s1::parser::make_FOREACH(ctx->loc); } -"in" { return s1::parser::make_IN(ctx->loc); } -"switch" { return s1::parser::make_SWITCH(ctx->loc); } -"case" { return s1::parser::make_CASE(ctx->loc); } -"default" { return s1::parser::make_DEFAULT(ctx->loc); } -"break" { return s1::parser::make_BREAK(ctx->loc); } -"continue" { return s1::parser::make_CONTINUE(ctx->loc); } -"return" { return s1::parser::make_RETURN(ctx->loc); } -"breakpoint" { return s1::parser::make_BREAKPOINT(ctx->loc); } -"prof_begin" { return s1::parser::make_PROFBEGIN(ctx->loc); } -"prof_end" { return s1::parser::make_PROFEND(ctx->loc); } -"thread" { return s1::parser::make_THREAD(ctx->loc); } -"childthread" { return s1::parser::make_CHILDTHREAD(ctx->loc); } -"thisthread" { return s1::parser::make_THISTHREAD(ctx->loc); } -"call" { return s1::parser::make_CALL(ctx->loc); } -"true" { return s1::parser::make_TRUE(ctx->loc); } -"false" { return s1::parser::make_FALSE(ctx->loc); } -"undefined" { return s1::parser::make_UNDEFINED(ctx->loc); } -".size" { return s1::parser::make_SIZE(ctx->loc); } -"game" { return s1::parser::make_GAME(ctx->loc); } -"self" { return s1::parser::make_SELF(ctx->loc); } -"anim" { return s1::parser::make_ANIM(ctx->loc); } -"level" { return s1::parser::make_LEVEL(ctx->loc); } -\( { return s1::parser::make_LPAREN(ctx->loc); } -\) { return s1::parser::make_RPAREN(ctx->loc); } -\{ { return s1::parser::make_LBRACE(ctx->loc); } -\} { return s1::parser::make_RBRACE(ctx->loc); } -\[ { return s1::parser::make_LBRACKET(ctx->loc); } -\] { return s1::parser::make_RBRACKET(ctx->loc); } -\, { return s1::parser::make_COMMA(ctx->loc); } -\. { return s1::parser::make_DOT(ctx->loc); } -\:\: { return s1::parser::make_DOUBLECOLON(ctx->loc); } -\: { return s1::parser::make_COLON(ctx->loc); } -\; { return s1::parser::make_SEMICOLON(ctx->loc); } -\? { return s1::parser::make_QMARK(ctx->loc); } -\+\+ { return s1::parser::make_INCREMENT(ctx->loc); } -\-\- { return s1::parser::make_DECREMENT(ctx->loc); } -\<\<\= { return s1::parser::make_ASSIGN_LSHIFT(ctx->loc); } -\>\>\= { return s1::parser::make_ASSIGN_RSHIFT(ctx->loc); } -\<\< { return s1::parser::make_LSHIFT(ctx->loc); } -\>\> { return s1::parser::make_RSHIFT(ctx->loc); } -\|\| { return s1::parser::make_OR(ctx->loc); } -\&\& { return s1::parser::make_AND(ctx->loc); } -\=\= { return s1::parser::make_EQUALITY(ctx->loc); } -\!\= { return s1::parser::make_INEQUALITY(ctx->loc); } -\<\= { return s1::parser::make_LESS_EQUAL(ctx->loc); } -\>\= { return s1::parser::make_GREATER_EQUAL(ctx->loc); } -\< { return s1::parser::make_LESS(ctx->loc); } -\> { return s1::parser::make_GREATER(ctx->loc); } -\+\= { return s1::parser::make_ASSIGN_ADD(ctx->loc); } -\-\= { return s1::parser::make_ASSIGN_SUB(ctx->loc); } -\*\= { return s1::parser::make_ASSIGN_MUL(ctx->loc); } -\/\= { return s1::parser::make_ASSIGN_DIV(ctx->loc); } -\%\= { return s1::parser::make_ASSIGN_MOD(ctx->loc); } -\|\= { return s1::parser::make_ASSIGN_BW_OR(ctx->loc); } -\&\= { return s1::parser::make_ASSIGN_BW_AND(ctx->loc); } -\^\= { return s1::parser::make_ASSIGN_BW_EXOR(ctx->loc); } -\= { return s1::parser::make_ASSIGN(ctx->loc); } -\+ { return s1::parser::make_ADD(ctx->loc); } -\- { return s1::parser::make_SUB(ctx->loc); } -\* { return s1::parser::make_MUL(ctx->loc); } -\/ { return s1::parser::make_DIV(ctx->loc); } -\% { return s1::parser::make_MOD(ctx->loc); } -\! { return s1::parser::make_NOT(ctx->loc); } -\~ { return s1::parser::make_COMPLEMENT(ctx->loc); } -\| { return s1::parser::make_BITWISE_OR(ctx->loc); } -\& { return s1::parser::make_BITWISE_AND(ctx->loc); } -\^ { return s1::parser::make_BITWISE_EXOR(ctx->loc); } -{RGX_PATH} { return s1::parser::make_PATH(xsk::gsc::s1::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -{RGX_IDENTIFIER} { return s1::parser::make_IDENTIFIER(xsk::gsc::s1::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -\&{RGX_STRING} { return s1::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_STRING} { return s1::parser::make_STRING(std::string(yytext), ctx->loc); } -{RGX_COLOR_S} { return s1::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_COLOR_L} { return s1::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_FLT_DEC} { return s1::parser::make_FLOAT(std::string(yytext), ctx->loc); } -{RGX_INT_OCT} { return s1::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } -{RGX_INT_BIN} { return s1::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } -{RGX_INT_HEX} { return s1::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } -{RGX_INT_DEC} { return s1::parser::make_INTEGER(std::string(yytext), ctx->loc); } -<> { if(ctx->header_top > 0) s1_pop_header(ctx); else return s1::parser::make_S1EOF(ctx->loc); } -<*>{RGX_DEFAULT} { throw s1::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - -%% - -void s1_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void s1_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} diff --git a/gen/s1/parser.ypp b/gen/s1/parser.ypp index b7601027..fa7218af 100644 --- a/gen/s1/parser.ypp +++ b/gen/s1/parser.ypp @@ -1,4 +1,4 @@ -/* Copyright 2021 xensik. All rights reserved. +/* Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,21 +19,15 @@ %define parse.trace %define parse.error detailed %define parse.lac full - %locations - -%lex-param { yyscan_t yyscanner } -%lex-param { xsk::gsc::context* ctx } - -%parse-param { yyscan_t yyscanner } -%parse-param { xsk::gsc::context* ctx } +%lex-param { xsk::gsc::s1::lexer& lexer } +%parse-param { xsk::gsc::s1::lexer& lexer } %parse-param { xsk::gsc::ast::program::ptr& ast } %code requires { #include "s1.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::s1::parser::symbol_type S1lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::s1 { class lexer; } } %code top @@ -42,7 +36,7 @@ typedef void *yyscan_t; #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::s1::parser::symbol_type S1lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::s1::parser::symbol_type S1lex(xsk::gsc::s1::lexer& lexer); } %token DEVBEGIN "/#" @@ -268,7 +262,7 @@ program ; inline - : INLINE expr_path SEMICOLON { s1_push_header(ctx, $2->value); } + : INLINE expr_path SEMICOLON { lexer.push_header($2->value); } ; include @@ -286,7 +280,7 @@ declaration decl_usingtree : USINGTREE LPAREN expr_string RPAREN SEMICOLON - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } ; decl_constant @@ -296,7 +290,7 @@ decl_constant decl_thread : expr_identifier LPAREN expr_parameters RPAREN stmt_block - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } ; stmt diff --git a/gen/s2/Makefile b/gen/s2/Makefile index ac50f47e..21e6155f 100644 --- a/gen/s2/Makefile +++ b/gen/s2/Makefile @@ -3,10 +3,7 @@ generate: S2 clean: rm -rf ./parser.hpp rm -rf ./parser.cpp - rm -rf ./lexer.hpp - rm -rf ./lexer.cpp -S2: lexer.lpp parser.ypp - flex lexer.lpp +S2: parser.ypp bison parser.ypp -Wcounterexamples - mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/s2/xsk/ + mv parser.hpp parser.cpp ../../src/s2/xsk/ diff --git a/gen/s2/lexer.lpp b/gen/s2/lexer.lpp deleted file mode 100644 index 37e6010f..00000000 --- a/gen/s2/lexer.lpp +++ /dev/null @@ -1,240 +0,0 @@ -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ - -%option outfile="lexer.cpp" -%option header-file="lexer.hpp" -%option prefix="s2_" -%option reentrant -%option noyywrap batch nounput noinput -%option never-interactive -%option nounistd - -%top{ -#include "stdafx.hpp" -#include "s2.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void s2_push_header(xsk::gsc::context* ctx, const std::string& file); -void s2_pop_header(xsk::gsc::context* ctx); -} - -%{ -#define YY_USER_ACTION ctx->loc.columns(yyleng); -%} - -RGX_PATH ([_A-Za-z0-9]+\\)+[_A-Za-z0-9]+ -RGX_IDENTIFIER [_A-Za-z][_A-Za-z0-9]* -RGX_STRING \"(?:\\.|[^\"])*?\"|\'(?:\\.|[^\'])*?\' -RGX_COLOR_S #[0-9a-fA-F]{3} -RGX_COLOR_L #[0-9a-fA-F]{6} -RGX_FLT_DEC [0-9]+\.(?:[0-9]*)?f?|\.[0-9]+f? -RGX_INT_OCT 0[1-7][0-7]* -RGX_INT_BIN 0[bB][01]+ -RGX_INT_HEX 0[xX][0-9a-fA-F]+ -RGX_INT_DEC [0-9]+ -RGX_DEFAULT (.|\n) - -%x COMMENT_STATE -%x DEV_OFF_STATE -%s DEV_ON_STATE - -%% - -%{ - ctx->loc.step(); -%} - -[ \t\r] { ctx->loc.step(); } -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } - -"//".* - -"/*" { BEGIN(COMMENT_STATE); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"*/" { BEGIN(INITIAL); } -<> { throw s2::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } -"*/" { throw s2::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - -"/#" { throw s2::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } -"#/" { BEGIN(INITIAL); return s2::parser::make_DEVEND(ctx->loc); } -<> { throw s2::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - -"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return s2::parser::make_DEVBEGIN(ctx->loc); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"#/" { BEGIN(INITIAL); } -<> { throw s2::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } -"#/" { throw s2::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - -"#inline" { return s2::parser::make_INLINE(ctx->loc); } -"#include" { return s2::parser::make_INCLUDE(ctx->loc); } -"#using_animtree" { return s2::parser::make_USINGTREE(ctx->loc); } -"#animtree" { return s2::parser::make_ANIMTREE(ctx->loc); } -"endon" { return s2::parser::make_ENDON(ctx->loc); } -"notify" { return s2::parser::make_NOTIFY(ctx->loc); } -"wait" { return s2::parser::make_WAIT(ctx->loc); } -"waittill" { return s2::parser::make_WAITTILL(ctx->loc); } -"waittillmatch" { return s2::parser::make_WAITTILLMATCH(ctx->loc); } -"waittillframeend" { return s2::parser::make_WAITTILLFRAMEEND(ctx->loc); } -"waitframe" { return s2::parser::make_WAITFRAME(ctx->loc); } -"if" { return s2::parser::make_IF(ctx->loc); } -"else" { return s2::parser::make_ELSE(ctx->loc); } -"do" { return s2::parser::make_DO(ctx->loc); } -"while" { return s2::parser::make_WHILE(ctx->loc); } -"for" { return s2::parser::make_FOR(ctx->loc); } -"foreach" { return s2::parser::make_FOREACH(ctx->loc); } -"in" { return s2::parser::make_IN(ctx->loc); } -"switch" { return s2::parser::make_SWITCH(ctx->loc); } -"case" { return s2::parser::make_CASE(ctx->loc); } -"default" { return s2::parser::make_DEFAULT(ctx->loc); } -"break" { return s2::parser::make_BREAK(ctx->loc); } -"continue" { return s2::parser::make_CONTINUE(ctx->loc); } -"return" { return s2::parser::make_RETURN(ctx->loc); } -"breakpoint" { return s2::parser::make_BREAKPOINT(ctx->loc); } -"prof_begin" { return s2::parser::make_PROFBEGIN(ctx->loc); } -"prof_end" { return s2::parser::make_PROFEND(ctx->loc); } -"thread" { return s2::parser::make_THREAD(ctx->loc); } -"childthread" { return s2::parser::make_CHILDTHREAD(ctx->loc); } -"thisthread" { return s2::parser::make_THISTHREAD(ctx->loc); } -"call" { return s2::parser::make_CALL(ctx->loc); } -"true" { return s2::parser::make_TRUE(ctx->loc); } -"false" { return s2::parser::make_FALSE(ctx->loc); } -"undefined" { return s2::parser::make_UNDEFINED(ctx->loc); } -".size" { return s2::parser::make_SIZE(ctx->loc); } -"game" { return s2::parser::make_GAME(ctx->loc); } -"self" { return s2::parser::make_SELF(ctx->loc); } -"anim" { return s2::parser::make_ANIM(ctx->loc); } -"level" { return s2::parser::make_LEVEL(ctx->loc); } -\( { return s2::parser::make_LPAREN(ctx->loc); } -\) { return s2::parser::make_RPAREN(ctx->loc); } -\{ { return s2::parser::make_LBRACE(ctx->loc); } -\} { return s2::parser::make_RBRACE(ctx->loc); } -\[ { return s2::parser::make_LBRACKET(ctx->loc); } -\] { return s2::parser::make_RBRACKET(ctx->loc); } -\, { return s2::parser::make_COMMA(ctx->loc); } -\. { return s2::parser::make_DOT(ctx->loc); } -\:\: { return s2::parser::make_DOUBLECOLON(ctx->loc); } -\: { return s2::parser::make_COLON(ctx->loc); } -\; { return s2::parser::make_SEMICOLON(ctx->loc); } -\? { return s2::parser::make_QMARK(ctx->loc); } -\+\+ { return s2::parser::make_INCREMENT(ctx->loc); } -\-\- { return s2::parser::make_DECREMENT(ctx->loc); } -\<\<\= { return s2::parser::make_ASSIGN_LSHIFT(ctx->loc); } -\>\>\= { return s2::parser::make_ASSIGN_RSHIFT(ctx->loc); } -\<\< { return s2::parser::make_LSHIFT(ctx->loc); } -\>\> { return s2::parser::make_RSHIFT(ctx->loc); } -\|\| { return s2::parser::make_OR(ctx->loc); } -\&\& { return s2::parser::make_AND(ctx->loc); } -\=\= { return s2::parser::make_EQUALITY(ctx->loc); } -\!\= { return s2::parser::make_INEQUALITY(ctx->loc); } -\<\= { return s2::parser::make_LESS_EQUAL(ctx->loc); } -\>\= { return s2::parser::make_GREATER_EQUAL(ctx->loc); } -\< { return s2::parser::make_LESS(ctx->loc); } -\> { return s2::parser::make_GREATER(ctx->loc); } -\+\= { return s2::parser::make_ASSIGN_ADD(ctx->loc); } -\-\= { return s2::parser::make_ASSIGN_SUB(ctx->loc); } -\*\= { return s2::parser::make_ASSIGN_MUL(ctx->loc); } -\/\= { return s2::parser::make_ASSIGN_DIV(ctx->loc); } -\%\= { return s2::parser::make_ASSIGN_MOD(ctx->loc); } -\|\= { return s2::parser::make_ASSIGN_BW_OR(ctx->loc); } -\&\= { return s2::parser::make_ASSIGN_BW_AND(ctx->loc); } -\^\= { return s2::parser::make_ASSIGN_BW_EXOR(ctx->loc); } -\= { return s2::parser::make_ASSIGN(ctx->loc); } -\+ { return s2::parser::make_ADD(ctx->loc); } -\- { return s2::parser::make_SUB(ctx->loc); } -\* { return s2::parser::make_MUL(ctx->loc); } -\/ { return s2::parser::make_DIV(ctx->loc); } -\% { return s2::parser::make_MOD(ctx->loc); } -\! { return s2::parser::make_NOT(ctx->loc); } -\~ { return s2::parser::make_COMPLEMENT(ctx->loc); } -\| { return s2::parser::make_BITWISE_OR(ctx->loc); } -\& { return s2::parser::make_BITWISE_AND(ctx->loc); } -\^ { return s2::parser::make_BITWISE_EXOR(ctx->loc); } -{RGX_PATH} { return s2::parser::make_PATH(xsk::gsc::s2::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -{RGX_IDENTIFIER} { return s2::parser::make_IDENTIFIER(xsk::gsc::s2::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -\&{RGX_STRING} { return s2::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_STRING} { return s2::parser::make_STRING(std::string(yytext), ctx->loc); } -{RGX_COLOR_S} { return s2::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_COLOR_L} { return s2::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_FLT_DEC} { return s2::parser::make_FLOAT(std::string(yytext), ctx->loc); } -{RGX_INT_OCT} { return s2::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } -{RGX_INT_BIN} { return s2::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } -{RGX_INT_HEX} { return s2::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } -{RGX_INT_DEC} { return s2::parser::make_INTEGER(std::string(yytext), ctx->loc); } -<> { if(ctx->header_top > 0) s2_pop_header(ctx); else return s2::parser::make_S2EOF(ctx->loc); } -<*>{RGX_DEFAULT} { throw s2::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - -%% - -void s2_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void s2_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} diff --git a/gen/s2/parser.ypp b/gen/s2/parser.ypp index 111b00cd..5ff46e34 100644 --- a/gen/s2/parser.ypp +++ b/gen/s2/parser.ypp @@ -1,4 +1,4 @@ -/* Copyright 2021 xensik. All rights reserved. +/* Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,21 +19,15 @@ %define parse.trace %define parse.error detailed %define parse.lac full - %locations - -%lex-param { yyscan_t yyscanner } -%lex-param { xsk::gsc::context* ctx } - -%parse-param { yyscan_t yyscanner } -%parse-param { xsk::gsc::context* ctx } +%lex-param { xsk::gsc::s2::lexer& lexer } +%parse-param { xsk::gsc::s2::lexer& lexer } %parse-param { xsk::gsc::ast::program::ptr& ast } %code requires { #include "s2.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::s2::parser::symbol_type S2lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::s2 { class lexer; } } %code top @@ -42,7 +36,7 @@ typedef void *yyscan_t; #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::s2::parser::symbol_type S2lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::s2::parser::symbol_type S2lex(xsk::gsc::s2::lexer& lexer); } %token DEVBEGIN "/#" @@ -268,7 +262,7 @@ program ; inline - : INLINE expr_path SEMICOLON { s2_push_header(ctx, $2->value); } + : INLINE expr_path SEMICOLON { lexer.push_header($2->value); } ; include @@ -286,7 +280,7 @@ declaration decl_usingtree : USINGTREE LPAREN expr_string RPAREN SEMICOLON - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } ; decl_constant @@ -296,7 +290,7 @@ decl_constant decl_thread : expr_identifier LPAREN expr_parameters RPAREN stmt_block - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } ; stmt diff --git a/gen/s4/Makefile b/gen/s4/Makefile index d1a04da6..7b55e700 100644 --- a/gen/s4/Makefile +++ b/gen/s4/Makefile @@ -3,10 +3,7 @@ generate: S4 clean: rm -rf ./parser.hpp rm -rf ./parser.cpp - rm -rf ./lexer.hpp - rm -rf ./lexer.cpp -S4: lexer.lpp parser.ypp - flex lexer.lpp +S4: parser.ypp bison parser.ypp -Wcounterexamples - mv lexer.hpp lexer.cpp parser.hpp parser.cpp ../../src/s4/xsk/ + mv parser.hpp parser.cpp ../../src/s4/xsk/ diff --git a/gen/s4/lexer.lpp b/gen/s4/lexer.lpp deleted file mode 100644 index c6254603..00000000 --- a/gen/s4/lexer.lpp +++ /dev/null @@ -1,242 +0,0 @@ -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ - -%option outfile="lexer.cpp" -%option header-file="lexer.hpp" -%option prefix="s4_" -%option reentrant -%option noyywrap batch nounput noinput -%option never-interactive -%option nounistd - -%top{ -#include "stdafx.hpp" -#include "s4.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void s4_push_header(xsk::gsc::context* ctx, const std::string& file); -void s4_pop_header(xsk::gsc::context* ctx); -} - -%{ -#define YY_USER_ACTION ctx->loc.columns(yyleng); -%} - -RGX_PATH ([_A-Za-z0-9]+\\)+[_A-Za-z0-9]+ -RGX_IDENTIFIER [_A-Za-z][_A-Za-z0-9]* -RGX_STRING \"(?:\\.|[^\"])*?\"|\'(?:\\.|[^\'])*?\' -RGX_COLOR_S #[0-9a-fA-F]{3} -RGX_COLOR_L #[0-9a-fA-F]{6} -RGX_FLT_DEC [0-9]+\.(?:[0-9]*)?f?|\.[0-9]+f? -RGX_INT_OCT 0[1-7][0-7]* -RGX_INT_BIN 0[bB][01]+ -RGX_INT_HEX 0[xX][0-9a-fA-F]+ -RGX_INT_DEC [0-9]+ -RGX_DEFAULT (.|\n) - -%x COMMENT_STATE -%x DEV_OFF_STATE -%s DEV_ON_STATE - -%% - -%{ - ctx->loc.step(); -%} - -[ \t\r] { ctx->loc.step(); } -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } - -"//".* - -"/*" { BEGIN(COMMENT_STATE); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"*/" { BEGIN(INITIAL); } -<> { throw s4::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } -"*/" { throw s4::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - -"/#" { throw s4::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } -"#/" { BEGIN(INITIAL); return s4::parser::make_DEVEND(ctx->loc); } -<> { throw s4::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - -"/#" { BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return s4::parser::make_DEVBEGIN(ctx->loc); } -. -\n { ctx->loc.lines(yyleng); ctx->loc.step(); } -"#/" { BEGIN(INITIAL); } -<> { throw s4::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } -"#/" { throw s4::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - -"#inline" { return s4::parser::make_INLINE(ctx->loc); } -"#include" { return s4::parser::make_INCLUDE(ctx->loc); } -"#using_animtree" { return s4::parser::make_USINGTREE(ctx->loc); } -"#animtree" { return s4::parser::make_ANIMTREE(ctx->loc); } -"endon" { return s4::parser::make_ENDON(ctx->loc); } -"notify" { return s4::parser::make_NOTIFY(ctx->loc); } -"wait" { return s4::parser::make_WAIT(ctx->loc); } -"waittill" { return s4::parser::make_WAITTILL(ctx->loc); } -"waittillmatch" { return s4::parser::make_WAITTILLMATCH(ctx->loc); } -"waittillframeend" { return s4::parser::make_WAITTILLFRAMEEND(ctx->loc); } -"waitframe" { return s4::parser::make_WAITFRAME(ctx->loc); } -"if" { return s4::parser::make_IF(ctx->loc); } -"else" { return s4::parser::make_ELSE(ctx->loc); } -"do" { return s4::parser::make_DO(ctx->loc); } -"while" { return s4::parser::make_WHILE(ctx->loc); } -"for" { return s4::parser::make_FOR(ctx->loc); } -"foreach" { return s4::parser::make_FOREACH(ctx->loc); } -"in" { return s4::parser::make_IN(ctx->loc); } -"switch" { return s4::parser::make_SWITCH(ctx->loc); } -"case" { return s4::parser::make_CASE(ctx->loc); } -"default" { return s4::parser::make_DEFAULT(ctx->loc); } -"break" { return s4::parser::make_BREAK(ctx->loc); } -"continue" { return s4::parser::make_CONTINUE(ctx->loc); } -"return" { return s4::parser::make_RETURN(ctx->loc); } -"breakpoint" { return s4::parser::make_BREAKPOINT(ctx->loc); } -"prof_begin" { return s4::parser::make_PROFBEGIN(ctx->loc); } -"prof_end" { return s4::parser::make_PROFEND(ctx->loc); } -"thread" { return s4::parser::make_THREAD(ctx->loc); } -"childthread" { return s4::parser::make_CHILDTHREAD(ctx->loc); } -"thisthread" { return s4::parser::make_THISTHREAD(ctx->loc); } -"call" { return s4::parser::make_CALL(ctx->loc); } -"true" { return s4::parser::make_TRUE(ctx->loc); } -"false" { return s4::parser::make_FALSE(ctx->loc); } -"undefined" { return s4::parser::make_UNDEFINED(ctx->loc); } -".size" { return s4::parser::make_SIZE(ctx->loc); } -"game" { return s4::parser::make_GAME(ctx->loc); } -"self" { return s4::parser::make_SELF(ctx->loc); } -"anim" { return s4::parser::make_ANIM(ctx->loc); } -"level" { return s4::parser::make_LEVEL(ctx->loc); } -(?i:isdefined) { return s4::parser::make_ISDEFINED(ctx->loc); } -(?i:istrue) { return s4::parser::make_ISTRUE(ctx->loc); } -\( { return s4::parser::make_LPAREN(ctx->loc); } -\) { return s4::parser::make_RPAREN(ctx->loc); } -\{ { return s4::parser::make_LBRACE(ctx->loc); } -\} { return s4::parser::make_RBRACE(ctx->loc); } -\[ { return s4::parser::make_LBRACKET(ctx->loc); } -\] { return s4::parser::make_RBRACKET(ctx->loc); } -\, { return s4::parser::make_COMMA(ctx->loc); } -\. { return s4::parser::make_DOT(ctx->loc); } -\:\: { return s4::parser::make_DOUBLECOLON(ctx->loc); } -\: { return s4::parser::make_COLON(ctx->loc); } -\; { return s4::parser::make_SEMICOLON(ctx->loc); } -\? { return s4::parser::make_QMARK(ctx->loc); } -\+\+ { return s4::parser::make_INCREMENT(ctx->loc); } -\-\- { return s4::parser::make_DECREMENT(ctx->loc); } -\<\<\= { return s4::parser::make_ASSIGN_LSHIFT(ctx->loc); } -\>\>\= { return s4::parser::make_ASSIGN_RSHIFT(ctx->loc); } -\<\< { return s4::parser::make_LSHIFT(ctx->loc); } -\>\> { return s4::parser::make_RSHIFT(ctx->loc); } -\|\| { return s4::parser::make_OR(ctx->loc); } -\&\& { return s4::parser::make_AND(ctx->loc); } -\=\= { return s4::parser::make_EQUALITY(ctx->loc); } -\!\= { return s4::parser::make_INEQUALITY(ctx->loc); } -\<\= { return s4::parser::make_LESS_EQUAL(ctx->loc); } -\>\= { return s4::parser::make_GREATER_EQUAL(ctx->loc); } -\< { return s4::parser::make_LESS(ctx->loc); } -\> { return s4::parser::make_GREATER(ctx->loc); } -\+\= { return s4::parser::make_ASSIGN_ADD(ctx->loc); } -\-\= { return s4::parser::make_ASSIGN_SUB(ctx->loc); } -\*\= { return s4::parser::make_ASSIGN_MUL(ctx->loc); } -\/\= { return s4::parser::make_ASSIGN_DIV(ctx->loc); } -\%\= { return s4::parser::make_ASSIGN_MOD(ctx->loc); } -\|\= { return s4::parser::make_ASSIGN_BW_OR(ctx->loc); } -\&\= { return s4::parser::make_ASSIGN_BW_AND(ctx->loc); } -\^\= { return s4::parser::make_ASSIGN_BW_EXOR(ctx->loc); } -\= { return s4::parser::make_ASSIGN(ctx->loc); } -\+ { return s4::parser::make_ADD(ctx->loc); } -\- { return s4::parser::make_SUB(ctx->loc); } -\* { return s4::parser::make_MUL(ctx->loc); } -\/ { return s4::parser::make_DIV(ctx->loc); } -\% { return s4::parser::make_MOD(ctx->loc); } -\! { return s4::parser::make_NOT(ctx->loc); } -\~ { return s4::parser::make_COMPLEMENT(ctx->loc); } -\| { return s4::parser::make_BITWISE_OR(ctx->loc); } -\& { return s4::parser::make_BITWISE_AND(ctx->loc); } -\^ { return s4::parser::make_BITWISE_EXOR(ctx->loc); } -{RGX_PATH} { return s4::parser::make_PATH(xsk::gsc::s4::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -{RGX_IDENTIFIER} { return s4::parser::make_IDENTIFIER(xsk::gsc::s4::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } -\&{RGX_STRING} { return s4::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_STRING} { return s4::parser::make_STRING(std::string(yytext), ctx->loc); } -{RGX_COLOR_S} { return s4::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_COLOR_L} { return s4::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } -{RGX_FLT_DEC} { return s4::parser::make_FLOAT(std::string(yytext), ctx->loc); } -{RGX_INT_OCT} { return s4::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } -{RGX_INT_BIN} { return s4::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } -{RGX_INT_HEX} { return s4::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } -{RGX_INT_DEC} { return s4::parser::make_INTEGER(std::string(yytext), ctx->loc); } -<> { if(ctx->header_top > 0) s4_pop_header(ctx); else return s4::parser::make_S4EOF(ctx->loc); } -<*>{RGX_DEFAULT} { throw s4::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - -%% - -void s4_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void s4_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} diff --git a/gen/s4/parser.ypp b/gen/s4/parser.ypp index ce274005..853796b9 100644 --- a/gen/s4/parser.ypp +++ b/gen/s4/parser.ypp @@ -1,4 +1,4 @@ -/* Copyright 2021 xensik. All rights reserved. +/* Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,21 +19,15 @@ %define parse.trace %define parse.error detailed %define parse.lac full - %locations - -%lex-param { yyscan_t yyscanner } -%lex-param { xsk::gsc::context* ctx } - -%parse-param { yyscan_t yyscanner } -%parse-param { xsk::gsc::context* ctx } +%lex-param { xsk::gsc::s4::lexer& lexer } +%parse-param { xsk::gsc::s4::lexer& lexer } %parse-param { xsk::gsc::ast::program::ptr& ast } %code requires { #include "s4.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::s4::parser::symbol_type S4lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::s4 { class lexer; } } %code top @@ -42,7 +36,7 @@ typedef void *yyscan_t; #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::s4::parser::symbol_type S4lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::s4::parser::symbol_type S4lex(xsk::gsc::s4::lexer& lexer); } %token DEVBEGIN "/#" @@ -272,7 +266,7 @@ program ; inline - : INLINE expr_path SEMICOLON { s4_push_header(ctx, $2->value); } + : INLINE expr_path SEMICOLON { lexer.push_header($2->value); } ; include @@ -290,7 +284,7 @@ declaration decl_usingtree : USINGTREE LPAREN expr_string RPAREN SEMICOLON - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($3)); } ; decl_constant @@ -300,7 +294,7 @@ decl_constant decl_thread : expr_identifier LPAREN expr_parameters RPAREN stmt_block - { ctx->restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } + { lexer.restrict_header(@$); $$ = std::make_unique(@$, std::move($1), std::move($3), std::move($5)); } ; stmt diff --git a/src/experimental/iw5_console/stdafx.cpp b/src/experimental/iw5_console/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/experimental/iw5_console/stdafx.cpp +++ b/src/experimental/iw5_console/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/iw5_console/stdafx.hpp b/src/experimental/iw5_console/stdafx.hpp index f40e1f92..fbee26af 100644 --- a/src/experimental/iw5_console/stdafx.hpp +++ b/src/experimental/iw5_console/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/iw5_console/xsk/iw5_console.cpp b/src/experimental/iw5_console/xsk/iw5_console.cpp index 79cdc03c..80d778c0 100644 --- a/src/experimental/iw5_console/xsk/iw5_console.cpp +++ b/src/experimental/iw5_console/xsk/iw5_console.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/iw5_console/xsk/iw5_console.hpp b/src/experimental/iw5_console/xsk/iw5_console.hpp index aa09216e..7f6c2427 100644 --- a/src/experimental/iw5_console/xsk/iw5_console.hpp +++ b/src/experimental/iw5_console/xsk/iw5_console.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/iw6_console/stdafx.cpp b/src/experimental/iw6_console/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/experimental/iw6_console/stdafx.cpp +++ b/src/experimental/iw6_console/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/iw6_console/stdafx.hpp b/src/experimental/iw6_console/stdafx.hpp index e0582d7f..f4cfd775 100644 --- a/src/experimental/iw6_console/stdafx.hpp +++ b/src/experimental/iw6_console/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/iw6_console/xsk/iw6_console.cpp b/src/experimental/iw6_console/xsk/iw6_console.cpp index 282c7d4c..0cf101f8 100644 --- a/src/experimental/iw6_console/xsk/iw6_console.cpp +++ b/src/experimental/iw6_console/xsk/iw6_console.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/iw6_console/xsk/iw6_console.hpp b/src/experimental/iw6_console/xsk/iw6_console.hpp index 3721612d..f9f90a5d 100644 --- a/src/experimental/iw6_console/xsk/iw6_console.hpp +++ b/src/experimental/iw6_console/xsk/iw6_console.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/s1_console/stdafx.cpp b/src/experimental/s1_console/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/experimental/s1_console/stdafx.cpp +++ b/src/experimental/s1_console/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/s1_console/stdafx.hpp b/src/experimental/s1_console/stdafx.hpp index e4892bcb..428f98d1 100644 --- a/src/experimental/s1_console/stdafx.hpp +++ b/src/experimental/s1_console/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/s1_console/xsk/s1_console.cpp b/src/experimental/s1_console/xsk/s1_console.cpp index fb535a94..f80475b1 100644 --- a/src/experimental/s1_console/xsk/s1_console.cpp +++ b/src/experimental/s1_console/xsk/s1_console.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/s1_console/xsk/s1_console.hpp b/src/experimental/s1_console/xsk/s1_console.hpp index 528c08be..dbddfc0e 100644 --- a/src/experimental/s1_console/xsk/s1_console.hpp +++ b/src/experimental/s1_console/xsk/s1_console.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/t4/stdafx.cpp b/src/experimental/t4/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/experimental/t4/stdafx.cpp +++ b/src/experimental/t4/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/t4/stdafx.hpp b/src/experimental/t4/stdafx.hpp index 896da922..4e9fe7c0 100644 --- a/src/experimental/t4/stdafx.hpp +++ b/src/experimental/t4/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/t4/xsk/t4.cpp b/src/experimental/t4/xsk/t4.cpp index 6b42fe67..2c5f31a8 100644 --- a/src/experimental/t4/xsk/t4.cpp +++ b/src/experimental/t4/xsk/t4.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/t4/xsk/t4.hpp b/src/experimental/t4/xsk/t4.hpp index 1817e07f..420842db 100644 --- a/src/experimental/t4/xsk/t4.hpp +++ b/src/experimental/t4/xsk/t4.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/t5/stdafx.cpp b/src/experimental/t5/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/experimental/t5/stdafx.cpp +++ b/src/experimental/t5/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/t5/stdafx.hpp b/src/experimental/t5/stdafx.hpp index 48ec457d..c6450c05 100644 --- a/src/experimental/t5/stdafx.hpp +++ b/src/experimental/t5/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/t5/xsk/t5.cpp b/src/experimental/t5/xsk/t5.cpp index 013378f9..dc857dff 100644 --- a/src/experimental/t5/xsk/t5.cpp +++ b/src/experimental/t5/xsk/t5.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/experimental/t5/xsk/t5.hpp b/src/experimental/t5/xsk/t5.hpp index 65a791fa..3d2cf1e2 100644 --- a/src/experimental/t5/xsk/t5.hpp +++ b/src/experimental/t5/xsk/t5.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/stdafx.cpp b/src/h1/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/h1/stdafx.cpp +++ b/src/h1/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/stdafx.hpp b/src/h1/stdafx.hpp index 99cffdea..c3b08391 100644 --- a/src/h1/stdafx.hpp +++ b/src/h1/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/xsk/assembler.cpp b/src/h1/xsk/assembler.cpp index 77896dc1..7b453bfd 100644 --- a/src/h1/xsk/assembler.cpp +++ b/src/h1/xsk/assembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/xsk/assembler.hpp b/src/h1/xsk/assembler.hpp index acd5c701..6556e2bd 100644 --- a/src/h1/xsk/assembler.hpp +++ b/src/h1/xsk/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/xsk/compiler.cpp b/src/h1/xsk/compiler.cpp index f72e0305..40abaf7e 100644 --- a/src/h1/xsk/compiler.cpp +++ b/src/h1/xsk/compiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,7 +19,6 @@ auto compiler::output() -> std::vector void compiler::compile(const std::string& file, std::vector& data) { filename_ = file; - sources_.clear(); auto prog = parse_buffer(filename_, data); @@ -33,39 +32,19 @@ void compiler::read_callback(std::function(const std:: auto compiler::parse_buffer(const std::string& file, std::vector& data) -> ast::program::ptr { - yyscan_t scanner; - context ctx; ast::program::ptr result(nullptr); - ctx.header_top = 0; - ctx.mode = mode_; - ctx.read_callback = read_callback_; - ctx.sources = &sources_; - ctx.loc.initialize(&file); + resolver::set_reader(read_callback_); - // Add the two NULL terminators, required by flex. - data.push_back(0); - data.push_back(0); + lexer lexer(file, reinterpret_cast(data.data()), data.size()); - if (h1_lex_init(&scanner)) - { - throw comp_error(ctx.loc, "An unknown error ocurred while starting lexer context."); - } - - ctx.scanner = scanner; - - YY_BUFFER_STATE yybuffer = h1__scan_buffer(reinterpret_cast(data.data()), data.size(), scanner); - - parser parser(scanner, &ctx, result); + parser parser(lexer, result); if (parser.parse() || result == nullptr) { - throw comp_error(ctx.loc, "An unknown error ocurred while parsing gsc file."); + throw comp_error(xsk::gsc::location(&file), "An unknown error ocurred while parsing gsc file."); } - h1__delete_buffer(yybuffer, scanner); - h1_lex_destroy(scanner); - return result; } diff --git a/src/h1/xsk/compiler.hpp b/src/h1/xsk/compiler.hpp index 7bdca330..100e6ab8 100644 --- a/src/h1/xsk/compiler.hpp +++ b/src/h1/xsk/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -25,7 +25,6 @@ class compiler : public gsc::compiler std::vector animtrees_; std::unordered_map constants_; std::function(const std::string&)> read_callback_; - std::vector sources_; std::vector break_blks_; std::vector continue_blks_; bool can_break_; diff --git a/src/h1/xsk/decompiler.cpp b/src/h1/xsk/decompiler.cpp index f406c2ab..946f9c6f 100644 --- a/src/h1/xsk/decompiler.cpp +++ b/src/h1/xsk/decompiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/xsk/decompiler.hpp b/src/h1/xsk/decompiler.hpp index 9c050de8..06d33750 100644 --- a/src/h1/xsk/decompiler.hpp +++ b/src/h1/xsk/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/xsk/disassembler.cpp b/src/h1/xsk/disassembler.cpp index d3f87785..6df661ea 100644 --- a/src/h1/xsk/disassembler.cpp +++ b/src/h1/xsk/disassembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/xsk/disassembler.hpp b/src/h1/xsk/disassembler.hpp index bad5150b..6e9df738 100644 --- a/src/h1/xsk/disassembler.hpp +++ b/src/h1/xsk/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/xsk/h1.cpp b/src/h1/xsk/h1.cpp index c0180fd7..f5fc7dc6 100644 --- a/src/h1/xsk/h1.cpp +++ b/src/h1/xsk/h1.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/xsk/h1.hpp b/src/h1/xsk/h1.hpp index 3ea1c44c..ac76c784 100644 --- a/src/h1/xsk/h1.hpp +++ b/src/h1/xsk/h1.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h1/xsk/lexer.cpp b/src/h1/xsk/lexer.cpp index ac83516f..ecd02805 100644 --- a/src/h1/xsk/lexer.cpp +++ b/src/h1/xsk/lexer.cpp @@ -1,3040 +1,990 @@ -#line 1 "lexer.cpp" -#include "stdafx.hpp" -#include "h1.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void h1_push_header(xsk::gsc::context* ctx, const std::string& file); -void h1_pop_header(xsk::gsc::context* ctx); - -#line 9 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define h1__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer h1__create_buffer -#endif - -#ifdef yy_delete_buffer -#define h1__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer h1__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define h1__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer h1__scan_buffer -#endif - -#ifdef yy_scan_string -#define h1__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string h1__scan_string -#endif - -#ifdef yy_scan_bytes -#define h1__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes h1__scan_bytes -#endif - -#ifdef yy_init_buffer -#define h1__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer h1__init_buffer -#endif - -#ifdef yy_flush_buffer -#define h1__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer h1__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define h1__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state h1__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define h1__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer h1__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define h1_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state h1_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define h1_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state h1_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define h1_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack h1_ensure_buffer_stack -#endif - -#ifdef yylex -#define h1_lex_ALREADY_DEFINED -#else -#define yylex h1_lex -#endif - -#ifdef yyrestart -#define h1_restart_ALREADY_DEFINED -#else -#define yyrestart h1_restart -#endif - -#ifdef yylex_init -#define h1_lex_init_ALREADY_DEFINED -#else -#define yylex_init h1_lex_init -#endif - -#ifdef yylex_init_extra -#define h1_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra h1_lex_init_extra -#endif - -#ifdef yylex_destroy -#define h1_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy h1_lex_destroy -#endif - -#ifdef yyget_debug -#define h1_get_debug_ALREADY_DEFINED -#else -#define yyget_debug h1_get_debug -#endif - -#ifdef yyset_debug -#define h1_set_debug_ALREADY_DEFINED -#else -#define yyset_debug h1_set_debug -#endif - -#ifdef yyget_extra -#define h1_get_extra_ALREADY_DEFINED -#else -#define yyget_extra h1_get_extra -#endif - -#ifdef yyset_extra -#define h1_set_extra_ALREADY_DEFINED -#else -#define yyset_extra h1_set_extra -#endif - -#ifdef yyget_in -#define h1_get_in_ALREADY_DEFINED -#else -#define yyget_in h1_get_in -#endif - -#ifdef yyset_in -#define h1_set_in_ALREADY_DEFINED -#else -#define yyset_in h1_set_in -#endif - -#ifdef yyget_out -#define h1_get_out_ALREADY_DEFINED -#else -#define yyget_out h1_get_out -#endif - -#ifdef yyset_out -#define h1_set_out_ALREADY_DEFINED -#else -#define yyset_out h1_set_out -#endif - -#ifdef yyget_leng -#define h1_get_leng_ALREADY_DEFINED -#else -#define yyget_leng h1_get_leng -#endif - -#ifdef yyget_text -#define h1_get_text_ALREADY_DEFINED -#else -#define yyget_text h1_get_text -#endif - -#ifdef yyget_lineno -#define h1_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno h1_get_lineno -#endif - -#ifdef yyset_lineno -#define h1_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno h1_set_lineno -#endif - -#ifdef yyget_column -#define h1_get_column_ALREADY_DEFINED -#else -#define yyget_column h1_get_column -#endif - -#ifdef yyset_column -#define h1_set_column_ALREADY_DEFINED -#else -#define yyset_column h1_set_column -#endif - -#ifdef yywrap -#define h1_wrap_ALREADY_DEFINED -#else -#define yywrap h1_wrap -#endif - -#ifdef yyalloc -#define h1_alloc_ALREADY_DEFINED -#else -#define yyalloc h1_alloc -#endif - -#ifdef yyrealloc -#define h1_realloc_ALREADY_DEFINED -#else -#define yyrealloc h1_realloc -#endif - -#ifdef yyfree -#define h1_free_ALREADY_DEFINED -#else -#define yyfree h1_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin , yyscanner ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define h1_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); -static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 112 -#define YY_END_OF_BUFFER 113 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[333] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 113, 111, - 1, 2, 95, 111, 111, 94, 98, 111, 55, 56, - 92, 90, 61, 91, 62, 93, 110, 110, 64, 65, - 79, 89, 80, 66, 101, 59, 60, 99, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 57, 97, 58, 96, 5, 6, - 5, 12, 13, 12, 111, 92, 93, 76, 0, 103, - 0, 15, 0, 0, 0, 0, 85, 0, 74, 0, - 87, 0, 0, 8, 83, 67, 81, 68, 82, 106, - 0, 11, 4, 3, 84, 106, 110, 107, 0, 0, - - 0, 0, 63, 71, 77, 75, 78, 72, 101, 88, - 101, 101, 101, 101, 101, 101, 29, 101, 101, 101, - 101, 101, 27, 33, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 86, 73, 7, 14, 10, - 9, 0, 103, 0, 0, 0, 0, 0, 0, 102, - 0, 0, 0, 0, 103, 0, 106, 0, 3, 106, - 106, 107, 108, 109, 100, 69, 70, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 31, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 104, 0, 0, 0, 0, 0, 102, 0, 0, - - 102, 0, 0, 53, 101, 46, 35, 101, 101, 101, - 28, 101, 101, 101, 51, 101, 101, 101, 101, 52, - 101, 101, 101, 47, 101, 22, 101, 0, 0, 0, - 0, 0, 50, 37, 101, 101, 101, 20, 48, 101, - 54, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 30, 0, 0, 0, 0, 0, 101, 101, 101, 101, - 101, 21, 101, 101, 39, 34, 101, 43, 101, 101, - 101, 105, 0, 0, 16, 0, 101, 101, 101, 36, - 32, 101, 101, 101, 101, 101, 101, 0, 17, 0, - 101, 101, 38, 101, 42, 101, 101, 101, 23, 19, - - 0, 101, 101, 101, 101, 49, 26, 101, 101, 0, - 40, 101, 41, 45, 101, 101, 0, 44, 101, 101, - 0, 101, 101, 0, 101, 24, 0, 101, 18, 101, - 25, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, - 25, 26, 27, 1, 28, 29, 28, 28, 28, 28, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 31, 30, 30, - 32, 33, 34, 35, 36, 1, 37, 38, 39, 40, - - 41, 42, 43, 44, 45, 30, 46, 47, 48, 49, - 50, 51, 30, 52, 53, 54, 55, 56, 57, 31, - 58, 59, 60, 61, 62, 63, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[64] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 5, 5, 5, - 5, 1, 1, 1, 1, 1, 1, 5, 5, 6, - 6, 1, 7, 1, 1, 6, 5, 5, 5, 5, - 5, 5, 6, 6, 8, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 8, 6, 6, 6, 6, 1, - 1, 1, 1 - } ; - -static const flex_int16_t yy_base[353] = - { 0, - 0, 0, 61, 62, 63, 64, 65, 66, 712, 713, - 713, 713, 686, 63, 58, 685, 76, 67, 713, 713, - 62, 67, 713, 73, 86, 85, 96, 102, 687, 713, - 65, 683, 68, 713, 674, 713, 713, 681, 75, 76, - 93, 99, 98, 105, 111, 108, 78, 103, 100, 113, - 118, 125, 123, 127, 713, 136, 713, 713, 713, 713, - 688, 713, 713, 687, 145, 678, 161, 713, 158, 713, - 163, 713, 0, 653, 652, 647, 713, 160, 713, 161, - 713, 165, 176, 713, 713, 713, 713, 713, 713, 183, - 654, 713, 713, 0, 713, 187, 194, 200, 195, 216, - - 234, 0, 713, 673, 713, 713, 713, 672, 663, 713, - 143, 148, 184, 147, 150, 197, 662, 189, 203, 191, - 193, 208, 661, 660, 190, 207, 214, 211, 233, 215, - 225, 224, 245, 236, 249, 713, 713, 713, 713, 713, - 713, 254, 263, 281, 0, 647, 148, 646, 278, 713, - 285, 280, 288, 283, 284, 292, 713, 631, 0, 284, - 713, 311, 290, 0, 656, 713, 713, 267, 287, 265, - 266, 286, 289, 301, 295, 302, 304, 306, 307, 308, - 309, 313, 312, 317, 318, 320, 323, 325, 327, 328, - 329, 0, 640, 640, 641, 636, 358, 360, 366, 361, - - 365, 372, 643, 650, 53, 649, 648, 344, 345, 346, - 647, 347, 354, 352, 646, 350, 367, 370, 355, 645, - 353, 369, 371, 644, 377, 378, 380, 0, 622, 620, - 625, 630, 713, 379, 381, 382, 389, 639, 638, 385, - 637, 383, 396, 384, 394, 395, 407, 409, 392, 410, - 636, 0, 616, 627, 625, 629, 412, 413, 393, 416, - 417, 631, 418, 419, 630, 629, 420, 628, 425, 423, - 430, 713, 619, 618, 713, 621, 431, 432, 434, 624, - 623, 436, 433, 445, 447, 448, 438, 614, 713, 605, - 449, 450, 620, 454, 619, 456, 457, 459, 461, 713, - - 606, 462, 468, 469, 471, 617, 616, 473, 475, 600, - 597, 474, 588, 546, 480, 477, 514, 534, 482, 487, - 487, 486, 488, 496, 495, 502, 493, 489, 713, 500, - 496, 713, 540, 548, 556, 561, 569, 575, 579, 587, - 519, 595, 603, 611, 619, 623, 518, 631, 639, 305, - 246, 179 - } ; - -static const flex_int16_t yy_def[353] = - { 0, - 332, 1, 333, 333, 334, 334, 1, 1, 332, 332, - 332, 332, 332, 335, 336, 332, 332, 337, 332, 332, - 332, 332, 332, 332, 332, 332, 338, 338, 332, 332, - 332, 332, 332, 332, 339, 332, 332, 332, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 336, 332, 332, 332, 335, 332, - 340, 332, 341, 341, 332, 332, 332, 342, 332, 343, - 332, 337, 344, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 345, 332, 332, 338, 338, 338, 338, - - 338, 346, 332, 332, 332, 332, 332, 332, 339, 332, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 332, 332, 332, 332, 332, - 332, 335, 335, 340, 347, 332, 332, 332, 342, 332, - 348, 343, 349, 337, 337, 344, 332, 332, 345, 332, - 332, 338, 338, 101, 346, 332, 332, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 350, 332, 332, 332, 332, 342, 342, 348, 343, - - 343, 349, 332, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 351, 332, 332, - 332, 332, 332, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 352, 332, 332, 332, 332, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 332, 332, 332, 332, 332, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 332, 332, 332, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 332, - - 332, 339, 339, 339, 339, 339, 339, 339, 339, 332, - 339, 339, 339, 339, 339, 339, 332, 339, 339, 339, - 332, 339, 339, 332, 339, 339, 332, 339, 332, 339, - 339, 0, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332 - } ; - -static const flex_int16_t yy_nxt[777] = - { 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, - 28, 29, 30, 31, 32, 33, 34, 35, 35, 35, - 35, 36, 10, 37, 38, 35, 39, 40, 41, 42, - 43, 44, 45, 35, 46, 35, 47, 35, 48, 35, - 49, 50, 51, 52, 53, 35, 54, 35, 35, 55, - 56, 57, 58, 60, 60, 63, 63, 70, 64, 64, - 65, 65, 61, 61, 72, 70, 66, 66, 84, 86, - 78, 67, 67, 79, 80, 102, 85, 88, 104, 105, - 92, 87, 107, 108, 74, 71, 93, 89, 234, 83, - - 81, 94, 75, 90, 90, 90, 90, 102, 102, 95, - 102, 96, 76, 97, 98, 98, 97, 96, 125, 97, - 97, 97, 97, 111, 100, 102, 101, 112, 102, 113, - 102, 102, 102, 100, 102, 102, 114, 102, 91, 116, - 102, 120, 115, 102, 118, 102, 119, 122, 117, 123, - 102, 127, 126, 128, 121, 102, 124, 102, 129, 102, - 136, 140, 70, 134, 150, 69, 141, 143, 131, 150, - 135, 133, 93, 70, 130, 102, 132, 94, 82, 102, - 102, 74, 102, 272, 155, 95, 194, 168, 169, 75, - 71, 172, 151, 153, 195, 144, 137, 83, 173, 76, - - 90, 90, 90, 90, 160, 160, 160, 160, 156, 96, - 332, 97, 97, 97, 97, 96, 102, 162, 162, 162, - 97, 102, 102, 102, 157, 102, 102, 102, 161, 102, - 170, 332, 102, 163, 163, 102, 171, 177, 174, 102, - 102, 175, 176, 102, 178, 180, 102, 102, 102, 332, - 252, 164, 164, 164, 164, 179, 102, 102, 70, 185, - 181, 164, 164, 182, 183, 102, 102, 70, 102, 186, - 164, 164, 164, 164, 164, 164, 187, 102, 188, 184, - 190, 102, 150, 69, 189, 143, 71, 149, 150, 198, - 152, 70, 70, 191, 82, 71, 201, 102, 102, 102, - - 155, 160, 160, 160, 160, 332, 207, 163, 163, 228, - 151, 206, 153, 144, 204, 83, 83, 199, 102, 102, - 202, 102, 102, 205, 156, 161, 96, 102, 162, 162, - 162, 97, 208, 102, 102, 211, 102, 210, 102, 102, - 102, 102, 209, 102, 102, 102, 214, 215, 216, 102, - 102, 212, 102, 217, 218, 102, 213, 102, 220, 102, - 102, 102, 150, 223, 150, 224, 219, 225, 149, 150, - 198, 221, 222, 150, 152, 227, 102, 102, 102, 102, - 201, 226, 102, 235, 102, 102, 102, 102, 240, 236, - 151, 245, 151, 153, 239, 238, 241, 153, 199, 102, - - 237, 102, 102, 102, 202, 243, 244, 247, 242, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 248, 249, - 251, 102, 246, 261, 102, 102, 102, 102, 102, 257, - 259, 250, 265, 263, 258, 260, 264, 266, 267, 102, - 262, 102, 102, 270, 102, 102, 268, 279, 102, 102, - 102, 102, 102, 269, 271, 102, 278, 102, 282, 286, - 281, 277, 102, 102, 102, 102, 102, 283, 102, 280, - 102, 284, 295, 285, 293, 291, 287, 102, 294, 102, - 102, 102, 102, 292, 299, 296, 102, 297, 102, 102, - 303, 102, 305, 102, 102, 298, 306, 302, 304, 307, - - 102, 102, 308, 102, 312, 102, 102, 102, 309, 102, - 314, 316, 102, 318, 102, 311, 319, 313, 102, 102, - 102, 102, 192, 145, 315, 323, 325, 102, 102, 322, - 320, 326, 102, 329, 102, 328, 327, 330, 324, 331, - 59, 59, 59, 59, 59, 59, 59, 59, 62, 62, - 62, 62, 62, 62, 62, 62, 69, 69, 69, 69, - 69, 69, 69, 69, 73, 73, 102, 321, 73, 82, - 82, 82, 82, 82, 82, 82, 82, 99, 102, 99, - 99, 99, 99, 109, 109, 109, 109, 142, 142, 142, - 142, 142, 142, 142, 142, 149, 149, 149, 149, 149, - - 149, 149, 149, 152, 152, 152, 152, 152, 152, 152, - 152, 154, 154, 154, 154, 154, 154, 154, 154, 159, - 102, 159, 159, 159, 159, 159, 159, 165, 165, 102, - 165, 197, 197, 197, 197, 197, 197, 197, 197, 200, - 200, 200, 200, 200, 200, 200, 200, 317, 102, 102, - 310, 102, 102, 301, 300, 102, 102, 290, 289, 288, - 102, 102, 102, 102, 276, 275, 274, 273, 102, 102, - 102, 102, 256, 255, 254, 253, 102, 102, 102, 102, - 102, 102, 102, 233, 232, 231, 230, 229, 102, 203, - 196, 193, 102, 102, 102, 102, 167, 166, 158, 148, - - 147, 146, 85, 139, 138, 110, 102, 106, 103, 77, - 68, 332, 9, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332 - } ; - -static const flex_int16_t yy_chk[777] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 5, 6, 14, 5, 6, - 7, 8, 3, 4, 15, 18, 7, 8, 21, 22, - 17, 7, 8, 17, 17, 205, 21, 24, 31, 31, - 26, 22, 33, 33, 15, 14, 26, 24, 205, 18, - - 17, 26, 15, 25, 25, 25, 25, 39, 40, 26, - 47, 27, 15, 27, 27, 27, 27, 28, 47, 28, - 28, 28, 28, 39, 27, 41, 27, 40, 27, 41, - 43, 42, 49, 27, 28, 48, 41, 44, 25, 42, - 46, 44, 41, 45, 43, 50, 43, 45, 42, 46, - 51, 49, 48, 50, 44, 53, 46, 52, 51, 54, - 56, 65, 69, 54, 78, 71, 67, 71, 52, 80, - 54, 53, 67, 82, 51, 111, 52, 67, 83, 114, - 112, 65, 115, 352, 83, 67, 147, 111, 112, 65, - 69, 114, 78, 80, 147, 71, 56, 82, 115, 65, - - 90, 90, 90, 90, 96, 96, 96, 96, 83, 97, - 99, 97, 97, 97, 97, 98, 113, 98, 98, 98, - 98, 118, 125, 120, 90, 121, 97, 99, 96, 116, - 113, 100, 98, 100, 100, 119, 113, 120, 116, 126, - 122, 118, 119, 128, 121, 125, 127, 130, 100, 101, - 351, 101, 101, 101, 101, 122, 132, 131, 142, 130, - 126, 101, 101, 127, 128, 129, 101, 143, 134, 131, - 101, 101, 101, 101, 101, 101, 131, 133, 132, 129, - 134, 135, 149, 144, 133, 144, 142, 151, 152, 151, - 153, 154, 155, 135, 156, 143, 153, 170, 171, 168, - - 156, 160, 160, 160, 160, 163, 171, 163, 163, 350, - 149, 170, 152, 144, 168, 154, 155, 151, 172, 169, - 153, 173, 163, 169, 156, 160, 162, 175, 162, 162, - 162, 162, 172, 174, 176, 175, 177, 174, 178, 179, - 180, 181, 173, 162, 183, 182, 178, 179, 180, 184, - 185, 176, 186, 181, 182, 187, 177, 188, 184, 189, - 190, 191, 197, 187, 198, 188, 183, 189, 199, 200, - 199, 185, 186, 201, 202, 191, 208, 209, 210, 212, - 202, 190, 216, 208, 214, 221, 213, 219, 214, 209, - 197, 221, 198, 200, 213, 212, 216, 201, 199, 217, - - 210, 222, 218, 223, 202, 218, 219, 223, 217, 225, - 226, 234, 227, 235, 236, 242, 244, 240, 225, 226, - 227, 237, 222, 240, 249, 259, 245, 246, 243, 234, - 236, 226, 244, 243, 235, 237, 243, 245, 246, 247, - 242, 248, 250, 249, 257, 258, 247, 259, 260, 261, - 263, 264, 267, 248, 250, 270, 258, 269, 263, 270, - 261, 257, 271, 277, 278, 283, 279, 264, 282, 260, - 287, 267, 283, 269, 279, 277, 271, 284, 282, 285, - 286, 291, 292, 278, 287, 284, 294, 285, 296, 297, - 292, 298, 296, 299, 302, 286, 297, 291, 294, 298, - - 303, 304, 299, 305, 303, 308, 312, 309, 299, 316, - 305, 309, 315, 312, 319, 302, 315, 304, 322, 320, - 323, 328, 347, 341, 308, 320, 322, 325, 331, 319, - 316, 323, 330, 327, 326, 325, 324, 328, 321, 330, - 333, 333, 333, 333, 333, 333, 333, 333, 334, 334, - 334, 334, 334, 334, 334, 334, 335, 335, 335, 335, - 335, 335, 335, 335, 336, 336, 318, 317, 336, 337, - 337, 337, 337, 337, 337, 337, 337, 338, 314, 338, - 338, 338, 338, 339, 339, 339, 339, 340, 340, 340, - 340, 340, 340, 340, 340, 342, 342, 342, 342, 342, - - 342, 342, 342, 343, 343, 343, 343, 343, 343, 343, - 343, 344, 344, 344, 344, 344, 344, 344, 344, 345, - 313, 345, 345, 345, 345, 345, 345, 346, 346, 311, - 346, 348, 348, 348, 348, 348, 348, 348, 348, 349, - 349, 349, 349, 349, 349, 349, 349, 310, 307, 306, - 301, 295, 293, 290, 288, 281, 280, 276, 274, 273, - 268, 266, 265, 262, 256, 255, 254, 253, 251, 241, - 239, 238, 232, 231, 230, 229, 224, 220, 215, 211, - 207, 206, 204, 203, 196, 195, 194, 193, 165, 158, - 148, 146, 124, 123, 117, 109, 108, 104, 91, 76, - - 75, 74, 66, 64, 61, 38, 35, 32, 29, 16, - 13, 9, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.lpp" -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ -#define YY_NO_INPUT 1 -#define YY_NO_UNISTD_H 1 - -#line 25 "lexer.lpp" -#define YY_USER_ACTION ctx->loc.columns(yyleng); -#line 933 "lexer.cpp" - -#line 935 "lexer.cpp" - -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#include "stdafx.hpp" +#include "h1.hpp" +#include "parser.hpp" +#include "lexer.hpp" + +xsk::gsc::h1::parser::symbol_type H1lex(xsk::gsc::h1::lexer& lexer) +{ + return lexer.lex(); +} + +namespace xsk::gsc::h1 +{ + +enum class keyword +{ +/* KW_pre_define, + KW_pre_undef, + KW_pre_ifdef, + KW_pre_ifndef, + KW_pre_if, + KW_pre_elif, + KW_pre_else, + KW_pre_endif,*/ + KW_pre_inline, + KW_pre_include, + KW_pre_using_animtree, + KW_pre_animtree, + KW_endon, + KW_notify, + KW_wait, + KW_waittill, + KW_waittillmatch, + KW_waittillframeend, + KW_waitframe, + KW_if, + KW_else, + KW_do, + KW_while, + KW_for, + KW_foreach, + KW_in, + KW_switch, + KW_case, + KW_default, + KW_break, + KW_continue, + KW_return, + KW_breakpoint, + KW_prof_begin, + KW_prof_end, + KW_thread, + KW_childthread, + KW_thisthread, + KW_call, + KW_true, + KW_false, + KW_undefined, + KW_dotsize, + KW_game, + KW_self, + KW_anim, + KW_level, + KW_INVALID, +}; + +buffer::buffer() : size(1024), length(0) +{ + data = static_cast(std::malloc(size)); +} + +buffer::~buffer() +{ + if(data) std::free(data); +} + +bool buffer::push(char c) +{ + if(length >= size) { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals ( yyscan_t yyscanner ); - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef YY_NO_UNPUT - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( yyscan_t yyscanner ); -#else -static int input ( yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_load_buffer_state( yyscanner ); - } - - { -#line 44 "lexer.lpp" - - - -#line 48 "lexer.lpp" - ctx->loc.step(); - - -#line 1204 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 332 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 51 "lexer.lpp" -{ ctx->loc.step(); } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 52 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 54 "lexer.lpp" - - YY_BREAK -case 4: -YY_RULE_SETUP -#line 56 "lexer.lpp" -{ BEGIN(COMMENT_STATE); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 57 "lexer.lpp" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 58 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(COMMENT_STATE): -#line 60 "lexer.lpp" -{ throw h1::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "lexer.lpp" -{ throw h1::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 63 "lexer.lpp" -{ throw h1::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 64 "lexer.lpp" -{ BEGIN(INITIAL); return h1::parser::make_DEVEND(ctx->loc); } - YY_BREAK -case YY_STATE_EOF(DEV_ON_STATE): -#line 65 "lexer.lpp" -{ throw h1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 67 "lexer.lpp" -{ BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return h1::parser::make_DEVBEGIN(ctx->loc); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 68 "lexer.lpp" - - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 69 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 70 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(DEV_OFF_STATE): -#line 71 "lexer.lpp" -{ throw h1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.lpp" -{ throw h1::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 74 "lexer.lpp" -{ return h1::parser::make_INLINE(ctx->loc); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 75 "lexer.lpp" -{ return h1::parser::make_INCLUDE(ctx->loc); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 76 "lexer.lpp" -{ return h1::parser::make_USINGTREE(ctx->loc); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 77 "lexer.lpp" -{ return h1::parser::make_ANIMTREE(ctx->loc); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 78 "lexer.lpp" -{ return h1::parser::make_ENDON(ctx->loc); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 79 "lexer.lpp" -{ return h1::parser::make_NOTIFY(ctx->loc); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 80 "lexer.lpp" -{ return h1::parser::make_WAIT(ctx->loc); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 81 "lexer.lpp" -{ return h1::parser::make_WAITTILL(ctx->loc); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 82 "lexer.lpp" -{ return h1::parser::make_WAITTILLMATCH(ctx->loc); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 83 "lexer.lpp" -{ return h1::parser::make_WAITTILLFRAMEEND(ctx->loc); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 84 "lexer.lpp" -{ return h1::parser::make_WAITFRAME(ctx->loc); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 85 "lexer.lpp" -{ return h1::parser::make_IF(ctx->loc); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 86 "lexer.lpp" -{ return h1::parser::make_ELSE(ctx->loc); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 87 "lexer.lpp" -{ return h1::parser::make_DO(ctx->loc); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 88 "lexer.lpp" -{ return h1::parser::make_WHILE(ctx->loc); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 89 "lexer.lpp" -{ return h1::parser::make_FOR(ctx->loc); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 90 "lexer.lpp" -{ return h1::parser::make_FOREACH(ctx->loc); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 91 "lexer.lpp" -{ return h1::parser::make_IN(ctx->loc); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 92 "lexer.lpp" -{ return h1::parser::make_SWITCH(ctx->loc); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 93 "lexer.lpp" -{ return h1::parser::make_CASE(ctx->loc); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 94 "lexer.lpp" -{ return h1::parser::make_DEFAULT(ctx->loc); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 95 "lexer.lpp" -{ return h1::parser::make_BREAK(ctx->loc); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 96 "lexer.lpp" -{ return h1::parser::make_CONTINUE(ctx->loc); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 97 "lexer.lpp" -{ return h1::parser::make_RETURN(ctx->loc); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 98 "lexer.lpp" -{ return h1::parser::make_BREAKPOINT(ctx->loc); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 99 "lexer.lpp" -{ return h1::parser::make_PROFBEGIN(ctx->loc); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 100 "lexer.lpp" -{ return h1::parser::make_PROFEND(ctx->loc); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 101 "lexer.lpp" -{ return h1::parser::make_THREAD(ctx->loc); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 102 "lexer.lpp" -{ return h1::parser::make_CHILDTHREAD(ctx->loc); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 103 "lexer.lpp" -{ return h1::parser::make_THISTHREAD(ctx->loc); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 104 "lexer.lpp" -{ return h1::parser::make_CALL(ctx->loc); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 105 "lexer.lpp" -{ return h1::parser::make_TRUE(ctx->loc); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 106 "lexer.lpp" -{ return h1::parser::make_FALSE(ctx->loc); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 107 "lexer.lpp" -{ return h1::parser::make_UNDEFINED(ctx->loc); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 108 "lexer.lpp" -{ return h1::parser::make_SIZE(ctx->loc); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 109 "lexer.lpp" -{ return h1::parser::make_GAME(ctx->loc); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 110 "lexer.lpp" -{ return h1::parser::make_SELF(ctx->loc); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 111 "lexer.lpp" -{ return h1::parser::make_ANIM(ctx->loc); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 112 "lexer.lpp" -{ return h1::parser::make_LEVEL(ctx->loc); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 113 "lexer.lpp" -{ return h1::parser::make_LPAREN(ctx->loc); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 114 "lexer.lpp" -{ return h1::parser::make_RPAREN(ctx->loc); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 115 "lexer.lpp" -{ return h1::parser::make_LBRACE(ctx->loc); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 116 "lexer.lpp" -{ return h1::parser::make_RBRACE(ctx->loc); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 117 "lexer.lpp" -{ return h1::parser::make_LBRACKET(ctx->loc); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 118 "lexer.lpp" -{ return h1::parser::make_RBRACKET(ctx->loc); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 119 "lexer.lpp" -{ return h1::parser::make_COMMA(ctx->loc); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 120 "lexer.lpp" -{ return h1::parser::make_DOT(ctx->loc); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 121 "lexer.lpp" -{ return h1::parser::make_DOUBLECOLON(ctx->loc); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 122 "lexer.lpp" -{ return h1::parser::make_COLON(ctx->loc); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 123 "lexer.lpp" -{ return h1::parser::make_SEMICOLON(ctx->loc); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 124 "lexer.lpp" -{ return h1::parser::make_QMARK(ctx->loc); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 125 "lexer.lpp" -{ return h1::parser::make_INCREMENT(ctx->loc); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 126 "lexer.lpp" -{ return h1::parser::make_DECREMENT(ctx->loc); } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 127 "lexer.lpp" -{ return h1::parser::make_ASSIGN_LSHIFT(ctx->loc); } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 128 "lexer.lpp" -{ return h1::parser::make_ASSIGN_RSHIFT(ctx->loc); } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 129 "lexer.lpp" -{ return h1::parser::make_LSHIFT(ctx->loc); } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 130 "lexer.lpp" -{ return h1::parser::make_RSHIFT(ctx->loc); } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 131 "lexer.lpp" -{ return h1::parser::make_OR(ctx->loc); } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 132 "lexer.lpp" -{ return h1::parser::make_AND(ctx->loc); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 133 "lexer.lpp" -{ return h1::parser::make_EQUALITY(ctx->loc); } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 134 "lexer.lpp" -{ return h1::parser::make_INEQUALITY(ctx->loc); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 135 "lexer.lpp" -{ return h1::parser::make_LESS_EQUAL(ctx->loc); } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 136 "lexer.lpp" -{ return h1::parser::make_GREATER_EQUAL(ctx->loc); } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 137 "lexer.lpp" -{ return h1::parser::make_LESS(ctx->loc); } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 138 "lexer.lpp" -{ return h1::parser::make_GREATER(ctx->loc); } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 139 "lexer.lpp" -{ return h1::parser::make_ASSIGN_ADD(ctx->loc); } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 140 "lexer.lpp" -{ return h1::parser::make_ASSIGN_SUB(ctx->loc); } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 141 "lexer.lpp" -{ return h1::parser::make_ASSIGN_MUL(ctx->loc); } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 142 "lexer.lpp" -{ return h1::parser::make_ASSIGN_DIV(ctx->loc); } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 143 "lexer.lpp" -{ return h1::parser::make_ASSIGN_MOD(ctx->loc); } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 144 "lexer.lpp" -{ return h1::parser::make_ASSIGN_BW_OR(ctx->loc); } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 145 "lexer.lpp" -{ return h1::parser::make_ASSIGN_BW_AND(ctx->loc); } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 146 "lexer.lpp" -{ return h1::parser::make_ASSIGN_BW_EXOR(ctx->loc); } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 147 "lexer.lpp" -{ return h1::parser::make_ASSIGN(ctx->loc); } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 148 "lexer.lpp" -{ return h1::parser::make_ADD(ctx->loc); } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 149 "lexer.lpp" -{ return h1::parser::make_SUB(ctx->loc); } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 150 "lexer.lpp" -{ return h1::parser::make_MUL(ctx->loc); } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 151 "lexer.lpp" -{ return h1::parser::make_DIV(ctx->loc); } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 152 "lexer.lpp" -{ return h1::parser::make_MOD(ctx->loc); } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 153 "lexer.lpp" -{ return h1::parser::make_NOT(ctx->loc); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 154 "lexer.lpp" -{ return h1::parser::make_COMPLEMENT(ctx->loc); } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 155 "lexer.lpp" -{ return h1::parser::make_BITWISE_OR(ctx->loc); } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 156 "lexer.lpp" -{ return h1::parser::make_BITWISE_AND(ctx->loc); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 157 "lexer.lpp" -{ return h1::parser::make_BITWISE_EXOR(ctx->loc); } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 158 "lexer.lpp" -{ return h1::parser::make_PATH(xsk::gsc::h1::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 101: -YY_RULE_SETUP -#line 159 "lexer.lpp" -{ return h1::parser::make_IDENTIFIER(xsk::gsc::h1::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 102: -/* rule 102 can match eol */ -YY_RULE_SETUP -#line 160 "lexer.lpp" -{ return h1::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 103: -/* rule 103 can match eol */ -YY_RULE_SETUP -#line 161 "lexer.lpp" -{ return h1::parser::make_STRING(std::string(yytext), ctx->loc); } - YY_BREAK -case 104: -YY_RULE_SETUP -#line 162 "lexer.lpp" -{ return h1::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 105: -YY_RULE_SETUP -#line 163 "lexer.lpp" -{ return h1::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 164 "lexer.lpp" -{ return h1::parser::make_FLOAT(std::string(yytext), ctx->loc); } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 165 "lexer.lpp" -{ return h1::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 166 "lexer.lpp" -{ return h1::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 167 "lexer.lpp" -{ return h1::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } - YY_BREAK -case 110: -YY_RULE_SETUP -#line 168 "lexer.lpp" -{ return h1::parser::make_INTEGER(std::string(yytext), ctx->loc); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 169 "lexer.lpp" -{ if(ctx->header_top > 0) h1_pop_header(ctx); else return h1::parser::make_H1EOF(ctx->loc); } - YY_BREAK -case 111: -/* rule 111 can match eol */ -YY_RULE_SETUP -#line 170 "lexer.lpp" -{ throw h1::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - YY_BREAK -case 112: -YY_RULE_SETUP -#line 172 "lexer.lpp" -ECHO; - YY_BREAK -#line 1839 "lexer.cpp" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap( yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin , yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + auto nsize = size * 2; + auto ndata = reinterpret_cast(std::malloc(nsize)); + + if(!ndata) return false; + + std::memmove(ndata, data, size); + std::free(data); + size = nsize; + data = ndata; + } + data[length++] = c; + return true; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; } -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +void reader::init(const char* data, size_t size) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 332); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + if(data && size) + { + state = reader::ok; + buffer_pos = data; + bytes_remaining = size; + last_byte = 0; + current_byte = *data; + } + else + { + state = reader::end; + buffer_pos = 0; + bytes_remaining = 0; + last_byte = 0; + current_byte = 0; + } } -#ifndef YY_NO_UNPUT - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - +void reader::advance() { - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + ++buffer_pos; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin , yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); - yy_load_buffer_state( yyscanner ); + if(bytes_remaining-- == 1) + { + state = reader::end; + bytes_remaining = 0; + last_byte = current_byte; + current_byte = 0; + } + else + { + last_byte = current_byte; + current_byte = *buffer_pos; + } } -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +lexer::lexer(const std::string& name, const char* data, size_t size) : in_dev_state_(false), loc_(xsk::gsc::location(&name)), + mode_(build::dev), header_top_(0), locs_(std::stack()), readers_(std::stack()) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + reader_.init(data, size); } -static void yy_load_buffer_state (yyscan_t yyscanner) +void lexer::push_header(const std::string& file) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + try + { + if (header_top_++ >= 10) + throw xsk::gsc::error("maximum gsh depth exceeded '10'"); + + auto data = resolver::file_data(file + ".gsh"); + + readers_.push(reader_); + locs_.push(loc_); + loc_.initialize(std::get<0>(data)); + reader_.init(std::get<1>(data), std::get<2>(data)); + } + catch (const std::exception& e) + { + throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); + } } -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +void lexer::pop_header() { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file , yyscanner); - - return b; + header_top_--; + loc_ = locs_.top(); + locs_.pop(); + reader_ = readers_.top(); + readers_.pop(); } -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void lexer::restrict_header(const xsk::gsc::location& loc) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf , yyscanner ); - - yyfree( (void *) b , yyscanner ); + if (header_top_ > 0) + { + throw comp_error(loc, "not allowed inside a gsh file"); + } } -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - +auto lexer::lex() -> xsk::gsc::h1::parser::symbol_type { - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + buffer_.length = 0; + loc_.step(); - yy_flush_buffer( b , yyscanner); + while (true) + { + if (reader_.state == reader::end) + { + if (in_dev_state_) + throw h1::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + if(header_top_ > 0) + pop_header(); + else + return h1::parser::make_H1EOF(loc_); + } - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + reader_.advance(); + auto& last = reader_.last_byte; + auto& curr = reader_.current_byte; + + switch (last) + { + case ' ': + case '\t': + case '\r': + loc_.step(); + continue; + case '\n': + loc_.lines(); + loc_.step(); + continue; + case '/': + if(reader_.state == reader::end || (curr != '/' && curr != '*' && curr != '#' && curr != '=')) + return h1::parser::make_DIV(loc_); + + reader_.advance(); + + if (last == '=') + return h1::parser::make_ASSIGN_DIV(loc_); + + if (last == '#') + { + if (in_dev_state_) + { + throw h1::parser::syntax_error(loc_, "cannot recurse devblock ('/#')"); + } + else if (mode_ == xsk::gsc::build::dev) + { + in_dev_state_ = true; + return h1::parser::make_DEVBEGIN(loc_); + } + else + { + while (true) + { + if (reader_.state == reader::end) + { + throw h1::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '#' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + } + else if (last == '*') + { + while (true) + { + if (reader_.state == reader::end) + { + throw h1::parser::syntax_error(loc_, "unmatched multiline comment start ('/*')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '*' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + else if (last == '/') + { + while (true) + { + if (reader_.state == reader::end || curr == '\n') + break; + + reader_.advance(); + } + } + continue; + case '#': + if (curr == '/') + { + if (!in_dev_state_) + throw h1::parser::syntax_error(loc_, "unmatched devblock end ('#/')"); + + in_dev_state_ = false; + reader_.advance(); + return h1::parser::make_DEVEND(loc_); + } + + buffer_.push(last); + while (reader_.state == reader::ok) + { + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + { + if (auto len = buffer_.length; len == 4 || len == 7) + { + auto data = buffer_.data; + auto color = true; + for (auto i = 1; i < len; i++) + { + if ((data[i] < 48 || data[i] > 57) && (data[i] < 65 || data[i] > 70) && (data[i] < 97 || data[i] > 102)) + { + color = false; + break; + } + } + + if (color) return h1::parser::make_COLOR(std::string(++data, --len), loc_); + } + + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); + + if (key == keyword::KW_INVALID) + throw h1::parser::syntax_error(loc_, utils::string::va("unknown preprocessor directive ('%s')", "#")); + + if (keyword_is_token(key)) + return keyword_token(key); + + // call preprocessor(key); + } + continue; + case '*': + if (reader_.state == reader::end || (curr != '/' && curr != '=')) + return h1::parser::make_MUL(loc_); + + reader_.advance(); + + if (curr == '/') + throw h1::parser::syntax_error(loc_, "unmatched multiline comment end ('*/')"); + + return h1::parser::make_ASSIGN_MUL(loc_); + case '"': + case '\'': + return read_string(last, false); + case '.': + return read_dotsize(); + case '(': + return h1::parser::make_LPAREN(loc_); + case ')': + return h1::parser::make_RPAREN(loc_); + case '{': + return h1::parser::make_LBRACE(loc_); + case '}': + return h1::parser::make_RBRACE(loc_); + case '[': + return h1::parser::make_LBRACKET(loc_); + case ']': + return h1::parser::make_RBRACKET(loc_); + case ',': + return h1::parser::make_COMMA(loc_); + case ';': + return h1::parser::make_SEMICOLON(loc_); + case ':': + if (curr != ':') + return h1::parser::make_COLON(loc_); + reader_.advance(); + return h1::parser::make_DOUBLECOLON(loc_); + case '?': + return h1::parser::make_QMARK(loc_); + case '=': + if (curr != '=') + return h1::parser::make_ASSIGN(loc_); + reader_.advance(); + return h1::parser::make_EQUALITY(loc_); + case '+': + if (curr != '+' && curr != '=') + return h1::parser::make_ADD(loc_); + reader_.advance(); + return (last == '+') ? h1::parser::make_INCREMENT(loc_) : h1::parser::make_ASSIGN_ADD(loc_); + case '-': + if (curr != '-' && curr != '=') + return h1::parser::make_SUB(loc_); + reader_.advance(); + return (last == '-') ? h1::parser::make_DECREMENT(loc_) : h1::parser::make_ASSIGN_SUB(loc_); + case '%': + if (curr != '=') + return h1::parser::make_MOD(loc_); + reader_.advance(); + return h1::parser::make_ASSIGN_MOD(loc_); + case '|': + if (curr != '|' && curr != '=') + return h1::parser::make_BITWISE_OR(loc_); + reader_.advance(); + return (last == '|') ? h1::parser::make_OR(loc_) : h1::parser::make_ASSIGN_BW_OR(loc_); + case '&': + if (curr != '&' && curr != '=' && curr != '"' && curr != '\'') + return h1::parser::make_BITWISE_AND(loc_); + reader_.advance(); + if (last == '"' || last == '\'') + return read_string(last, true); + return (last == '&') ? h1::parser::make_AND(loc_) : h1::parser::make_ASSIGN_BW_AND(loc_); + case '^': + if (curr != '=') + return h1::parser::make_BITWISE_EXOR(loc_); + reader_.advance(); + return h1::parser::make_ASSIGN_BW_EXOR(loc_); + case '!': + if (curr != '=') + return h1::parser::make_NOT(loc_); + reader_.advance(); + return h1::parser::make_INEQUALITY(loc_); + case '~': + return h1::parser::make_COMPLEMENT(loc_); + case '<': + if (curr != '<' && curr != '=') + return h1::parser::make_LESS(loc_); + reader_.advance(); + if (last == '<') + { + reader_.advance(); + return (last == '=') ? h1::parser::make_ASSIGN_LSHIFT(loc_) : h1::parser::make_LSHIFT(loc_); + } + return h1::parser::make_LESS_EQUAL(loc_); + case '>': + if (curr != '>' && curr != '=') + return h1::parser::make_GREATER(loc_); + reader_.advance(); + if (last == '>') + { + reader_.advance(); + return (last == '=') ? h1::parser::make_ASSIGN_RSHIFT(loc_) : h1::parser::make_RSHIFT(loc_); + } + return h1::parser::make_GREATER_EQUAL(loc_); + default: + if (last >= '0' && last <= '9') + return lexer::read_number(last); + else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z') + return lexer::read_word(last); + + throw h1::parser::syntax_error(loc_, utils::string::va("bad token: \'%c\'", last)); + } + } +} + +auto lexer::read_string(char quote, bool localize) -> xsk::gsc::h1::parser::symbol_type +{ + if (localize) + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + reader_.advance(); + + if (last == '\n') + throw h1::parser::syntax_error(loc_, "unterminated string"); + + if (last == '\\') // process scapes + { + // TODO: + } + + if (last != '\\' && curr == quote) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); } - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b , yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n , yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n , yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int _line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = _line_number; -} - -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column (int _column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = _column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int _bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = _bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (reader_.state == reader::end) + { + throw h1::parser::syntax_error(loc_, utils::string::va("unmatched string start ('%s')", (quote == '"') ? "\"" : "\\'")); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + if (localize) + return h1::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + return h1::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_); +} + +auto lexer::read_number(char first) -> xsk::gsc::h1::parser::symbol_type +{ + if (first == '.') + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = true; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw h1::parser::syntax_error(loc_, "invalid number '.'"); + } + if (data[i] == 'f' && i != len - 1) + throw h1::parser::syntax_error(loc_, "invalid number 'f'"); + } + + return h1::parser::make_FLOAT(std::string(data, len), loc_); + } + else + { + auto curr = reader_.current_byte; + + if (first == '0' && curr == 'o') + { + buffer_.push(first); + buffer_.push('o'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'o')) + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'o' && last == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr > 47 && curr < 56)) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid octal literal!"); + + return h1::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data + 2), loc_); + } + else if (first == '0' && curr == 'b') + { + buffer_.push(first); + buffer_.push('b'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'b')) + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'b' && last == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (curr != '0' && curr != '1') + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid binary literal!"); + + return h1::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_); + } + else if (first == '0' && curr == 'x') + { + buffer_.push(first); + buffer_.push('x'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'x')) + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'x' && last == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!((curr > 47 && curr < 58) || (curr > 64 && curr < 71) || (curr > 96 && curr < 103))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid hexadecimal literal!"); + + return h1::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_); + } + else + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h1::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = false; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw h1::parser::syntax_error(loc_, "invalid number '.'"); + + dot = true; + } + if (data[i] == 'f' && i != len - 1) + throw h1::parser::syntax_error(loc_, "invalid number 'f'"); + } + + if (dot || data[len - 1] == 'f') + return h1::parser::make_FLOAT(std::string(data, len), loc_); + + return h1::parser::make_INTEGER(std::string(data, len), loc_); + } + } +} + +auto lexer::read_word(char first) -> xsk::gsc::h1::parser::symbol_type +{ + auto path = false; + + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto curr = reader_.current_byte; + + if (!(curr == '\\' || curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (curr == '\\') + { + if (reader_.last_byte == '\\') + throw h1::parser::syntax_error(loc_, "invalid path '\\\\'"); + + path = true; + curr = '/'; + } + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); - return yy_init_globals ( *ptr_yy_globals ); -} + if (key != keyword::KW_INVALID) + return keyword_token(key); -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; + if (path) + { + if (buffer_.data[buffer_.length - 1] == '/') + throw h1::parser::syntax_error(loc_, "invalid path end '\\'"); - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + return h1::parser::make_PATH(xsk::gsc::h1::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + return h1::parser::make_IDENTIFIER(xsk::gsc::h1::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); +} - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; +auto lexer::read_dotsize() -> xsk::gsc::h1::parser::symbol_type +{ + auto curr = reader_.current_byte; + + if (curr > 47 && curr < 58) + { + return lexer::read_number('.'); + } + else if (curr == '_' || curr > 64 && curr < 91 || curr > 96 && curr < 123) + { + reader save; + save.state = reader_.state; + save.bytes_remaining = reader_.bytes_remaining; + save.buffer_pos = reader_.buffer_pos; + save.last_byte = reader_.last_byte; + save.current_byte = reader_.current_byte; + + while (reader_.state == reader::ok) + { + curr = reader_.current_byte; + + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (std::string_view(buffer_.data, buffer_.length) == "size") + { + return h1::parser::make_SIZE(loc_); + } + + reader_.state = save.state; + reader_.bytes_remaining = save.bytes_remaining; + reader_.buffer_pos = save.buffer_pos; + reader_.last_byte = save.last_byte; + reader_.current_byte = save.current_byte; + + return h1::parser::make_DOT(loc_); + + } + else return h1::parser::make_DOT(loc_); +} + +auto lexer::keyword_token(keyword k) -> xsk::gsc::h1::parser::symbol_type +{ + switch (k) + { + case keyword::KW_pre_inline: + return h1::parser::make_INLINE(loc_); + case keyword::KW_pre_include: + return h1::parser::make_INCLUDE(loc_); + case keyword::KW_pre_using_animtree: + return h1::parser::make_USINGTREE(loc_); + case keyword::KW_pre_animtree: + return h1::parser::make_ANIMTREE(loc_); + case keyword::KW_endon: + return h1::parser::make_ENDON(loc_); + case keyword::KW_notify: + return h1::parser::make_NOTIFY(loc_); + case keyword::KW_wait: + return h1::parser::make_WAIT(loc_); + case keyword::KW_waittill: + return h1::parser::make_WAITTILL(loc_); + case keyword::KW_waittillmatch: + return h1::parser::make_WAITTILLMATCH(loc_); + case keyword::KW_waittillframeend: + return h1::parser::make_WAITTILLFRAMEEND(loc_); + case keyword::KW_waitframe: + return h1::parser::make_WAITFRAME(loc_); + case keyword::KW_if: + return h1::parser::make_IF(loc_); + case keyword::KW_else: + return h1::parser::make_ELSE(loc_); + case keyword::KW_do: + return h1::parser::make_DO(loc_); + case keyword::KW_while: + return h1::parser::make_WHILE(loc_); + case keyword::KW_for: + return h1::parser::make_FOR(loc_); + case keyword::KW_foreach: + return h1::parser::make_FOREACH(loc_); + case keyword::KW_in: + return h1::parser::make_IN(loc_); + case keyword::KW_switch: + return h1::parser::make_SWITCH(loc_); + case keyword::KW_case: + return h1::parser::make_CASE(loc_); + case keyword::KW_default: + return h1::parser::make_DEFAULT(loc_); + case keyword::KW_break: + return h1::parser::make_BREAK(loc_); + case keyword::KW_continue: + return h1::parser::make_CONTINUE(loc_); + case keyword::KW_return: + return h1::parser::make_RETURN(loc_); + case keyword::KW_breakpoint: + return h1::parser::make_BREAKPOINT(loc_); + case keyword::KW_prof_begin: + return h1::parser::make_PROFBEGIN(loc_); + case keyword::KW_prof_end: + return h1::parser::make_PROFEND(loc_); + case keyword::KW_thread: + return h1::parser::make_THREAD(loc_); + case keyword::KW_childthread: + return h1::parser::make_CHILDTHREAD(loc_); + case keyword::KW_thisthread: + return h1::parser::make_THISTHREAD(loc_); + case keyword::KW_call: + return h1::parser::make_CALL(loc_); + case keyword::KW_true: + return h1::parser::make_TRUE(loc_); + case keyword::KW_false: + return h1::parser::make_FALSE(loc_); + case keyword::KW_undefined: + return h1::parser::make_UNDEFINED(loc_); + case keyword::KW_dotsize: + return h1::parser::make_SIZE(loc_); + case keyword::KW_game: + return h1::parser::make_GAME(loc_); + case keyword::KW_self: + return h1::parser::make_SELF(loc_); + case keyword::KW_anim: + return h1::parser::make_ANIM(loc_); + case keyword::KW_level: + return h1::parser::make_LEVEL(loc_); + default: + throw error("gsc lexer: INVALID KEYWORD TOKEN!"); + } +} + +auto lexer::keyword_is_token(keyword k) -> bool +{ + switch (k) + { +/* case keyword::KW_pre_define: + case keyword::KW_pre_undef: + case keyword::KW_pre_ifdef: + case keyword::KW_pre_ifndef: + case keyword::KW_pre_if: + case keyword::KW_pre_elif: + case keyword::KW_pre_else: + case keyword::KW_pre_endif:*/ + case keyword::KW_INVALID: + return false; + default: + return true; + } +} + +auto lexer::get_keyword(std::string_view str) -> keyword +{ + auto itr = keywords.find(str); + + if(itr != keywords.end()) + { + return itr->second; } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + return keyword::KW_INVALID; } -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack , yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack , yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s , yyscan_t yyscanner) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 172 "lexer.lpp" - - -void h1_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void h1_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} +std::unordered_map lexer::keywords +{{ +/* { "#define", keyword::KW_pre_define }, + { "#undef", keyword::KW_pre_undef }, + { "#ifdef", keyword::KW_pre_ifdef }, + { "#ifndef", keyword::KW_pre_ifndef }, + { "#if", keyword::KW_pre_if }, + { "#elif", keyword::KW_pre_elif }, + { "#else", keyword::KW_pre_else }, + { "#endif", keyword::KW_pre_endif },*/ + { "#inline", keyword::KW_pre_inline }, + { "#include", keyword::KW_pre_include }, + { "#using_animtree", keyword::KW_pre_using_animtree }, + { "#animtree", keyword::KW_pre_animtree }, + { "endon", keyword::KW_endon }, + { "notify", keyword::KW_notify }, + { "wait", keyword::KW_wait }, + { "waittill", keyword::KW_waittill }, + { "waittillmatch", keyword::KW_waittillmatch }, + { "waittillframeend", keyword::KW_waittillframeend }, + { "waitframe", keyword::KW_waitframe }, + { "if", keyword::KW_if }, + { "else", keyword::KW_else }, + { "do", keyword::KW_do }, + { "while", keyword::KW_while }, + { "for", keyword::KW_for }, + { "foreach", keyword::KW_foreach }, + { "in", keyword::KW_in }, + { "switch", keyword::KW_switch }, + { "case", keyword::KW_case }, + { "default", keyword::KW_default }, + { "break", keyword::KW_break }, + { "continue", keyword::KW_continue }, + { "return", keyword::KW_return }, + { "breakpoint", keyword::KW_breakpoint }, + { "prof_begin", keyword::KW_prof_begin }, + { "prof_end", keyword::KW_prof_end }, + { "thread", keyword::KW_thread }, + { "childthread", keyword::KW_childthread }, + { "thisthread", keyword::KW_thisthread }, + { "call", keyword::KW_call }, + { "true", keyword::KW_true }, + { "false", keyword::KW_false }, + { "undefined", keyword::KW_undefined }, + { ".size", keyword::KW_dotsize }, + { "game", keyword::KW_game }, + { "self", keyword::KW_self }, + { "anim", keyword::KW_anim }, + { "level", keyword::KW_level }, +}}; +} // namespace xsk::gsc::h1 diff --git a/src/h1/xsk/lexer.hpp b/src/h1/xsk/lexer.hpp index a5e0276b..a8a47aca 100644 --- a/src/h1/xsk/lexer.hpp +++ b/src/h1/xsk/lexer.hpp @@ -1,711 +1,79 @@ -#ifndef h1_HEADER_H -#define h1_HEADER_H 1 -#define h1_IN_HEADER 1 - -#line 5 "lexer.hpp" -#include "stdafx.hpp" -#include "h1.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void h1_push_header(xsk::gsc::context* ctx, const std::string& file); -void h1_pop_header(xsk::gsc::context* ctx); - -#line 13 "lexer.hpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define h1__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer h1__create_buffer -#endif - -#ifdef yy_delete_buffer -#define h1__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer h1__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define h1__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer h1__scan_buffer -#endif - -#ifdef yy_scan_string -#define h1__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string h1__scan_string -#endif - -#ifdef yy_scan_bytes -#define h1__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes h1__scan_bytes -#endif - -#ifdef yy_init_buffer -#define h1__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer h1__init_buffer -#endif - -#ifdef yy_flush_buffer -#define h1__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer h1__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define h1__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state h1__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define h1__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer h1__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define h1_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state h1_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define h1_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state h1_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define h1_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack h1_ensure_buffer_stack -#endif - -#ifdef yylex -#define h1_lex_ALREADY_DEFINED -#else -#define yylex h1_lex -#endif - -#ifdef yyrestart -#define h1_restart_ALREADY_DEFINED -#else -#define yyrestart h1_restart -#endif - -#ifdef yylex_init -#define h1_lex_init_ALREADY_DEFINED -#else -#define yylex_init h1_lex_init -#endif - -#ifdef yylex_init_extra -#define h1_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra h1_lex_init_extra -#endif - -#ifdef yylex_destroy -#define h1_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy h1_lex_destroy -#endif - -#ifdef yyget_debug -#define h1_get_debug_ALREADY_DEFINED -#else -#define yyget_debug h1_get_debug -#endif - -#ifdef yyset_debug -#define h1_set_debug_ALREADY_DEFINED -#else -#define yyset_debug h1_set_debug -#endif - -#ifdef yyget_extra -#define h1_get_extra_ALREADY_DEFINED -#else -#define yyget_extra h1_get_extra -#endif - -#ifdef yyset_extra -#define h1_set_extra_ALREADY_DEFINED -#else -#define yyset_extra h1_set_extra -#endif - -#ifdef yyget_in -#define h1_get_in_ALREADY_DEFINED -#else -#define yyget_in h1_get_in -#endif - -#ifdef yyset_in -#define h1_set_in_ALREADY_DEFINED -#else -#define yyset_in h1_set_in -#endif - -#ifdef yyget_out -#define h1_get_out_ALREADY_DEFINED -#else -#define yyget_out h1_get_out -#endif - -#ifdef yyset_out -#define h1_set_out_ALREADY_DEFINED -#else -#define yyset_out h1_set_out -#endif - -#ifdef yyget_leng -#define h1_get_leng_ALREADY_DEFINED -#else -#define yyget_leng h1_get_leng -#endif - -#ifdef yyget_text -#define h1_get_text_ALREADY_DEFINED -#else -#define yyget_text h1_get_text -#endif - -#ifdef yyget_lineno -#define h1_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno h1_get_lineno -#endif - -#ifdef yyset_lineno -#define h1_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno h1_set_lineno -#endif - -#ifdef yyget_column -#define h1_get_column_ALREADY_DEFINED -#else -#define yyget_column h1_get_column -#endif - -#ifdef yyset_column -#define h1_set_column_ALREADY_DEFINED -#else -#define yyset_column h1_set_column -#endif - -#ifdef yywrap -#define h1_wrap_ALREADY_DEFINED -#else -#define yywrap h1_wrap -#endif - -#ifdef yyalloc -#define h1_alloc_ALREADY_DEFINED -#else -#define yyalloc h1_alloc -#endif - -#ifdef yyrealloc -#define h1_realloc_ALREADY_DEFINED -#else -#define yyrealloc h1_realloc -#endif - -#ifdef yyfree -#define h1_free_ALREADY_DEFINED -#else -#define yyfree h1_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define h1_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#ifndef h1__create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef h1__delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef h1__scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef h1__scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef h1__scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef h1__init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef h1__flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef h1__load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef h1__switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef h1_push_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef h1_pop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef h1_ensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef h1_lex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef h1_restart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef h1_lex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef h1_lex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef h1_lex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef h1_get_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef h1_set_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef h1_get_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef h1_set_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef h1_get_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef h1_set_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef h1_get_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef h1_set_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef h1_get_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef h1_get_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef h1_get_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef h1_set_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef h1_get_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef h1_set_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef h1_wrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef h1_get_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef h1_set_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef h1_get_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef h1_set_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef h1_alloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef h1_realloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef h1_free_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef h1_text_ALREADY_DEFINED -#undef yytext -#endif -#ifndef h1_leng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef h1_in_ALREADY_DEFINED -#undef yyin -#endif -#ifndef h1_out_ALREADY_DEFINED -#undef yyout -#endif -#ifndef h1__flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef h1_lineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef h1_tables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef h1_tables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef h1_TABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 172 "lexer.lpp" - - -#line 709 "lexer.hpp" -#undef h1_IN_HEADER -#endif /* h1_HEADER_H */ +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#pragma once + +#include "h1.hpp" + +namespace xsk::gsc::h1 +{ + +enum class keyword; + +struct buffer +{ + int size; + int length; + char* data; + + buffer(); + ~buffer(); + bool push(char c); +}; + +struct reader +{ + enum states { end, ok }; + + states state; + int bytes_remaining; + const char* buffer_pos; + char last_byte; + char current_byte; + + reader(); + + reader& operator=(const reader& r) + { + std::memcpy(this, &r, sizeof(reader)); + return *this; + } + + void init(const char* data, size_t size); + void advance(); +}; + +class lexer +{ +private: + reader reader_; + buffer buffer_; + location loc_; + build mode_; + bool in_dev_state_; + std::stack locs_; + std::stack readers_; + std::uint32_t header_top_; + +public: + lexer(const std::string& name, const char* data, size_t size); + auto lex() -> xsk::gsc::h1::parser::symbol_type; + void push_header(const std::string& file); + void pop_header(); + void restrict_header(const xsk::gsc::location& loc); + +private: + auto read_string(char quote, bool localize) -> xsk::gsc::h1::parser::symbol_type; + auto read_number(char first) -> xsk::gsc::h1::parser::symbol_type; + auto read_word(char first) -> xsk::gsc::h1::parser::symbol_type; + auto read_dotsize() -> xsk::gsc::h1::parser::symbol_type; + auto keyword_token(keyword k) -> xsk::gsc::h1::parser::symbol_type; + static auto keyword_is_token(keyword k) -> bool; + static auto get_keyword(std::string_view str) -> keyword; + + static std::unordered_map keywords; +}; + +} // namespace xsk::gsc::h1 diff --git a/src/h1/xsk/parser.cpp b/src/h1/xsk/parser.cpp index 22be956d..9c5f219a 100644 --- a/src/h1/xsk/parser.cpp +++ b/src/h1/xsk/parser.cpp @@ -35,13 +35,13 @@ // private implementation details that can be changed or removed. // "%code top" blocks. -#line 40 "parser.ypp" +#line 34 "parser.ypp" #include "stdafx.hpp" #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::h1::parser::symbol_type H1lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::h1::parser::symbol_type H1lex(xsk::gsc::h1::lexer& lexer); #line 47 "parser.cpp" @@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace h1 { #line 149 "parser.cpp" /// Build a parser object. - parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) + parser::parser (xsk::gsc::h1::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) #if H1DEBUG : yydebug_ (false), yycdebug_ (&std::cerr), @@ -156,8 +156,7 @@ namespace xsk { namespace gsc { namespace h1 { : #endif yy_lac_established_ (false), - yyscanner (yyscanner_yyarg), - ctx (ctx_yyarg), + lexer (lexer_yyarg), ast (ast_yyarg) {} @@ -1593,7 +1592,7 @@ namespace xsk { namespace gsc { namespace h1 { try #endif // YY_EXCEPTIONS { - symbol_type yylookahead (yylex (yyscanner, ctx)); + symbol_type yylookahead (yylex (lexer)); yyla.move (yylookahead); } #if YY_EXCEPTIONS @@ -1980,1303 +1979,1303 @@ namespace xsk { namespace gsc { namespace h1 { switch (yyn) { case 2: // root: program -#line 251 "parser.ypp" +#line 245 "parser.ypp" { ast = std::move(yystack_[0].value.as < ast::program::ptr > ()); } -#line 1986 "parser.cpp" +#line 1985 "parser.cpp" break; case 3: // root: %empty -#line 252 "parser.ypp" +#line 246 "parser.ypp" { ast = std::make_unique(yylhs.location); } -#line 1992 "parser.cpp" +#line 1991 "parser.cpp" break; case 4: // program: program inline -#line 257 "parser.ypp" +#line 251 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); } -#line 1998 "parser.cpp" +#line 1997 "parser.cpp" break; case 5: // program: program include -#line 259 "parser.ypp" +#line 253 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2004 "parser.cpp" +#line 2003 "parser.cpp" break; case 6: // program: program declaration -#line 261 "parser.ypp" +#line 255 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2010 "parser.cpp" +#line 2009 "parser.cpp" break; case 7: // program: inline -#line 263 "parser.ypp" +#line 257 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); } -#line 2016 "parser.cpp" +#line 2015 "parser.cpp" break; case 8: // program: include -#line 265 "parser.ypp" +#line 259 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2022 "parser.cpp" +#line 2021 "parser.cpp" break; case 9: // program: declaration -#line 267 "parser.ypp" +#line 261 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2028 "parser.cpp" +#line 2027 "parser.cpp" break; case 10: // inline: "#inline" expr_path ";" -#line 271 "parser.ypp" - { h1_push_header(ctx, yystack_[1].value.as < ast::expr_path::ptr > ()->value); } -#line 2034 "parser.cpp" +#line 265 "parser.ypp" + { lexer.push_header(yystack_[1].value.as < ast::expr_path::ptr > ()->value); } +#line 2033 "parser.cpp" break; case 11: // include: "#include" expr_path ";" -#line 276 "parser.ypp" +#line 270 "parser.ypp" { yylhs.value.as < ast::include::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_path::ptr > ())); } -#line 2040 "parser.cpp" +#line 2039 "parser.cpp" break; case 12: // declaration: "/#" -#line 280 "parser.ypp" +#line 274 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_begin = std::make_unique(yylhs.location); } -#line 2046 "parser.cpp" +#line 2045 "parser.cpp" break; case 13: // declaration: "#/" -#line 281 "parser.ypp" +#line 275 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_end = std::make_unique(yylhs.location); } -#line 2052 "parser.cpp" +#line 2051 "parser.cpp" break; case 14: // declaration: decl_usingtree -#line 282 "parser.ypp" +#line 276 "parser.ypp" { yylhs.value.as < ast::decl > ().as_usingtree = std::move(yystack_[0].value.as < ast::decl_usingtree::ptr > ()); } -#line 2058 "parser.cpp" +#line 2057 "parser.cpp" break; case 15: // declaration: decl_constant -#line 283 "parser.ypp" +#line 277 "parser.ypp" { yylhs.value.as < ast::decl > ().as_constant = std::move(yystack_[0].value.as < ast::decl_constant::ptr > ()); } -#line 2064 "parser.cpp" +#line 2063 "parser.cpp" break; case 16: // declaration: decl_thread -#line 284 "parser.ypp" +#line 278 "parser.ypp" { yylhs.value.as < ast::decl > ().as_thread = std::move(yystack_[0].value.as < ast::decl_thread::ptr > ()); } -#line 2070 "parser.cpp" +#line 2069 "parser.cpp" break; case 17: // decl_usingtree: "#using_animtree" "(" expr_string ")" ";" -#line 289 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } -#line 2076 "parser.cpp" +#line 283 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } +#line 2075 "parser.cpp" break; case 18: // decl_constant: expr_identifier "=" expr ";" -#line 294 "parser.ypp" +#line 288 "parser.ypp" { yylhs.value.as < ast::decl_constant::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2082 "parser.cpp" +#line 2081 "parser.cpp" break; case 19: // decl_thread: expr_identifier "(" expr_parameters ")" stmt_block -#line 299 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2088 "parser.cpp" +#line 293 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } +#line 2087 "parser.cpp" break; case 20: // stmt: stmt_dev -#line 303 "parser.ypp" +#line 297 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2094 "parser.cpp" +#line 2093 "parser.cpp" break; case 21: // stmt: stmt_block -#line 304 "parser.ypp" +#line 298 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2100 "parser.cpp" +#line 2099 "parser.cpp" break; case 22: // stmt: stmt_call -#line 305 "parser.ypp" +#line 299 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_call = std::move(yystack_[0].value.as < ast::stmt_call::ptr > ()); } -#line 2106 "parser.cpp" +#line 2105 "parser.cpp" break; case 23: // stmt: stmt_assign -#line 306 "parser.ypp" +#line 300 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_assign = std::move(yystack_[0].value.as < ast::stmt_assign::ptr > ()); } -#line 2112 "parser.cpp" +#line 2111 "parser.cpp" break; case 24: // stmt: stmt_endon -#line 307 "parser.ypp" +#line 301 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_endon = std::move(yystack_[0].value.as < ast::stmt_endon::ptr > ()); } -#line 2118 "parser.cpp" +#line 2117 "parser.cpp" break; case 25: // stmt: stmt_notify -#line 308 "parser.ypp" +#line 302 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_notify = std::move(yystack_[0].value.as < ast::stmt_notify::ptr > ()); } -#line 2124 "parser.cpp" +#line 2123 "parser.cpp" break; case 26: // stmt: stmt_wait -#line 309 "parser.ypp" +#line 303 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_wait = std::move(yystack_[0].value.as < ast::stmt_wait::ptr > ()); } -#line 2130 "parser.cpp" +#line 2129 "parser.cpp" break; case 27: // stmt: stmt_waittill -#line 310 "parser.ypp" +#line 304 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittill = std::move(yystack_[0].value.as < ast::stmt_waittill::ptr > ()); } -#line 2136 "parser.cpp" +#line 2135 "parser.cpp" break; case 28: // stmt: stmt_waittillmatch -#line 311 "parser.ypp" +#line 305 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillmatch = std::move(yystack_[0].value.as < ast::stmt_waittillmatch::ptr > ()); } -#line 2142 "parser.cpp" +#line 2141 "parser.cpp" break; case 29: // stmt: stmt_waittillframeend -#line 312 "parser.ypp" +#line 306 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillframeend = std::move(yystack_[0].value.as < ast::stmt_waittillframeend::ptr > ()); } -#line 2148 "parser.cpp" +#line 2147 "parser.cpp" break; case 30: // stmt: stmt_waitframe -#line 313 "parser.ypp" +#line 307 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waitframe = std::move(yystack_[0].value.as < ast::stmt_waitframe::ptr > ()); } -#line 2154 "parser.cpp" +#line 2153 "parser.cpp" break; case 31: // stmt: stmt_if -#line 314 "parser.ypp" +#line 308 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_if = std::move(yystack_[0].value.as < ast::stmt_if::ptr > ()); } -#line 2160 "parser.cpp" +#line 2159 "parser.cpp" break; case 32: // stmt: stmt_ifelse -#line 315 "parser.ypp" +#line 309 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_ifelse = std::move(yystack_[0].value.as < ast::stmt_ifelse::ptr > ()); } -#line 2166 "parser.cpp" +#line 2165 "parser.cpp" break; case 33: // stmt: stmt_while -#line 316 "parser.ypp" +#line 310 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_while = std::move(yystack_[0].value.as < ast::stmt_while::ptr > ()); } -#line 2172 "parser.cpp" +#line 2171 "parser.cpp" break; case 34: // stmt: stmt_dowhile -#line 317 "parser.ypp" +#line 311 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_dowhile = std::move(yystack_[0].value.as < ast::stmt_dowhile::ptr > ()); } -#line 2178 "parser.cpp" +#line 2177 "parser.cpp" break; case 35: // stmt: stmt_for -#line 318 "parser.ypp" +#line 312 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_for = std::move(yystack_[0].value.as < ast::stmt_for::ptr > ()); } -#line 2184 "parser.cpp" +#line 2183 "parser.cpp" break; case 36: // stmt: stmt_foreach -#line 319 "parser.ypp" +#line 313 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_foreach = std::move(yystack_[0].value.as < ast::stmt_foreach::ptr > ()); } -#line 2190 "parser.cpp" +#line 2189 "parser.cpp" break; case 37: // stmt: stmt_switch -#line 320 "parser.ypp" +#line 314 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_switch = std::move(yystack_[0].value.as < ast::stmt_switch::ptr > ()); } -#line 2196 "parser.cpp" +#line 2195 "parser.cpp" break; case 38: // stmt: stmt_case -#line 321 "parser.ypp" +#line 315 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_case = std::move(yystack_[0].value.as < ast::stmt_case::ptr > ()); } -#line 2202 "parser.cpp" +#line 2201 "parser.cpp" break; case 39: // stmt: stmt_default -#line 322 "parser.ypp" +#line 316 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_default = std::move(yystack_[0].value.as < ast::stmt_default::ptr > ()); } -#line 2208 "parser.cpp" +#line 2207 "parser.cpp" break; case 40: // stmt: stmt_break -#line 323 "parser.ypp" +#line 317 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_break = std::move(yystack_[0].value.as < ast::stmt_break::ptr > ()); } -#line 2214 "parser.cpp" +#line 2213 "parser.cpp" break; case 41: // stmt: stmt_continue -#line 324 "parser.ypp" +#line 318 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_continue = std::move(yystack_[0].value.as < ast::stmt_continue::ptr > ()); } -#line 2220 "parser.cpp" +#line 2219 "parser.cpp" break; case 42: // stmt: stmt_return -#line 325 "parser.ypp" +#line 319 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_return = std::move(yystack_[0].value.as < ast::stmt_return::ptr > ()); } -#line 2226 "parser.cpp" +#line 2225 "parser.cpp" break; case 43: // stmt: stmt_breakpoint -#line 326 "parser.ypp" +#line 320 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_breakpoint = std::move(yystack_[0].value.as < ast::stmt_breakpoint::ptr > ()); } -#line 2232 "parser.cpp" +#line 2231 "parser.cpp" break; case 44: // stmt: stmt_prof_begin -#line 327 "parser.ypp" +#line 321 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_begin = std::move(yystack_[0].value.as < ast::stmt_prof_begin::ptr > ()); } -#line 2238 "parser.cpp" +#line 2237 "parser.cpp" break; case 45: // stmt: stmt_prof_end -#line 328 "parser.ypp" +#line 322 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_end = std::move(yystack_[0].value.as < ast::stmt_prof_end::ptr > ()); } -#line 2244 "parser.cpp" +#line 2243 "parser.cpp" break; case 46: // stmt_dev: "/#" stmt_list "#/" -#line 332 "parser.ypp" +#line 326 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2250 "parser.cpp" +#line 2249 "parser.cpp" break; case 47: // stmt_dev: "/#" "#/" -#line 333 "parser.ypp" +#line 327 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2256 "parser.cpp" +#line 2255 "parser.cpp" break; case 48: // stmt_block: "{" stmt_list "}" -#line 337 "parser.ypp" +#line 331 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2262 "parser.cpp" +#line 2261 "parser.cpp" break; case 49: // stmt_block: "{" "}" -#line 338 "parser.ypp" +#line 332 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2268 "parser.cpp" +#line 2267 "parser.cpp" break; case 50: // stmt_list: stmt_list stmt -#line 343 "parser.ypp" +#line 337 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2274 "parser.cpp" +#line 2273 "parser.cpp" break; case 51: // stmt_list: stmt -#line 345 "parser.ypp" +#line 339 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2280 "parser.cpp" +#line 2279 "parser.cpp" break; case 52: // stmt_expr: expr_assign -#line 350 "parser.ypp" +#line 344 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2286 "parser.cpp" +#line 2285 "parser.cpp" break; case 53: // stmt_expr: expr_increment -#line 352 "parser.ypp" +#line 346 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2292 "parser.cpp" +#line 2291 "parser.cpp" break; case 54: // stmt_expr: expr_decrement -#line 354 "parser.ypp" +#line 348 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2298 "parser.cpp" +#line 2297 "parser.cpp" break; case 55: // stmt_expr: %empty -#line 356 "parser.ypp" +#line 350 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2304 "parser.cpp" +#line 2303 "parser.cpp" break; case 56: // stmt_call: expr_call ";" -#line 361 "parser.ypp" +#line 355 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_call::ptr > ()))); } -#line 2310 "parser.cpp" +#line 2309 "parser.cpp" break; case 57: // stmt_call: expr_method ";" -#line 363 "parser.ypp" +#line 357 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_method::ptr > ()))); } -#line 2316 "parser.cpp" +#line 2315 "parser.cpp" break; case 58: // stmt_assign: expr_assign ";" -#line 368 "parser.ypp" +#line 362 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2322 "parser.cpp" +#line 2321 "parser.cpp" break; case 59: // stmt_assign: expr_increment ";" -#line 370 "parser.ypp" +#line 364 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2328 "parser.cpp" +#line 2327 "parser.cpp" break; case 60: // stmt_assign: expr_decrement ";" -#line 372 "parser.ypp" +#line 366 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2334 "parser.cpp" +#line 2333 "parser.cpp" break; case 61: // stmt_endon: expr_object "endon" "(" expr ")" ";" -#line 377 "parser.ypp" +#line 371 "parser.ypp" { yylhs.value.as < ast::stmt_endon::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ())); } -#line 2340 "parser.cpp" +#line 2339 "parser.cpp" break; case 62: // stmt_notify: expr_object "notify" "(" expr "," expr_arguments_no_empty ")" ";" -#line 382 "parser.ypp" +#line 376 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2346 "parser.cpp" +#line 2345 "parser.cpp" break; case 63: // stmt_notify: expr_object "notify" "(" expr ")" ";" -#line 384 "parser.ypp" +#line 378 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2352 "parser.cpp" +#line 2351 "parser.cpp" break; case 64: // stmt_wait: "wait" expr ";" -#line 389 "parser.ypp" +#line 383 "parser.ypp" { yylhs.value.as < ast::stmt_wait::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2358 "parser.cpp" +#line 2357 "parser.cpp" break; case 65: // stmt_waittill: expr_object "waittill" "(" expr "," expr_arguments_no_empty ")" ";" -#line 394 "parser.ypp" +#line 388 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2364 "parser.cpp" +#line 2363 "parser.cpp" break; case 66: // stmt_waittill: expr_object "waittill" "(" expr ")" ";" -#line 396 "parser.ypp" +#line 390 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2370 "parser.cpp" +#line 2369 "parser.cpp" break; case 67: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr "," expr_arguments_no_empty ")" ";" -#line 401 "parser.ypp" +#line 395 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2376 "parser.cpp" +#line 2375 "parser.cpp" break; case 68: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr ")" ";" -#line 403 "parser.ypp" +#line 397 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2382 "parser.cpp" +#line 2381 "parser.cpp" break; case 69: // stmt_waittillframeend: "waittillframeend" ";" -#line 408 "parser.ypp" +#line 402 "parser.ypp" { yylhs.value.as < ast::stmt_waittillframeend::ptr > () = std::make_unique(yylhs.location); } -#line 2388 "parser.cpp" +#line 2387 "parser.cpp" break; case 70: // stmt_waitframe: "waitframe" ";" -#line 413 "parser.ypp" +#line 407 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2394 "parser.cpp" +#line 2393 "parser.cpp" break; case 71: // stmt_waitframe: "waitframe" "(" ")" ";" -#line 415 "parser.ypp" +#line 409 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2400 "parser.cpp" +#line 2399 "parser.cpp" break; case 72: // stmt_if: "if" "(" expr ")" stmt -#line 420 "parser.ypp" +#line 414 "parser.ypp" { yylhs.value.as < ast::stmt_if::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2406 "parser.cpp" +#line 2405 "parser.cpp" break; case 73: // stmt_ifelse: "if" "(" expr ")" stmt "else" stmt -#line 425 "parser.ypp" +#line 419 "parser.ypp" { yylhs.value.as < ast::stmt_ifelse::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::stmt > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2412 "parser.cpp" +#line 2411 "parser.cpp" break; case 74: // stmt_while: "while" "(" expr ")" stmt -#line 430 "parser.ypp" +#line 424 "parser.ypp" { yylhs.value.as < ast::stmt_while::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2418 "parser.cpp" +#line 2417 "parser.cpp" break; case 75: // stmt_dowhile: "do" stmt "while" "(" expr ")" ";" -#line 435 "parser.ypp" +#line 429 "parser.ypp" { yylhs.value.as < ast::stmt_dowhile::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[5].value.as < ast::stmt > ())); } -#line 2424 "parser.cpp" +#line 2423 "parser.cpp" break; case 76: // stmt_for: "for" "(" stmt_expr ";" expr_or_empty ";" stmt_expr ")" stmt -#line 440 "parser.ypp" +#line 434 "parser.ypp" { yylhs.value.as < ast::stmt_for::ptr > () = std::make_unique(yylhs.location, ast::stmt(std::move(yystack_[6].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[4].value.as < ast::expr > ()), ast::stmt(std::move(yystack_[2].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2430 "parser.cpp" +#line 2429 "parser.cpp" break; case 77: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt -#line 445 "parser.ypp" +#line 439 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2436 "parser.cpp" +#line 2435 "parser.cpp" break; case 78: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt -#line 447 "parser.ypp" +#line 441 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[6].value.as < ast::expr_identifier::ptr > ())), ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2442 "parser.cpp" +#line 2441 "parser.cpp" break; case 79: // stmt_switch: "switch" "(" expr ")" stmt_block -#line 452 "parser.ypp" +#line 446 "parser.ypp" { yylhs.value.as < ast::stmt_switch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2448 "parser.cpp" +#line 2447 "parser.cpp" break; case 80: // stmt_case: "case" expr_integer ":" -#line 457 "parser.ypp" +#line 451 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_integer::ptr > ())), std::make_unique(yylhs.location)); } -#line 2454 "parser.cpp" +#line 2453 "parser.cpp" break; case 81: // stmt_case: "case" expr_string ":" -#line 459 "parser.ypp" +#line 453 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_string::ptr > ())), std::make_unique(yylhs.location)); } -#line 2460 "parser.cpp" +#line 2459 "parser.cpp" break; case 82: // stmt_default: "default" ":" -#line 464 "parser.ypp" +#line 458 "parser.ypp" { yylhs.value.as < ast::stmt_default::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2466 "parser.cpp" +#line 2465 "parser.cpp" break; case 83: // stmt_break: "break" ";" -#line 469 "parser.ypp" +#line 463 "parser.ypp" { yylhs.value.as < ast::stmt_break::ptr > () = std::make_unique(yylhs.location); } -#line 2472 "parser.cpp" +#line 2471 "parser.cpp" break; case 84: // stmt_continue: "continue" ";" -#line 474 "parser.ypp" +#line 468 "parser.ypp" { yylhs.value.as < ast::stmt_continue::ptr > () = std::make_unique(yylhs.location); } -#line 2478 "parser.cpp" +#line 2477 "parser.cpp" break; case 85: // stmt_return: "return" expr ";" -#line 479 "parser.ypp" +#line 473 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2484 "parser.cpp" +#line 2483 "parser.cpp" break; case 86: // stmt_return: "return" ";" -#line 481 "parser.ypp" +#line 475 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2490 "parser.cpp" +#line 2489 "parser.cpp" break; case 87: // stmt_breakpoint: "breakpoint" ";" -#line 486 "parser.ypp" +#line 480 "parser.ypp" { yylhs.value.as < ast::stmt_breakpoint::ptr > () = std::make_unique(yylhs.location); } -#line 2496 "parser.cpp" +#line 2495 "parser.cpp" break; case 88: // stmt_prof_begin: "prof_begin" "(" expr_arguments ")" ";" -#line 491 "parser.ypp" +#line 485 "parser.ypp" { yylhs.value.as < ast::stmt_prof_begin::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2502 "parser.cpp" +#line 2501 "parser.cpp" break; case 89: // stmt_prof_end: "prof_end" "(" expr_arguments ")" ";" -#line 496 "parser.ypp" +#line 490 "parser.ypp" { yylhs.value.as < ast::stmt_prof_end::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2508 "parser.cpp" +#line 2507 "parser.cpp" break; case 90: // expr: expr_ternary -#line 500 "parser.ypp" +#line 494 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2514 "parser.cpp" +#line 2513 "parser.cpp" break; case 91: // expr: expr_binary -#line 501 "parser.ypp" +#line 495 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2520 "parser.cpp" +#line 2519 "parser.cpp" break; case 92: // expr: expr_primitive -#line 502 "parser.ypp" +#line 496 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2526 "parser.cpp" +#line 2525 "parser.cpp" break; case 93: // expr_or_empty: expr -#line 506 "parser.ypp" +#line 500 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2532 "parser.cpp" +#line 2531 "parser.cpp" break; case 94: // expr_or_empty: %empty -#line 507 "parser.ypp" +#line 501 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location); } -#line 2538 "parser.cpp" +#line 2537 "parser.cpp" break; case 95: // expr_assign: expr_object "=" expr -#line 512 "parser.ypp" +#line 506 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2544 "parser.cpp" +#line 2543 "parser.cpp" break; case 96: // expr_assign: expr_object "|=" expr -#line 514 "parser.ypp" +#line 508 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2550 "parser.cpp" +#line 2549 "parser.cpp" break; case 97: // expr_assign: expr_object "&=" expr -#line 516 "parser.ypp" +#line 510 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2556 "parser.cpp" +#line 2555 "parser.cpp" break; case 98: // expr_assign: expr_object "^=" expr -#line 518 "parser.ypp" +#line 512 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2562 "parser.cpp" +#line 2561 "parser.cpp" break; case 99: // expr_assign: expr_object "<<=" expr -#line 520 "parser.ypp" +#line 514 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()),std::move( yystack_[0].value.as < ast::expr > ())); } -#line 2568 "parser.cpp" +#line 2567 "parser.cpp" break; case 100: // expr_assign: expr_object ">>=" expr -#line 522 "parser.ypp" +#line 516 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2574 "parser.cpp" +#line 2573 "parser.cpp" break; case 101: // expr_assign: expr_object "+=" expr -#line 524 "parser.ypp" +#line 518 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2580 "parser.cpp" +#line 2579 "parser.cpp" break; case 102: // expr_assign: expr_object "-=" expr -#line 526 "parser.ypp" +#line 520 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2586 "parser.cpp" +#line 2585 "parser.cpp" break; case 103: // expr_assign: expr_object "*=" expr -#line 528 "parser.ypp" +#line 522 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2592 "parser.cpp" +#line 2591 "parser.cpp" break; case 104: // expr_assign: expr_object "/=" expr -#line 530 "parser.ypp" +#line 524 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2598 "parser.cpp" +#line 2597 "parser.cpp" break; case 105: // expr_assign: expr_object "%=" expr -#line 532 "parser.ypp" +#line 526 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2604 "parser.cpp" +#line 2603 "parser.cpp" break; case 106: // expr_increment: "++" expr_object -#line 537 "parser.ypp" +#line 531 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2610 "parser.cpp" +#line 2609 "parser.cpp" break; case 107: // expr_increment: expr_object "++" -#line 539 "parser.ypp" +#line 533 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2616 "parser.cpp" +#line 2615 "parser.cpp" break; case 108: // expr_decrement: "--" expr_object -#line 544 "parser.ypp" +#line 538 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2622 "parser.cpp" +#line 2621 "parser.cpp" break; case 109: // expr_decrement: expr_object "--" -#line 546 "parser.ypp" +#line 540 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2628 "parser.cpp" +#line 2627 "parser.cpp" break; case 110: // expr_ternary: expr "?" expr ":" expr -#line 551 "parser.ypp" +#line 545 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2634 "parser.cpp" +#line 2633 "parser.cpp" break; case 111: // expr_binary: expr "||" expr -#line 556 "parser.ypp" +#line 550 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2640 "parser.cpp" +#line 2639 "parser.cpp" break; case 112: // expr_binary: expr "&&" expr -#line 558 "parser.ypp" +#line 552 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2646 "parser.cpp" +#line 2645 "parser.cpp" break; case 113: // expr_binary: expr "==" expr -#line 560 "parser.ypp" +#line 554 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2652 "parser.cpp" +#line 2651 "parser.cpp" break; case 114: // expr_binary: expr "!=" expr -#line 562 "parser.ypp" +#line 556 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2658 "parser.cpp" +#line 2657 "parser.cpp" break; case 115: // expr_binary: expr "<=" expr -#line 564 "parser.ypp" +#line 558 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2664 "parser.cpp" +#line 2663 "parser.cpp" break; case 116: // expr_binary: expr ">=" expr -#line 566 "parser.ypp" +#line 560 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2670 "parser.cpp" +#line 2669 "parser.cpp" break; case 117: // expr_binary: expr "<" expr -#line 568 "parser.ypp" +#line 562 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2676 "parser.cpp" +#line 2675 "parser.cpp" break; case 118: // expr_binary: expr ">" expr -#line 570 "parser.ypp" +#line 564 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2682 "parser.cpp" +#line 2681 "parser.cpp" break; case 119: // expr_binary: expr "|" expr -#line 572 "parser.ypp" +#line 566 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2688 "parser.cpp" +#line 2687 "parser.cpp" break; case 120: // expr_binary: expr "&" expr -#line 574 "parser.ypp" +#line 568 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2694 "parser.cpp" +#line 2693 "parser.cpp" break; case 121: // expr_binary: expr "^" expr -#line 576 "parser.ypp" +#line 570 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2700 "parser.cpp" +#line 2699 "parser.cpp" break; case 122: // expr_binary: expr "<<" expr -#line 578 "parser.ypp" +#line 572 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2706 "parser.cpp" +#line 2705 "parser.cpp" break; case 123: // expr_binary: expr ">>" expr -#line 580 "parser.ypp" +#line 574 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2712 "parser.cpp" +#line 2711 "parser.cpp" break; case 124: // expr_binary: expr "+" expr -#line 582 "parser.ypp" +#line 576 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2718 "parser.cpp" +#line 2717 "parser.cpp" break; case 125: // expr_binary: expr "-" expr -#line 584 "parser.ypp" +#line 578 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2724 "parser.cpp" +#line 2723 "parser.cpp" break; case 126: // expr_binary: expr "*" expr -#line 586 "parser.ypp" +#line 580 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2730 "parser.cpp" +#line 2729 "parser.cpp" break; case 127: // expr_binary: expr "/" expr -#line 588 "parser.ypp" +#line 582 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2736 "parser.cpp" +#line 2735 "parser.cpp" break; case 128: // expr_binary: expr "%" expr -#line 590 "parser.ypp" +#line 584 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2742 "parser.cpp" +#line 2741 "parser.cpp" break; case 129: // expr_primitive: expr_complement -#line 594 "parser.ypp" +#line 588 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_complement::ptr > ()); } -#line 2748 "parser.cpp" +#line 2747 "parser.cpp" break; case 130: // expr_primitive: expr_not -#line 595 "parser.ypp" +#line 589 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_not::ptr > ()); } -#line 2754 "parser.cpp" +#line 2753 "parser.cpp" break; case 131: // expr_primitive: expr_call -#line 596 "parser.ypp" +#line 590 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 2760 "parser.cpp" +#line 2759 "parser.cpp" break; case 132: // expr_primitive: expr_method -#line 597 "parser.ypp" +#line 591 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 2766 "parser.cpp" +#line 2765 "parser.cpp" break; case 133: // expr_primitive: expr_add_array -#line 598 "parser.ypp" +#line 592 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_add_array::ptr > ()); } -#line 2772 "parser.cpp" +#line 2771 "parser.cpp" break; case 134: // expr_primitive: expr_reference -#line 599 "parser.ypp" +#line 593 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_reference::ptr > ()); } -#line 2778 "parser.cpp" +#line 2777 "parser.cpp" break; case 135: // expr_primitive: expr_array -#line 600 "parser.ypp" +#line 594 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 2784 "parser.cpp" +#line 2783 "parser.cpp" break; case 136: // expr_primitive: expr_field -#line 601 "parser.ypp" +#line 595 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 2790 "parser.cpp" +#line 2789 "parser.cpp" break; case 137: // expr_primitive: expr_size -#line 602 "parser.ypp" +#line 596 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_size::ptr > ()); } -#line 2796 "parser.cpp" +#line 2795 "parser.cpp" break; case 138: // expr_primitive: expr_paren -#line 603 "parser.ypp" +#line 597 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_paren::ptr > ()); } -#line 2802 "parser.cpp" +#line 2801 "parser.cpp" break; case 139: // expr_primitive: expr_thisthread -#line 604 "parser.ypp" +#line 598 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_thisthread::ptr > ()); } -#line 2808 "parser.cpp" +#line 2807 "parser.cpp" break; case 140: // expr_primitive: expr_empty_array -#line 605 "parser.ypp" +#line 599 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_empty_array::ptr > ()); } -#line 2814 "parser.cpp" +#line 2813 "parser.cpp" break; case 141: // expr_primitive: expr_undefined -#line 606 "parser.ypp" +#line 600 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_undefined::ptr > ()); } -#line 2820 "parser.cpp" +#line 2819 "parser.cpp" break; case 142: // expr_primitive: expr_game -#line 607 "parser.ypp" +#line 601 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 2826 "parser.cpp" +#line 2825 "parser.cpp" break; case 143: // expr_primitive: expr_self -#line 608 "parser.ypp" +#line 602 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 2832 "parser.cpp" +#line 2831 "parser.cpp" break; case 144: // expr_primitive: expr_anim -#line 609 "parser.ypp" +#line 603 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 2838 "parser.cpp" +#line 2837 "parser.cpp" break; case 145: // expr_primitive: expr_level -#line 610 "parser.ypp" +#line 604 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 2844 "parser.cpp" +#line 2843 "parser.cpp" break; case 146: // expr_primitive: expr_animation -#line 611 "parser.ypp" +#line 605 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animation::ptr > ()); } -#line 2850 "parser.cpp" +#line 2849 "parser.cpp" break; case 147: // expr_primitive: expr_animtree -#line 612 "parser.ypp" +#line 606 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animtree::ptr > ()); } -#line 2856 "parser.cpp" +#line 2855 "parser.cpp" break; case 148: // expr_primitive: expr_identifier -#line 613 "parser.ypp" +#line 607 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 2862 "parser.cpp" +#line 2861 "parser.cpp" break; case 149: // expr_primitive: expr_istring -#line 614 "parser.ypp" +#line 608 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istring::ptr > ()); } -#line 2868 "parser.cpp" +#line 2867 "parser.cpp" break; case 150: // expr_primitive: expr_string -#line 615 "parser.ypp" +#line 609 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_string::ptr > ()); } -#line 2874 "parser.cpp" +#line 2873 "parser.cpp" break; case 151: // expr_primitive: expr_color -#line 616 "parser.ypp" +#line 610 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_color::ptr > ()); } -#line 2880 "parser.cpp" +#line 2879 "parser.cpp" break; case 152: // expr_primitive: expr_vector -#line 617 "parser.ypp" +#line 611 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_vector::ptr > ()); } -#line 2886 "parser.cpp" +#line 2885 "parser.cpp" break; case 153: // expr_primitive: expr_float -#line 618 "parser.ypp" +#line 612 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_float::ptr > ()); } -#line 2892 "parser.cpp" +#line 2891 "parser.cpp" break; case 154: // expr_primitive: expr_integer -#line 619 "parser.ypp" +#line 613 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_integer::ptr > ()); } -#line 2898 "parser.cpp" +#line 2897 "parser.cpp" break; case 155: // expr_primitive: expr_false -#line 620 "parser.ypp" +#line 614 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_false::ptr > ()); } -#line 2904 "parser.cpp" +#line 2903 "parser.cpp" break; case 156: // expr_primitive: expr_true -#line 621 "parser.ypp" +#line 615 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_true::ptr > ()); } -#line 2910 "parser.cpp" +#line 2909 "parser.cpp" break; case 157: // expr_complement: "~" expr -#line 626 "parser.ypp" +#line 620 "parser.ypp" { yylhs.value.as < ast::expr_complement::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2916 "parser.cpp" +#line 2915 "parser.cpp" break; case 158: // expr_not: "!" expr -#line 631 "parser.ypp" +#line 625 "parser.ypp" { yylhs.value.as < ast::expr_not::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2922 "parser.cpp" +#line 2921 "parser.cpp" break; case 159: // expr_call: expr_function -#line 635 "parser.ypp" +#line 629 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2928 "parser.cpp" +#line 2927 "parser.cpp" break; case 160: // expr_call: expr_pointer -#line 636 "parser.ypp" +#line 630 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2934 "parser.cpp" +#line 2933 "parser.cpp" break; case 161: // expr_method: expr_object expr_function -#line 639 "parser.ypp" +#line 633 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2940 "parser.cpp" +#line 2939 "parser.cpp" break; case 162: // expr_method: expr_object expr_pointer -#line 640 "parser.ypp" +#line 634 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2946 "parser.cpp" +#line 2945 "parser.cpp" break; case 163: // expr_function: expr_identifier "(" expr_arguments ")" -#line 645 "parser.ypp" +#line 639 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2952 "parser.cpp" +#line 2951 "parser.cpp" break; case 164: // expr_function: expr_path "::" expr_identifier "(" expr_arguments ")" -#line 647 "parser.ypp" +#line 641 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2958 "parser.cpp" +#line 2957 "parser.cpp" break; case 165: // expr_function: "thread" expr_identifier "(" expr_arguments ")" -#line 649 "parser.ypp" +#line 643 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2964 "parser.cpp" +#line 2963 "parser.cpp" break; case 166: // expr_function: "thread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 651 "parser.ypp" +#line 645 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2970 "parser.cpp" +#line 2969 "parser.cpp" break; case 167: // expr_function: "childthread" expr_identifier "(" expr_arguments ")" -#line 653 "parser.ypp" +#line 647 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2976 "parser.cpp" +#line 2975 "parser.cpp" break; case 168: // expr_function: "childthread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 655 "parser.ypp" +#line 649 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2982 "parser.cpp" +#line 2981 "parser.cpp" break; case 169: // expr_pointer: "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 660 "parser.ypp" +#line 654 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2988 "parser.cpp" +#line 2987 "parser.cpp" break; case 170: // expr_pointer: "thread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 662 "parser.ypp" +#line 656 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2994 "parser.cpp" +#line 2993 "parser.cpp" break; case 171: // expr_pointer: "childthread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 664 "parser.ypp" +#line 658 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3000 "parser.cpp" +#line 2999 "parser.cpp" break; case 172: // expr_pointer: "call" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 666 "parser.ypp" +#line 660 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::builtin); } -#line 3006 "parser.cpp" +#line 3005 "parser.cpp" break; case 173: // expr_add_array: "[" expr_arguments_no_empty "]" -#line 671 "parser.ypp" +#line 665 "parser.ypp" { yylhs.value.as < ast::expr_add_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ())); } -#line 3012 "parser.cpp" +#line 3011 "parser.cpp" break; case 174: // expr_parameters: expr_parameters "," expr_identifier -#line 676 "parser.ypp" +#line 670 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3018 "parser.cpp" +#line 3017 "parser.cpp" break; case 175: // expr_parameters: expr_identifier -#line 678 "parser.ypp" +#line 672 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3024 "parser.cpp" +#line 3023 "parser.cpp" break; case 176: // expr_parameters: %empty -#line 680 "parser.ypp" +#line 674 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); } -#line 3030 "parser.cpp" +#line 3029 "parser.cpp" break; case 177: // expr_arguments: expr_arguments_no_empty -#line 685 "parser.ypp" +#line 679 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[0].value.as < ast::expr_arguments::ptr > ()); } -#line 3036 "parser.cpp" +#line 3035 "parser.cpp" break; case 178: // expr_arguments: %empty -#line 687 "parser.ypp" +#line 681 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); } -#line 3042 "parser.cpp" +#line 3041 "parser.cpp" break; case 179: // expr_arguments_no_empty: expr_arguments "," expr -#line 692 "parser.ypp" +#line 686 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ()); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3048 "parser.cpp" +#line 3047 "parser.cpp" break; case 180: // expr_arguments_no_empty: expr -#line 694 "parser.ypp" +#line 688 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3054 "parser.cpp" +#line 3053 "parser.cpp" break; case 181: // expr_reference: "::" expr_identifier -#line 699 "parser.ypp" +#line 693 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3060 "parser.cpp" +#line 3059 "parser.cpp" break; case 182: // expr_reference: expr_path "::" expr_identifier -#line 701 "parser.ypp" +#line 695 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_path::ptr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3066 "parser.cpp" +#line 3065 "parser.cpp" break; case 183: // expr_array: expr_object "[" expr "]" -#line 706 "parser.ypp" +#line 700 "parser.ypp" { yylhs.value.as < ast::expr_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3072 "parser.cpp" +#line 3071 "parser.cpp" break; case 184: // expr_field: expr_object "." expr_identifier -#line 711 "parser.ypp" +#line 705 "parser.ypp" { yylhs.value.as < ast::expr_field::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3078 "parser.cpp" +#line 3077 "parser.cpp" break; case 185: // expr_size: expr_object ".size" -#line 716 "parser.ypp" +#line 710 "parser.ypp" { yylhs.value.as < ast::expr_size::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3084 "parser.cpp" +#line 3083 "parser.cpp" break; case 186: // expr_paren: "(" expr ")" -#line 721 "parser.ypp" +#line 715 "parser.ypp" { yylhs.value.as < ast::expr_paren::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3090 "parser.cpp" +#line 3089 "parser.cpp" break; case 187: // expr_object: expr_call -#line 725 "parser.ypp" +#line 719 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 3096 "parser.cpp" +#line 3095 "parser.cpp" break; case 188: // expr_object: expr_method -#line 726 "parser.ypp" +#line 720 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 3102 "parser.cpp" +#line 3101 "parser.cpp" break; case 189: // expr_object: expr_array -#line 727 "parser.ypp" +#line 721 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 3108 "parser.cpp" +#line 3107 "parser.cpp" break; case 190: // expr_object: expr_field -#line 728 "parser.ypp" +#line 722 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 3114 "parser.cpp" +#line 3113 "parser.cpp" break; case 191: // expr_object: expr_game -#line 729 "parser.ypp" +#line 723 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 3120 "parser.cpp" +#line 3119 "parser.cpp" break; case 192: // expr_object: expr_self -#line 730 "parser.ypp" +#line 724 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 3126 "parser.cpp" +#line 3125 "parser.cpp" break; case 193: // expr_object: expr_anim -#line 731 "parser.ypp" +#line 725 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 3132 "parser.cpp" +#line 3131 "parser.cpp" break; case 194: // expr_object: expr_level -#line 732 "parser.ypp" +#line 726 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 3138 "parser.cpp" +#line 3137 "parser.cpp" break; case 195: // expr_object: expr_identifier -#line 733 "parser.ypp" +#line 727 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 3144 "parser.cpp" +#line 3143 "parser.cpp" break; case 196: // expr_thisthread: "thisthread" -#line 738 "parser.ypp" +#line 732 "parser.ypp" { yylhs.value.as < ast::expr_thisthread::ptr > () = std::make_unique(yylhs.location); } -#line 3150 "parser.cpp" +#line 3149 "parser.cpp" break; case 197: // expr_empty_array: "[" "]" -#line 743 "parser.ypp" +#line 737 "parser.ypp" { yylhs.value.as < ast::expr_empty_array::ptr > () = std::make_unique(yylhs.location); } -#line 3156 "parser.cpp" +#line 3155 "parser.cpp" break; case 198: // expr_undefined: "undefined" -#line 748 "parser.ypp" +#line 742 "parser.ypp" { yylhs.value.as < ast::expr_undefined::ptr > () = std::make_unique(yylhs.location); } -#line 3162 "parser.cpp" +#line 3161 "parser.cpp" break; case 199: // expr_game: "game" -#line 753 "parser.ypp" +#line 747 "parser.ypp" { yylhs.value.as < ast::expr_game::ptr > () = std::make_unique(yylhs.location); } -#line 3168 "parser.cpp" +#line 3167 "parser.cpp" break; case 200: // expr_self: "self" -#line 758 "parser.ypp" +#line 752 "parser.ypp" { yylhs.value.as < ast::expr_self::ptr > () = std::make_unique(yylhs.location); } -#line 3174 "parser.cpp" +#line 3173 "parser.cpp" break; case 201: // expr_anim: "anim" -#line 763 "parser.ypp" +#line 757 "parser.ypp" { yylhs.value.as < ast::expr_anim::ptr > () = std::make_unique(yylhs.location); } -#line 3180 "parser.cpp" +#line 3179 "parser.cpp" break; case 202: // expr_level: "level" -#line 768 "parser.ypp" +#line 762 "parser.ypp" { yylhs.value.as < ast::expr_level::ptr > () = std::make_unique(yylhs.location); } -#line 3186 "parser.cpp" +#line 3185 "parser.cpp" break; case 203: // expr_animation: "%" "identifier" -#line 773 "parser.ypp" +#line 767 "parser.ypp" { yylhs.value.as < ast::expr_animation::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3192 "parser.cpp" +#line 3191 "parser.cpp" break; case 204: // expr_animtree: "#animtree" -#line 778 "parser.ypp" +#line 772 "parser.ypp" { yylhs.value.as < ast::expr_animtree::ptr > () = std::make_unique(yylhs.location); } -#line 3198 "parser.cpp" +#line 3197 "parser.cpp" break; case 205: // expr_identifier: "identifier" -#line 783 "parser.ypp" +#line 777 "parser.ypp" { yylhs.value.as < ast::expr_identifier::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3204 "parser.cpp" +#line 3203 "parser.cpp" break; case 206: // expr_path: "path" -#line 788 "parser.ypp" +#line 782 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3210 "parser.cpp" +#line 3209 "parser.cpp" break; case 207: // expr_path: expr_identifier -#line 790 "parser.ypp" +#line 784 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < ast::expr_identifier::ptr > ()->value); } -#line 3216 "parser.cpp" +#line 3215 "parser.cpp" break; case 208: // expr_istring: "localized string" -#line 795 "parser.ypp" +#line 789 "parser.ypp" { yylhs.value.as < ast::expr_istring::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3222 "parser.cpp" +#line 3221 "parser.cpp" break; case 209: // expr_string: "string literal" -#line 800 "parser.ypp" +#line 794 "parser.ypp" { yylhs.value.as < ast::expr_string::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3228 "parser.cpp" +#line 3227 "parser.cpp" break; case 210: // expr_color: "color" -#line 805 "parser.ypp" +#line 799 "parser.ypp" { yylhs.value.as < ast::expr_color::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3234 "parser.cpp" +#line 3233 "parser.cpp" break; case 211: // expr_vector: "(" expr "," expr "," expr ")" -#line 810 "parser.ypp" +#line 804 "parser.ypp" { yylhs.value.as < ast::expr_vector::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3240 "parser.cpp" +#line 3239 "parser.cpp" break; case 212: // expr_float: "-" "float" -#line 815 "parser.ypp" +#line 809 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3246 "parser.cpp" +#line 3245 "parser.cpp" break; case 213: // expr_float: "float" -#line 817 "parser.ypp" +#line 811 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3252 "parser.cpp" +#line 3251 "parser.cpp" break; case 214: // expr_integer: "-" "integer" -#line 822 "parser.ypp" +#line 816 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3258 "parser.cpp" +#line 3257 "parser.cpp" break; case 215: // expr_integer: "integer" -#line 824 "parser.ypp" +#line 818 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3264 "parser.cpp" +#line 3263 "parser.cpp" break; case 216: // expr_false: "false" -#line 829 "parser.ypp" +#line 823 "parser.ypp" { yylhs.value.as < ast::expr_false::ptr > () = std::make_unique(yylhs.location); } -#line 3270 "parser.cpp" +#line 3269 "parser.cpp" break; case 217: // expr_true: "true" -#line 834 "parser.ypp" +#line 828 "parser.ypp" { yylhs.value.as < ast::expr_true::ptr > () = std::make_unique(yylhs.location); } -#line 3276 "parser.cpp" +#line 3275 "parser.cpp" break; -#line 3280 "parser.cpp" +#line 3279 "parser.cpp" default: break; @@ -4446,28 +4445,28 @@ namespace xsk { namespace gsc { namespace h1 { const short parser::yyrline_[] = { - 0, 251, 251, 252, 256, 258, 260, 262, 264, 266, - 271, 275, 280, 281, 282, 283, 284, 288, 293, 298, - 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, - 323, 324, 325, 326, 327, 328, 332, 333, 337, 338, - 342, 344, 349, 351, 353, 356, 360, 362, 367, 369, - 371, 376, 381, 383, 388, 393, 395, 400, 402, 407, - 412, 414, 419, 424, 429, 434, 439, 444, 446, 451, - 456, 458, 463, 468, 473, 478, 480, 485, 490, 495, - 500, 501, 502, 506, 507, 511, 513, 515, 517, 519, - 521, 523, 525, 527, 529, 531, 536, 538, 543, 545, - 550, 555, 557, 559, 561, 563, 565, 567, 569, 571, - 573, 575, 577, 579, 581, 583, 585, 587, 589, 594, - 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, - 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, - 615, 616, 617, 618, 619, 620, 621, 625, 630, 635, - 636, 639, 640, 644, 646, 648, 650, 652, 654, 659, - 661, 663, 665, 670, 675, 677, 680, 684, 687, 691, - 693, 698, 700, 705, 710, 715, 720, 725, 726, 727, - 728, 729, 730, 731, 732, 733, 737, 742, 747, 752, - 757, 762, 767, 772, 777, 782, 787, 789, 794, 799, - 804, 809, 814, 816, 821, 823, 828, 833 + 0, 245, 245, 246, 250, 252, 254, 256, 258, 260, + 265, 269, 274, 275, 276, 277, 278, 282, 287, 292, + 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 326, 327, 331, 332, + 336, 338, 343, 345, 347, 350, 354, 356, 361, 363, + 365, 370, 375, 377, 382, 387, 389, 394, 396, 401, + 406, 408, 413, 418, 423, 428, 433, 438, 440, 445, + 450, 452, 457, 462, 467, 472, 474, 479, 484, 489, + 494, 495, 496, 500, 501, 505, 507, 509, 511, 513, + 515, 517, 519, 521, 523, 525, 530, 532, 537, 539, + 544, 549, 551, 553, 555, 557, 559, 561, 563, 565, + 567, 569, 571, 573, 575, 577, 579, 581, 583, 588, + 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, + 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, + 609, 610, 611, 612, 613, 614, 615, 619, 624, 629, + 630, 633, 634, 638, 640, 642, 644, 646, 648, 653, + 655, 657, 659, 664, 669, 671, 674, 678, 681, 685, + 687, 692, 694, 699, 704, 709, 714, 719, 720, 721, + 722, 723, 724, 725, 726, 727, 731, 736, 741, 746, + 751, 756, 761, 766, 771, 776, 781, 783, 788, 793, + 798, 803, 808, 810, 815, 817, 822, 827 }; void @@ -4500,9 +4499,9 @@ namespace xsk { namespace gsc { namespace h1 { #line 13 "parser.ypp" } } } // xsk::gsc::h1 -#line 4504 "parser.cpp" +#line 4503 "parser.cpp" -#line 837 "parser.ypp" +#line 831 "parser.ypp" void xsk::gsc::h1::parser::error(const xsk::gsc::location& loc, const std::string& msg) diff --git a/src/h1/xsk/parser.hpp b/src/h1/xsk/parser.hpp index 3a62bfcc..b7daac55 100644 --- a/src/h1/xsk/parser.hpp +++ b/src/h1/xsk/parser.hpp @@ -45,13 +45,12 @@ #ifndef YY_H1_PARSER_HPP_INCLUDED # define YY_H1_PARSER_HPP_INCLUDED // "%code requires" blocks. -#line 33 "parser.ypp" +#line 28 "parser.ypp" #include "h1.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::h1::parser::symbol_type H1lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::h1 { class lexer; } -#line 55 "parser.hpp" +#line 54 "parser.hpp" # include # include // std::abort @@ -194,7 +193,7 @@ typedef void *yyscan_t; #line 13 "parser.ypp" namespace xsk { namespace gsc { namespace h1 { -#line 198 "parser.hpp" +#line 197 "parser.hpp" @@ -2685,7 +2684,7 @@ switch (yykind) }; /// Build a parser object. - parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); + parser (xsk::gsc::h1::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); virtual ~parser (); #if 201103L <= YY_CPLUSPLUS @@ -4656,8 +4655,7 @@ switch (yykind) // User arguments. - yyscan_t yyscanner; - xsk::gsc::context* ctx; + xsk::gsc::h1::lexer& lexer; xsk::gsc::ast::program::ptr& ast; }; @@ -5342,7 +5340,7 @@ switch (yykind) #line 13 "parser.ypp" } } } // xsk::gsc::h1 -#line 5346 "parser.hpp" +#line 5344 "parser.hpp" diff --git a/src/h1/xsk/resolver.cpp b/src/h1/xsk/resolver.cpp index 722cc847..aaf16f11 100644 --- a/src/h1/xsk/resolver.cpp +++ b/src/h1/xsk/resolver.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -206,6 +206,35 @@ auto resolver::make_token(std::string_view str) -> std::string return data; } +std::function(const std::string&)> read_callback = nullptr; +std::unordered_map> files; + +auto resolver::file_data(const std::string& name) -> std::tuple +{ + const auto& itr = files.find(name); + + if(itr != files.end()) + { + return { &itr->first ,reinterpret_cast(itr->second.data()), itr->second.size() }; + } + + auto data = read_callback(name); + + const auto& res = files.insert({ name, std::move(data)}); + + if(res.second) + { + return { &res.first->first, reinterpret_cast(res.first->second.data()), res.first->second.size() }; + } + + throw error("couldn't open gsc file '" + name + "'"); +} + +void resolver::set_reader(std::function(const std::string&)> callback) +{ + read_callback = callback; +} + const std::array, 154> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/h1/xsk/resolver.hpp b/src/h1/xsk/resolver.hpp index eb5213b1..25386738 100644 --- a/src/h1/xsk/resolver.hpp +++ b/src/h1/xsk/resolver.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -30,6 +30,8 @@ public: static auto find_method(const std::string& name) -> bool; static auto make_token(std::string_view str) -> std::string; + static auto file_data(const std::string& name) -> std::tuple; + static void set_reader(std::function(const std::string&)> callback); }; } // namespace xsk::gsc::h1 diff --git a/src/h2/stdafx.cpp b/src/h2/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/h2/stdafx.cpp +++ b/src/h2/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/stdafx.hpp b/src/h2/stdafx.hpp index 1119f2bb..8a8255a0 100644 --- a/src/h2/stdafx.hpp +++ b/src/h2/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/xsk/assembler.cpp b/src/h2/xsk/assembler.cpp index 8b55e028..47db133e 100644 --- a/src/h2/xsk/assembler.cpp +++ b/src/h2/xsk/assembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/xsk/assembler.hpp b/src/h2/xsk/assembler.hpp index 61c67263..fd89bea1 100644 --- a/src/h2/xsk/assembler.hpp +++ b/src/h2/xsk/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/xsk/compiler.cpp b/src/h2/xsk/compiler.cpp index 1ca2afd8..1123a5c3 100644 --- a/src/h2/xsk/compiler.cpp +++ b/src/h2/xsk/compiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,7 +19,6 @@ auto compiler::output() -> std::vector void compiler::compile(const std::string& file, std::vector& data) { filename_ = file; - sources_.clear(); auto prog = parse_buffer(filename_, data); @@ -33,39 +32,19 @@ void compiler::read_callback(std::function(const std:: auto compiler::parse_buffer(const std::string& file, std::vector& data) -> ast::program::ptr { - yyscan_t scanner; - context ctx; ast::program::ptr result(nullptr); - ctx.header_top = 0; - ctx.mode = mode_; - ctx.read_callback = read_callback_; - ctx.sources = &sources_; - ctx.loc.initialize(&file); + resolver::set_reader(read_callback_); - // Add the two NULL terminators, required by flex. - data.push_back(0); - data.push_back(0); + lexer lexer(file, reinterpret_cast(data.data()), data.size()); - if (h2_lex_init(&scanner)) - { - throw comp_error(ctx.loc, "An unknown error ocurred while starting lexer context."); - } - - ctx.scanner = scanner; - - YY_BUFFER_STATE yybuffer = h2__scan_buffer(reinterpret_cast(data.data()), data.size(), scanner); - - parser parser(scanner, &ctx, result); + parser parser(lexer, result); if (parser.parse() || result == nullptr) { - throw comp_error(ctx.loc, "An unknown error ocurred while parsing gsc file."); + throw comp_error(xsk::gsc::location(&file), "An unknown error ocurred while parsing gsc file."); } - h2__delete_buffer(yybuffer, scanner); - h2_lex_destroy(scanner); - return result; } diff --git a/src/h2/xsk/compiler.hpp b/src/h2/xsk/compiler.hpp index 2c7f16bd..09e17901 100644 --- a/src/h2/xsk/compiler.hpp +++ b/src/h2/xsk/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -25,7 +25,6 @@ class compiler : public gsc::compiler std::vector animtrees_; std::unordered_map constants_; std::function(const std::string&)> read_callback_; - std::vector sources_; std::vector break_blks_; std::vector continue_blks_; bool can_break_; diff --git a/src/h2/xsk/decompiler.cpp b/src/h2/xsk/decompiler.cpp index 7d760edb..59074cd8 100644 --- a/src/h2/xsk/decompiler.cpp +++ b/src/h2/xsk/decompiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/xsk/decompiler.hpp b/src/h2/xsk/decompiler.hpp index ba287c60..c0acddd8 100644 --- a/src/h2/xsk/decompiler.hpp +++ b/src/h2/xsk/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/xsk/disassembler.cpp b/src/h2/xsk/disassembler.cpp index a4f0555f..666e7c7a 100644 --- a/src/h2/xsk/disassembler.cpp +++ b/src/h2/xsk/disassembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/xsk/disassembler.hpp b/src/h2/xsk/disassembler.hpp index 185c8478..2c7989c5 100644 --- a/src/h2/xsk/disassembler.hpp +++ b/src/h2/xsk/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/xsk/h2.cpp b/src/h2/xsk/h2.cpp index d85eb350..d594737c 100644 --- a/src/h2/xsk/h2.cpp +++ b/src/h2/xsk/h2.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/xsk/h2.hpp b/src/h2/xsk/h2.hpp index 571fdd4d..056c542c 100644 --- a/src/h2/xsk/h2.hpp +++ b/src/h2/xsk/h2.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/h2/xsk/lexer.cpp b/src/h2/xsk/lexer.cpp index 1fb3e156..517753fb 100644 --- a/src/h2/xsk/lexer.cpp +++ b/src/h2/xsk/lexer.cpp @@ -1,3040 +1,990 @@ -#line 1 "lexer.cpp" -#include "stdafx.hpp" -#include "h2.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void h2_push_header(xsk::gsc::context* ctx, const std::string& file); -void h2_pop_header(xsk::gsc::context* ctx); - -#line 9 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define h2__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer h2__create_buffer -#endif - -#ifdef yy_delete_buffer -#define h2__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer h2__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define h2__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer h2__scan_buffer -#endif - -#ifdef yy_scan_string -#define h2__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string h2__scan_string -#endif - -#ifdef yy_scan_bytes -#define h2__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes h2__scan_bytes -#endif - -#ifdef yy_init_buffer -#define h2__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer h2__init_buffer -#endif - -#ifdef yy_flush_buffer -#define h2__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer h2__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define h2__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state h2__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define h2__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer h2__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define h2_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state h2_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define h2_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state h2_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define h2_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack h2_ensure_buffer_stack -#endif - -#ifdef yylex -#define h2_lex_ALREADY_DEFINED -#else -#define yylex h2_lex -#endif - -#ifdef yyrestart -#define h2_restart_ALREADY_DEFINED -#else -#define yyrestart h2_restart -#endif - -#ifdef yylex_init -#define h2_lex_init_ALREADY_DEFINED -#else -#define yylex_init h2_lex_init -#endif - -#ifdef yylex_init_extra -#define h2_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra h2_lex_init_extra -#endif - -#ifdef yylex_destroy -#define h2_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy h2_lex_destroy -#endif - -#ifdef yyget_debug -#define h2_get_debug_ALREADY_DEFINED -#else -#define yyget_debug h2_get_debug -#endif - -#ifdef yyset_debug -#define h2_set_debug_ALREADY_DEFINED -#else -#define yyset_debug h2_set_debug -#endif - -#ifdef yyget_extra -#define h2_get_extra_ALREADY_DEFINED -#else -#define yyget_extra h2_get_extra -#endif - -#ifdef yyset_extra -#define h2_set_extra_ALREADY_DEFINED -#else -#define yyset_extra h2_set_extra -#endif - -#ifdef yyget_in -#define h2_get_in_ALREADY_DEFINED -#else -#define yyget_in h2_get_in -#endif - -#ifdef yyset_in -#define h2_set_in_ALREADY_DEFINED -#else -#define yyset_in h2_set_in -#endif - -#ifdef yyget_out -#define h2_get_out_ALREADY_DEFINED -#else -#define yyget_out h2_get_out -#endif - -#ifdef yyset_out -#define h2_set_out_ALREADY_DEFINED -#else -#define yyset_out h2_set_out -#endif - -#ifdef yyget_leng -#define h2_get_leng_ALREADY_DEFINED -#else -#define yyget_leng h2_get_leng -#endif - -#ifdef yyget_text -#define h2_get_text_ALREADY_DEFINED -#else -#define yyget_text h2_get_text -#endif - -#ifdef yyget_lineno -#define h2_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno h2_get_lineno -#endif - -#ifdef yyset_lineno -#define h2_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno h2_set_lineno -#endif - -#ifdef yyget_column -#define h2_get_column_ALREADY_DEFINED -#else -#define yyget_column h2_get_column -#endif - -#ifdef yyset_column -#define h2_set_column_ALREADY_DEFINED -#else -#define yyset_column h2_set_column -#endif - -#ifdef yywrap -#define h2_wrap_ALREADY_DEFINED -#else -#define yywrap h2_wrap -#endif - -#ifdef yyalloc -#define h2_alloc_ALREADY_DEFINED -#else -#define yyalloc h2_alloc -#endif - -#ifdef yyrealloc -#define h2_realloc_ALREADY_DEFINED -#else -#define yyrealloc h2_realloc -#endif - -#ifdef yyfree -#define h2_free_ALREADY_DEFINED -#else -#define yyfree h2_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin , yyscanner ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define h2_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); -static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 112 -#define YY_END_OF_BUFFER 113 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[333] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 113, 111, - 1, 2, 95, 111, 111, 94, 98, 111, 55, 56, - 92, 90, 61, 91, 62, 93, 110, 110, 64, 65, - 79, 89, 80, 66, 101, 59, 60, 99, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 57, 97, 58, 96, 5, 6, - 5, 12, 13, 12, 111, 92, 93, 76, 0, 103, - 0, 15, 0, 0, 0, 0, 85, 0, 74, 0, - 87, 0, 0, 8, 83, 67, 81, 68, 82, 106, - 0, 11, 4, 3, 84, 106, 110, 107, 0, 0, - - 0, 0, 63, 71, 77, 75, 78, 72, 101, 88, - 101, 101, 101, 101, 101, 101, 29, 101, 101, 101, - 101, 101, 27, 33, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 86, 73, 7, 14, 10, - 9, 0, 103, 0, 0, 0, 0, 0, 0, 102, - 0, 0, 0, 0, 103, 0, 106, 0, 3, 106, - 106, 107, 108, 109, 100, 69, 70, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 31, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 104, 0, 0, 0, 0, 0, 102, 0, 0, - - 102, 0, 0, 53, 101, 46, 35, 101, 101, 101, - 28, 101, 101, 101, 51, 101, 101, 101, 101, 52, - 101, 101, 101, 47, 101, 22, 101, 0, 0, 0, - 0, 0, 50, 37, 101, 101, 101, 20, 48, 101, - 54, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 30, 0, 0, 0, 0, 0, 101, 101, 101, 101, - 101, 21, 101, 101, 39, 34, 101, 43, 101, 101, - 101, 105, 0, 0, 16, 0, 101, 101, 101, 36, - 32, 101, 101, 101, 101, 101, 101, 0, 17, 0, - 101, 101, 38, 101, 42, 101, 101, 101, 23, 19, - - 0, 101, 101, 101, 101, 49, 26, 101, 101, 0, - 40, 101, 41, 45, 101, 101, 0, 44, 101, 101, - 0, 101, 101, 0, 101, 24, 0, 101, 18, 101, - 25, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, - 25, 26, 27, 1, 28, 29, 28, 28, 28, 28, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 31, 30, 30, - 32, 33, 34, 35, 36, 1, 37, 38, 39, 40, - - 41, 42, 43, 44, 45, 30, 46, 47, 48, 49, - 50, 51, 30, 52, 53, 54, 55, 56, 57, 31, - 58, 59, 60, 61, 62, 63, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[64] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 5, 5, 5, - 5, 1, 1, 1, 1, 1, 1, 5, 5, 6, - 6, 1, 7, 1, 1, 6, 5, 5, 5, 5, - 5, 5, 6, 6, 8, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 8, 6, 6, 6, 6, 1, - 1, 1, 1 - } ; - -static const flex_int16_t yy_base[353] = - { 0, - 0, 0, 61, 62, 63, 64, 65, 66, 712, 713, - 713, 713, 686, 63, 58, 685, 76, 67, 713, 713, - 62, 67, 713, 73, 86, 85, 96, 102, 687, 713, - 65, 683, 68, 713, 674, 713, 713, 681, 75, 76, - 93, 99, 98, 105, 111, 108, 78, 103, 100, 113, - 118, 125, 123, 127, 713, 136, 713, 713, 713, 713, - 688, 713, 713, 687, 145, 678, 161, 713, 158, 713, - 163, 713, 0, 653, 652, 647, 713, 160, 713, 161, - 713, 165, 176, 713, 713, 713, 713, 713, 713, 183, - 654, 713, 713, 0, 713, 187, 194, 200, 195, 216, - - 234, 0, 713, 673, 713, 713, 713, 672, 663, 713, - 143, 148, 184, 147, 150, 197, 662, 189, 203, 191, - 193, 208, 661, 660, 190, 207, 214, 211, 233, 215, - 225, 224, 245, 236, 249, 713, 713, 713, 713, 713, - 713, 254, 263, 281, 0, 647, 148, 646, 278, 713, - 285, 280, 288, 283, 284, 292, 713, 631, 0, 284, - 713, 311, 290, 0, 656, 713, 713, 267, 287, 265, - 266, 286, 289, 301, 295, 302, 304, 306, 307, 308, - 309, 313, 312, 317, 318, 320, 323, 325, 327, 328, - 329, 0, 640, 640, 641, 636, 358, 360, 366, 361, - - 365, 372, 643, 650, 53, 649, 648, 344, 345, 346, - 647, 347, 354, 352, 646, 350, 367, 370, 355, 645, - 353, 369, 371, 644, 377, 378, 380, 0, 622, 620, - 625, 630, 713, 379, 381, 382, 389, 639, 638, 385, - 637, 383, 396, 384, 394, 395, 407, 409, 392, 410, - 636, 0, 616, 627, 625, 629, 412, 413, 393, 416, - 417, 631, 418, 419, 630, 629, 420, 628, 425, 423, - 430, 713, 619, 618, 713, 621, 431, 432, 434, 624, - 623, 436, 433, 445, 447, 448, 438, 614, 713, 605, - 449, 450, 620, 454, 619, 456, 457, 459, 461, 713, - - 606, 462, 468, 469, 471, 617, 616, 473, 475, 600, - 597, 474, 588, 546, 480, 477, 514, 534, 482, 487, - 487, 486, 488, 496, 495, 502, 493, 489, 713, 500, - 496, 713, 540, 548, 556, 561, 569, 575, 579, 587, - 519, 595, 603, 611, 619, 623, 518, 631, 639, 305, - 246, 179 - } ; - -static const flex_int16_t yy_def[353] = - { 0, - 332, 1, 333, 333, 334, 334, 1, 1, 332, 332, - 332, 332, 332, 335, 336, 332, 332, 337, 332, 332, - 332, 332, 332, 332, 332, 332, 338, 338, 332, 332, - 332, 332, 332, 332, 339, 332, 332, 332, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 336, 332, 332, 332, 335, 332, - 340, 332, 341, 341, 332, 332, 332, 342, 332, 343, - 332, 337, 344, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 345, 332, 332, 338, 338, 338, 338, - - 338, 346, 332, 332, 332, 332, 332, 332, 339, 332, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 332, 332, 332, 332, 332, - 332, 335, 335, 340, 347, 332, 332, 332, 342, 332, - 348, 343, 349, 337, 337, 344, 332, 332, 345, 332, - 332, 338, 338, 101, 346, 332, 332, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 350, 332, 332, 332, 332, 342, 342, 348, 343, - - 343, 349, 332, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 351, 332, 332, - 332, 332, 332, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 352, 332, 332, 332, 332, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 332, 332, 332, 332, 332, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 332, 332, 332, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 332, - - 332, 339, 339, 339, 339, 339, 339, 339, 339, 332, - 339, 339, 339, 339, 339, 339, 332, 339, 339, 339, - 332, 339, 339, 332, 339, 339, 332, 339, 332, 339, - 339, 0, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332 - } ; - -static const flex_int16_t yy_nxt[777] = - { 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, - 28, 29, 30, 31, 32, 33, 34, 35, 35, 35, - 35, 36, 10, 37, 38, 35, 39, 40, 41, 42, - 43, 44, 45, 35, 46, 35, 47, 35, 48, 35, - 49, 50, 51, 52, 53, 35, 54, 35, 35, 55, - 56, 57, 58, 60, 60, 63, 63, 70, 64, 64, - 65, 65, 61, 61, 72, 70, 66, 66, 84, 86, - 78, 67, 67, 79, 80, 102, 85, 88, 104, 105, - 92, 87, 107, 108, 74, 71, 93, 89, 234, 83, - - 81, 94, 75, 90, 90, 90, 90, 102, 102, 95, - 102, 96, 76, 97, 98, 98, 97, 96, 125, 97, - 97, 97, 97, 111, 100, 102, 101, 112, 102, 113, - 102, 102, 102, 100, 102, 102, 114, 102, 91, 116, - 102, 120, 115, 102, 118, 102, 119, 122, 117, 123, - 102, 127, 126, 128, 121, 102, 124, 102, 129, 102, - 136, 140, 70, 134, 150, 69, 141, 143, 131, 150, - 135, 133, 93, 70, 130, 102, 132, 94, 82, 102, - 102, 74, 102, 272, 155, 95, 194, 168, 169, 75, - 71, 172, 151, 153, 195, 144, 137, 83, 173, 76, - - 90, 90, 90, 90, 160, 160, 160, 160, 156, 96, - 332, 97, 97, 97, 97, 96, 102, 162, 162, 162, - 97, 102, 102, 102, 157, 102, 102, 102, 161, 102, - 170, 332, 102, 163, 163, 102, 171, 177, 174, 102, - 102, 175, 176, 102, 178, 180, 102, 102, 102, 332, - 252, 164, 164, 164, 164, 179, 102, 102, 70, 185, - 181, 164, 164, 182, 183, 102, 102, 70, 102, 186, - 164, 164, 164, 164, 164, 164, 187, 102, 188, 184, - 190, 102, 150, 69, 189, 143, 71, 149, 150, 198, - 152, 70, 70, 191, 82, 71, 201, 102, 102, 102, - - 155, 160, 160, 160, 160, 332, 207, 163, 163, 228, - 151, 206, 153, 144, 204, 83, 83, 199, 102, 102, - 202, 102, 102, 205, 156, 161, 96, 102, 162, 162, - 162, 97, 208, 102, 102, 211, 102, 210, 102, 102, - 102, 102, 209, 102, 102, 102, 214, 215, 216, 102, - 102, 212, 102, 217, 218, 102, 213, 102, 220, 102, - 102, 102, 150, 223, 150, 224, 219, 225, 149, 150, - 198, 221, 222, 150, 152, 227, 102, 102, 102, 102, - 201, 226, 102, 235, 102, 102, 102, 102, 240, 236, - 151, 245, 151, 153, 239, 238, 241, 153, 199, 102, - - 237, 102, 102, 102, 202, 243, 244, 247, 242, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 248, 249, - 251, 102, 246, 261, 102, 102, 102, 102, 102, 257, - 259, 250, 265, 263, 258, 260, 264, 266, 267, 102, - 262, 102, 102, 270, 102, 102, 268, 279, 102, 102, - 102, 102, 102, 269, 271, 102, 278, 102, 282, 286, - 281, 277, 102, 102, 102, 102, 102, 283, 102, 280, - 102, 284, 295, 285, 293, 291, 287, 102, 294, 102, - 102, 102, 102, 292, 299, 296, 102, 297, 102, 102, - 303, 102, 305, 102, 102, 298, 306, 302, 304, 307, - - 102, 102, 308, 102, 312, 102, 102, 102, 309, 102, - 314, 316, 102, 318, 102, 311, 319, 313, 102, 102, - 102, 102, 192, 145, 315, 323, 325, 102, 102, 322, - 320, 326, 102, 329, 102, 328, 327, 330, 324, 331, - 59, 59, 59, 59, 59, 59, 59, 59, 62, 62, - 62, 62, 62, 62, 62, 62, 69, 69, 69, 69, - 69, 69, 69, 69, 73, 73, 102, 321, 73, 82, - 82, 82, 82, 82, 82, 82, 82, 99, 102, 99, - 99, 99, 99, 109, 109, 109, 109, 142, 142, 142, - 142, 142, 142, 142, 142, 149, 149, 149, 149, 149, - - 149, 149, 149, 152, 152, 152, 152, 152, 152, 152, - 152, 154, 154, 154, 154, 154, 154, 154, 154, 159, - 102, 159, 159, 159, 159, 159, 159, 165, 165, 102, - 165, 197, 197, 197, 197, 197, 197, 197, 197, 200, - 200, 200, 200, 200, 200, 200, 200, 317, 102, 102, - 310, 102, 102, 301, 300, 102, 102, 290, 289, 288, - 102, 102, 102, 102, 276, 275, 274, 273, 102, 102, - 102, 102, 256, 255, 254, 253, 102, 102, 102, 102, - 102, 102, 102, 233, 232, 231, 230, 229, 102, 203, - 196, 193, 102, 102, 102, 102, 167, 166, 158, 148, - - 147, 146, 85, 139, 138, 110, 102, 106, 103, 77, - 68, 332, 9, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332 - } ; - -static const flex_int16_t yy_chk[777] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 5, 6, 14, 5, 6, - 7, 8, 3, 4, 15, 18, 7, 8, 21, 22, - 17, 7, 8, 17, 17, 205, 21, 24, 31, 31, - 26, 22, 33, 33, 15, 14, 26, 24, 205, 18, - - 17, 26, 15, 25, 25, 25, 25, 39, 40, 26, - 47, 27, 15, 27, 27, 27, 27, 28, 47, 28, - 28, 28, 28, 39, 27, 41, 27, 40, 27, 41, - 43, 42, 49, 27, 28, 48, 41, 44, 25, 42, - 46, 44, 41, 45, 43, 50, 43, 45, 42, 46, - 51, 49, 48, 50, 44, 53, 46, 52, 51, 54, - 56, 65, 69, 54, 78, 71, 67, 71, 52, 80, - 54, 53, 67, 82, 51, 111, 52, 67, 83, 114, - 112, 65, 115, 352, 83, 67, 147, 111, 112, 65, - 69, 114, 78, 80, 147, 71, 56, 82, 115, 65, - - 90, 90, 90, 90, 96, 96, 96, 96, 83, 97, - 99, 97, 97, 97, 97, 98, 113, 98, 98, 98, - 98, 118, 125, 120, 90, 121, 97, 99, 96, 116, - 113, 100, 98, 100, 100, 119, 113, 120, 116, 126, - 122, 118, 119, 128, 121, 125, 127, 130, 100, 101, - 351, 101, 101, 101, 101, 122, 132, 131, 142, 130, - 126, 101, 101, 127, 128, 129, 101, 143, 134, 131, - 101, 101, 101, 101, 101, 101, 131, 133, 132, 129, - 134, 135, 149, 144, 133, 144, 142, 151, 152, 151, - 153, 154, 155, 135, 156, 143, 153, 170, 171, 168, - - 156, 160, 160, 160, 160, 163, 171, 163, 163, 350, - 149, 170, 152, 144, 168, 154, 155, 151, 172, 169, - 153, 173, 163, 169, 156, 160, 162, 175, 162, 162, - 162, 162, 172, 174, 176, 175, 177, 174, 178, 179, - 180, 181, 173, 162, 183, 182, 178, 179, 180, 184, - 185, 176, 186, 181, 182, 187, 177, 188, 184, 189, - 190, 191, 197, 187, 198, 188, 183, 189, 199, 200, - 199, 185, 186, 201, 202, 191, 208, 209, 210, 212, - 202, 190, 216, 208, 214, 221, 213, 219, 214, 209, - 197, 221, 198, 200, 213, 212, 216, 201, 199, 217, - - 210, 222, 218, 223, 202, 218, 219, 223, 217, 225, - 226, 234, 227, 235, 236, 242, 244, 240, 225, 226, - 227, 237, 222, 240, 249, 259, 245, 246, 243, 234, - 236, 226, 244, 243, 235, 237, 243, 245, 246, 247, - 242, 248, 250, 249, 257, 258, 247, 259, 260, 261, - 263, 264, 267, 248, 250, 270, 258, 269, 263, 270, - 261, 257, 271, 277, 278, 283, 279, 264, 282, 260, - 287, 267, 283, 269, 279, 277, 271, 284, 282, 285, - 286, 291, 292, 278, 287, 284, 294, 285, 296, 297, - 292, 298, 296, 299, 302, 286, 297, 291, 294, 298, - - 303, 304, 299, 305, 303, 308, 312, 309, 299, 316, - 305, 309, 315, 312, 319, 302, 315, 304, 322, 320, - 323, 328, 347, 341, 308, 320, 322, 325, 331, 319, - 316, 323, 330, 327, 326, 325, 324, 328, 321, 330, - 333, 333, 333, 333, 333, 333, 333, 333, 334, 334, - 334, 334, 334, 334, 334, 334, 335, 335, 335, 335, - 335, 335, 335, 335, 336, 336, 318, 317, 336, 337, - 337, 337, 337, 337, 337, 337, 337, 338, 314, 338, - 338, 338, 338, 339, 339, 339, 339, 340, 340, 340, - 340, 340, 340, 340, 340, 342, 342, 342, 342, 342, - - 342, 342, 342, 343, 343, 343, 343, 343, 343, 343, - 343, 344, 344, 344, 344, 344, 344, 344, 344, 345, - 313, 345, 345, 345, 345, 345, 345, 346, 346, 311, - 346, 348, 348, 348, 348, 348, 348, 348, 348, 349, - 349, 349, 349, 349, 349, 349, 349, 310, 307, 306, - 301, 295, 293, 290, 288, 281, 280, 276, 274, 273, - 268, 266, 265, 262, 256, 255, 254, 253, 251, 241, - 239, 238, 232, 231, 230, 229, 224, 220, 215, 211, - 207, 206, 204, 203, 196, 195, 194, 193, 165, 158, - 148, 146, 124, 123, 117, 109, 108, 104, 91, 76, - - 75, 74, 66, 64, 61, 38, 35, 32, 29, 16, - 13, 9, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.lpp" -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ -#define YY_NO_INPUT 1 -#define YY_NO_UNISTD_H 1 - -#line 25 "lexer.lpp" -#define YY_USER_ACTION ctx->loc.columns(yyleng); -#line 933 "lexer.cpp" - -#line 935 "lexer.cpp" - -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#include "stdafx.hpp" +#include "h2.hpp" +#include "parser.hpp" +#include "lexer.hpp" + +xsk::gsc::h2::parser::symbol_type H2lex(xsk::gsc::h2::lexer& lexer) +{ + return lexer.lex(); +} + +namespace xsk::gsc::h2 +{ + +enum class keyword +{ +/* KW_pre_define, + KW_pre_undef, + KW_pre_ifdef, + KW_pre_ifndef, + KW_pre_if, + KW_pre_elif, + KW_pre_else, + KW_pre_endif,*/ + KW_pre_inline, + KW_pre_include, + KW_pre_using_animtree, + KW_pre_animtree, + KW_endon, + KW_notify, + KW_wait, + KW_waittill, + KW_waittillmatch, + KW_waittillframeend, + KW_waitframe, + KW_if, + KW_else, + KW_do, + KW_while, + KW_for, + KW_foreach, + KW_in, + KW_switch, + KW_case, + KW_default, + KW_break, + KW_continue, + KW_return, + KW_breakpoint, + KW_prof_begin, + KW_prof_end, + KW_thread, + KW_childthread, + KW_thisthread, + KW_call, + KW_true, + KW_false, + KW_undefined, + KW_dotsize, + KW_game, + KW_self, + KW_anim, + KW_level, + KW_INVALID, +}; + +buffer::buffer() : size(1024), length(0) +{ + data = static_cast(std::malloc(size)); +} + +buffer::~buffer() +{ + if(data) std::free(data); +} + +bool buffer::push(char c) +{ + if(length >= size) { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals ( yyscan_t yyscanner ); - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef YY_NO_UNPUT - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( yyscan_t yyscanner ); -#else -static int input ( yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_load_buffer_state( yyscanner ); - } - - { -#line 44 "lexer.lpp" - - - -#line 48 "lexer.lpp" - ctx->loc.step(); - - -#line 1204 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 332 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 51 "lexer.lpp" -{ ctx->loc.step(); } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 52 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 54 "lexer.lpp" - - YY_BREAK -case 4: -YY_RULE_SETUP -#line 56 "lexer.lpp" -{ BEGIN(COMMENT_STATE); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 57 "lexer.lpp" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 58 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(COMMENT_STATE): -#line 60 "lexer.lpp" -{ throw h2::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "lexer.lpp" -{ throw h2::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 63 "lexer.lpp" -{ throw h2::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 64 "lexer.lpp" -{ BEGIN(INITIAL); return h2::parser::make_DEVEND(ctx->loc); } - YY_BREAK -case YY_STATE_EOF(DEV_ON_STATE): -#line 65 "lexer.lpp" -{ throw h2::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 67 "lexer.lpp" -{ BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return h2::parser::make_DEVBEGIN(ctx->loc); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 68 "lexer.lpp" - - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 69 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 70 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(DEV_OFF_STATE): -#line 71 "lexer.lpp" -{ throw h2::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.lpp" -{ throw h2::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 74 "lexer.lpp" -{ return h2::parser::make_INLINE(ctx->loc); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 75 "lexer.lpp" -{ return h2::parser::make_INCLUDE(ctx->loc); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 76 "lexer.lpp" -{ return h2::parser::make_USINGTREE(ctx->loc); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 77 "lexer.lpp" -{ return h2::parser::make_ANIMTREE(ctx->loc); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 78 "lexer.lpp" -{ return h2::parser::make_ENDON(ctx->loc); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 79 "lexer.lpp" -{ return h2::parser::make_NOTIFY(ctx->loc); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 80 "lexer.lpp" -{ return h2::parser::make_WAIT(ctx->loc); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 81 "lexer.lpp" -{ return h2::parser::make_WAITTILL(ctx->loc); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 82 "lexer.lpp" -{ return h2::parser::make_WAITTILLMATCH(ctx->loc); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 83 "lexer.lpp" -{ return h2::parser::make_WAITTILLFRAMEEND(ctx->loc); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 84 "lexer.lpp" -{ return h2::parser::make_WAITFRAME(ctx->loc); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 85 "lexer.lpp" -{ return h2::parser::make_IF(ctx->loc); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 86 "lexer.lpp" -{ return h2::parser::make_ELSE(ctx->loc); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 87 "lexer.lpp" -{ return h2::parser::make_DO(ctx->loc); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 88 "lexer.lpp" -{ return h2::parser::make_WHILE(ctx->loc); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 89 "lexer.lpp" -{ return h2::parser::make_FOR(ctx->loc); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 90 "lexer.lpp" -{ return h2::parser::make_FOREACH(ctx->loc); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 91 "lexer.lpp" -{ return h2::parser::make_IN(ctx->loc); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 92 "lexer.lpp" -{ return h2::parser::make_SWITCH(ctx->loc); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 93 "lexer.lpp" -{ return h2::parser::make_CASE(ctx->loc); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 94 "lexer.lpp" -{ return h2::parser::make_DEFAULT(ctx->loc); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 95 "lexer.lpp" -{ return h2::parser::make_BREAK(ctx->loc); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 96 "lexer.lpp" -{ return h2::parser::make_CONTINUE(ctx->loc); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 97 "lexer.lpp" -{ return h2::parser::make_RETURN(ctx->loc); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 98 "lexer.lpp" -{ return h2::parser::make_BREAKPOINT(ctx->loc); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 99 "lexer.lpp" -{ return h2::parser::make_PROFBEGIN(ctx->loc); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 100 "lexer.lpp" -{ return h2::parser::make_PROFEND(ctx->loc); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 101 "lexer.lpp" -{ return h2::parser::make_THREAD(ctx->loc); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 102 "lexer.lpp" -{ return h2::parser::make_CHILDTHREAD(ctx->loc); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 103 "lexer.lpp" -{ return h2::parser::make_THISTHREAD(ctx->loc); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 104 "lexer.lpp" -{ return h2::parser::make_CALL(ctx->loc); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 105 "lexer.lpp" -{ return h2::parser::make_TRUE(ctx->loc); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 106 "lexer.lpp" -{ return h2::parser::make_FALSE(ctx->loc); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 107 "lexer.lpp" -{ return h2::parser::make_UNDEFINED(ctx->loc); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 108 "lexer.lpp" -{ return h2::parser::make_SIZE(ctx->loc); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 109 "lexer.lpp" -{ return h2::parser::make_GAME(ctx->loc); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 110 "lexer.lpp" -{ return h2::parser::make_SELF(ctx->loc); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 111 "lexer.lpp" -{ return h2::parser::make_ANIM(ctx->loc); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 112 "lexer.lpp" -{ return h2::parser::make_LEVEL(ctx->loc); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 113 "lexer.lpp" -{ return h2::parser::make_LPAREN(ctx->loc); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 114 "lexer.lpp" -{ return h2::parser::make_RPAREN(ctx->loc); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 115 "lexer.lpp" -{ return h2::parser::make_LBRACE(ctx->loc); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 116 "lexer.lpp" -{ return h2::parser::make_RBRACE(ctx->loc); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 117 "lexer.lpp" -{ return h2::parser::make_LBRACKET(ctx->loc); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 118 "lexer.lpp" -{ return h2::parser::make_RBRACKET(ctx->loc); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 119 "lexer.lpp" -{ return h2::parser::make_COMMA(ctx->loc); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 120 "lexer.lpp" -{ return h2::parser::make_DOT(ctx->loc); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 121 "lexer.lpp" -{ return h2::parser::make_DOUBLECOLON(ctx->loc); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 122 "lexer.lpp" -{ return h2::parser::make_COLON(ctx->loc); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 123 "lexer.lpp" -{ return h2::parser::make_SEMICOLON(ctx->loc); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 124 "lexer.lpp" -{ return h2::parser::make_QMARK(ctx->loc); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 125 "lexer.lpp" -{ return h2::parser::make_INCREMENT(ctx->loc); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 126 "lexer.lpp" -{ return h2::parser::make_DECREMENT(ctx->loc); } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 127 "lexer.lpp" -{ return h2::parser::make_ASSIGN_LSHIFT(ctx->loc); } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 128 "lexer.lpp" -{ return h2::parser::make_ASSIGN_RSHIFT(ctx->loc); } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 129 "lexer.lpp" -{ return h2::parser::make_LSHIFT(ctx->loc); } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 130 "lexer.lpp" -{ return h2::parser::make_RSHIFT(ctx->loc); } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 131 "lexer.lpp" -{ return h2::parser::make_OR(ctx->loc); } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 132 "lexer.lpp" -{ return h2::parser::make_AND(ctx->loc); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 133 "lexer.lpp" -{ return h2::parser::make_EQUALITY(ctx->loc); } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 134 "lexer.lpp" -{ return h2::parser::make_INEQUALITY(ctx->loc); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 135 "lexer.lpp" -{ return h2::parser::make_LESS_EQUAL(ctx->loc); } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 136 "lexer.lpp" -{ return h2::parser::make_GREATER_EQUAL(ctx->loc); } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 137 "lexer.lpp" -{ return h2::parser::make_LESS(ctx->loc); } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 138 "lexer.lpp" -{ return h2::parser::make_GREATER(ctx->loc); } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 139 "lexer.lpp" -{ return h2::parser::make_ASSIGN_ADD(ctx->loc); } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 140 "lexer.lpp" -{ return h2::parser::make_ASSIGN_SUB(ctx->loc); } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 141 "lexer.lpp" -{ return h2::parser::make_ASSIGN_MUL(ctx->loc); } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 142 "lexer.lpp" -{ return h2::parser::make_ASSIGN_DIV(ctx->loc); } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 143 "lexer.lpp" -{ return h2::parser::make_ASSIGN_MOD(ctx->loc); } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 144 "lexer.lpp" -{ return h2::parser::make_ASSIGN_BW_OR(ctx->loc); } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 145 "lexer.lpp" -{ return h2::parser::make_ASSIGN_BW_AND(ctx->loc); } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 146 "lexer.lpp" -{ return h2::parser::make_ASSIGN_BW_EXOR(ctx->loc); } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 147 "lexer.lpp" -{ return h2::parser::make_ASSIGN(ctx->loc); } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 148 "lexer.lpp" -{ return h2::parser::make_ADD(ctx->loc); } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 149 "lexer.lpp" -{ return h2::parser::make_SUB(ctx->loc); } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 150 "lexer.lpp" -{ return h2::parser::make_MUL(ctx->loc); } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 151 "lexer.lpp" -{ return h2::parser::make_DIV(ctx->loc); } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 152 "lexer.lpp" -{ return h2::parser::make_MOD(ctx->loc); } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 153 "lexer.lpp" -{ return h2::parser::make_NOT(ctx->loc); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 154 "lexer.lpp" -{ return h2::parser::make_COMPLEMENT(ctx->loc); } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 155 "lexer.lpp" -{ return h2::parser::make_BITWISE_OR(ctx->loc); } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 156 "lexer.lpp" -{ return h2::parser::make_BITWISE_AND(ctx->loc); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 157 "lexer.lpp" -{ return h2::parser::make_BITWISE_EXOR(ctx->loc); } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 158 "lexer.lpp" -{ return h2::parser::make_PATH(xsk::gsc::h2::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 101: -YY_RULE_SETUP -#line 159 "lexer.lpp" -{ return h2::parser::make_IDENTIFIER(xsk::gsc::h2::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 102: -/* rule 102 can match eol */ -YY_RULE_SETUP -#line 160 "lexer.lpp" -{ return h2::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 103: -/* rule 103 can match eol */ -YY_RULE_SETUP -#line 161 "lexer.lpp" -{ return h2::parser::make_STRING(std::string(yytext), ctx->loc); } - YY_BREAK -case 104: -YY_RULE_SETUP -#line 162 "lexer.lpp" -{ return h2::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 105: -YY_RULE_SETUP -#line 163 "lexer.lpp" -{ return h2::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 164 "lexer.lpp" -{ return h2::parser::make_FLOAT(std::string(yytext), ctx->loc); } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 165 "lexer.lpp" -{ return h2::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 166 "lexer.lpp" -{ return h2::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 167 "lexer.lpp" -{ return h2::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } - YY_BREAK -case 110: -YY_RULE_SETUP -#line 168 "lexer.lpp" -{ return h2::parser::make_INTEGER(std::string(yytext), ctx->loc); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 169 "lexer.lpp" -{ if(ctx->header_top > 0) h2_pop_header(ctx); else return h2::parser::make_H2EOF(ctx->loc); } - YY_BREAK -case 111: -/* rule 111 can match eol */ -YY_RULE_SETUP -#line 170 "lexer.lpp" -{ throw h2::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - YY_BREAK -case 112: -YY_RULE_SETUP -#line 172 "lexer.lpp" -ECHO; - YY_BREAK -#line 1839 "lexer.cpp" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap( yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin , yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + auto nsize = size * 2; + auto ndata = reinterpret_cast(std::malloc(nsize)); + + if(!ndata) return false; + + std::memmove(ndata, data, size); + std::free(data); + size = nsize; + data = ndata; + } + data[length++] = c; + return true; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; } -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +void reader::init(const char* data, size_t size) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 332); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + if(data && size) + { + state = reader::ok; + buffer_pos = data; + bytes_remaining = size; + last_byte = 0; + current_byte = *data; + } + else + { + state = reader::end; + buffer_pos = 0; + bytes_remaining = 0; + last_byte = 0; + current_byte = 0; + } } -#ifndef YY_NO_UNPUT - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - +void reader::advance() { - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + ++buffer_pos; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin , yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); - yy_load_buffer_state( yyscanner ); + if(bytes_remaining-- == 1) + { + state = reader::end; + bytes_remaining = 0; + last_byte = current_byte; + current_byte = 0; + } + else + { + last_byte = current_byte; + current_byte = *buffer_pos; + } } -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +lexer::lexer(const std::string& name, const char* data, size_t size) : in_dev_state_(false), loc_(xsk::gsc::location(&name)), + mode_(build::dev), header_top_(0), locs_(std::stack()), readers_(std::stack()) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + reader_.init(data, size); } -static void yy_load_buffer_state (yyscan_t yyscanner) +void lexer::push_header(const std::string& file) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + try + { + if (header_top_++ >= 10) + throw xsk::gsc::error("maximum gsh depth exceeded '10'"); + + auto data = resolver::file_data(file + ".gsh"); + + readers_.push(reader_); + locs_.push(loc_); + loc_.initialize(std::get<0>(data)); + reader_.init(std::get<1>(data), std::get<2>(data)); + } + catch (const std::exception& e) + { + throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); + } } -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +void lexer::pop_header() { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file , yyscanner); - - return b; + header_top_--; + loc_ = locs_.top(); + locs_.pop(); + reader_ = readers_.top(); + readers_.pop(); } -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void lexer::restrict_header(const xsk::gsc::location& loc) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf , yyscanner ); - - yyfree( (void *) b , yyscanner ); + if (header_top_ > 0) + { + throw comp_error(loc, "not allowed inside a gsh file"); + } } -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - +auto lexer::lex() -> xsk::gsc::h2::parser::symbol_type { - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + buffer_.length = 0; + loc_.step(); - yy_flush_buffer( b , yyscanner); + while (true) + { + if (reader_.state == reader::end) + { + if (in_dev_state_) + throw h2::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + if(header_top_ > 0) + pop_header(); + else + return h2::parser::make_H2EOF(loc_); + } - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + reader_.advance(); + auto& last = reader_.last_byte; + auto& curr = reader_.current_byte; + + switch (last) + { + case ' ': + case '\t': + case '\r': + loc_.step(); + continue; + case '\n': + loc_.lines(); + loc_.step(); + continue; + case '/': + if(reader_.state == reader::end || (curr != '/' && curr != '*' && curr != '#' && curr != '=')) + return h2::parser::make_DIV(loc_); + + reader_.advance(); + + if (last == '=') + return h2::parser::make_ASSIGN_DIV(loc_); + + if (last == '#') + { + if (in_dev_state_) + { + throw h2::parser::syntax_error(loc_, "cannot recurse devblock ('/#')"); + } + else if (mode_ == xsk::gsc::build::dev) + { + in_dev_state_ = true; + return h2::parser::make_DEVBEGIN(loc_); + } + else + { + while (true) + { + if (reader_.state == reader::end) + { + throw h2::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '#' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + } + else if (last == '*') + { + while (true) + { + if (reader_.state == reader::end) + { + throw h2::parser::syntax_error(loc_, "unmatched multiline comment start ('/*')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '*' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + else if (last == '/') + { + while (true) + { + if (reader_.state == reader::end || curr == '\n') + break; + + reader_.advance(); + } + } + continue; + case '#': + if (curr == '/') + { + if (!in_dev_state_) + throw h2::parser::syntax_error(loc_, "unmatched devblock end ('#/')"); + + in_dev_state_ = false; + reader_.advance(); + return h2::parser::make_DEVEND(loc_); + } + + buffer_.push(last); + while (reader_.state == reader::ok) + { + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + { + if (auto len = buffer_.length; len == 4 || len == 7) + { + auto data = buffer_.data; + auto color = true; + for (auto i = 1; i < len; i++) + { + if ((data[i] < 48 || data[i] > 57) && (data[i] < 65 || data[i] > 70) && (data[i] < 97 || data[i] > 102)) + { + color = false; + break; + } + } + + if (color) return h2::parser::make_COLOR(std::string(++data, --len), loc_); + } + + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); + + if (key == keyword::KW_INVALID) + throw h2::parser::syntax_error(loc_, utils::string::va("unknown preprocessor directive ('%s')", "#")); + + if (keyword_is_token(key)) + return keyword_token(key); + + // call preprocessor(key); + } + continue; + case '*': + if (reader_.state == reader::end || (curr != '/' && curr != '=')) + return h2::parser::make_MUL(loc_); + + reader_.advance(); + + if (curr == '/') + throw h2::parser::syntax_error(loc_, "unmatched multiline comment end ('*/')"); + + return h2::parser::make_ASSIGN_MUL(loc_); + case '"': + case '\'': + return read_string(last, false); + case '.': + return read_dotsize(); + case '(': + return h2::parser::make_LPAREN(loc_); + case ')': + return h2::parser::make_RPAREN(loc_); + case '{': + return h2::parser::make_LBRACE(loc_); + case '}': + return h2::parser::make_RBRACE(loc_); + case '[': + return h2::parser::make_LBRACKET(loc_); + case ']': + return h2::parser::make_RBRACKET(loc_); + case ',': + return h2::parser::make_COMMA(loc_); + case ';': + return h2::parser::make_SEMICOLON(loc_); + case ':': + if (curr != ':') + return h2::parser::make_COLON(loc_); + reader_.advance(); + return h2::parser::make_DOUBLECOLON(loc_); + case '?': + return h2::parser::make_QMARK(loc_); + case '=': + if (curr != '=') + return h2::parser::make_ASSIGN(loc_); + reader_.advance(); + return h2::parser::make_EQUALITY(loc_); + case '+': + if (curr != '+' && curr != '=') + return h2::parser::make_ADD(loc_); + reader_.advance(); + return (last == '+') ? h2::parser::make_INCREMENT(loc_) : h2::parser::make_ASSIGN_ADD(loc_); + case '-': + if (curr != '-' && curr != '=') + return h2::parser::make_SUB(loc_); + reader_.advance(); + return (last == '-') ? h2::parser::make_DECREMENT(loc_) : h2::parser::make_ASSIGN_SUB(loc_); + case '%': + if (curr != '=') + return h2::parser::make_MOD(loc_); + reader_.advance(); + return h2::parser::make_ASSIGN_MOD(loc_); + case '|': + if (curr != '|' && curr != '=') + return h2::parser::make_BITWISE_OR(loc_); + reader_.advance(); + return (last == '|') ? h2::parser::make_OR(loc_) : h2::parser::make_ASSIGN_BW_OR(loc_); + case '&': + if (curr != '&' && curr != '=' && curr != '"' && curr != '\'') + return h2::parser::make_BITWISE_AND(loc_); + reader_.advance(); + if (last == '"' || last == '\'') + return read_string(last, true); + return (last == '&') ? h2::parser::make_AND(loc_) : h2::parser::make_ASSIGN_BW_AND(loc_); + case '^': + if (curr != '=') + return h2::parser::make_BITWISE_EXOR(loc_); + reader_.advance(); + return h2::parser::make_ASSIGN_BW_EXOR(loc_); + case '!': + if (curr != '=') + return h2::parser::make_NOT(loc_); + reader_.advance(); + return h2::parser::make_INEQUALITY(loc_); + case '~': + return h2::parser::make_COMPLEMENT(loc_); + case '<': + if (curr != '<' && curr != '=') + return h2::parser::make_LESS(loc_); + reader_.advance(); + if (last == '<') + { + reader_.advance(); + return (last == '=') ? h2::parser::make_ASSIGN_LSHIFT(loc_) : h2::parser::make_LSHIFT(loc_); + } + return h2::parser::make_LESS_EQUAL(loc_); + case '>': + if (curr != '>' && curr != '=') + return h2::parser::make_GREATER(loc_); + reader_.advance(); + if (last == '>') + { + reader_.advance(); + return (last == '=') ? h2::parser::make_ASSIGN_RSHIFT(loc_) : h2::parser::make_RSHIFT(loc_); + } + return h2::parser::make_GREATER_EQUAL(loc_); + default: + if (last >= '0' && last <= '9') + return lexer::read_number(last); + else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z') + return lexer::read_word(last); + + throw h2::parser::syntax_error(loc_, utils::string::va("bad token: \'%c\'", last)); + } + } +} + +auto lexer::read_string(char quote, bool localize) -> xsk::gsc::h2::parser::symbol_type +{ + if (localize) + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + reader_.advance(); + + if (last == '\n') + throw h2::parser::syntax_error(loc_, "unterminated string"); + + if (last == '\\') // process scapes + { + // TODO: + } + + if (last != '\\' && curr == quote) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); } - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b , yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n , yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n , yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int _line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = _line_number; -} - -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column (int _column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = _column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int _bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = _bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (reader_.state == reader::end) + { + throw h2::parser::syntax_error(loc_, utils::string::va("unmatched string start ('%s')", (quote == '"') ? "\"" : "\\'")); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + if (localize) + return h2::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + return h2::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_); +} + +auto lexer::read_number(char first) -> xsk::gsc::h2::parser::symbol_type +{ + if (first == '.') + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = true; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw h2::parser::syntax_error(loc_, "invalid number '.'"); + } + if (data[i] == 'f' && i != len - 1) + throw h2::parser::syntax_error(loc_, "invalid number 'f'"); + } + + return h2::parser::make_FLOAT(std::string(data, len), loc_); + } + else + { + auto curr = reader_.current_byte; + + if (first == '0' && curr == 'o') + { + buffer_.push(first); + buffer_.push('o'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'o')) + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'o' && last == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr > 47 && curr < 56)) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid octal literal!"); + + return h2::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data + 2), loc_); + } + else if (first == '0' && curr == 'b') + { + buffer_.push(first); + buffer_.push('b'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'b')) + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'b' && last == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (curr != '0' && curr != '1') + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid binary literal!"); + + return h2::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_); + } + else if (first == '0' && curr == 'x') + { + buffer_.push(first); + buffer_.push('x'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'x')) + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'x' && last == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!((curr > 47 && curr < 58) || (curr > 64 && curr < 71) || (curr > 96 && curr < 103))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid hexadecimal literal!"); + + return h2::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_); + } + else + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw h2::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = false; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw h2::parser::syntax_error(loc_, "invalid number '.'"); + + dot = true; + } + if (data[i] == 'f' && i != len - 1) + throw h2::parser::syntax_error(loc_, "invalid number 'f'"); + } + + if (dot || data[len - 1] == 'f') + return h2::parser::make_FLOAT(std::string(data, len), loc_); + + return h2::parser::make_INTEGER(std::string(data, len), loc_); + } + } +} + +auto lexer::read_word(char first) -> xsk::gsc::h2::parser::symbol_type +{ + auto path = false; + + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto curr = reader_.current_byte; + + if (!(curr == '\\' || curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (curr == '\\') + { + if (reader_.last_byte == '\\') + throw h2::parser::syntax_error(loc_, "invalid path '\\\\'"); + + path = true; + curr = '/'; + } + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); - return yy_init_globals ( *ptr_yy_globals ); -} + if (key != keyword::KW_INVALID) + return keyword_token(key); -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; + if (path) + { + if (buffer_.data[buffer_.length - 1] == '/') + throw h2::parser::syntax_error(loc_, "invalid path end '\\'"); - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + return h2::parser::make_PATH(xsk::gsc::h2::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + return h2::parser::make_IDENTIFIER(xsk::gsc::h2::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); +} - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; +auto lexer::read_dotsize() -> xsk::gsc::h2::parser::symbol_type +{ + auto curr = reader_.current_byte; + + if (curr > 47 && curr < 58) + { + return lexer::read_number('.'); + } + else if (curr == '_' || curr > 64 && curr < 91 || curr > 96 && curr < 123) + { + reader save; + save.state = reader_.state; + save.bytes_remaining = reader_.bytes_remaining; + save.buffer_pos = reader_.buffer_pos; + save.last_byte = reader_.last_byte; + save.current_byte = reader_.current_byte; + + while (reader_.state == reader::ok) + { + curr = reader_.current_byte; + + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (std::string_view(buffer_.data, buffer_.length) == "size") + { + return h2::parser::make_SIZE(loc_); + } + + reader_.state = save.state; + reader_.bytes_remaining = save.bytes_remaining; + reader_.buffer_pos = save.buffer_pos; + reader_.last_byte = save.last_byte; + reader_.current_byte = save.current_byte; + + return h2::parser::make_DOT(loc_); + + } + else return h2::parser::make_DOT(loc_); +} + +auto lexer::keyword_token(keyword k) -> xsk::gsc::h2::parser::symbol_type +{ + switch (k) + { + case keyword::KW_pre_inline: + return h2::parser::make_INLINE(loc_); + case keyword::KW_pre_include: + return h2::parser::make_INCLUDE(loc_); + case keyword::KW_pre_using_animtree: + return h2::parser::make_USINGTREE(loc_); + case keyword::KW_pre_animtree: + return h2::parser::make_ANIMTREE(loc_); + case keyword::KW_endon: + return h2::parser::make_ENDON(loc_); + case keyword::KW_notify: + return h2::parser::make_NOTIFY(loc_); + case keyword::KW_wait: + return h2::parser::make_WAIT(loc_); + case keyword::KW_waittill: + return h2::parser::make_WAITTILL(loc_); + case keyword::KW_waittillmatch: + return h2::parser::make_WAITTILLMATCH(loc_); + case keyword::KW_waittillframeend: + return h2::parser::make_WAITTILLFRAMEEND(loc_); + case keyword::KW_waitframe: + return h2::parser::make_WAITFRAME(loc_); + case keyword::KW_if: + return h2::parser::make_IF(loc_); + case keyword::KW_else: + return h2::parser::make_ELSE(loc_); + case keyword::KW_do: + return h2::parser::make_DO(loc_); + case keyword::KW_while: + return h2::parser::make_WHILE(loc_); + case keyword::KW_for: + return h2::parser::make_FOR(loc_); + case keyword::KW_foreach: + return h2::parser::make_FOREACH(loc_); + case keyword::KW_in: + return h2::parser::make_IN(loc_); + case keyword::KW_switch: + return h2::parser::make_SWITCH(loc_); + case keyword::KW_case: + return h2::parser::make_CASE(loc_); + case keyword::KW_default: + return h2::parser::make_DEFAULT(loc_); + case keyword::KW_break: + return h2::parser::make_BREAK(loc_); + case keyword::KW_continue: + return h2::parser::make_CONTINUE(loc_); + case keyword::KW_return: + return h2::parser::make_RETURN(loc_); + case keyword::KW_breakpoint: + return h2::parser::make_BREAKPOINT(loc_); + case keyword::KW_prof_begin: + return h2::parser::make_PROFBEGIN(loc_); + case keyword::KW_prof_end: + return h2::parser::make_PROFEND(loc_); + case keyword::KW_thread: + return h2::parser::make_THREAD(loc_); + case keyword::KW_childthread: + return h2::parser::make_CHILDTHREAD(loc_); + case keyword::KW_thisthread: + return h2::parser::make_THISTHREAD(loc_); + case keyword::KW_call: + return h2::parser::make_CALL(loc_); + case keyword::KW_true: + return h2::parser::make_TRUE(loc_); + case keyword::KW_false: + return h2::parser::make_FALSE(loc_); + case keyword::KW_undefined: + return h2::parser::make_UNDEFINED(loc_); + case keyword::KW_dotsize: + return h2::parser::make_SIZE(loc_); + case keyword::KW_game: + return h2::parser::make_GAME(loc_); + case keyword::KW_self: + return h2::parser::make_SELF(loc_); + case keyword::KW_anim: + return h2::parser::make_ANIM(loc_); + case keyword::KW_level: + return h2::parser::make_LEVEL(loc_); + default: + throw error("gsc lexer: INVALID KEYWORD TOKEN!"); + } +} + +auto lexer::keyword_is_token(keyword k) -> bool +{ + switch (k) + { +/* case keyword::KW_pre_define: + case keyword::KW_pre_undef: + case keyword::KW_pre_ifdef: + case keyword::KW_pre_ifndef: + case keyword::KW_pre_if: + case keyword::KW_pre_elif: + case keyword::KW_pre_else: + case keyword::KW_pre_endif:*/ + case keyword::KW_INVALID: + return false; + default: + return true; + } +} + +auto lexer::get_keyword(std::string_view str) -> keyword +{ + auto itr = keywords.find(str); + + if(itr != keywords.end()) + { + return itr->second; } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + return keyword::KW_INVALID; } -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack , yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack , yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s , yyscan_t yyscanner) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 172 "lexer.lpp" - - -void h2_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void h2_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} +std::unordered_map lexer::keywords +{{ +/* { "#define", keyword::KW_pre_define }, + { "#undef", keyword::KW_pre_undef }, + { "#ifdef", keyword::KW_pre_ifdef }, + { "#ifndef", keyword::KW_pre_ifndef }, + { "#if", keyword::KW_pre_if }, + { "#elif", keyword::KW_pre_elif }, + { "#else", keyword::KW_pre_else }, + { "#endif", keyword::KW_pre_endif },*/ + { "#inline", keyword::KW_pre_inline }, + { "#include", keyword::KW_pre_include }, + { "#using_animtree", keyword::KW_pre_using_animtree }, + { "#animtree", keyword::KW_pre_animtree }, + { "endon", keyword::KW_endon }, + { "notify", keyword::KW_notify }, + { "wait", keyword::KW_wait }, + { "waittill", keyword::KW_waittill }, + { "waittillmatch", keyword::KW_waittillmatch }, + { "waittillframeend", keyword::KW_waittillframeend }, + { "waitframe", keyword::KW_waitframe }, + { "if", keyword::KW_if }, + { "else", keyword::KW_else }, + { "do", keyword::KW_do }, + { "while", keyword::KW_while }, + { "for", keyword::KW_for }, + { "foreach", keyword::KW_foreach }, + { "in", keyword::KW_in }, + { "switch", keyword::KW_switch }, + { "case", keyword::KW_case }, + { "default", keyword::KW_default }, + { "break", keyword::KW_break }, + { "continue", keyword::KW_continue }, + { "return", keyword::KW_return }, + { "breakpoint", keyword::KW_breakpoint }, + { "prof_begin", keyword::KW_prof_begin }, + { "prof_end", keyword::KW_prof_end }, + { "thread", keyword::KW_thread }, + { "childthread", keyword::KW_childthread }, + { "thisthread", keyword::KW_thisthread }, + { "call", keyword::KW_call }, + { "true", keyword::KW_true }, + { "false", keyword::KW_false }, + { "undefined", keyword::KW_undefined }, + { ".size", keyword::KW_dotsize }, + { "game", keyword::KW_game }, + { "self", keyword::KW_self }, + { "anim", keyword::KW_anim }, + { "level", keyword::KW_level }, +}}; +} // namespace xsk::gsc::h2 diff --git a/src/h2/xsk/lexer.hpp b/src/h2/xsk/lexer.hpp index 8a004ccf..9ed5cd3f 100644 --- a/src/h2/xsk/lexer.hpp +++ b/src/h2/xsk/lexer.hpp @@ -1,711 +1,77 @@ -#ifndef h2_HEADER_H -#define h2_HEADER_H 1 -#define h2_IN_HEADER 1 - -#line 5 "lexer.hpp" -#include "stdafx.hpp" -#include "h2.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void h2_push_header(xsk::gsc::context* ctx, const std::string& file); -void h2_pop_header(xsk::gsc::context* ctx); - -#line 13 "lexer.hpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define h2__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer h2__create_buffer -#endif - -#ifdef yy_delete_buffer -#define h2__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer h2__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define h2__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer h2__scan_buffer -#endif - -#ifdef yy_scan_string -#define h2__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string h2__scan_string -#endif - -#ifdef yy_scan_bytes -#define h2__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes h2__scan_bytes -#endif - -#ifdef yy_init_buffer -#define h2__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer h2__init_buffer -#endif - -#ifdef yy_flush_buffer -#define h2__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer h2__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define h2__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state h2__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define h2__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer h2__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define h2_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state h2_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define h2_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state h2_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define h2_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack h2_ensure_buffer_stack -#endif - -#ifdef yylex -#define h2_lex_ALREADY_DEFINED -#else -#define yylex h2_lex -#endif - -#ifdef yyrestart -#define h2_restart_ALREADY_DEFINED -#else -#define yyrestart h2_restart -#endif - -#ifdef yylex_init -#define h2_lex_init_ALREADY_DEFINED -#else -#define yylex_init h2_lex_init -#endif - -#ifdef yylex_init_extra -#define h2_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra h2_lex_init_extra -#endif - -#ifdef yylex_destroy -#define h2_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy h2_lex_destroy -#endif - -#ifdef yyget_debug -#define h2_get_debug_ALREADY_DEFINED -#else -#define yyget_debug h2_get_debug -#endif - -#ifdef yyset_debug -#define h2_set_debug_ALREADY_DEFINED -#else -#define yyset_debug h2_set_debug -#endif - -#ifdef yyget_extra -#define h2_get_extra_ALREADY_DEFINED -#else -#define yyget_extra h2_get_extra -#endif - -#ifdef yyset_extra -#define h2_set_extra_ALREADY_DEFINED -#else -#define yyset_extra h2_set_extra -#endif - -#ifdef yyget_in -#define h2_get_in_ALREADY_DEFINED -#else -#define yyget_in h2_get_in -#endif - -#ifdef yyset_in -#define h2_set_in_ALREADY_DEFINED -#else -#define yyset_in h2_set_in -#endif - -#ifdef yyget_out -#define h2_get_out_ALREADY_DEFINED -#else -#define yyget_out h2_get_out -#endif - -#ifdef yyset_out -#define h2_set_out_ALREADY_DEFINED -#else -#define yyset_out h2_set_out -#endif - -#ifdef yyget_leng -#define h2_get_leng_ALREADY_DEFINED -#else -#define yyget_leng h2_get_leng -#endif - -#ifdef yyget_text -#define h2_get_text_ALREADY_DEFINED -#else -#define yyget_text h2_get_text -#endif - -#ifdef yyget_lineno -#define h2_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno h2_get_lineno -#endif - -#ifdef yyset_lineno -#define h2_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno h2_set_lineno -#endif - -#ifdef yyget_column -#define h2_get_column_ALREADY_DEFINED -#else -#define yyget_column h2_get_column -#endif - -#ifdef yyset_column -#define h2_set_column_ALREADY_DEFINED -#else -#define yyset_column h2_set_column -#endif - -#ifdef yywrap -#define h2_wrap_ALREADY_DEFINED -#else -#define yywrap h2_wrap -#endif - -#ifdef yyalloc -#define h2_alloc_ALREADY_DEFINED -#else -#define yyalloc h2_alloc -#endif - -#ifdef yyrealloc -#define h2_realloc_ALREADY_DEFINED -#else -#define yyrealloc h2_realloc -#endif - -#ifdef yyfree -#define h2_free_ALREADY_DEFINED -#else -#define yyfree h2_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define h2_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#ifndef h2__create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef h2__delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef h2__scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef h2__scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef h2__scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef h2__init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef h2__flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef h2__load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef h2__switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef h2_push_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef h2_pop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef h2_ensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef h2_lex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef h2_restart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef h2_lex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef h2_lex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef h2_lex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef h2_get_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef h2_set_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef h2_get_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef h2_set_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef h2_get_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef h2_set_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef h2_get_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef h2_set_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef h2_get_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef h2_get_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef h2_get_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef h2_set_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef h2_get_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef h2_set_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef h2_wrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef h2_get_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef h2_set_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef h2_get_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef h2_set_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef h2_alloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef h2_realloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef h2_free_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef h2_text_ALREADY_DEFINED -#undef yytext -#endif -#ifndef h2_leng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef h2_in_ALREADY_DEFINED -#undef yyin -#endif -#ifndef h2_out_ALREADY_DEFINED -#undef yyout -#endif -#ifndef h2__flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef h2_lineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef h2_tables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef h2_tables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef h2_TABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 172 "lexer.lpp" - - -#line 709 "lexer.hpp" -#undef h2_IN_HEADER -#endif /* h2_HEADER_H */ +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#pragma once + +namespace xsk::gsc::h2 +{ + +enum class keyword; + +struct buffer +{ + int size; + int length; + char* data; + + buffer(); + ~buffer(); + bool push(char c); +}; + +struct reader +{ + enum states { end, ok }; + + states state; + int bytes_remaining; + const char* buffer_pos; + char last_byte; + char current_byte; + + reader(); + + reader& operator=(const reader& r) + { + std::memcpy(this, &r, sizeof(reader)); + return *this; + } + + void init(const char* data, size_t size); + void advance(); +}; + +class lexer +{ +private: + reader reader_; + buffer buffer_; + location loc_; + build mode_; + bool in_dev_state_; + std::stack locs_; + std::stack readers_; + std::uint32_t header_top_; + +public: + lexer(const std::string& name, const char* data, size_t size); + auto lex() -> xsk::gsc::h2::parser::symbol_type; + void push_header(const std::string& file); + void pop_header(); + void restrict_header(const xsk::gsc::location& loc); + +private: + auto read_string(char quote, bool localize) -> xsk::gsc::h2::parser::symbol_type; + auto read_number(char first) -> xsk::gsc::h2::parser::symbol_type; + auto read_word(char first) -> xsk::gsc::h2::parser::symbol_type; + auto read_dotsize() -> xsk::gsc::h2::parser::symbol_type; + auto keyword_token(keyword k) -> xsk::gsc::h2::parser::symbol_type; + static auto keyword_is_token(keyword k) -> bool; + static auto get_keyword(std::string_view str) -> keyword; + + static std::unordered_map keywords; +}; + +} // namespace xsk::gsc::h2 diff --git a/src/h2/xsk/parser.cpp b/src/h2/xsk/parser.cpp index 64454b1d..6201d461 100644 --- a/src/h2/xsk/parser.cpp +++ b/src/h2/xsk/parser.cpp @@ -35,13 +35,13 @@ // private implementation details that can be changed or removed. // "%code top" blocks. -#line 40 "parser.ypp" +#line 34 "parser.ypp" #include "stdafx.hpp" #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::h2::parser::symbol_type H2lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::h2::parser::symbol_type H2lex(xsk::gsc::h2::lexer& lexer); #line 47 "parser.cpp" @@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace h2 { #line 149 "parser.cpp" /// Build a parser object. - parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) + parser::parser (xsk::gsc::h2::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) #if H2DEBUG : yydebug_ (false), yycdebug_ (&std::cerr), @@ -156,8 +156,7 @@ namespace xsk { namespace gsc { namespace h2 { : #endif yy_lac_established_ (false), - yyscanner (yyscanner_yyarg), - ctx (ctx_yyarg), + lexer (lexer_yyarg), ast (ast_yyarg) {} @@ -1593,7 +1592,7 @@ namespace xsk { namespace gsc { namespace h2 { try #endif // YY_EXCEPTIONS { - symbol_type yylookahead (yylex (yyscanner, ctx)); + symbol_type yylookahead (yylex (lexer)); yyla.move (yylookahead); } #if YY_EXCEPTIONS @@ -1980,1303 +1979,1303 @@ namespace xsk { namespace gsc { namespace h2 { switch (yyn) { case 2: // root: program -#line 251 "parser.ypp" +#line 245 "parser.ypp" { ast = std::move(yystack_[0].value.as < ast::program::ptr > ()); } -#line 1986 "parser.cpp" +#line 1985 "parser.cpp" break; case 3: // root: %empty -#line 252 "parser.ypp" +#line 246 "parser.ypp" { ast = std::make_unique(yylhs.location); } -#line 1992 "parser.cpp" +#line 1991 "parser.cpp" break; case 4: // program: program inline -#line 257 "parser.ypp" +#line 251 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); } -#line 1998 "parser.cpp" +#line 1997 "parser.cpp" break; case 5: // program: program include -#line 259 "parser.ypp" +#line 253 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2004 "parser.cpp" +#line 2003 "parser.cpp" break; case 6: // program: program declaration -#line 261 "parser.ypp" +#line 255 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2010 "parser.cpp" +#line 2009 "parser.cpp" break; case 7: // program: inline -#line 263 "parser.ypp" +#line 257 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); } -#line 2016 "parser.cpp" +#line 2015 "parser.cpp" break; case 8: // program: include -#line 265 "parser.ypp" +#line 259 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2022 "parser.cpp" +#line 2021 "parser.cpp" break; case 9: // program: declaration -#line 267 "parser.ypp" +#line 261 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2028 "parser.cpp" +#line 2027 "parser.cpp" break; case 10: // inline: "#inline" expr_path ";" -#line 271 "parser.ypp" - { h2_push_header(ctx, yystack_[1].value.as < ast::expr_path::ptr > ()->value); } -#line 2034 "parser.cpp" +#line 265 "parser.ypp" + { lexer.push_header(yystack_[1].value.as < ast::expr_path::ptr > ()->value); } +#line 2033 "parser.cpp" break; case 11: // include: "#include" expr_path ";" -#line 276 "parser.ypp" +#line 270 "parser.ypp" { yylhs.value.as < ast::include::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_path::ptr > ())); } -#line 2040 "parser.cpp" +#line 2039 "parser.cpp" break; case 12: // declaration: "/#" -#line 280 "parser.ypp" +#line 274 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_begin = std::make_unique(yylhs.location); } -#line 2046 "parser.cpp" +#line 2045 "parser.cpp" break; case 13: // declaration: "#/" -#line 281 "parser.ypp" +#line 275 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_end = std::make_unique(yylhs.location); } -#line 2052 "parser.cpp" +#line 2051 "parser.cpp" break; case 14: // declaration: decl_usingtree -#line 282 "parser.ypp" +#line 276 "parser.ypp" { yylhs.value.as < ast::decl > ().as_usingtree = std::move(yystack_[0].value.as < ast::decl_usingtree::ptr > ()); } -#line 2058 "parser.cpp" +#line 2057 "parser.cpp" break; case 15: // declaration: decl_constant -#line 283 "parser.ypp" +#line 277 "parser.ypp" { yylhs.value.as < ast::decl > ().as_constant = std::move(yystack_[0].value.as < ast::decl_constant::ptr > ()); } -#line 2064 "parser.cpp" +#line 2063 "parser.cpp" break; case 16: // declaration: decl_thread -#line 284 "parser.ypp" +#line 278 "parser.ypp" { yylhs.value.as < ast::decl > ().as_thread = std::move(yystack_[0].value.as < ast::decl_thread::ptr > ()); } -#line 2070 "parser.cpp" +#line 2069 "parser.cpp" break; case 17: // decl_usingtree: "#using_animtree" "(" expr_string ")" ";" -#line 289 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } -#line 2076 "parser.cpp" +#line 283 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } +#line 2075 "parser.cpp" break; case 18: // decl_constant: expr_identifier "=" expr ";" -#line 294 "parser.ypp" +#line 288 "parser.ypp" { yylhs.value.as < ast::decl_constant::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2082 "parser.cpp" +#line 2081 "parser.cpp" break; case 19: // decl_thread: expr_identifier "(" expr_parameters ")" stmt_block -#line 299 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2088 "parser.cpp" +#line 293 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } +#line 2087 "parser.cpp" break; case 20: // stmt: stmt_dev -#line 303 "parser.ypp" +#line 297 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2094 "parser.cpp" +#line 2093 "parser.cpp" break; case 21: // stmt: stmt_block -#line 304 "parser.ypp" +#line 298 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2100 "parser.cpp" +#line 2099 "parser.cpp" break; case 22: // stmt: stmt_call -#line 305 "parser.ypp" +#line 299 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_call = std::move(yystack_[0].value.as < ast::stmt_call::ptr > ()); } -#line 2106 "parser.cpp" +#line 2105 "parser.cpp" break; case 23: // stmt: stmt_assign -#line 306 "parser.ypp" +#line 300 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_assign = std::move(yystack_[0].value.as < ast::stmt_assign::ptr > ()); } -#line 2112 "parser.cpp" +#line 2111 "parser.cpp" break; case 24: // stmt: stmt_endon -#line 307 "parser.ypp" +#line 301 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_endon = std::move(yystack_[0].value.as < ast::stmt_endon::ptr > ()); } -#line 2118 "parser.cpp" +#line 2117 "parser.cpp" break; case 25: // stmt: stmt_notify -#line 308 "parser.ypp" +#line 302 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_notify = std::move(yystack_[0].value.as < ast::stmt_notify::ptr > ()); } -#line 2124 "parser.cpp" +#line 2123 "parser.cpp" break; case 26: // stmt: stmt_wait -#line 309 "parser.ypp" +#line 303 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_wait = std::move(yystack_[0].value.as < ast::stmt_wait::ptr > ()); } -#line 2130 "parser.cpp" +#line 2129 "parser.cpp" break; case 27: // stmt: stmt_waittill -#line 310 "parser.ypp" +#line 304 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittill = std::move(yystack_[0].value.as < ast::stmt_waittill::ptr > ()); } -#line 2136 "parser.cpp" +#line 2135 "parser.cpp" break; case 28: // stmt: stmt_waittillmatch -#line 311 "parser.ypp" +#line 305 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillmatch = std::move(yystack_[0].value.as < ast::stmt_waittillmatch::ptr > ()); } -#line 2142 "parser.cpp" +#line 2141 "parser.cpp" break; case 29: // stmt: stmt_waittillframeend -#line 312 "parser.ypp" +#line 306 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillframeend = std::move(yystack_[0].value.as < ast::stmt_waittillframeend::ptr > ()); } -#line 2148 "parser.cpp" +#line 2147 "parser.cpp" break; case 30: // stmt: stmt_waitframe -#line 313 "parser.ypp" +#line 307 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waitframe = std::move(yystack_[0].value.as < ast::stmt_waitframe::ptr > ()); } -#line 2154 "parser.cpp" +#line 2153 "parser.cpp" break; case 31: // stmt: stmt_if -#line 314 "parser.ypp" +#line 308 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_if = std::move(yystack_[0].value.as < ast::stmt_if::ptr > ()); } -#line 2160 "parser.cpp" +#line 2159 "parser.cpp" break; case 32: // stmt: stmt_ifelse -#line 315 "parser.ypp" +#line 309 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_ifelse = std::move(yystack_[0].value.as < ast::stmt_ifelse::ptr > ()); } -#line 2166 "parser.cpp" +#line 2165 "parser.cpp" break; case 33: // stmt: stmt_while -#line 316 "parser.ypp" +#line 310 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_while = std::move(yystack_[0].value.as < ast::stmt_while::ptr > ()); } -#line 2172 "parser.cpp" +#line 2171 "parser.cpp" break; case 34: // stmt: stmt_dowhile -#line 317 "parser.ypp" +#line 311 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_dowhile = std::move(yystack_[0].value.as < ast::stmt_dowhile::ptr > ()); } -#line 2178 "parser.cpp" +#line 2177 "parser.cpp" break; case 35: // stmt: stmt_for -#line 318 "parser.ypp" +#line 312 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_for = std::move(yystack_[0].value.as < ast::stmt_for::ptr > ()); } -#line 2184 "parser.cpp" +#line 2183 "parser.cpp" break; case 36: // stmt: stmt_foreach -#line 319 "parser.ypp" +#line 313 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_foreach = std::move(yystack_[0].value.as < ast::stmt_foreach::ptr > ()); } -#line 2190 "parser.cpp" +#line 2189 "parser.cpp" break; case 37: // stmt: stmt_switch -#line 320 "parser.ypp" +#line 314 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_switch = std::move(yystack_[0].value.as < ast::stmt_switch::ptr > ()); } -#line 2196 "parser.cpp" +#line 2195 "parser.cpp" break; case 38: // stmt: stmt_case -#line 321 "parser.ypp" +#line 315 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_case = std::move(yystack_[0].value.as < ast::stmt_case::ptr > ()); } -#line 2202 "parser.cpp" +#line 2201 "parser.cpp" break; case 39: // stmt: stmt_default -#line 322 "parser.ypp" +#line 316 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_default = std::move(yystack_[0].value.as < ast::stmt_default::ptr > ()); } -#line 2208 "parser.cpp" +#line 2207 "parser.cpp" break; case 40: // stmt: stmt_break -#line 323 "parser.ypp" +#line 317 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_break = std::move(yystack_[0].value.as < ast::stmt_break::ptr > ()); } -#line 2214 "parser.cpp" +#line 2213 "parser.cpp" break; case 41: // stmt: stmt_continue -#line 324 "parser.ypp" +#line 318 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_continue = std::move(yystack_[0].value.as < ast::stmt_continue::ptr > ()); } -#line 2220 "parser.cpp" +#line 2219 "parser.cpp" break; case 42: // stmt: stmt_return -#line 325 "parser.ypp" +#line 319 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_return = std::move(yystack_[0].value.as < ast::stmt_return::ptr > ()); } -#line 2226 "parser.cpp" +#line 2225 "parser.cpp" break; case 43: // stmt: stmt_breakpoint -#line 326 "parser.ypp" +#line 320 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_breakpoint = std::move(yystack_[0].value.as < ast::stmt_breakpoint::ptr > ()); } -#line 2232 "parser.cpp" +#line 2231 "parser.cpp" break; case 44: // stmt: stmt_prof_begin -#line 327 "parser.ypp" +#line 321 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_begin = std::move(yystack_[0].value.as < ast::stmt_prof_begin::ptr > ()); } -#line 2238 "parser.cpp" +#line 2237 "parser.cpp" break; case 45: // stmt: stmt_prof_end -#line 328 "parser.ypp" +#line 322 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_end = std::move(yystack_[0].value.as < ast::stmt_prof_end::ptr > ()); } -#line 2244 "parser.cpp" +#line 2243 "parser.cpp" break; case 46: // stmt_dev: "/#" stmt_list "#/" -#line 332 "parser.ypp" +#line 326 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2250 "parser.cpp" +#line 2249 "parser.cpp" break; case 47: // stmt_dev: "/#" "#/" -#line 333 "parser.ypp" +#line 327 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2256 "parser.cpp" +#line 2255 "parser.cpp" break; case 48: // stmt_block: "{" stmt_list "}" -#line 337 "parser.ypp" +#line 331 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2262 "parser.cpp" +#line 2261 "parser.cpp" break; case 49: // stmt_block: "{" "}" -#line 338 "parser.ypp" +#line 332 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2268 "parser.cpp" +#line 2267 "parser.cpp" break; case 50: // stmt_list: stmt_list stmt -#line 343 "parser.ypp" +#line 337 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2274 "parser.cpp" +#line 2273 "parser.cpp" break; case 51: // stmt_list: stmt -#line 345 "parser.ypp" +#line 339 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2280 "parser.cpp" +#line 2279 "parser.cpp" break; case 52: // stmt_expr: expr_assign -#line 350 "parser.ypp" +#line 344 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2286 "parser.cpp" +#line 2285 "parser.cpp" break; case 53: // stmt_expr: expr_increment -#line 352 "parser.ypp" +#line 346 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2292 "parser.cpp" +#line 2291 "parser.cpp" break; case 54: // stmt_expr: expr_decrement -#line 354 "parser.ypp" +#line 348 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2298 "parser.cpp" +#line 2297 "parser.cpp" break; case 55: // stmt_expr: %empty -#line 356 "parser.ypp" +#line 350 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2304 "parser.cpp" +#line 2303 "parser.cpp" break; case 56: // stmt_call: expr_call ";" -#line 361 "parser.ypp" +#line 355 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_call::ptr > ()))); } -#line 2310 "parser.cpp" +#line 2309 "parser.cpp" break; case 57: // stmt_call: expr_method ";" -#line 363 "parser.ypp" +#line 357 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_method::ptr > ()))); } -#line 2316 "parser.cpp" +#line 2315 "parser.cpp" break; case 58: // stmt_assign: expr_assign ";" -#line 368 "parser.ypp" +#line 362 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2322 "parser.cpp" +#line 2321 "parser.cpp" break; case 59: // stmt_assign: expr_increment ";" -#line 370 "parser.ypp" +#line 364 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2328 "parser.cpp" +#line 2327 "parser.cpp" break; case 60: // stmt_assign: expr_decrement ";" -#line 372 "parser.ypp" +#line 366 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2334 "parser.cpp" +#line 2333 "parser.cpp" break; case 61: // stmt_endon: expr_object "endon" "(" expr ")" ";" -#line 377 "parser.ypp" +#line 371 "parser.ypp" { yylhs.value.as < ast::stmt_endon::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ())); } -#line 2340 "parser.cpp" +#line 2339 "parser.cpp" break; case 62: // stmt_notify: expr_object "notify" "(" expr "," expr_arguments_no_empty ")" ";" -#line 382 "parser.ypp" +#line 376 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2346 "parser.cpp" +#line 2345 "parser.cpp" break; case 63: // stmt_notify: expr_object "notify" "(" expr ")" ";" -#line 384 "parser.ypp" +#line 378 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2352 "parser.cpp" +#line 2351 "parser.cpp" break; case 64: // stmt_wait: "wait" expr ";" -#line 389 "parser.ypp" +#line 383 "parser.ypp" { yylhs.value.as < ast::stmt_wait::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2358 "parser.cpp" +#line 2357 "parser.cpp" break; case 65: // stmt_waittill: expr_object "waittill" "(" expr "," expr_arguments_no_empty ")" ";" -#line 394 "parser.ypp" +#line 388 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2364 "parser.cpp" +#line 2363 "parser.cpp" break; case 66: // stmt_waittill: expr_object "waittill" "(" expr ")" ";" -#line 396 "parser.ypp" +#line 390 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2370 "parser.cpp" +#line 2369 "parser.cpp" break; case 67: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr "," expr_arguments_no_empty ")" ";" -#line 401 "parser.ypp" +#line 395 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2376 "parser.cpp" +#line 2375 "parser.cpp" break; case 68: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr ")" ";" -#line 403 "parser.ypp" +#line 397 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2382 "parser.cpp" +#line 2381 "parser.cpp" break; case 69: // stmt_waittillframeend: "waittillframeend" ";" -#line 408 "parser.ypp" +#line 402 "parser.ypp" { yylhs.value.as < ast::stmt_waittillframeend::ptr > () = std::make_unique(yylhs.location); } -#line 2388 "parser.cpp" +#line 2387 "parser.cpp" break; case 70: // stmt_waitframe: "waitframe" ";" -#line 413 "parser.ypp" +#line 407 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2394 "parser.cpp" +#line 2393 "parser.cpp" break; case 71: // stmt_waitframe: "waitframe" "(" ")" ";" -#line 415 "parser.ypp" +#line 409 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2400 "parser.cpp" +#line 2399 "parser.cpp" break; case 72: // stmt_if: "if" "(" expr ")" stmt -#line 420 "parser.ypp" +#line 414 "parser.ypp" { yylhs.value.as < ast::stmt_if::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2406 "parser.cpp" +#line 2405 "parser.cpp" break; case 73: // stmt_ifelse: "if" "(" expr ")" stmt "else" stmt -#line 425 "parser.ypp" +#line 419 "parser.ypp" { yylhs.value.as < ast::stmt_ifelse::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::stmt > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2412 "parser.cpp" +#line 2411 "parser.cpp" break; case 74: // stmt_while: "while" "(" expr ")" stmt -#line 430 "parser.ypp" +#line 424 "parser.ypp" { yylhs.value.as < ast::stmt_while::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2418 "parser.cpp" +#line 2417 "parser.cpp" break; case 75: // stmt_dowhile: "do" stmt "while" "(" expr ")" ";" -#line 435 "parser.ypp" +#line 429 "parser.ypp" { yylhs.value.as < ast::stmt_dowhile::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[5].value.as < ast::stmt > ())); } -#line 2424 "parser.cpp" +#line 2423 "parser.cpp" break; case 76: // stmt_for: "for" "(" stmt_expr ";" expr_or_empty ";" stmt_expr ")" stmt -#line 440 "parser.ypp" +#line 434 "parser.ypp" { yylhs.value.as < ast::stmt_for::ptr > () = std::make_unique(yylhs.location, ast::stmt(std::move(yystack_[6].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[4].value.as < ast::expr > ()), ast::stmt(std::move(yystack_[2].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2430 "parser.cpp" +#line 2429 "parser.cpp" break; case 77: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt -#line 445 "parser.ypp" +#line 439 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2436 "parser.cpp" +#line 2435 "parser.cpp" break; case 78: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt -#line 447 "parser.ypp" +#line 441 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[6].value.as < ast::expr_identifier::ptr > ())), ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2442 "parser.cpp" +#line 2441 "parser.cpp" break; case 79: // stmt_switch: "switch" "(" expr ")" stmt_block -#line 452 "parser.ypp" +#line 446 "parser.ypp" { yylhs.value.as < ast::stmt_switch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2448 "parser.cpp" +#line 2447 "parser.cpp" break; case 80: // stmt_case: "case" expr_integer ":" -#line 457 "parser.ypp" +#line 451 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_integer::ptr > ())), std::make_unique(yylhs.location)); } -#line 2454 "parser.cpp" +#line 2453 "parser.cpp" break; case 81: // stmt_case: "case" expr_string ":" -#line 459 "parser.ypp" +#line 453 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_string::ptr > ())), std::make_unique(yylhs.location)); } -#line 2460 "parser.cpp" +#line 2459 "parser.cpp" break; case 82: // stmt_default: "default" ":" -#line 464 "parser.ypp" +#line 458 "parser.ypp" { yylhs.value.as < ast::stmt_default::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2466 "parser.cpp" +#line 2465 "parser.cpp" break; case 83: // stmt_break: "break" ";" -#line 469 "parser.ypp" +#line 463 "parser.ypp" { yylhs.value.as < ast::stmt_break::ptr > () = std::make_unique(yylhs.location); } -#line 2472 "parser.cpp" +#line 2471 "parser.cpp" break; case 84: // stmt_continue: "continue" ";" -#line 474 "parser.ypp" +#line 468 "parser.ypp" { yylhs.value.as < ast::stmt_continue::ptr > () = std::make_unique(yylhs.location); } -#line 2478 "parser.cpp" +#line 2477 "parser.cpp" break; case 85: // stmt_return: "return" expr ";" -#line 479 "parser.ypp" +#line 473 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2484 "parser.cpp" +#line 2483 "parser.cpp" break; case 86: // stmt_return: "return" ";" -#line 481 "parser.ypp" +#line 475 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2490 "parser.cpp" +#line 2489 "parser.cpp" break; case 87: // stmt_breakpoint: "breakpoint" ";" -#line 486 "parser.ypp" +#line 480 "parser.ypp" { yylhs.value.as < ast::stmt_breakpoint::ptr > () = std::make_unique(yylhs.location); } -#line 2496 "parser.cpp" +#line 2495 "parser.cpp" break; case 88: // stmt_prof_begin: "prof_begin" "(" expr_arguments ")" ";" -#line 491 "parser.ypp" +#line 485 "parser.ypp" { yylhs.value.as < ast::stmt_prof_begin::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2502 "parser.cpp" +#line 2501 "parser.cpp" break; case 89: // stmt_prof_end: "prof_end" "(" expr_arguments ")" ";" -#line 496 "parser.ypp" +#line 490 "parser.ypp" { yylhs.value.as < ast::stmt_prof_end::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2508 "parser.cpp" +#line 2507 "parser.cpp" break; case 90: // expr: expr_ternary -#line 500 "parser.ypp" +#line 494 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2514 "parser.cpp" +#line 2513 "parser.cpp" break; case 91: // expr: expr_binary -#line 501 "parser.ypp" +#line 495 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2520 "parser.cpp" +#line 2519 "parser.cpp" break; case 92: // expr: expr_primitive -#line 502 "parser.ypp" +#line 496 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2526 "parser.cpp" +#line 2525 "parser.cpp" break; case 93: // expr_or_empty: expr -#line 506 "parser.ypp" +#line 500 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2532 "parser.cpp" +#line 2531 "parser.cpp" break; case 94: // expr_or_empty: %empty -#line 507 "parser.ypp" +#line 501 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location); } -#line 2538 "parser.cpp" +#line 2537 "parser.cpp" break; case 95: // expr_assign: expr_object "=" expr -#line 512 "parser.ypp" +#line 506 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2544 "parser.cpp" +#line 2543 "parser.cpp" break; case 96: // expr_assign: expr_object "|=" expr -#line 514 "parser.ypp" +#line 508 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2550 "parser.cpp" +#line 2549 "parser.cpp" break; case 97: // expr_assign: expr_object "&=" expr -#line 516 "parser.ypp" +#line 510 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2556 "parser.cpp" +#line 2555 "parser.cpp" break; case 98: // expr_assign: expr_object "^=" expr -#line 518 "parser.ypp" +#line 512 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2562 "parser.cpp" +#line 2561 "parser.cpp" break; case 99: // expr_assign: expr_object "<<=" expr -#line 520 "parser.ypp" +#line 514 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()),std::move( yystack_[0].value.as < ast::expr > ())); } -#line 2568 "parser.cpp" +#line 2567 "parser.cpp" break; case 100: // expr_assign: expr_object ">>=" expr -#line 522 "parser.ypp" +#line 516 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2574 "parser.cpp" +#line 2573 "parser.cpp" break; case 101: // expr_assign: expr_object "+=" expr -#line 524 "parser.ypp" +#line 518 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2580 "parser.cpp" +#line 2579 "parser.cpp" break; case 102: // expr_assign: expr_object "-=" expr -#line 526 "parser.ypp" +#line 520 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2586 "parser.cpp" +#line 2585 "parser.cpp" break; case 103: // expr_assign: expr_object "*=" expr -#line 528 "parser.ypp" +#line 522 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2592 "parser.cpp" +#line 2591 "parser.cpp" break; case 104: // expr_assign: expr_object "/=" expr -#line 530 "parser.ypp" +#line 524 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2598 "parser.cpp" +#line 2597 "parser.cpp" break; case 105: // expr_assign: expr_object "%=" expr -#line 532 "parser.ypp" +#line 526 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2604 "parser.cpp" +#line 2603 "parser.cpp" break; case 106: // expr_increment: "++" expr_object -#line 537 "parser.ypp" +#line 531 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2610 "parser.cpp" +#line 2609 "parser.cpp" break; case 107: // expr_increment: expr_object "++" -#line 539 "parser.ypp" +#line 533 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2616 "parser.cpp" +#line 2615 "parser.cpp" break; case 108: // expr_decrement: "--" expr_object -#line 544 "parser.ypp" +#line 538 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2622 "parser.cpp" +#line 2621 "parser.cpp" break; case 109: // expr_decrement: expr_object "--" -#line 546 "parser.ypp" +#line 540 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2628 "parser.cpp" +#line 2627 "parser.cpp" break; case 110: // expr_ternary: expr "?" expr ":" expr -#line 551 "parser.ypp" +#line 545 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2634 "parser.cpp" +#line 2633 "parser.cpp" break; case 111: // expr_binary: expr "||" expr -#line 556 "parser.ypp" +#line 550 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2640 "parser.cpp" +#line 2639 "parser.cpp" break; case 112: // expr_binary: expr "&&" expr -#line 558 "parser.ypp" +#line 552 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2646 "parser.cpp" +#line 2645 "parser.cpp" break; case 113: // expr_binary: expr "==" expr -#line 560 "parser.ypp" +#line 554 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2652 "parser.cpp" +#line 2651 "parser.cpp" break; case 114: // expr_binary: expr "!=" expr -#line 562 "parser.ypp" +#line 556 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2658 "parser.cpp" +#line 2657 "parser.cpp" break; case 115: // expr_binary: expr "<=" expr -#line 564 "parser.ypp" +#line 558 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2664 "parser.cpp" +#line 2663 "parser.cpp" break; case 116: // expr_binary: expr ">=" expr -#line 566 "parser.ypp" +#line 560 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2670 "parser.cpp" +#line 2669 "parser.cpp" break; case 117: // expr_binary: expr "<" expr -#line 568 "parser.ypp" +#line 562 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2676 "parser.cpp" +#line 2675 "parser.cpp" break; case 118: // expr_binary: expr ">" expr -#line 570 "parser.ypp" +#line 564 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2682 "parser.cpp" +#line 2681 "parser.cpp" break; case 119: // expr_binary: expr "|" expr -#line 572 "parser.ypp" +#line 566 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2688 "parser.cpp" +#line 2687 "parser.cpp" break; case 120: // expr_binary: expr "&" expr -#line 574 "parser.ypp" +#line 568 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2694 "parser.cpp" +#line 2693 "parser.cpp" break; case 121: // expr_binary: expr "^" expr -#line 576 "parser.ypp" +#line 570 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2700 "parser.cpp" +#line 2699 "parser.cpp" break; case 122: // expr_binary: expr "<<" expr -#line 578 "parser.ypp" +#line 572 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2706 "parser.cpp" +#line 2705 "parser.cpp" break; case 123: // expr_binary: expr ">>" expr -#line 580 "parser.ypp" +#line 574 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2712 "parser.cpp" +#line 2711 "parser.cpp" break; case 124: // expr_binary: expr "+" expr -#line 582 "parser.ypp" +#line 576 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2718 "parser.cpp" +#line 2717 "parser.cpp" break; case 125: // expr_binary: expr "-" expr -#line 584 "parser.ypp" +#line 578 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2724 "parser.cpp" +#line 2723 "parser.cpp" break; case 126: // expr_binary: expr "*" expr -#line 586 "parser.ypp" +#line 580 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2730 "parser.cpp" +#line 2729 "parser.cpp" break; case 127: // expr_binary: expr "/" expr -#line 588 "parser.ypp" +#line 582 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2736 "parser.cpp" +#line 2735 "parser.cpp" break; case 128: // expr_binary: expr "%" expr -#line 590 "parser.ypp" +#line 584 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2742 "parser.cpp" +#line 2741 "parser.cpp" break; case 129: // expr_primitive: expr_complement -#line 594 "parser.ypp" +#line 588 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_complement::ptr > ()); } -#line 2748 "parser.cpp" +#line 2747 "parser.cpp" break; case 130: // expr_primitive: expr_not -#line 595 "parser.ypp" +#line 589 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_not::ptr > ()); } -#line 2754 "parser.cpp" +#line 2753 "parser.cpp" break; case 131: // expr_primitive: expr_call -#line 596 "parser.ypp" +#line 590 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 2760 "parser.cpp" +#line 2759 "parser.cpp" break; case 132: // expr_primitive: expr_method -#line 597 "parser.ypp" +#line 591 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 2766 "parser.cpp" +#line 2765 "parser.cpp" break; case 133: // expr_primitive: expr_add_array -#line 598 "parser.ypp" +#line 592 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_add_array::ptr > ()); } -#line 2772 "parser.cpp" +#line 2771 "parser.cpp" break; case 134: // expr_primitive: expr_reference -#line 599 "parser.ypp" +#line 593 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_reference::ptr > ()); } -#line 2778 "parser.cpp" +#line 2777 "parser.cpp" break; case 135: // expr_primitive: expr_array -#line 600 "parser.ypp" +#line 594 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 2784 "parser.cpp" +#line 2783 "parser.cpp" break; case 136: // expr_primitive: expr_field -#line 601 "parser.ypp" +#line 595 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 2790 "parser.cpp" +#line 2789 "parser.cpp" break; case 137: // expr_primitive: expr_size -#line 602 "parser.ypp" +#line 596 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_size::ptr > ()); } -#line 2796 "parser.cpp" +#line 2795 "parser.cpp" break; case 138: // expr_primitive: expr_paren -#line 603 "parser.ypp" +#line 597 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_paren::ptr > ()); } -#line 2802 "parser.cpp" +#line 2801 "parser.cpp" break; case 139: // expr_primitive: expr_thisthread -#line 604 "parser.ypp" +#line 598 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_thisthread::ptr > ()); } -#line 2808 "parser.cpp" +#line 2807 "parser.cpp" break; case 140: // expr_primitive: expr_empty_array -#line 605 "parser.ypp" +#line 599 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_empty_array::ptr > ()); } -#line 2814 "parser.cpp" +#line 2813 "parser.cpp" break; case 141: // expr_primitive: expr_undefined -#line 606 "parser.ypp" +#line 600 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_undefined::ptr > ()); } -#line 2820 "parser.cpp" +#line 2819 "parser.cpp" break; case 142: // expr_primitive: expr_game -#line 607 "parser.ypp" +#line 601 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 2826 "parser.cpp" +#line 2825 "parser.cpp" break; case 143: // expr_primitive: expr_self -#line 608 "parser.ypp" +#line 602 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 2832 "parser.cpp" +#line 2831 "parser.cpp" break; case 144: // expr_primitive: expr_anim -#line 609 "parser.ypp" +#line 603 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 2838 "parser.cpp" +#line 2837 "parser.cpp" break; case 145: // expr_primitive: expr_level -#line 610 "parser.ypp" +#line 604 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 2844 "parser.cpp" +#line 2843 "parser.cpp" break; case 146: // expr_primitive: expr_animation -#line 611 "parser.ypp" +#line 605 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animation::ptr > ()); } -#line 2850 "parser.cpp" +#line 2849 "parser.cpp" break; case 147: // expr_primitive: expr_animtree -#line 612 "parser.ypp" +#line 606 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animtree::ptr > ()); } -#line 2856 "parser.cpp" +#line 2855 "parser.cpp" break; case 148: // expr_primitive: expr_identifier -#line 613 "parser.ypp" +#line 607 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 2862 "parser.cpp" +#line 2861 "parser.cpp" break; case 149: // expr_primitive: expr_istring -#line 614 "parser.ypp" +#line 608 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istring::ptr > ()); } -#line 2868 "parser.cpp" +#line 2867 "parser.cpp" break; case 150: // expr_primitive: expr_string -#line 615 "parser.ypp" +#line 609 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_string::ptr > ()); } -#line 2874 "parser.cpp" +#line 2873 "parser.cpp" break; case 151: // expr_primitive: expr_color -#line 616 "parser.ypp" +#line 610 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_color::ptr > ()); } -#line 2880 "parser.cpp" +#line 2879 "parser.cpp" break; case 152: // expr_primitive: expr_vector -#line 617 "parser.ypp" +#line 611 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_vector::ptr > ()); } -#line 2886 "parser.cpp" +#line 2885 "parser.cpp" break; case 153: // expr_primitive: expr_float -#line 618 "parser.ypp" +#line 612 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_float::ptr > ()); } -#line 2892 "parser.cpp" +#line 2891 "parser.cpp" break; case 154: // expr_primitive: expr_integer -#line 619 "parser.ypp" +#line 613 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_integer::ptr > ()); } -#line 2898 "parser.cpp" +#line 2897 "parser.cpp" break; case 155: // expr_primitive: expr_false -#line 620 "parser.ypp" +#line 614 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_false::ptr > ()); } -#line 2904 "parser.cpp" +#line 2903 "parser.cpp" break; case 156: // expr_primitive: expr_true -#line 621 "parser.ypp" +#line 615 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_true::ptr > ()); } -#line 2910 "parser.cpp" +#line 2909 "parser.cpp" break; case 157: // expr_complement: "~" expr -#line 626 "parser.ypp" +#line 620 "parser.ypp" { yylhs.value.as < ast::expr_complement::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2916 "parser.cpp" +#line 2915 "parser.cpp" break; case 158: // expr_not: "!" expr -#line 631 "parser.ypp" +#line 625 "parser.ypp" { yylhs.value.as < ast::expr_not::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2922 "parser.cpp" +#line 2921 "parser.cpp" break; case 159: // expr_call: expr_function -#line 635 "parser.ypp" +#line 629 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2928 "parser.cpp" +#line 2927 "parser.cpp" break; case 160: // expr_call: expr_pointer -#line 636 "parser.ypp" +#line 630 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2934 "parser.cpp" +#line 2933 "parser.cpp" break; case 161: // expr_method: expr_object expr_function -#line 639 "parser.ypp" +#line 633 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2940 "parser.cpp" +#line 2939 "parser.cpp" break; case 162: // expr_method: expr_object expr_pointer -#line 640 "parser.ypp" +#line 634 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2946 "parser.cpp" +#line 2945 "parser.cpp" break; case 163: // expr_function: expr_identifier "(" expr_arguments ")" -#line 645 "parser.ypp" +#line 639 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2952 "parser.cpp" +#line 2951 "parser.cpp" break; case 164: // expr_function: expr_path "::" expr_identifier "(" expr_arguments ")" -#line 647 "parser.ypp" +#line 641 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2958 "parser.cpp" +#line 2957 "parser.cpp" break; case 165: // expr_function: "thread" expr_identifier "(" expr_arguments ")" -#line 649 "parser.ypp" +#line 643 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2964 "parser.cpp" +#line 2963 "parser.cpp" break; case 166: // expr_function: "thread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 651 "parser.ypp" +#line 645 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2970 "parser.cpp" +#line 2969 "parser.cpp" break; case 167: // expr_function: "childthread" expr_identifier "(" expr_arguments ")" -#line 653 "parser.ypp" +#line 647 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2976 "parser.cpp" +#line 2975 "parser.cpp" break; case 168: // expr_function: "childthread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 655 "parser.ypp" +#line 649 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2982 "parser.cpp" +#line 2981 "parser.cpp" break; case 169: // expr_pointer: "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 660 "parser.ypp" +#line 654 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2988 "parser.cpp" +#line 2987 "parser.cpp" break; case 170: // expr_pointer: "thread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 662 "parser.ypp" +#line 656 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2994 "parser.cpp" +#line 2993 "parser.cpp" break; case 171: // expr_pointer: "childthread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 664 "parser.ypp" +#line 658 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3000 "parser.cpp" +#line 2999 "parser.cpp" break; case 172: // expr_pointer: "call" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 666 "parser.ypp" +#line 660 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::builtin); } -#line 3006 "parser.cpp" +#line 3005 "parser.cpp" break; case 173: // expr_add_array: "[" expr_arguments_no_empty "]" -#line 671 "parser.ypp" +#line 665 "parser.ypp" { yylhs.value.as < ast::expr_add_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ())); } -#line 3012 "parser.cpp" +#line 3011 "parser.cpp" break; case 174: // expr_parameters: expr_parameters "," expr_identifier -#line 676 "parser.ypp" +#line 670 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3018 "parser.cpp" +#line 3017 "parser.cpp" break; case 175: // expr_parameters: expr_identifier -#line 678 "parser.ypp" +#line 672 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3024 "parser.cpp" +#line 3023 "parser.cpp" break; case 176: // expr_parameters: %empty -#line 680 "parser.ypp" +#line 674 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); } -#line 3030 "parser.cpp" +#line 3029 "parser.cpp" break; case 177: // expr_arguments: expr_arguments_no_empty -#line 685 "parser.ypp" +#line 679 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[0].value.as < ast::expr_arguments::ptr > ()); } -#line 3036 "parser.cpp" +#line 3035 "parser.cpp" break; case 178: // expr_arguments: %empty -#line 687 "parser.ypp" +#line 681 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); } -#line 3042 "parser.cpp" +#line 3041 "parser.cpp" break; case 179: // expr_arguments_no_empty: expr_arguments "," expr -#line 692 "parser.ypp" +#line 686 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ()); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3048 "parser.cpp" +#line 3047 "parser.cpp" break; case 180: // expr_arguments_no_empty: expr -#line 694 "parser.ypp" +#line 688 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3054 "parser.cpp" +#line 3053 "parser.cpp" break; case 181: // expr_reference: "::" expr_identifier -#line 699 "parser.ypp" +#line 693 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3060 "parser.cpp" +#line 3059 "parser.cpp" break; case 182: // expr_reference: expr_path "::" expr_identifier -#line 701 "parser.ypp" +#line 695 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_path::ptr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3066 "parser.cpp" +#line 3065 "parser.cpp" break; case 183: // expr_array: expr_object "[" expr "]" -#line 706 "parser.ypp" +#line 700 "parser.ypp" { yylhs.value.as < ast::expr_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3072 "parser.cpp" +#line 3071 "parser.cpp" break; case 184: // expr_field: expr_object "." expr_identifier -#line 711 "parser.ypp" +#line 705 "parser.ypp" { yylhs.value.as < ast::expr_field::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3078 "parser.cpp" +#line 3077 "parser.cpp" break; case 185: // expr_size: expr_object ".size" -#line 716 "parser.ypp" +#line 710 "parser.ypp" { yylhs.value.as < ast::expr_size::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3084 "parser.cpp" +#line 3083 "parser.cpp" break; case 186: // expr_paren: "(" expr ")" -#line 721 "parser.ypp" +#line 715 "parser.ypp" { yylhs.value.as < ast::expr_paren::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3090 "parser.cpp" +#line 3089 "parser.cpp" break; case 187: // expr_object: expr_call -#line 725 "parser.ypp" +#line 719 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 3096 "parser.cpp" +#line 3095 "parser.cpp" break; case 188: // expr_object: expr_method -#line 726 "parser.ypp" +#line 720 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 3102 "parser.cpp" +#line 3101 "parser.cpp" break; case 189: // expr_object: expr_array -#line 727 "parser.ypp" +#line 721 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 3108 "parser.cpp" +#line 3107 "parser.cpp" break; case 190: // expr_object: expr_field -#line 728 "parser.ypp" +#line 722 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 3114 "parser.cpp" +#line 3113 "parser.cpp" break; case 191: // expr_object: expr_game -#line 729 "parser.ypp" +#line 723 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 3120 "parser.cpp" +#line 3119 "parser.cpp" break; case 192: // expr_object: expr_self -#line 730 "parser.ypp" +#line 724 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 3126 "parser.cpp" +#line 3125 "parser.cpp" break; case 193: // expr_object: expr_anim -#line 731 "parser.ypp" +#line 725 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 3132 "parser.cpp" +#line 3131 "parser.cpp" break; case 194: // expr_object: expr_level -#line 732 "parser.ypp" +#line 726 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 3138 "parser.cpp" +#line 3137 "parser.cpp" break; case 195: // expr_object: expr_identifier -#line 733 "parser.ypp" +#line 727 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 3144 "parser.cpp" +#line 3143 "parser.cpp" break; case 196: // expr_thisthread: "thisthread" -#line 738 "parser.ypp" +#line 732 "parser.ypp" { yylhs.value.as < ast::expr_thisthread::ptr > () = std::make_unique(yylhs.location); } -#line 3150 "parser.cpp" +#line 3149 "parser.cpp" break; case 197: // expr_empty_array: "[" "]" -#line 743 "parser.ypp" +#line 737 "parser.ypp" { yylhs.value.as < ast::expr_empty_array::ptr > () = std::make_unique(yylhs.location); } -#line 3156 "parser.cpp" +#line 3155 "parser.cpp" break; case 198: // expr_undefined: "undefined" -#line 748 "parser.ypp" +#line 742 "parser.ypp" { yylhs.value.as < ast::expr_undefined::ptr > () = std::make_unique(yylhs.location); } -#line 3162 "parser.cpp" +#line 3161 "parser.cpp" break; case 199: // expr_game: "game" -#line 753 "parser.ypp" +#line 747 "parser.ypp" { yylhs.value.as < ast::expr_game::ptr > () = std::make_unique(yylhs.location); } -#line 3168 "parser.cpp" +#line 3167 "parser.cpp" break; case 200: // expr_self: "self" -#line 758 "parser.ypp" +#line 752 "parser.ypp" { yylhs.value.as < ast::expr_self::ptr > () = std::make_unique(yylhs.location); } -#line 3174 "parser.cpp" +#line 3173 "parser.cpp" break; case 201: // expr_anim: "anim" -#line 763 "parser.ypp" +#line 757 "parser.ypp" { yylhs.value.as < ast::expr_anim::ptr > () = std::make_unique(yylhs.location); } -#line 3180 "parser.cpp" +#line 3179 "parser.cpp" break; case 202: // expr_level: "level" -#line 768 "parser.ypp" +#line 762 "parser.ypp" { yylhs.value.as < ast::expr_level::ptr > () = std::make_unique(yylhs.location); } -#line 3186 "parser.cpp" +#line 3185 "parser.cpp" break; case 203: // expr_animation: "%" "identifier" -#line 773 "parser.ypp" +#line 767 "parser.ypp" { yylhs.value.as < ast::expr_animation::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3192 "parser.cpp" +#line 3191 "parser.cpp" break; case 204: // expr_animtree: "#animtree" -#line 778 "parser.ypp" +#line 772 "parser.ypp" { yylhs.value.as < ast::expr_animtree::ptr > () = std::make_unique(yylhs.location); } -#line 3198 "parser.cpp" +#line 3197 "parser.cpp" break; case 205: // expr_identifier: "identifier" -#line 783 "parser.ypp" +#line 777 "parser.ypp" { yylhs.value.as < ast::expr_identifier::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3204 "parser.cpp" +#line 3203 "parser.cpp" break; case 206: // expr_path: "path" -#line 788 "parser.ypp" +#line 782 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3210 "parser.cpp" +#line 3209 "parser.cpp" break; case 207: // expr_path: expr_identifier -#line 790 "parser.ypp" +#line 784 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < ast::expr_identifier::ptr > ()->value); } -#line 3216 "parser.cpp" +#line 3215 "parser.cpp" break; case 208: // expr_istring: "localized string" -#line 795 "parser.ypp" +#line 789 "parser.ypp" { yylhs.value.as < ast::expr_istring::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3222 "parser.cpp" +#line 3221 "parser.cpp" break; case 209: // expr_string: "string literal" -#line 800 "parser.ypp" +#line 794 "parser.ypp" { yylhs.value.as < ast::expr_string::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3228 "parser.cpp" +#line 3227 "parser.cpp" break; case 210: // expr_color: "color" -#line 805 "parser.ypp" +#line 799 "parser.ypp" { yylhs.value.as < ast::expr_color::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3234 "parser.cpp" +#line 3233 "parser.cpp" break; case 211: // expr_vector: "(" expr "," expr "," expr ")" -#line 810 "parser.ypp" +#line 804 "parser.ypp" { yylhs.value.as < ast::expr_vector::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3240 "parser.cpp" +#line 3239 "parser.cpp" break; case 212: // expr_float: "-" "float" -#line 815 "parser.ypp" +#line 809 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3246 "parser.cpp" +#line 3245 "parser.cpp" break; case 213: // expr_float: "float" -#line 817 "parser.ypp" +#line 811 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3252 "parser.cpp" +#line 3251 "parser.cpp" break; case 214: // expr_integer: "-" "integer" -#line 822 "parser.ypp" +#line 816 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3258 "parser.cpp" +#line 3257 "parser.cpp" break; case 215: // expr_integer: "integer" -#line 824 "parser.ypp" +#line 818 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3264 "parser.cpp" +#line 3263 "parser.cpp" break; case 216: // expr_false: "false" -#line 829 "parser.ypp" +#line 823 "parser.ypp" { yylhs.value.as < ast::expr_false::ptr > () = std::make_unique(yylhs.location); } -#line 3270 "parser.cpp" +#line 3269 "parser.cpp" break; case 217: // expr_true: "true" -#line 834 "parser.ypp" +#line 828 "parser.ypp" { yylhs.value.as < ast::expr_true::ptr > () = std::make_unique(yylhs.location); } -#line 3276 "parser.cpp" +#line 3275 "parser.cpp" break; -#line 3280 "parser.cpp" +#line 3279 "parser.cpp" default: break; @@ -4446,28 +4445,28 @@ namespace xsk { namespace gsc { namespace h2 { const short parser::yyrline_[] = { - 0, 251, 251, 252, 256, 258, 260, 262, 264, 266, - 271, 275, 280, 281, 282, 283, 284, 288, 293, 298, - 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, - 323, 324, 325, 326, 327, 328, 332, 333, 337, 338, - 342, 344, 349, 351, 353, 356, 360, 362, 367, 369, - 371, 376, 381, 383, 388, 393, 395, 400, 402, 407, - 412, 414, 419, 424, 429, 434, 439, 444, 446, 451, - 456, 458, 463, 468, 473, 478, 480, 485, 490, 495, - 500, 501, 502, 506, 507, 511, 513, 515, 517, 519, - 521, 523, 525, 527, 529, 531, 536, 538, 543, 545, - 550, 555, 557, 559, 561, 563, 565, 567, 569, 571, - 573, 575, 577, 579, 581, 583, 585, 587, 589, 594, - 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, - 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, - 615, 616, 617, 618, 619, 620, 621, 625, 630, 635, - 636, 639, 640, 644, 646, 648, 650, 652, 654, 659, - 661, 663, 665, 670, 675, 677, 680, 684, 687, 691, - 693, 698, 700, 705, 710, 715, 720, 725, 726, 727, - 728, 729, 730, 731, 732, 733, 737, 742, 747, 752, - 757, 762, 767, 772, 777, 782, 787, 789, 794, 799, - 804, 809, 814, 816, 821, 823, 828, 833 + 0, 245, 245, 246, 250, 252, 254, 256, 258, 260, + 265, 269, 274, 275, 276, 277, 278, 282, 287, 292, + 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 326, 327, 331, 332, + 336, 338, 343, 345, 347, 350, 354, 356, 361, 363, + 365, 370, 375, 377, 382, 387, 389, 394, 396, 401, + 406, 408, 413, 418, 423, 428, 433, 438, 440, 445, + 450, 452, 457, 462, 467, 472, 474, 479, 484, 489, + 494, 495, 496, 500, 501, 505, 507, 509, 511, 513, + 515, 517, 519, 521, 523, 525, 530, 532, 537, 539, + 544, 549, 551, 553, 555, 557, 559, 561, 563, 565, + 567, 569, 571, 573, 575, 577, 579, 581, 583, 588, + 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, + 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, + 609, 610, 611, 612, 613, 614, 615, 619, 624, 629, + 630, 633, 634, 638, 640, 642, 644, 646, 648, 653, + 655, 657, 659, 664, 669, 671, 674, 678, 681, 685, + 687, 692, 694, 699, 704, 709, 714, 719, 720, 721, + 722, 723, 724, 725, 726, 727, 731, 736, 741, 746, + 751, 756, 761, 766, 771, 776, 781, 783, 788, 793, + 798, 803, 808, 810, 815, 817, 822, 827 }; void @@ -4500,9 +4499,9 @@ namespace xsk { namespace gsc { namespace h2 { #line 13 "parser.ypp" } } } // xsk::gsc::h2 -#line 4504 "parser.cpp" +#line 4503 "parser.cpp" -#line 837 "parser.ypp" +#line 831 "parser.ypp" void xsk::gsc::h2::parser::error(const xsk::gsc::location& loc, const std::string& msg) diff --git a/src/h2/xsk/parser.hpp b/src/h2/xsk/parser.hpp index cdbf40e1..76ddd9f6 100644 --- a/src/h2/xsk/parser.hpp +++ b/src/h2/xsk/parser.hpp @@ -45,13 +45,12 @@ #ifndef YY_H2_PARSER_HPP_INCLUDED # define YY_H2_PARSER_HPP_INCLUDED // "%code requires" blocks. -#line 33 "parser.ypp" +#line 28 "parser.ypp" #include "h2.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::h2::parser::symbol_type H2lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::h2 { class lexer; } -#line 55 "parser.hpp" +#line 54 "parser.hpp" # include # include // std::abort @@ -194,7 +193,7 @@ typedef void *yyscan_t; #line 13 "parser.ypp" namespace xsk { namespace gsc { namespace h2 { -#line 198 "parser.hpp" +#line 197 "parser.hpp" @@ -2685,7 +2684,7 @@ switch (yykind) }; /// Build a parser object. - parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); + parser (xsk::gsc::h2::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); virtual ~parser (); #if 201103L <= YY_CPLUSPLUS @@ -4656,8 +4655,7 @@ switch (yykind) // User arguments. - yyscan_t yyscanner; - xsk::gsc::context* ctx; + xsk::gsc::h2::lexer& lexer; xsk::gsc::ast::program::ptr& ast; }; @@ -5342,7 +5340,7 @@ switch (yykind) #line 13 "parser.ypp" } } } // xsk::gsc::h2 -#line 5346 "parser.hpp" +#line 5344 "parser.hpp" diff --git a/src/h2/xsk/resolver.cpp b/src/h2/xsk/resolver.cpp index 50f6d2b7..c7fd0540 100644 --- a/src/h2/xsk/resolver.cpp +++ b/src/h2/xsk/resolver.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -206,6 +206,35 @@ auto resolver::make_token(std::string_view str) -> std::string return data; } +std::function(const std::string&)> read_callback = nullptr; +std::unordered_map> files; + +auto resolver::file_data(const std::string& name) -> std::tuple +{ + const auto& itr = files.find(name); + + if(itr != files.end()) + { + return { &itr->first ,reinterpret_cast(itr->second.data()), itr->second.size() }; + } + + auto data = read_callback(name); + + const auto& res = files.insert({ name, std::move(data)}); + + if(res.second) + { + return { &res.first->first, reinterpret_cast(res.first->second.data()), res.first->second.size() }; + } + + throw error("couldn't open gsc file '" + name + "'"); +} + +void resolver::set_reader(std::function(const std::string&)> callback) +{ + read_callback = callback; +} + const std::array, 154> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/h2/xsk/resolver.hpp b/src/h2/xsk/resolver.hpp index 8ee107ed..ab3b339d 100644 --- a/src/h2/xsk/resolver.hpp +++ b/src/h2/xsk/resolver.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -30,6 +30,8 @@ public: static auto find_method(const std::string& name) -> bool; static auto make_token(std::string_view str) -> std::string; + static auto file_data(const std::string& name) -> std::tuple; + static void set_reader(std::function(const std::string&)> callback); }; } // namespace xsk::gsc::h2 diff --git a/src/iw5/stdafx.cpp b/src/iw5/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/iw5/stdafx.cpp +++ b/src/iw5/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/stdafx.hpp b/src/iw5/stdafx.hpp index 748b660c..00b73550 100644 --- a/src/iw5/stdafx.hpp +++ b/src/iw5/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/xsk/assembler.cpp b/src/iw5/xsk/assembler.cpp index 4e0add41..6d3a23e1 100644 --- a/src/iw5/xsk/assembler.cpp +++ b/src/iw5/xsk/assembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/xsk/assembler.hpp b/src/iw5/xsk/assembler.hpp index b39b5b78..e0489d6f 100644 --- a/src/iw5/xsk/assembler.hpp +++ b/src/iw5/xsk/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/xsk/compiler.cpp b/src/iw5/xsk/compiler.cpp index 8b32b6e8..83b717ae 100644 --- a/src/iw5/xsk/compiler.cpp +++ b/src/iw5/xsk/compiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,7 +19,6 @@ auto compiler::output() -> std::vector void compiler::compile(const std::string& file, std::vector& data) { filename_ = file; - sources_.clear(); auto prog = parse_buffer(filename_, data); @@ -33,39 +32,19 @@ void compiler::read_callback(std::function(const std:: auto compiler::parse_buffer(const std::string& file, std::vector& data) -> ast::program::ptr { - yyscan_t scanner; - context ctx; ast::program::ptr result(nullptr); - ctx.header_top = 0; - ctx.mode = mode_; - ctx.read_callback = read_callback_; - ctx.sources = &sources_; - ctx.loc.initialize(&file); + resolver::set_reader(read_callback_); - // Add the two NULL terminators, required by flex. - data.push_back(0); - data.push_back(0); + lexer lexer(file, reinterpret_cast(data.data()), data.size()); - if (iw5_lex_init(&scanner)) - { - throw comp_error(ctx.loc, "An unknown error ocurred while starting lexer context."); - } - - ctx.scanner = scanner; - - YY_BUFFER_STATE yybuffer = iw5__scan_buffer(reinterpret_cast(data.data()), data.size(), scanner); - - parser parser(scanner, &ctx, result); + parser parser(lexer, result); if (parser.parse() || result == nullptr) { - throw comp_error(ctx.loc, "An unknown error ocurred while parsing gsc file."); + throw comp_error(xsk::gsc::location(&file), "An unknown error ocurred while parsing gsc file."); } - iw5__delete_buffer(yybuffer, scanner); - iw5_lex_destroy(scanner); - return result; } diff --git a/src/iw5/xsk/compiler.hpp b/src/iw5/xsk/compiler.hpp index bd85f6d5..bec2244f 100644 --- a/src/iw5/xsk/compiler.hpp +++ b/src/iw5/xsk/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -25,7 +25,6 @@ class compiler : public gsc::compiler std::vector animtrees_; std::unordered_map constants_; std::function(const std::string&)> read_callback_; - std::vector sources_; std::vector break_blks_; std::vector continue_blks_; bool can_break_; diff --git a/src/iw5/xsk/decompiler.cpp b/src/iw5/xsk/decompiler.cpp index 86b3818c..336856ac 100644 --- a/src/iw5/xsk/decompiler.cpp +++ b/src/iw5/xsk/decompiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/xsk/decompiler.hpp b/src/iw5/xsk/decompiler.hpp index 3bc72e9b..7e56762c 100644 --- a/src/iw5/xsk/decompiler.hpp +++ b/src/iw5/xsk/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/xsk/disassembler.cpp b/src/iw5/xsk/disassembler.cpp index 3d73fb6d..55f06c66 100644 --- a/src/iw5/xsk/disassembler.cpp +++ b/src/iw5/xsk/disassembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/xsk/disassembler.hpp b/src/iw5/xsk/disassembler.hpp index 07211652..6ea4f864 100644 --- a/src/iw5/xsk/disassembler.hpp +++ b/src/iw5/xsk/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/xsk/iw5.cpp b/src/iw5/xsk/iw5.cpp index 5ccb5512..9f07cbf4 100644 --- a/src/iw5/xsk/iw5.cpp +++ b/src/iw5/xsk/iw5.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/xsk/iw5.hpp b/src/iw5/xsk/iw5.hpp index 7e38a311..84d94ef9 100644 --- a/src/iw5/xsk/iw5.hpp +++ b/src/iw5/xsk/iw5.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw5/xsk/lexer.cpp b/src/iw5/xsk/lexer.cpp index d2b3be3c..05e1d0af 100644 --- a/src/iw5/xsk/lexer.cpp +++ b/src/iw5/xsk/lexer.cpp @@ -1,3030 +1,986 @@ -#line 1 "lexer.cpp" -#include "stdafx.hpp" -#include "iw5.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw5_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw5_pop_header(xsk::gsc::context* ctx); - -#line 9 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define iw5__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer iw5__create_buffer -#endif - -#ifdef yy_delete_buffer -#define iw5__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer iw5__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define iw5__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer iw5__scan_buffer -#endif - -#ifdef yy_scan_string -#define iw5__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string iw5__scan_string -#endif - -#ifdef yy_scan_bytes -#define iw5__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes iw5__scan_bytes -#endif - -#ifdef yy_init_buffer -#define iw5__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer iw5__init_buffer -#endif - -#ifdef yy_flush_buffer -#define iw5__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer iw5__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define iw5__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state iw5__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define iw5__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer iw5__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define iw5_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state iw5_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define iw5_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state iw5_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define iw5_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack iw5_ensure_buffer_stack -#endif - -#ifdef yylex -#define iw5_lex_ALREADY_DEFINED -#else -#define yylex iw5_lex -#endif - -#ifdef yyrestart -#define iw5_restart_ALREADY_DEFINED -#else -#define yyrestart iw5_restart -#endif - -#ifdef yylex_init -#define iw5_lex_init_ALREADY_DEFINED -#else -#define yylex_init iw5_lex_init -#endif - -#ifdef yylex_init_extra -#define iw5_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra iw5_lex_init_extra -#endif - -#ifdef yylex_destroy -#define iw5_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy iw5_lex_destroy -#endif - -#ifdef yyget_debug -#define iw5_get_debug_ALREADY_DEFINED -#else -#define yyget_debug iw5_get_debug -#endif - -#ifdef yyset_debug -#define iw5_set_debug_ALREADY_DEFINED -#else -#define yyset_debug iw5_set_debug -#endif - -#ifdef yyget_extra -#define iw5_get_extra_ALREADY_DEFINED -#else -#define yyget_extra iw5_get_extra -#endif - -#ifdef yyset_extra -#define iw5_set_extra_ALREADY_DEFINED -#else -#define yyset_extra iw5_set_extra -#endif - -#ifdef yyget_in -#define iw5_get_in_ALREADY_DEFINED -#else -#define yyget_in iw5_get_in -#endif - -#ifdef yyset_in -#define iw5_set_in_ALREADY_DEFINED -#else -#define yyset_in iw5_set_in -#endif - -#ifdef yyget_out -#define iw5_get_out_ALREADY_DEFINED -#else -#define yyget_out iw5_get_out -#endif - -#ifdef yyset_out -#define iw5_set_out_ALREADY_DEFINED -#else -#define yyset_out iw5_set_out -#endif - -#ifdef yyget_leng -#define iw5_get_leng_ALREADY_DEFINED -#else -#define yyget_leng iw5_get_leng -#endif - -#ifdef yyget_text -#define iw5_get_text_ALREADY_DEFINED -#else -#define yyget_text iw5_get_text -#endif - -#ifdef yyget_lineno -#define iw5_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno iw5_get_lineno -#endif - -#ifdef yyset_lineno -#define iw5_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno iw5_set_lineno -#endif - -#ifdef yyget_column -#define iw5_get_column_ALREADY_DEFINED -#else -#define yyget_column iw5_get_column -#endif - -#ifdef yyset_column -#define iw5_set_column_ALREADY_DEFINED -#else -#define yyset_column iw5_set_column -#endif - -#ifdef yywrap -#define iw5_wrap_ALREADY_DEFINED -#else -#define yywrap iw5_wrap -#endif - -#ifdef yyalloc -#define iw5_alloc_ALREADY_DEFINED -#else -#define yyalloc iw5_alloc -#endif - -#ifdef yyrealloc -#define iw5_realloc_ALREADY_DEFINED -#else -#define yyrealloc iw5_realloc -#endif - -#ifdef yyfree -#define iw5_free_ALREADY_DEFINED -#else -#define yyfree iw5_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin , yyscanner ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define iw5_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); -static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 111 -#define YY_END_OF_BUFFER 112 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[328] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 112, 110, - 1, 2, 94, 110, 110, 93, 97, 110, 54, 55, - 91, 89, 60, 90, 61, 92, 109, 109, 63, 64, - 78, 88, 79, 65, 100, 58, 59, 98, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, - 100, 100, 100, 100, 56, 96, 57, 95, 5, 6, - 5, 12, 13, 12, 110, 91, 92, 75, 0, 102, - 0, 15, 0, 0, 0, 0, 84, 0, 73, 0, - 86, 0, 0, 8, 82, 66, 80, 67, 81, 105, - 0, 11, 4, 3, 83, 105, 109, 106, 0, 0, - - 0, 0, 62, 70, 76, 74, 77, 71, 100, 87, - 100, 100, 100, 100, 100, 100, 28, 100, 100, 100, - 100, 100, 26, 32, 100, 100, 100, 100, 100, 100, - 100, 100, 100, 100, 100, 85, 72, 7, 14, 10, - 9, 0, 102, 0, 0, 0, 0, 0, 0, 101, - 0, 0, 0, 0, 102, 0, 105, 0, 3, 105, - 105, 106, 107, 108, 99, 68, 69, 100, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 30, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, - 100, 103, 0, 0, 0, 0, 0, 101, 0, 0, - - 101, 0, 0, 52, 100, 45, 34, 100, 100, 100, - 27, 100, 100, 100, 50, 100, 100, 100, 100, 51, - 100, 100, 100, 46, 100, 22, 100, 0, 0, 0, - 0, 0, 49, 36, 100, 100, 100, 20, 47, 100, - 53, 100, 100, 100, 100, 100, 100, 100, 100, 29, - 0, 0, 0, 0, 0, 100, 100, 100, 100, 100, - 21, 100, 100, 38, 33, 100, 42, 100, 100, 104, - 0, 0, 16, 0, 100, 100, 100, 35, 31, 100, - 100, 100, 100, 100, 0, 17, 0, 100, 100, 37, - 100, 41, 100, 100, 23, 19, 0, 100, 100, 100, - - 100, 48, 100, 100, 0, 39, 100, 40, 44, 100, - 100, 0, 43, 100, 100, 0, 100, 100, 0, 100, - 24, 0, 100, 18, 100, 25, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, - 25, 26, 27, 1, 28, 29, 28, 28, 28, 28, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 31, 30, 30, - 32, 33, 34, 35, 36, 1, 37, 38, 39, 40, - - 41, 42, 43, 44, 45, 30, 46, 47, 48, 49, - 50, 51, 30, 52, 53, 54, 55, 56, 57, 31, - 58, 59, 60, 61, 62, 63, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[64] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 5, 5, 5, - 5, 1, 1, 1, 1, 1, 1, 5, 5, 6, - 6, 1, 7, 1, 1, 6, 5, 5, 5, 5, - 5, 5, 6, 6, 8, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 8, 6, 6, 6, 6, 1, - 1, 1, 1 - } ; - -static const flex_int16_t yy_base[348] = - { 0, - 0, 0, 61, 62, 63, 64, 65, 66, 702, 703, - 703, 703, 676, 63, 58, 675, 76, 67, 703, 703, - 62, 67, 703, 73, 86, 85, 96, 102, 677, 703, - 65, 673, 68, 703, 664, 703, 703, 671, 75, 76, - 93, 99, 98, 105, 111, 108, 78, 103, 100, 113, - 118, 125, 123, 127, 703, 136, 703, 703, 703, 703, - 678, 703, 703, 677, 145, 668, 161, 703, 158, 703, - 163, 703, 0, 643, 642, 637, 703, 160, 703, 161, - 703, 165, 176, 703, 703, 703, 703, 703, 703, 183, - 644, 703, 703, 0, 703, 187, 194, 200, 195, 216, - - 234, 0, 703, 663, 703, 703, 703, 662, 653, 703, - 143, 148, 184, 147, 150, 197, 652, 189, 203, 191, - 193, 208, 651, 650, 190, 207, 214, 211, 233, 215, - 225, 224, 245, 236, 249, 703, 703, 703, 703, 703, - 703, 254, 263, 281, 0, 637, 148, 636, 278, 703, - 285, 280, 288, 283, 284, 292, 703, 621, 0, 284, - 703, 311, 290, 0, 646, 703, 703, 267, 287, 265, - 266, 286, 289, 301, 295, 302, 304, 306, 307, 308, - 309, 313, 312, 317, 318, 320, 323, 325, 327, 328, - 329, 0, 630, 630, 631, 626, 358, 360, 366, 361, - - 365, 372, 633, 640, 53, 639, 638, 344, 345, 346, - 637, 347, 354, 352, 636, 350, 367, 370, 355, 635, - 353, 369, 371, 634, 377, 378, 379, 0, 612, 610, - 615, 620, 703, 380, 381, 384, 382, 629, 628, 383, - 627, 385, 401, 388, 392, 394, 407, 408, 411, 626, - 0, 606, 617, 615, 619, 395, 413, 393, 397, 416, - 621, 417, 419, 620, 619, 421, 618, 422, 428, 703, - 609, 608, 703, 611, 429, 426, 431, 614, 613, 433, - 430, 436, 446, 434, 604, 703, 595, 447, 449, 610, - 450, 609, 451, 452, 456, 703, 596, 432, 460, 458, - - 461, 607, 466, 469, 591, 588, 470, 579, 537, 472, - 467, 505, 525, 475, 478, 478, 479, 480, 488, 481, - 495, 486, 482, 703, 486, 492, 703, 531, 539, 547, - 552, 560, 566, 570, 578, 511, 586, 594, 602, 610, - 614, 419, 622, 630, 305, 246, 179 - } ; - -static const flex_int16_t yy_def[348] = - { 0, - 327, 1, 328, 328, 329, 329, 1, 1, 327, 327, - 327, 327, 327, 330, 331, 327, 327, 332, 327, 327, - 327, 327, 327, 327, 327, 327, 333, 333, 327, 327, - 327, 327, 327, 327, 334, 327, 327, 327, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 331, 327, 327, 327, 330, 327, - 335, 327, 336, 336, 327, 327, 327, 337, 327, 338, - 327, 332, 339, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 340, 327, 327, 333, 333, 333, 333, - - 333, 341, 327, 327, 327, 327, 327, 327, 334, 327, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 327, 327, 327, 327, 327, - 327, 330, 330, 335, 342, 327, 327, 327, 337, 327, - 343, 338, 344, 332, 332, 339, 327, 327, 340, 327, - 327, 333, 333, 101, 341, 327, 327, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 345, 327, 327, 327, 327, 337, 337, 343, 338, - - 338, 344, 327, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 346, 327, 327, - 327, 327, 327, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 347, 327, 327, 327, 327, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 327, - 327, 327, 327, 327, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 327, 327, 327, 334, 334, 334, - 334, 334, 334, 334, 334, 327, 327, 334, 334, 334, - - 334, 334, 334, 334, 327, 334, 334, 334, 334, 334, - 334, 327, 334, 334, 334, 327, 334, 334, 327, 334, - 334, 327, 334, 327, 334, 334, 0, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327 - } ; - -static const flex_int16_t yy_nxt[767] = - { 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, - 28, 29, 30, 31, 32, 33, 34, 35, 35, 35, - 35, 36, 10, 37, 38, 35, 39, 40, 41, 42, - 43, 44, 45, 35, 46, 35, 47, 35, 48, 35, - 49, 50, 51, 52, 53, 35, 54, 35, 35, 55, - 56, 57, 58, 60, 60, 63, 63, 70, 64, 64, - 65, 65, 61, 61, 72, 70, 66, 66, 84, 86, - 78, 67, 67, 79, 80, 102, 85, 88, 104, 105, - 92, 87, 107, 108, 74, 71, 93, 89, 234, 83, - - 81, 94, 75, 90, 90, 90, 90, 102, 102, 95, - 102, 96, 76, 97, 98, 98, 97, 96, 125, 97, - 97, 97, 97, 111, 100, 102, 101, 112, 102, 113, - 102, 102, 102, 100, 102, 102, 114, 102, 91, 116, - 102, 120, 115, 102, 118, 102, 119, 122, 117, 123, - 102, 127, 126, 128, 121, 102, 124, 102, 129, 102, - 136, 140, 70, 134, 150, 69, 141, 143, 131, 150, - 135, 133, 93, 70, 130, 102, 132, 94, 82, 102, - 102, 74, 102, 270, 155, 95, 194, 168, 169, 75, - 71, 172, 151, 153, 195, 144, 137, 83, 173, 76, - - 90, 90, 90, 90, 160, 160, 160, 160, 156, 96, - 327, 97, 97, 97, 97, 96, 102, 162, 162, 162, - 97, 102, 102, 102, 157, 102, 102, 102, 161, 102, - 170, 327, 102, 163, 163, 102, 171, 177, 174, 102, - 102, 175, 176, 102, 178, 180, 102, 102, 102, 327, - 251, 164, 164, 164, 164, 179, 102, 102, 70, 185, - 181, 164, 164, 182, 183, 102, 102, 70, 102, 186, - 164, 164, 164, 164, 164, 164, 187, 102, 188, 184, - 190, 102, 150, 69, 189, 143, 71, 149, 150, 198, - 152, 70, 70, 191, 82, 71, 201, 102, 102, 102, - - 155, 160, 160, 160, 160, 327, 207, 163, 163, 228, - 151, 206, 153, 144, 204, 83, 83, 199, 102, 102, - 202, 102, 102, 205, 156, 161, 96, 102, 162, 162, - 162, 97, 208, 102, 102, 211, 102, 210, 102, 102, - 102, 102, 209, 102, 102, 102, 214, 215, 216, 102, - 102, 212, 102, 217, 218, 102, 213, 102, 220, 102, - 102, 102, 150, 223, 150, 224, 219, 225, 149, 150, - 198, 221, 222, 150, 152, 227, 102, 102, 102, 102, - 201, 226, 102, 235, 102, 102, 102, 102, 240, 236, - 151, 245, 151, 153, 239, 238, 241, 153, 199, 102, - - 237, 102, 102, 102, 202, 243, 244, 247, 242, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 248, 250, - 102, 260, 246, 192, 102, 102, 102, 102, 259, 102, - 256, 249, 258, 102, 257, 265, 264, 266, 262, 102, - 102, 263, 261, 102, 275, 102, 267, 277, 102, 102, - 278, 102, 268, 102, 102, 269, 276, 280, 102, 279, - 102, 102, 102, 102, 102, 102, 102, 281, 102, 292, - 283, 290, 282, 288, 284, 291, 293, 289, 102, 102, - 295, 102, 102, 102, 102, 306, 294, 301, 102, 299, - 102, 302, 102, 102, 300, 298, 307, 303, 102, 102, - - 309, 102, 102, 304, 102, 311, 308, 102, 314, 313, - 102, 102, 102, 102, 102, 145, 318, 310, 102, 320, - 315, 323, 317, 321, 102, 326, 324, 102, 322, 319, - 325, 59, 59, 59, 59, 59, 59, 59, 59, 62, - 62, 62, 62, 62, 62, 62, 62, 69, 69, 69, - 69, 69, 69, 69, 69, 73, 73, 102, 316, 73, - 82, 82, 82, 82, 82, 82, 82, 82, 99, 102, - 99, 99, 99, 99, 109, 109, 109, 109, 142, 142, - 142, 142, 142, 142, 142, 142, 149, 149, 149, 149, - 149, 149, 149, 149, 152, 152, 152, 152, 152, 152, - - 152, 152, 154, 154, 154, 154, 154, 154, 154, 154, - 159, 102, 159, 159, 159, 159, 159, 159, 165, 165, - 102, 165, 197, 197, 197, 197, 197, 197, 197, 197, - 200, 200, 200, 200, 200, 200, 200, 200, 312, 102, - 305, 102, 102, 297, 296, 102, 102, 287, 286, 285, - 102, 102, 102, 102, 274, 273, 272, 271, 102, 102, - 102, 102, 255, 254, 253, 252, 102, 102, 102, 102, - 102, 102, 102, 233, 232, 231, 230, 229, 102, 203, - 196, 193, 102, 102, 102, 102, 167, 166, 158, 148, - 147, 146, 85, 139, 138, 110, 102, 106, 103, 77, - - 68, 327, 9, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327 - } ; - -static const flex_int16_t yy_chk[767] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 5, 6, 14, 5, 6, - 7, 8, 3, 4, 15, 18, 7, 8, 21, 22, - 17, 7, 8, 17, 17, 205, 21, 24, 31, 31, - 26, 22, 33, 33, 15, 14, 26, 24, 205, 18, - - 17, 26, 15, 25, 25, 25, 25, 39, 40, 26, - 47, 27, 15, 27, 27, 27, 27, 28, 47, 28, - 28, 28, 28, 39, 27, 41, 27, 40, 27, 41, - 43, 42, 49, 27, 28, 48, 41, 44, 25, 42, - 46, 44, 41, 45, 43, 50, 43, 45, 42, 46, - 51, 49, 48, 50, 44, 53, 46, 52, 51, 54, - 56, 65, 69, 54, 78, 71, 67, 71, 52, 80, - 54, 53, 67, 82, 51, 111, 52, 67, 83, 114, - 112, 65, 115, 347, 83, 67, 147, 111, 112, 65, - 69, 114, 78, 80, 147, 71, 56, 82, 115, 65, - - 90, 90, 90, 90, 96, 96, 96, 96, 83, 97, - 99, 97, 97, 97, 97, 98, 113, 98, 98, 98, - 98, 118, 125, 120, 90, 121, 97, 99, 96, 116, - 113, 100, 98, 100, 100, 119, 113, 120, 116, 126, - 122, 118, 119, 128, 121, 125, 127, 130, 100, 101, - 346, 101, 101, 101, 101, 122, 132, 131, 142, 130, - 126, 101, 101, 127, 128, 129, 101, 143, 134, 131, - 101, 101, 101, 101, 101, 101, 131, 133, 132, 129, - 134, 135, 149, 144, 133, 144, 142, 151, 152, 151, - 153, 154, 155, 135, 156, 143, 153, 170, 171, 168, - - 156, 160, 160, 160, 160, 163, 171, 163, 163, 345, - 149, 170, 152, 144, 168, 154, 155, 151, 172, 169, - 153, 173, 163, 169, 156, 160, 162, 175, 162, 162, - 162, 162, 172, 174, 176, 175, 177, 174, 178, 179, - 180, 181, 173, 162, 183, 182, 178, 179, 180, 184, - 185, 176, 186, 181, 182, 187, 177, 188, 184, 189, - 190, 191, 197, 187, 198, 188, 183, 189, 199, 200, - 199, 185, 186, 201, 202, 191, 208, 209, 210, 212, - 202, 190, 216, 208, 214, 221, 213, 219, 214, 209, - 197, 221, 198, 200, 213, 212, 216, 201, 199, 217, - - 210, 222, 218, 223, 202, 218, 219, 223, 217, 225, - 226, 227, 234, 235, 237, 240, 236, 242, 225, 227, - 244, 240, 222, 342, 245, 258, 246, 256, 237, 259, - 234, 226, 236, 243, 235, 245, 244, 246, 243, 247, - 248, 243, 242, 249, 256, 257, 247, 258, 260, 262, - 259, 263, 248, 266, 268, 249, 257, 262, 276, 260, - 269, 275, 281, 277, 298, 280, 284, 263, 282, 281, - 268, 277, 266, 275, 269, 280, 282, 276, 283, 288, - 284, 289, 291, 293, 294, 298, 283, 293, 295, 289, - 300, 294, 299, 301, 291, 288, 299, 295, 303, 311, - - 301, 304, 307, 295, 310, 304, 300, 314, 310, 307, - 315, 317, 318, 320, 323, 336, 315, 303, 325, 317, - 311, 320, 314, 318, 326, 325, 322, 321, 319, 316, - 323, 328, 328, 328, 328, 328, 328, 328, 328, 329, - 329, 329, 329, 329, 329, 329, 329, 330, 330, 330, - 330, 330, 330, 330, 330, 331, 331, 313, 312, 331, - 332, 332, 332, 332, 332, 332, 332, 332, 333, 309, - 333, 333, 333, 333, 334, 334, 334, 334, 335, 335, - 335, 335, 335, 335, 335, 335, 337, 337, 337, 337, - 337, 337, 337, 337, 338, 338, 338, 338, 338, 338, - - 338, 338, 339, 339, 339, 339, 339, 339, 339, 339, - 340, 308, 340, 340, 340, 340, 340, 340, 341, 341, - 306, 341, 343, 343, 343, 343, 343, 343, 343, 343, - 344, 344, 344, 344, 344, 344, 344, 344, 305, 302, - 297, 292, 290, 287, 285, 279, 278, 274, 272, 271, - 267, 265, 264, 261, 255, 254, 253, 252, 250, 241, - 239, 238, 232, 231, 230, 229, 224, 220, 215, 211, - 207, 206, 204, 203, 196, 195, 194, 193, 165, 158, - 148, 146, 124, 123, 117, 109, 108, 104, 91, 76, - 75, 74, 66, 64, 61, 38, 35, 32, 29, 16, - - 13, 9, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.lpp" -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ -#define YY_NO_INPUT 1 -#define YY_NO_UNISTD_H 1 - -#line 25 "lexer.lpp" -#define YY_USER_ACTION ctx->loc.columns(yyleng); -#line 928 "lexer.cpp" - -#line 930 "lexer.cpp" - -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#include "stdafx.hpp" +#include "iw5.hpp" +#include "parser.hpp" +#include "lexer.hpp" + +xsk::gsc::iw5::parser::symbol_type IW5lex(xsk::gsc::iw5::lexer& lexer) +{ + return lexer.lex(); +} + +namespace xsk::gsc::iw5 +{ + +enum class keyword +{ +/* KW_pre_define, + KW_pre_undef, + KW_pre_ifdef, + KW_pre_ifndef, + KW_pre_if, + KW_pre_elif, + KW_pre_else, + KW_pre_endif,*/ + KW_pre_inline, + KW_pre_include, + KW_pre_using_animtree, + KW_pre_animtree, + KW_endon, + KW_notify, + KW_wait, + KW_waittill, + KW_waittillmatch, + KW_waittillframeend, + KW_if, + KW_else, + KW_do, + KW_while, + KW_for, + KW_foreach, + KW_in, + KW_switch, + KW_case, + KW_default, + KW_break, + KW_continue, + KW_return, + KW_breakpoint, + KW_prof_begin, + KW_prof_end, + KW_thread, + KW_childthread, + KW_thisthread, + KW_call, + KW_true, + KW_false, + KW_undefined, + KW_dotsize, + KW_game, + KW_self, + KW_anim, + KW_level, + KW_INVALID, +}; + +buffer::buffer() : size(1024), length(0) +{ + data = static_cast(std::malloc(size)); +} + +buffer::~buffer() +{ + if(data) std::free(data); +} + +bool buffer::push(char c) +{ + if(length >= size) { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals ( yyscan_t yyscanner ); - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef YY_NO_UNPUT - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( yyscan_t yyscanner ); -#else -static int input ( yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_load_buffer_state( yyscanner ); - } - - { -#line 44 "lexer.lpp" - - - -#line 48 "lexer.lpp" - ctx->loc.step(); - - -#line 1199 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 328 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 327 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 51 "lexer.lpp" -{ ctx->loc.step(); } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 52 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 54 "lexer.lpp" - - YY_BREAK -case 4: -YY_RULE_SETUP -#line 56 "lexer.lpp" -{ BEGIN(COMMENT_STATE); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 57 "lexer.lpp" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 58 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(COMMENT_STATE): -#line 60 "lexer.lpp" -{ throw iw5::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "lexer.lpp" -{ throw iw5::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 63 "lexer.lpp" -{ throw iw5::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 64 "lexer.lpp" -{ BEGIN(INITIAL); return iw5::parser::make_DEVEND(ctx->loc); } - YY_BREAK -case YY_STATE_EOF(DEV_ON_STATE): -#line 65 "lexer.lpp" -{ throw iw5::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 67 "lexer.lpp" -{ BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return iw5::parser::make_DEVBEGIN(ctx->loc); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 68 "lexer.lpp" - - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 69 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 70 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(DEV_OFF_STATE): -#line 71 "lexer.lpp" -{ throw iw5::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.lpp" -{ throw iw5::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 74 "lexer.lpp" -{ return iw5::parser::make_INLINE(ctx->loc); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 75 "lexer.lpp" -{ return iw5::parser::make_INCLUDE(ctx->loc); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 76 "lexer.lpp" -{ return iw5::parser::make_USINGTREE(ctx->loc); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 77 "lexer.lpp" -{ return iw5::parser::make_ANIMTREE(ctx->loc); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 78 "lexer.lpp" -{ return iw5::parser::make_ENDON(ctx->loc); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 79 "lexer.lpp" -{ return iw5::parser::make_NOTIFY(ctx->loc); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 80 "lexer.lpp" -{ return iw5::parser::make_WAIT(ctx->loc); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 81 "lexer.lpp" -{ return iw5::parser::make_WAITTILL(ctx->loc); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 82 "lexer.lpp" -{ return iw5::parser::make_WAITTILLMATCH(ctx->loc); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 83 "lexer.lpp" -{ return iw5::parser::make_WAITTILLFRAMEEND(ctx->loc); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 84 "lexer.lpp" -{ return iw5::parser::make_IF(ctx->loc); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 85 "lexer.lpp" -{ return iw5::parser::make_ELSE(ctx->loc); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 86 "lexer.lpp" -{ return iw5::parser::make_DO(ctx->loc); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 87 "lexer.lpp" -{ return iw5::parser::make_WHILE(ctx->loc); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 88 "lexer.lpp" -{ return iw5::parser::make_FOR(ctx->loc); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 89 "lexer.lpp" -{ return iw5::parser::make_FOREACH(ctx->loc); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 90 "lexer.lpp" -{ return iw5::parser::make_IN(ctx->loc); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 91 "lexer.lpp" -{ return iw5::parser::make_SWITCH(ctx->loc); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 92 "lexer.lpp" -{ return iw5::parser::make_CASE(ctx->loc); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 93 "lexer.lpp" -{ return iw5::parser::make_DEFAULT(ctx->loc); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 94 "lexer.lpp" -{ return iw5::parser::make_BREAK(ctx->loc); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 95 "lexer.lpp" -{ return iw5::parser::make_CONTINUE(ctx->loc); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 96 "lexer.lpp" -{ return iw5::parser::make_RETURN(ctx->loc); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 97 "lexer.lpp" -{ return iw5::parser::make_BREAKPOINT(ctx->loc); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 98 "lexer.lpp" -{ return iw5::parser::make_PROFBEGIN(ctx->loc); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 99 "lexer.lpp" -{ return iw5::parser::make_PROFEND(ctx->loc); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 100 "lexer.lpp" -{ return iw5::parser::make_THREAD(ctx->loc); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 101 "lexer.lpp" -{ return iw5::parser::make_CHILDTHREAD(ctx->loc); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 102 "lexer.lpp" -{ return iw5::parser::make_THISTHREAD(ctx->loc); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 103 "lexer.lpp" -{ return iw5::parser::make_CALL(ctx->loc); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 104 "lexer.lpp" -{ return iw5::parser::make_TRUE(ctx->loc); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 105 "lexer.lpp" -{ return iw5::parser::make_FALSE(ctx->loc); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 106 "lexer.lpp" -{ return iw5::parser::make_UNDEFINED(ctx->loc); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 107 "lexer.lpp" -{ return iw5::parser::make_SIZE(ctx->loc); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 108 "lexer.lpp" -{ return iw5::parser::make_GAME(ctx->loc); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 109 "lexer.lpp" -{ return iw5::parser::make_SELF(ctx->loc); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 110 "lexer.lpp" -{ return iw5::parser::make_ANIM(ctx->loc); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 111 "lexer.lpp" -{ return iw5::parser::make_LEVEL(ctx->loc); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 112 "lexer.lpp" -{ return iw5::parser::make_LPAREN(ctx->loc); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 113 "lexer.lpp" -{ return iw5::parser::make_RPAREN(ctx->loc); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 114 "lexer.lpp" -{ return iw5::parser::make_LBRACE(ctx->loc); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 115 "lexer.lpp" -{ return iw5::parser::make_RBRACE(ctx->loc); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 116 "lexer.lpp" -{ return iw5::parser::make_LBRACKET(ctx->loc); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 117 "lexer.lpp" -{ return iw5::parser::make_RBRACKET(ctx->loc); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 118 "lexer.lpp" -{ return iw5::parser::make_COMMA(ctx->loc); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 119 "lexer.lpp" -{ return iw5::parser::make_DOT(ctx->loc); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 120 "lexer.lpp" -{ return iw5::parser::make_DOUBLECOLON(ctx->loc); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 121 "lexer.lpp" -{ return iw5::parser::make_COLON(ctx->loc); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 122 "lexer.lpp" -{ return iw5::parser::make_SEMICOLON(ctx->loc); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 123 "lexer.lpp" -{ return iw5::parser::make_QMARK(ctx->loc); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 124 "lexer.lpp" -{ return iw5::parser::make_INCREMENT(ctx->loc); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 125 "lexer.lpp" -{ return iw5::parser::make_DECREMENT(ctx->loc); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 126 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_LSHIFT(ctx->loc); } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 127 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_RSHIFT(ctx->loc); } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 128 "lexer.lpp" -{ return iw5::parser::make_LSHIFT(ctx->loc); } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 129 "lexer.lpp" -{ return iw5::parser::make_RSHIFT(ctx->loc); } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 130 "lexer.lpp" -{ return iw5::parser::make_OR(ctx->loc); } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 131 "lexer.lpp" -{ return iw5::parser::make_AND(ctx->loc); } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 132 "lexer.lpp" -{ return iw5::parser::make_EQUALITY(ctx->loc); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 133 "lexer.lpp" -{ return iw5::parser::make_INEQUALITY(ctx->loc); } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 134 "lexer.lpp" -{ return iw5::parser::make_LESS_EQUAL(ctx->loc); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 135 "lexer.lpp" -{ return iw5::parser::make_GREATER_EQUAL(ctx->loc); } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 136 "lexer.lpp" -{ return iw5::parser::make_LESS(ctx->loc); } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 137 "lexer.lpp" -{ return iw5::parser::make_GREATER(ctx->loc); } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 138 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_ADD(ctx->loc); } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 139 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_SUB(ctx->loc); } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 140 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_MUL(ctx->loc); } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 141 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_DIV(ctx->loc); } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 142 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_MOD(ctx->loc); } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 143 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_BW_OR(ctx->loc); } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 144 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_BW_AND(ctx->loc); } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 145 "lexer.lpp" -{ return iw5::parser::make_ASSIGN_BW_EXOR(ctx->loc); } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 146 "lexer.lpp" -{ return iw5::parser::make_ASSIGN(ctx->loc); } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 147 "lexer.lpp" -{ return iw5::parser::make_ADD(ctx->loc); } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 148 "lexer.lpp" -{ return iw5::parser::make_SUB(ctx->loc); } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 149 "lexer.lpp" -{ return iw5::parser::make_MUL(ctx->loc); } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 150 "lexer.lpp" -{ return iw5::parser::make_DIV(ctx->loc); } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 151 "lexer.lpp" -{ return iw5::parser::make_MOD(ctx->loc); } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 152 "lexer.lpp" -{ return iw5::parser::make_NOT(ctx->loc); } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 153 "lexer.lpp" -{ return iw5::parser::make_COMPLEMENT(ctx->loc); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 154 "lexer.lpp" -{ return iw5::parser::make_BITWISE_OR(ctx->loc); } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 155 "lexer.lpp" -{ return iw5::parser::make_BITWISE_AND(ctx->loc); } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 156 "lexer.lpp" -{ return iw5::parser::make_BITWISE_EXOR(ctx->loc); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 157 "lexer.lpp" -{ return iw5::parser::make_PATH(xsk::gsc::iw5::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 158 "lexer.lpp" -{ return iw5::parser::make_IDENTIFIER(xsk::gsc::iw5::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 101: -/* rule 101 can match eol */ -YY_RULE_SETUP -#line 159 "lexer.lpp" -{ return iw5::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 102: -/* rule 102 can match eol */ -YY_RULE_SETUP -#line 160 "lexer.lpp" -{ return iw5::parser::make_STRING(std::string(yytext), ctx->loc); } - YY_BREAK -case 103: -YY_RULE_SETUP -#line 161 "lexer.lpp" -{ return iw5::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 104: -YY_RULE_SETUP -#line 162 "lexer.lpp" -{ return iw5::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 105: -YY_RULE_SETUP -#line 163 "lexer.lpp" -{ return iw5::parser::make_FLOAT(std::string(yytext), ctx->loc); } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 164 "lexer.lpp" -{ return iw5::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 165 "lexer.lpp" -{ return iw5::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 166 "lexer.lpp" -{ return iw5::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 167 "lexer.lpp" -{ return iw5::parser::make_INTEGER(std::string(yytext), ctx->loc); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 168 "lexer.lpp" -{ if(ctx->header_top > 0) iw5_pop_header(ctx); else return iw5::parser::make_IW5EOF(ctx->loc); } - YY_BREAK -case 110: -/* rule 110 can match eol */ -YY_RULE_SETUP -#line 169 "lexer.lpp" -{ throw iw5::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - YY_BREAK -case 111: -YY_RULE_SETUP -#line 171 "lexer.lpp" -ECHO; - YY_BREAK -#line 1829 "lexer.cpp" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap( yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin , yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + auto nsize = size * 2; + auto ndata = reinterpret_cast(std::malloc(nsize)); + + if(!ndata) return false; + + std::memmove(ndata, data, size); + std::free(data); + size = nsize; + data = ndata; + } + data[length++] = c; + return true; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 328 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; } -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +void reader::init(const char* data, size_t size) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 328 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 327); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + if(data && size) + { + state = reader::ok; + buffer_pos = data; + bytes_remaining = size; + last_byte = 0; + current_byte = *data; + } + else + { + state = reader::end; + buffer_pos = 0; + bytes_remaining = 0; + last_byte = 0; + current_byte = 0; + } } -#ifndef YY_NO_UNPUT - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - +void reader::advance() { - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + ++buffer_pos; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin , yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); - yy_load_buffer_state( yyscanner ); + if(bytes_remaining-- == 1) + { + state = reader::end; + bytes_remaining = 0; + last_byte = current_byte; + current_byte = 0; + } + else + { + last_byte = current_byte; + current_byte = *buffer_pos; + } } -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +lexer::lexer(const std::string& name, const char* data, size_t size) : in_dev_state_(false), loc_(xsk::gsc::location(&name)), + mode_(build::dev), header_top_(0), locs_(std::stack()), readers_(std::stack()) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + reader_.init(data, size); } -static void yy_load_buffer_state (yyscan_t yyscanner) +void lexer::push_header(const std::string& file) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + try + { + if (header_top_++ >= 10) + throw xsk::gsc::error("maximum gsh depth exceeded '10'"); + + auto data = resolver::file_data(file + ".gsh"); + + readers_.push(reader_); + locs_.push(loc_); + loc_.initialize(std::get<0>(data)); + reader_.init(std::get<1>(data), std::get<2>(data)); + } + catch (const std::exception& e) + { + throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); + } } -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +void lexer::pop_header() { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file , yyscanner); - - return b; + header_top_--; + loc_ = locs_.top(); + locs_.pop(); + reader_ = readers_.top(); + readers_.pop(); } -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void lexer::restrict_header(const xsk::gsc::location& loc) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf , yyscanner ); - - yyfree( (void *) b , yyscanner ); + if (header_top_ > 0) + { + throw comp_error(loc, "not allowed inside a gsh file"); + } } -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - +auto lexer::lex() -> xsk::gsc::iw5::parser::symbol_type { - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + buffer_.length = 0; + loc_.step(); - yy_flush_buffer( b , yyscanner); + while (true) + { + if (reader_.state == reader::end) + { + if (in_dev_state_) + throw iw5::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + if(header_top_ > 0) + pop_header(); + else + return iw5::parser::make_IW5EOF(loc_); + } - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + reader_.advance(); + auto& last = reader_.last_byte; + auto& curr = reader_.current_byte; + + switch (last) + { + case ' ': + case '\t': + case '\r': + loc_.step(); + continue; + case '\n': + loc_.lines(); + loc_.step(); + continue; + case '/': + if(reader_.state == reader::end || (curr != '/' && curr != '*' && curr != '#' && curr != '=')) + return iw5::parser::make_DIV(loc_); + + reader_.advance(); + + if (last == '=') + return iw5::parser::make_ASSIGN_DIV(loc_); + + if (last == '#') + { + if (in_dev_state_) + { + throw iw5::parser::syntax_error(loc_, "cannot recurse devblock ('/#')"); + } + else if (mode_ == xsk::gsc::build::dev) + { + in_dev_state_ = true; + return iw5::parser::make_DEVBEGIN(loc_); + } + else + { + while (true) + { + if (reader_.state == reader::end) + { + throw iw5::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '#' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + } + else if (last == '*') + { + while (true) + { + if (reader_.state == reader::end) + { + throw iw5::parser::syntax_error(loc_, "unmatched multiline comment start ('/*')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '*' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + else if (last == '/') + { + while (true) + { + if (reader_.state == reader::end || curr == '\n') + break; + + reader_.advance(); + } + } + continue; + case '#': + if (curr == '/') + { + if (!in_dev_state_) + throw iw5::parser::syntax_error(loc_, "unmatched devblock end ('#/')"); + + in_dev_state_ = false; + reader_.advance(); + return iw5::parser::make_DEVEND(loc_); + } + + buffer_.push(last); + while (reader_.state == reader::ok) + { + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + { + if (auto len = buffer_.length; len == 4 || len == 7) + { + auto data = buffer_.data; + auto color = true; + for (auto i = 1; i < len; i++) + { + if ((data[i] < 48 || data[i] > 57) && (data[i] < 65 || data[i] > 70) && (data[i] < 97 || data[i] > 102)) + { + color = false; + break; + } + } + + if (color) return iw5::parser::make_COLOR(std::string(++data, --len), loc_); + } + + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); + + if (key == keyword::KW_INVALID) + throw iw5::parser::syntax_error(loc_, utils::string::va("unknown preprocessor directive ('%s')", "#")); + + if (keyword_is_token(key)) + return keyword_token(key); + + // call preprocessor(key); + } + continue; + case '*': + if (reader_.state == reader::end || (curr != '/' && curr != '=')) + return iw5::parser::make_MUL(loc_); + + reader_.advance(); + + if (curr == '/') + throw iw5::parser::syntax_error(loc_, "unmatched multiline comment end ('*/')"); + + return iw5::parser::make_ASSIGN_MUL(loc_); + case '"': + case '\'': + return read_string(last, false); + case '.': + return read_dotsize(); + case '(': + return iw5::parser::make_LPAREN(loc_); + case ')': + return iw5::parser::make_RPAREN(loc_); + case '{': + return iw5::parser::make_LBRACE(loc_); + case '}': + return iw5::parser::make_RBRACE(loc_); + case '[': + return iw5::parser::make_LBRACKET(loc_); + case ']': + return iw5::parser::make_RBRACKET(loc_); + case ',': + return iw5::parser::make_COMMA(loc_); + case ';': + return iw5::parser::make_SEMICOLON(loc_); + case ':': + if (curr != ':') + return iw5::parser::make_COLON(loc_); + reader_.advance(); + return iw5::parser::make_DOUBLECOLON(loc_); + case '?': + return iw5::parser::make_QMARK(loc_); + case '=': + if (curr != '=') + return iw5::parser::make_ASSIGN(loc_); + reader_.advance(); + return iw5::parser::make_EQUALITY(loc_); + case '+': + if (curr != '+' && curr != '=') + return iw5::parser::make_ADD(loc_); + reader_.advance(); + return (last == '+') ? iw5::parser::make_INCREMENT(loc_) : iw5::parser::make_ASSIGN_ADD(loc_); + case '-': + if (curr != '-' && curr != '=') + return iw5::parser::make_SUB(loc_); + reader_.advance(); + return (last == '-') ? iw5::parser::make_DECREMENT(loc_) : iw5::parser::make_ASSIGN_SUB(loc_); + case '%': + if (curr != '=') + return iw5::parser::make_MOD(loc_); + reader_.advance(); + return iw5::parser::make_ASSIGN_MOD(loc_); + case '|': + if (curr != '|' && curr != '=') + return iw5::parser::make_BITWISE_OR(loc_); + reader_.advance(); + return (last == '|') ? iw5::parser::make_OR(loc_) : iw5::parser::make_ASSIGN_BW_OR(loc_); + case '&': + if (curr != '&' && curr != '=' && curr != '"' && curr != '\'') + return iw5::parser::make_BITWISE_AND(loc_); + reader_.advance(); + if (last == '"' || last == '\'') + return read_string(last, true); + return (last == '&') ? iw5::parser::make_AND(loc_) : iw5::parser::make_ASSIGN_BW_AND(loc_); + case '^': + if (curr != '=') + return iw5::parser::make_BITWISE_EXOR(loc_); + reader_.advance(); + return iw5::parser::make_ASSIGN_BW_EXOR(loc_); + case '!': + if (curr != '=') + return iw5::parser::make_NOT(loc_); + reader_.advance(); + return iw5::parser::make_INEQUALITY(loc_); + case '~': + return iw5::parser::make_COMPLEMENT(loc_); + case '<': + if (curr != '<' && curr != '=') + return iw5::parser::make_LESS(loc_); + reader_.advance(); + if (last == '<') + { + reader_.advance(); + return (last == '=') ? iw5::parser::make_ASSIGN_LSHIFT(loc_) : iw5::parser::make_LSHIFT(loc_); + } + return iw5::parser::make_LESS_EQUAL(loc_); + case '>': + if (curr != '>' && curr != '=') + return iw5::parser::make_GREATER(loc_); + reader_.advance(); + if (last == '>') + { + reader_.advance(); + return (last == '=') ? iw5::parser::make_ASSIGN_RSHIFT(loc_) : iw5::parser::make_RSHIFT(loc_); + } + return iw5::parser::make_GREATER_EQUAL(loc_); + default: + if (last >= '0' && last <= '9') + return lexer::read_number(last); + else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z') + return lexer::read_word(last); + + throw iw5::parser::syntax_error(loc_, utils::string::va("bad token: \'%c\'", last)); + } + } +} + +auto lexer::read_string(char quote, bool localize) -> xsk::gsc::iw5::parser::symbol_type +{ + if (localize) + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + reader_.advance(); + + if (last == '\n') + throw iw5::parser::syntax_error(loc_, "unterminated string"); + + if (last == '\\') // process scapes + { + // TODO: + } + + if (last != '\\' && curr == quote) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); } - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b , yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n , yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n , yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int _line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = _line_number; -} - -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column (int _column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = _column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int _bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = _bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (reader_.state == reader::end) + { + throw iw5::parser::syntax_error(loc_, utils::string::va("unmatched string start ('%s')", (quote == '"') ? "\"" : "\\'")); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + if (localize) + return iw5::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + return iw5::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_); +} + +auto lexer::read_number(char first) -> xsk::gsc::iw5::parser::symbol_type +{ + if (first == '.') + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = true; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw iw5::parser::syntax_error(loc_, "invalid number '.'"); + } + if (data[i] == 'f' && i != len - 1) + throw iw5::parser::syntax_error(loc_, "invalid number 'f'"); + } + + return iw5::parser::make_FLOAT(std::string(data, len), loc_); + } + else + { + auto curr = reader_.current_byte; + + if (first == '0' && curr == 'o') + { + buffer_.push(first); + buffer_.push('o'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'o')) + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'o' && last == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr > 47 && curr < 56)) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid octal literal!"); + + return iw5::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data + 2), loc_); + } + else if (first == '0' && curr == 'b') + { + buffer_.push(first); + buffer_.push('b'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'b')) + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'b' && last == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (curr != '0' && curr != '1') + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid binary literal!"); + + return iw5::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_); + } + else if (first == '0' && curr == 'x') + { + buffer_.push(first); + buffer_.push('x'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'x')) + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'x' && last == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!((curr > 47 && curr < 58) || (curr > 64 && curr < 71) || (curr > 96 && curr < 103))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid hexadecimal literal!"); + + return iw5::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_); + } + else + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw5::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = false; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw iw5::parser::syntax_error(loc_, "invalid number '.'"); + + dot = true; + } + if (data[i] == 'f' && i != len - 1) + throw iw5::parser::syntax_error(loc_, "invalid number 'f'"); + } + + if (dot || data[len - 1] == 'f') + return iw5::parser::make_FLOAT(std::string(data, len), loc_); + + return iw5::parser::make_INTEGER(std::string(data, len), loc_); + } + } +} + +auto lexer::read_word(char first) -> xsk::gsc::iw5::parser::symbol_type +{ + auto path = false; + + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto curr = reader_.current_byte; + + if (!(curr == '\\' || curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (curr == '\\') + { + if (reader_.last_byte == '\\') + throw iw5::parser::syntax_error(loc_, "invalid path '\\\\'"); + + path = true; + curr = '/'; + } + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); - return yy_init_globals ( *ptr_yy_globals ); -} + if (key != keyword::KW_INVALID) + return keyword_token(key); -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; + if (path) + { + if (buffer_.data[buffer_.length - 1] == '/') + throw iw5::parser::syntax_error(loc_, "invalid path end '\\'"); - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + return iw5::parser::make_PATH(xsk::gsc::iw5::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + return iw5::parser::make_IDENTIFIER(xsk::gsc::iw5::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); +} - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; +auto lexer::read_dotsize() -> xsk::gsc::iw5::parser::symbol_type +{ + auto curr = reader_.current_byte; + + if (curr > 47 && curr < 58) + { + return lexer::read_number('.'); + } + else if (curr == '_' || curr > 64 && curr < 91 || curr > 96 && curr < 123) + { + reader save; + save.state = reader_.state; + save.bytes_remaining = reader_.bytes_remaining; + save.buffer_pos = reader_.buffer_pos; + save.last_byte = reader_.last_byte; + save.current_byte = reader_.current_byte; + + while (reader_.state == reader::ok) + { + curr = reader_.current_byte; + + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (std::string_view(buffer_.data, buffer_.length) == "size") + { + return iw5::parser::make_SIZE(loc_); + } + + reader_.state = save.state; + reader_.bytes_remaining = save.bytes_remaining; + reader_.buffer_pos = save.buffer_pos; + reader_.last_byte = save.last_byte; + reader_.current_byte = save.current_byte; + + return iw5::parser::make_DOT(loc_); + + } + else return iw5::parser::make_DOT(loc_); +} + +auto lexer::keyword_token(keyword k) -> xsk::gsc::iw5::parser::symbol_type +{ + switch (k) + { + case keyword::KW_pre_inline: + return iw5::parser::make_INLINE(loc_); + case keyword::KW_pre_include: + return iw5::parser::make_INCLUDE(loc_); + case keyword::KW_pre_using_animtree: + return iw5::parser::make_USINGTREE(loc_); + case keyword::KW_pre_animtree: + return iw5::parser::make_ANIMTREE(loc_); + case keyword::KW_endon: + return iw5::parser::make_ENDON(loc_); + case keyword::KW_notify: + return iw5::parser::make_NOTIFY(loc_); + case keyword::KW_wait: + return iw5::parser::make_WAIT(loc_); + case keyword::KW_waittill: + return iw5::parser::make_WAITTILL(loc_); + case keyword::KW_waittillmatch: + return iw5::parser::make_WAITTILLMATCH(loc_); + case keyword::KW_waittillframeend: + return iw5::parser::make_WAITTILLFRAMEEND(loc_); + case keyword::KW_if: + return iw5::parser::make_IF(loc_); + case keyword::KW_else: + return iw5::parser::make_ELSE(loc_); + case keyword::KW_do: + return iw5::parser::make_DO(loc_); + case keyword::KW_while: + return iw5::parser::make_WHILE(loc_); + case keyword::KW_for: + return iw5::parser::make_FOR(loc_); + case keyword::KW_foreach: + return iw5::parser::make_FOREACH(loc_); + case keyword::KW_in: + return iw5::parser::make_IN(loc_); + case keyword::KW_switch: + return iw5::parser::make_SWITCH(loc_); + case keyword::KW_case: + return iw5::parser::make_CASE(loc_); + case keyword::KW_default: + return iw5::parser::make_DEFAULT(loc_); + case keyword::KW_break: + return iw5::parser::make_BREAK(loc_); + case keyword::KW_continue: + return iw5::parser::make_CONTINUE(loc_); + case keyword::KW_return: + return iw5::parser::make_RETURN(loc_); + case keyword::KW_breakpoint: + return iw5::parser::make_BREAKPOINT(loc_); + case keyword::KW_prof_begin: + return iw5::parser::make_PROFBEGIN(loc_); + case keyword::KW_prof_end: + return iw5::parser::make_PROFEND(loc_); + case keyword::KW_thread: + return iw5::parser::make_THREAD(loc_); + case keyword::KW_childthread: + return iw5::parser::make_CHILDTHREAD(loc_); + case keyword::KW_thisthread: + return iw5::parser::make_THISTHREAD(loc_); + case keyword::KW_call: + return iw5::parser::make_CALL(loc_); + case keyword::KW_true: + return iw5::parser::make_TRUE(loc_); + case keyword::KW_false: + return iw5::parser::make_FALSE(loc_); + case keyword::KW_undefined: + return iw5::parser::make_UNDEFINED(loc_); + case keyword::KW_dotsize: + return iw5::parser::make_SIZE(loc_); + case keyword::KW_game: + return iw5::parser::make_GAME(loc_); + case keyword::KW_self: + return iw5::parser::make_SELF(loc_); + case keyword::KW_anim: + return iw5::parser::make_ANIM(loc_); + case keyword::KW_level: + return iw5::parser::make_LEVEL(loc_); + default: + throw error("gsc lexer: INVALID KEYWORD TOKEN!"); + } +} + +auto lexer::keyword_is_token(keyword k) -> bool +{ + switch (k) + { +/* case keyword::KW_pre_define: + case keyword::KW_pre_undef: + case keyword::KW_pre_ifdef: + case keyword::KW_pre_ifndef: + case keyword::KW_pre_if: + case keyword::KW_pre_elif: + case keyword::KW_pre_else: + case keyword::KW_pre_endif:*/ + case keyword::KW_INVALID: + return false; + default: + return true; + } +} + +auto lexer::get_keyword(std::string_view str) -> keyword +{ + auto itr = keywords.find(str); + + if(itr != keywords.end()) + { + return itr->second; } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + return keyword::KW_INVALID; } -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack , yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack , yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s , yyscan_t yyscanner) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 171 "lexer.lpp" - - -void iw5_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void iw5_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} +std::unordered_map lexer::keywords +{{ +/* { "#define", keyword::KW_pre_define }, + { "#undef", keyword::KW_pre_undef }, + { "#ifdef", keyword::KW_pre_ifdef }, + { "#ifndef", keyword::KW_pre_ifndef }, + { "#if", keyword::KW_pre_if }, + { "#elif", keyword::KW_pre_elif }, + { "#else", keyword::KW_pre_else }, + { "#endif", keyword::KW_pre_endif },*/ + { "#inline", keyword::KW_pre_inline }, + { "#include", keyword::KW_pre_include }, + { "#using_animtree", keyword::KW_pre_using_animtree }, + { "#animtree", keyword::KW_pre_animtree }, + { "endon", keyword::KW_endon }, + { "notify", keyword::KW_notify }, + { "wait", keyword::KW_wait }, + { "waittill", keyword::KW_waittill }, + { "waittillmatch", keyword::KW_waittillmatch }, + { "waittillframeend", keyword::KW_waittillframeend }, + { "if", keyword::KW_if }, + { "else", keyword::KW_else }, + { "do", keyword::KW_do }, + { "while", keyword::KW_while }, + { "for", keyword::KW_for }, + { "foreach", keyword::KW_foreach }, + { "in", keyword::KW_in }, + { "switch", keyword::KW_switch }, + { "case", keyword::KW_case }, + { "default", keyword::KW_default }, + { "break", keyword::KW_break }, + { "continue", keyword::KW_continue }, + { "return", keyword::KW_return }, + { "breakpoint", keyword::KW_breakpoint }, + { "prof_begin", keyword::KW_prof_begin }, + { "prof_end", keyword::KW_prof_end }, + { "thread", keyword::KW_thread }, + { "childthread", keyword::KW_childthread }, + { "thisthread", keyword::KW_thisthread }, + { "call", keyword::KW_call }, + { "true", keyword::KW_true }, + { "false", keyword::KW_false }, + { "undefined", keyword::KW_undefined }, + { ".size", keyword::KW_dotsize }, + { "game", keyword::KW_game }, + { "self", keyword::KW_self }, + { "anim", keyword::KW_anim }, + { "level", keyword::KW_level }, +}}; +} // namespace xsk::gsc::iw5 diff --git a/src/iw5/xsk/lexer.hpp b/src/iw5/xsk/lexer.hpp index a4e5d0ae..0359062c 100644 --- a/src/iw5/xsk/lexer.hpp +++ b/src/iw5/xsk/lexer.hpp @@ -1,711 +1,79 @@ -#ifndef iw5_HEADER_H -#define iw5_HEADER_H 1 -#define iw5_IN_HEADER 1 - -#line 5 "lexer.hpp" -#include "stdafx.hpp" -#include "iw5.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw5_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw5_pop_header(xsk::gsc::context* ctx); - -#line 13 "lexer.hpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define iw5__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer iw5__create_buffer -#endif - -#ifdef yy_delete_buffer -#define iw5__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer iw5__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define iw5__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer iw5__scan_buffer -#endif - -#ifdef yy_scan_string -#define iw5__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string iw5__scan_string -#endif - -#ifdef yy_scan_bytes -#define iw5__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes iw5__scan_bytes -#endif - -#ifdef yy_init_buffer -#define iw5__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer iw5__init_buffer -#endif - -#ifdef yy_flush_buffer -#define iw5__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer iw5__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define iw5__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state iw5__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define iw5__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer iw5__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define iw5_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state iw5_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define iw5_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state iw5_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define iw5_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack iw5_ensure_buffer_stack -#endif - -#ifdef yylex -#define iw5_lex_ALREADY_DEFINED -#else -#define yylex iw5_lex -#endif - -#ifdef yyrestart -#define iw5_restart_ALREADY_DEFINED -#else -#define yyrestart iw5_restart -#endif - -#ifdef yylex_init -#define iw5_lex_init_ALREADY_DEFINED -#else -#define yylex_init iw5_lex_init -#endif - -#ifdef yylex_init_extra -#define iw5_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra iw5_lex_init_extra -#endif - -#ifdef yylex_destroy -#define iw5_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy iw5_lex_destroy -#endif - -#ifdef yyget_debug -#define iw5_get_debug_ALREADY_DEFINED -#else -#define yyget_debug iw5_get_debug -#endif - -#ifdef yyset_debug -#define iw5_set_debug_ALREADY_DEFINED -#else -#define yyset_debug iw5_set_debug -#endif - -#ifdef yyget_extra -#define iw5_get_extra_ALREADY_DEFINED -#else -#define yyget_extra iw5_get_extra -#endif - -#ifdef yyset_extra -#define iw5_set_extra_ALREADY_DEFINED -#else -#define yyset_extra iw5_set_extra -#endif - -#ifdef yyget_in -#define iw5_get_in_ALREADY_DEFINED -#else -#define yyget_in iw5_get_in -#endif - -#ifdef yyset_in -#define iw5_set_in_ALREADY_DEFINED -#else -#define yyset_in iw5_set_in -#endif - -#ifdef yyget_out -#define iw5_get_out_ALREADY_DEFINED -#else -#define yyget_out iw5_get_out -#endif - -#ifdef yyset_out -#define iw5_set_out_ALREADY_DEFINED -#else -#define yyset_out iw5_set_out -#endif - -#ifdef yyget_leng -#define iw5_get_leng_ALREADY_DEFINED -#else -#define yyget_leng iw5_get_leng -#endif - -#ifdef yyget_text -#define iw5_get_text_ALREADY_DEFINED -#else -#define yyget_text iw5_get_text -#endif - -#ifdef yyget_lineno -#define iw5_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno iw5_get_lineno -#endif - -#ifdef yyset_lineno -#define iw5_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno iw5_set_lineno -#endif - -#ifdef yyget_column -#define iw5_get_column_ALREADY_DEFINED -#else -#define yyget_column iw5_get_column -#endif - -#ifdef yyset_column -#define iw5_set_column_ALREADY_DEFINED -#else -#define yyset_column iw5_set_column -#endif - -#ifdef yywrap -#define iw5_wrap_ALREADY_DEFINED -#else -#define yywrap iw5_wrap -#endif - -#ifdef yyalloc -#define iw5_alloc_ALREADY_DEFINED -#else -#define yyalloc iw5_alloc -#endif - -#ifdef yyrealloc -#define iw5_realloc_ALREADY_DEFINED -#else -#define yyrealloc iw5_realloc -#endif - -#ifdef yyfree -#define iw5_free_ALREADY_DEFINED -#else -#define yyfree iw5_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define iw5_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#ifndef iw5__create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef iw5__delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef iw5__scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef iw5__scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef iw5__scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef iw5__init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef iw5__flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef iw5__load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef iw5__switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef iw5_push_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef iw5_pop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef iw5_ensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef iw5_lex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef iw5_restart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef iw5_lex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef iw5_lex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef iw5_lex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef iw5_get_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef iw5_set_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef iw5_get_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef iw5_set_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef iw5_get_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef iw5_set_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef iw5_get_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef iw5_set_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef iw5_get_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef iw5_get_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef iw5_get_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef iw5_set_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef iw5_get_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef iw5_set_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef iw5_wrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef iw5_get_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef iw5_set_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef iw5_get_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef iw5_set_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef iw5_alloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef iw5_realloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef iw5_free_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef iw5_text_ALREADY_DEFINED -#undef yytext -#endif -#ifndef iw5_leng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef iw5_in_ALREADY_DEFINED -#undef yyin -#endif -#ifndef iw5_out_ALREADY_DEFINED -#undef yyout -#endif -#ifndef iw5__flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef iw5_lineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef iw5_tables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef iw5_tables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef iw5_TABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 171 "lexer.lpp" - - -#line 709 "lexer.hpp" -#undef iw5_IN_HEADER -#endif /* iw5_HEADER_H */ +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#pragma once + +#include "iw5.hpp" + +namespace xsk::gsc::iw5 +{ + +enum class keyword; + +struct buffer +{ + int size; + int length; + char* data; + + buffer(); + ~buffer(); + bool push(char c); +}; + +struct reader +{ + enum states { end, ok }; + + states state; + int bytes_remaining; + const char* buffer_pos; + char last_byte; + char current_byte; + + reader(); + + reader& operator=(const reader& r) + { + std::memcpy(this, &r, sizeof(reader)); + return *this; + } + + void init(const char* data, size_t size); + void advance(); +}; + +class lexer +{ +private: + reader reader_; + buffer buffer_; + location loc_; + build mode_; + bool in_dev_state_; + std::stack locs_; + std::stack readers_; + std::uint32_t header_top_; + +public: + lexer(const std::string& name, const char* data, size_t size); + auto lex() -> xsk::gsc::iw5::parser::symbol_type; + void push_header(const std::string& file); + void pop_header(); + void restrict_header(const xsk::gsc::location& loc); + +private: + auto read_string(char quote, bool localize) -> xsk::gsc::iw5::parser::symbol_type; + auto read_number(char first) -> xsk::gsc::iw5::parser::symbol_type; + auto read_word(char first) -> xsk::gsc::iw5::parser::symbol_type; + auto read_dotsize() -> xsk::gsc::iw5::parser::symbol_type; + auto keyword_token(keyword k) -> xsk::gsc::iw5::parser::symbol_type; + static auto keyword_is_token(keyword k) -> bool; + static auto get_keyword(std::string_view str) -> keyword; + + static std::unordered_map keywords; +}; + +} // namespace xsk::gsc::iw5 diff --git a/src/iw5/xsk/parser.cpp b/src/iw5/xsk/parser.cpp index 5cf79c42..044f7a98 100644 --- a/src/iw5/xsk/parser.cpp +++ b/src/iw5/xsk/parser.cpp @@ -35,13 +35,13 @@ // private implementation details that can be changed or removed. // "%code top" blocks. -#line 40 "parser.ypp" +#line 34 "parser.ypp" #include "stdafx.hpp" #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::iw5::parser::symbol_type IW5lex(xsk::gsc::iw5::lexer& lexer); #line 47 "parser.cpp" @@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace iw5 { #line 149 "parser.cpp" /// Build a parser object. - parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) + parser::parser (xsk::gsc::iw5::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) #if IW5DEBUG : yydebug_ (false), yycdebug_ (&std::cerr), @@ -156,8 +156,7 @@ namespace xsk { namespace gsc { namespace iw5 { : #endif yy_lac_established_ (false), - yyscanner (yyscanner_yyarg), - ctx (ctx_yyarg), + lexer (lexer_yyarg), ast (ast_yyarg) {} @@ -1577,7 +1576,7 @@ namespace xsk { namespace gsc { namespace iw5 { try #endif // YY_EXCEPTIONS { - symbol_type yylookahead (yylex (yyscanner, ctx)); + symbol_type yylookahead (yylex (lexer)); yyla.move (yylookahead); } #if YY_EXCEPTIONS @@ -1960,1285 +1959,1285 @@ namespace xsk { namespace gsc { namespace iw5 { switch (yyn) { case 2: // root: program -#line 249 "parser.ypp" +#line 243 "parser.ypp" { ast = std::move(yystack_[0].value.as < ast::program::ptr > ()); } -#line 1966 "parser.cpp" +#line 1965 "parser.cpp" break; case 3: // root: %empty -#line 250 "parser.ypp" +#line 244 "parser.ypp" { ast = std::make_unique(yylhs.location); } -#line 1972 "parser.cpp" +#line 1971 "parser.cpp" break; case 4: // program: program inline -#line 255 "parser.ypp" +#line 249 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); } -#line 1978 "parser.cpp" +#line 1977 "parser.cpp" break; case 5: // program: program include -#line 257 "parser.ypp" +#line 251 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 1984 "parser.cpp" +#line 1983 "parser.cpp" break; case 6: // program: program declaration -#line 259 "parser.ypp" +#line 253 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 1990 "parser.cpp" +#line 1989 "parser.cpp" break; case 7: // program: inline -#line 261 "parser.ypp" +#line 255 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); } -#line 1996 "parser.cpp" +#line 1995 "parser.cpp" break; case 8: // program: include -#line 263 "parser.ypp" +#line 257 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2002 "parser.cpp" +#line 2001 "parser.cpp" break; case 9: // program: declaration -#line 265 "parser.ypp" +#line 259 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2008 "parser.cpp" +#line 2007 "parser.cpp" break; case 10: // inline: "#inline" expr_path ";" -#line 269 "parser.ypp" - { iw5_push_header(ctx, yystack_[1].value.as < ast::expr_path::ptr > ()->value); } -#line 2014 "parser.cpp" +#line 263 "parser.ypp" + { lexer.push_header(yystack_[1].value.as < ast::expr_path::ptr > ()->value); } +#line 2013 "parser.cpp" break; case 11: // include: "#include" expr_path ";" -#line 274 "parser.ypp" +#line 268 "parser.ypp" { yylhs.value.as < ast::include::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_path::ptr > ())); } -#line 2020 "parser.cpp" +#line 2019 "parser.cpp" break; case 12: // declaration: "/#" -#line 278 "parser.ypp" +#line 272 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_begin = std::make_unique(yylhs.location); } -#line 2026 "parser.cpp" +#line 2025 "parser.cpp" break; case 13: // declaration: "#/" -#line 279 "parser.ypp" +#line 273 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_end = std::make_unique(yylhs.location); } -#line 2032 "parser.cpp" +#line 2031 "parser.cpp" break; case 14: // declaration: decl_usingtree -#line 280 "parser.ypp" +#line 274 "parser.ypp" { yylhs.value.as < ast::decl > ().as_usingtree = std::move(yystack_[0].value.as < ast::decl_usingtree::ptr > ()); } -#line 2038 "parser.cpp" +#line 2037 "parser.cpp" break; case 15: // declaration: decl_constant -#line 281 "parser.ypp" +#line 275 "parser.ypp" { yylhs.value.as < ast::decl > ().as_constant = std::move(yystack_[0].value.as < ast::decl_constant::ptr > ()); } -#line 2044 "parser.cpp" +#line 2043 "parser.cpp" break; case 16: // declaration: decl_thread -#line 282 "parser.ypp" +#line 276 "parser.ypp" { yylhs.value.as < ast::decl > ().as_thread = std::move(yystack_[0].value.as < ast::decl_thread::ptr > ()); } -#line 2050 "parser.cpp" +#line 2049 "parser.cpp" break; case 17: // decl_usingtree: "#using_animtree" "(" expr_string ")" ";" -#line 287 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } -#line 2056 "parser.cpp" +#line 281 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } +#line 2055 "parser.cpp" break; case 18: // decl_constant: expr_identifier "=" expr ";" -#line 292 "parser.ypp" +#line 286 "parser.ypp" { yylhs.value.as < ast::decl_constant::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2062 "parser.cpp" +#line 2061 "parser.cpp" break; case 19: // decl_thread: expr_identifier "(" expr_parameters ")" stmt_block -#line 297 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2068 "parser.cpp" +#line 291 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } +#line 2067 "parser.cpp" break; case 20: // stmt: stmt_dev -#line 301 "parser.ypp" +#line 295 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2074 "parser.cpp" +#line 2073 "parser.cpp" break; case 21: // stmt: stmt_block -#line 302 "parser.ypp" +#line 296 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2080 "parser.cpp" +#line 2079 "parser.cpp" break; case 22: // stmt: stmt_call -#line 303 "parser.ypp" +#line 297 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_call = std::move(yystack_[0].value.as < ast::stmt_call::ptr > ()); } -#line 2086 "parser.cpp" +#line 2085 "parser.cpp" break; case 23: // stmt: stmt_assign -#line 304 "parser.ypp" +#line 298 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_assign = std::move(yystack_[0].value.as < ast::stmt_assign::ptr > ()); } -#line 2092 "parser.cpp" +#line 2091 "parser.cpp" break; case 24: // stmt: stmt_endon -#line 305 "parser.ypp" +#line 299 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_endon = std::move(yystack_[0].value.as < ast::stmt_endon::ptr > ()); } -#line 2098 "parser.cpp" +#line 2097 "parser.cpp" break; case 25: // stmt: stmt_notify -#line 306 "parser.ypp" +#line 300 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_notify = std::move(yystack_[0].value.as < ast::stmt_notify::ptr > ()); } -#line 2104 "parser.cpp" +#line 2103 "parser.cpp" break; case 26: // stmt: stmt_wait -#line 307 "parser.ypp" +#line 301 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_wait = std::move(yystack_[0].value.as < ast::stmt_wait::ptr > ()); } -#line 2110 "parser.cpp" +#line 2109 "parser.cpp" break; case 27: // stmt: stmt_waittill -#line 308 "parser.ypp" +#line 302 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittill = std::move(yystack_[0].value.as < ast::stmt_waittill::ptr > ()); } -#line 2116 "parser.cpp" +#line 2115 "parser.cpp" break; case 28: // stmt: stmt_waittillmatch -#line 309 "parser.ypp" +#line 303 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillmatch = std::move(yystack_[0].value.as < ast::stmt_waittillmatch::ptr > ()); } -#line 2122 "parser.cpp" +#line 2121 "parser.cpp" break; case 29: // stmt: stmt_waittillframeend -#line 310 "parser.ypp" +#line 304 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillframeend = std::move(yystack_[0].value.as < ast::stmt_waittillframeend::ptr > ()); } -#line 2128 "parser.cpp" +#line 2127 "parser.cpp" break; case 30: // stmt: stmt_if -#line 311 "parser.ypp" +#line 305 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_if = std::move(yystack_[0].value.as < ast::stmt_if::ptr > ()); } -#line 2134 "parser.cpp" +#line 2133 "parser.cpp" break; case 31: // stmt: stmt_ifelse -#line 312 "parser.ypp" +#line 306 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_ifelse = std::move(yystack_[0].value.as < ast::stmt_ifelse::ptr > ()); } -#line 2140 "parser.cpp" +#line 2139 "parser.cpp" break; case 32: // stmt: stmt_while -#line 313 "parser.ypp" +#line 307 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_while = std::move(yystack_[0].value.as < ast::stmt_while::ptr > ()); } -#line 2146 "parser.cpp" +#line 2145 "parser.cpp" break; case 33: // stmt: stmt_dowhile -#line 314 "parser.ypp" +#line 308 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_dowhile = std::move(yystack_[0].value.as < ast::stmt_dowhile::ptr > ()); } -#line 2152 "parser.cpp" +#line 2151 "parser.cpp" break; case 34: // stmt: stmt_for -#line 315 "parser.ypp" +#line 309 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_for = std::move(yystack_[0].value.as < ast::stmt_for::ptr > ()); } -#line 2158 "parser.cpp" +#line 2157 "parser.cpp" break; case 35: // stmt: stmt_foreach -#line 316 "parser.ypp" +#line 310 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_foreach = std::move(yystack_[0].value.as < ast::stmt_foreach::ptr > ()); } -#line 2164 "parser.cpp" +#line 2163 "parser.cpp" break; case 36: // stmt: stmt_switch -#line 317 "parser.ypp" +#line 311 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_switch = std::move(yystack_[0].value.as < ast::stmt_switch::ptr > ()); } -#line 2170 "parser.cpp" +#line 2169 "parser.cpp" break; case 37: // stmt: stmt_case -#line 318 "parser.ypp" +#line 312 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_case = std::move(yystack_[0].value.as < ast::stmt_case::ptr > ()); } -#line 2176 "parser.cpp" +#line 2175 "parser.cpp" break; case 38: // stmt: stmt_default -#line 319 "parser.ypp" +#line 313 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_default = std::move(yystack_[0].value.as < ast::stmt_default::ptr > ()); } -#line 2182 "parser.cpp" +#line 2181 "parser.cpp" break; case 39: // stmt: stmt_break -#line 320 "parser.ypp" +#line 314 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_break = std::move(yystack_[0].value.as < ast::stmt_break::ptr > ()); } -#line 2188 "parser.cpp" +#line 2187 "parser.cpp" break; case 40: // stmt: stmt_continue -#line 321 "parser.ypp" +#line 315 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_continue = std::move(yystack_[0].value.as < ast::stmt_continue::ptr > ()); } -#line 2194 "parser.cpp" +#line 2193 "parser.cpp" break; case 41: // stmt: stmt_return -#line 322 "parser.ypp" +#line 316 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_return = std::move(yystack_[0].value.as < ast::stmt_return::ptr > ()); } -#line 2200 "parser.cpp" +#line 2199 "parser.cpp" break; case 42: // stmt: stmt_breakpoint -#line 323 "parser.ypp" +#line 317 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_breakpoint = std::move(yystack_[0].value.as < ast::stmt_breakpoint::ptr > ()); } -#line 2206 "parser.cpp" +#line 2205 "parser.cpp" break; case 43: // stmt: stmt_prof_begin -#line 324 "parser.ypp" +#line 318 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_begin = std::move(yystack_[0].value.as < ast::stmt_prof_begin::ptr > ()); } -#line 2212 "parser.cpp" +#line 2211 "parser.cpp" break; case 44: // stmt: stmt_prof_end -#line 325 "parser.ypp" +#line 319 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_end = std::move(yystack_[0].value.as < ast::stmt_prof_end::ptr > ()); } -#line 2218 "parser.cpp" +#line 2217 "parser.cpp" break; case 45: // stmt_dev: "/#" stmt_list "#/" -#line 329 "parser.ypp" +#line 323 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2224 "parser.cpp" +#line 2223 "parser.cpp" break; case 46: // stmt_dev: "/#" "#/" -#line 330 "parser.ypp" +#line 324 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2230 "parser.cpp" +#line 2229 "parser.cpp" break; case 47: // stmt_block: "{" stmt_list "}" -#line 334 "parser.ypp" +#line 328 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2236 "parser.cpp" +#line 2235 "parser.cpp" break; case 48: // stmt_block: "{" "}" -#line 335 "parser.ypp" +#line 329 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2242 "parser.cpp" +#line 2241 "parser.cpp" break; case 49: // stmt_list: stmt_list stmt -#line 340 "parser.ypp" +#line 334 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2248 "parser.cpp" +#line 2247 "parser.cpp" break; case 50: // stmt_list: stmt -#line 342 "parser.ypp" +#line 336 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2254 "parser.cpp" +#line 2253 "parser.cpp" break; case 51: // stmt_expr: expr_assign -#line 347 "parser.ypp" +#line 341 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2260 "parser.cpp" +#line 2259 "parser.cpp" break; case 52: // stmt_expr: expr_increment -#line 349 "parser.ypp" +#line 343 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2266 "parser.cpp" +#line 2265 "parser.cpp" break; case 53: // stmt_expr: expr_decrement -#line 351 "parser.ypp" +#line 345 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2272 "parser.cpp" +#line 2271 "parser.cpp" break; case 54: // stmt_expr: %empty -#line 353 "parser.ypp" +#line 347 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2278 "parser.cpp" +#line 2277 "parser.cpp" break; case 55: // stmt_call: expr_call ";" -#line 358 "parser.ypp" +#line 352 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_call::ptr > ()))); } -#line 2284 "parser.cpp" +#line 2283 "parser.cpp" break; case 56: // stmt_call: expr_method ";" -#line 360 "parser.ypp" +#line 354 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_method::ptr > ()))); } -#line 2290 "parser.cpp" +#line 2289 "parser.cpp" break; case 57: // stmt_assign: expr_assign ";" -#line 365 "parser.ypp" +#line 359 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2296 "parser.cpp" +#line 2295 "parser.cpp" break; case 58: // stmt_assign: expr_increment ";" -#line 367 "parser.ypp" +#line 361 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2302 "parser.cpp" +#line 2301 "parser.cpp" break; case 59: // stmt_assign: expr_decrement ";" -#line 369 "parser.ypp" +#line 363 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2308 "parser.cpp" +#line 2307 "parser.cpp" break; case 60: // stmt_endon: expr_object "endon" "(" expr ")" ";" -#line 374 "parser.ypp" +#line 368 "parser.ypp" { yylhs.value.as < ast::stmt_endon::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ())); } -#line 2314 "parser.cpp" +#line 2313 "parser.cpp" break; case 61: // stmt_notify: expr_object "notify" "(" expr "," expr_arguments_no_empty ")" ";" -#line 379 "parser.ypp" +#line 373 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2320 "parser.cpp" +#line 2319 "parser.cpp" break; case 62: // stmt_notify: expr_object "notify" "(" expr ")" ";" -#line 381 "parser.ypp" +#line 375 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2326 "parser.cpp" +#line 2325 "parser.cpp" break; case 63: // stmt_wait: "wait" expr ";" -#line 386 "parser.ypp" +#line 380 "parser.ypp" { yylhs.value.as < ast::stmt_wait::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2332 "parser.cpp" +#line 2331 "parser.cpp" break; case 64: // stmt_waittill: expr_object "waittill" "(" expr "," expr_arguments_no_empty ")" ";" -#line 391 "parser.ypp" +#line 385 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2338 "parser.cpp" +#line 2337 "parser.cpp" break; case 65: // stmt_waittill: expr_object "waittill" "(" expr ")" ";" -#line 393 "parser.ypp" +#line 387 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2344 "parser.cpp" +#line 2343 "parser.cpp" break; case 66: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr "," expr_arguments_no_empty ")" ";" -#line 398 "parser.ypp" +#line 392 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2350 "parser.cpp" +#line 2349 "parser.cpp" break; case 67: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr ")" ";" -#line 400 "parser.ypp" +#line 394 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2356 "parser.cpp" +#line 2355 "parser.cpp" break; case 68: // stmt_waittillframeend: "waittillframeend" ";" -#line 405 "parser.ypp" +#line 399 "parser.ypp" { yylhs.value.as < ast::stmt_waittillframeend::ptr > () = std::make_unique(yylhs.location); } -#line 2362 "parser.cpp" +#line 2361 "parser.cpp" break; case 69: // stmt_if: "if" "(" expr ")" stmt -#line 410 "parser.ypp" +#line 404 "parser.ypp" { yylhs.value.as < ast::stmt_if::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2368 "parser.cpp" +#line 2367 "parser.cpp" break; case 70: // stmt_ifelse: "if" "(" expr ")" stmt "else" stmt -#line 415 "parser.ypp" +#line 409 "parser.ypp" { yylhs.value.as < ast::stmt_ifelse::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::stmt > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2374 "parser.cpp" +#line 2373 "parser.cpp" break; case 71: // stmt_while: "while" "(" expr ")" stmt -#line 420 "parser.ypp" +#line 414 "parser.ypp" { yylhs.value.as < ast::stmt_while::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2380 "parser.cpp" +#line 2379 "parser.cpp" break; case 72: // stmt_dowhile: "do" stmt "while" "(" expr ")" ";" -#line 425 "parser.ypp" +#line 419 "parser.ypp" { yylhs.value.as < ast::stmt_dowhile::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[5].value.as < ast::stmt > ())); } -#line 2386 "parser.cpp" +#line 2385 "parser.cpp" break; case 73: // stmt_for: "for" "(" stmt_expr ";" expr_or_empty ";" stmt_expr ")" stmt -#line 430 "parser.ypp" +#line 424 "parser.ypp" { yylhs.value.as < ast::stmt_for::ptr > () = std::make_unique(yylhs.location, ast::stmt(std::move(yystack_[6].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[4].value.as < ast::expr > ()), ast::stmt(std::move(yystack_[2].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2392 "parser.cpp" +#line 2391 "parser.cpp" break; case 74: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt -#line 435 "parser.ypp" +#line 429 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2398 "parser.cpp" +#line 2397 "parser.cpp" break; case 75: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt -#line 437 "parser.ypp" +#line 431 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[6].value.as < ast::expr_identifier::ptr > ())), ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2404 "parser.cpp" +#line 2403 "parser.cpp" break; case 76: // stmt_switch: "switch" "(" expr ")" stmt_block -#line 442 "parser.ypp" +#line 436 "parser.ypp" { yylhs.value.as < ast::stmt_switch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2410 "parser.cpp" +#line 2409 "parser.cpp" break; case 77: // stmt_case: "case" expr_integer ":" -#line 447 "parser.ypp" +#line 441 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_integer::ptr > ())), std::make_unique(yylhs.location)); } -#line 2416 "parser.cpp" +#line 2415 "parser.cpp" break; case 78: // stmt_case: "case" expr_string ":" -#line 449 "parser.ypp" +#line 443 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_string::ptr > ())), std::make_unique(yylhs.location)); } -#line 2422 "parser.cpp" +#line 2421 "parser.cpp" break; case 79: // stmt_default: "default" ":" -#line 454 "parser.ypp" +#line 448 "parser.ypp" { yylhs.value.as < ast::stmt_default::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2428 "parser.cpp" +#line 2427 "parser.cpp" break; case 80: // stmt_break: "break" ";" -#line 459 "parser.ypp" +#line 453 "parser.ypp" { yylhs.value.as < ast::stmt_break::ptr > () = std::make_unique(yylhs.location); } -#line 2434 "parser.cpp" +#line 2433 "parser.cpp" break; case 81: // stmt_continue: "continue" ";" -#line 464 "parser.ypp" +#line 458 "parser.ypp" { yylhs.value.as < ast::stmt_continue::ptr > () = std::make_unique(yylhs.location); } -#line 2440 "parser.cpp" +#line 2439 "parser.cpp" break; case 82: // stmt_return: "return" expr ";" -#line 469 "parser.ypp" +#line 463 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2446 "parser.cpp" +#line 2445 "parser.cpp" break; case 83: // stmt_return: "return" ";" -#line 471 "parser.ypp" +#line 465 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2452 "parser.cpp" +#line 2451 "parser.cpp" break; case 84: // stmt_breakpoint: "breakpoint" ";" -#line 476 "parser.ypp" +#line 470 "parser.ypp" { yylhs.value.as < ast::stmt_breakpoint::ptr > () = std::make_unique(yylhs.location); } -#line 2458 "parser.cpp" +#line 2457 "parser.cpp" break; case 85: // stmt_prof_begin: "prof_begin" "(" expr_arguments ")" ";" -#line 481 "parser.ypp" +#line 475 "parser.ypp" { yylhs.value.as < ast::stmt_prof_begin::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2464 "parser.cpp" +#line 2463 "parser.cpp" break; case 86: // stmt_prof_end: "prof_end" "(" expr_arguments ")" ";" -#line 486 "parser.ypp" +#line 480 "parser.ypp" { yylhs.value.as < ast::stmt_prof_end::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2470 "parser.cpp" +#line 2469 "parser.cpp" break; case 87: // expr: expr_ternary -#line 490 "parser.ypp" +#line 484 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2476 "parser.cpp" +#line 2475 "parser.cpp" break; case 88: // expr: expr_binary -#line 491 "parser.ypp" +#line 485 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2482 "parser.cpp" +#line 2481 "parser.cpp" break; case 89: // expr: expr_primitive -#line 492 "parser.ypp" +#line 486 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2488 "parser.cpp" +#line 2487 "parser.cpp" break; case 90: // expr_or_empty: expr -#line 496 "parser.ypp" +#line 490 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2494 "parser.cpp" +#line 2493 "parser.cpp" break; case 91: // expr_or_empty: %empty -#line 497 "parser.ypp" +#line 491 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location); } -#line 2500 "parser.cpp" +#line 2499 "parser.cpp" break; case 92: // expr_assign: expr_object "=" expr -#line 502 "parser.ypp" +#line 496 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2506 "parser.cpp" +#line 2505 "parser.cpp" break; case 93: // expr_assign: expr_object "|=" expr -#line 504 "parser.ypp" +#line 498 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2512 "parser.cpp" +#line 2511 "parser.cpp" break; case 94: // expr_assign: expr_object "&=" expr -#line 506 "parser.ypp" +#line 500 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2518 "parser.cpp" +#line 2517 "parser.cpp" break; case 95: // expr_assign: expr_object "^=" expr -#line 508 "parser.ypp" +#line 502 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2524 "parser.cpp" +#line 2523 "parser.cpp" break; case 96: // expr_assign: expr_object "<<=" expr -#line 510 "parser.ypp" +#line 504 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()),std::move( yystack_[0].value.as < ast::expr > ())); } -#line 2530 "parser.cpp" +#line 2529 "parser.cpp" break; case 97: // expr_assign: expr_object ">>=" expr -#line 512 "parser.ypp" +#line 506 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2536 "parser.cpp" +#line 2535 "parser.cpp" break; case 98: // expr_assign: expr_object "+=" expr -#line 514 "parser.ypp" +#line 508 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2542 "parser.cpp" +#line 2541 "parser.cpp" break; case 99: // expr_assign: expr_object "-=" expr -#line 516 "parser.ypp" +#line 510 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2548 "parser.cpp" +#line 2547 "parser.cpp" break; case 100: // expr_assign: expr_object "*=" expr -#line 518 "parser.ypp" +#line 512 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2554 "parser.cpp" +#line 2553 "parser.cpp" break; case 101: // expr_assign: expr_object "/=" expr -#line 520 "parser.ypp" +#line 514 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2560 "parser.cpp" +#line 2559 "parser.cpp" break; case 102: // expr_assign: expr_object "%=" expr -#line 522 "parser.ypp" +#line 516 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2566 "parser.cpp" +#line 2565 "parser.cpp" break; case 103: // expr_increment: "++" expr_object -#line 527 "parser.ypp" +#line 521 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2572 "parser.cpp" +#line 2571 "parser.cpp" break; case 104: // expr_increment: expr_object "++" -#line 529 "parser.ypp" +#line 523 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2578 "parser.cpp" +#line 2577 "parser.cpp" break; case 105: // expr_decrement: "--" expr_object -#line 534 "parser.ypp" +#line 528 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2584 "parser.cpp" +#line 2583 "parser.cpp" break; case 106: // expr_decrement: expr_object "--" -#line 536 "parser.ypp" +#line 530 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2590 "parser.cpp" +#line 2589 "parser.cpp" break; case 107: // expr_ternary: expr "?" expr ":" expr -#line 541 "parser.ypp" +#line 535 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2596 "parser.cpp" +#line 2595 "parser.cpp" break; case 108: // expr_binary: expr "||" expr -#line 546 "parser.ypp" +#line 540 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2602 "parser.cpp" +#line 2601 "parser.cpp" break; case 109: // expr_binary: expr "&&" expr -#line 548 "parser.ypp" +#line 542 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2608 "parser.cpp" +#line 2607 "parser.cpp" break; case 110: // expr_binary: expr "==" expr -#line 550 "parser.ypp" +#line 544 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2614 "parser.cpp" +#line 2613 "parser.cpp" break; case 111: // expr_binary: expr "!=" expr -#line 552 "parser.ypp" +#line 546 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2620 "parser.cpp" +#line 2619 "parser.cpp" break; case 112: // expr_binary: expr "<=" expr -#line 554 "parser.ypp" +#line 548 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2626 "parser.cpp" +#line 2625 "parser.cpp" break; case 113: // expr_binary: expr ">=" expr -#line 556 "parser.ypp" +#line 550 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2632 "parser.cpp" +#line 2631 "parser.cpp" break; case 114: // expr_binary: expr "<" expr -#line 558 "parser.ypp" +#line 552 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2638 "parser.cpp" +#line 2637 "parser.cpp" break; case 115: // expr_binary: expr ">" expr -#line 560 "parser.ypp" +#line 554 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2644 "parser.cpp" +#line 2643 "parser.cpp" break; case 116: // expr_binary: expr "|" expr -#line 562 "parser.ypp" +#line 556 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2650 "parser.cpp" +#line 2649 "parser.cpp" break; case 117: // expr_binary: expr "&" expr -#line 564 "parser.ypp" +#line 558 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2656 "parser.cpp" +#line 2655 "parser.cpp" break; case 118: // expr_binary: expr "^" expr -#line 566 "parser.ypp" +#line 560 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2662 "parser.cpp" +#line 2661 "parser.cpp" break; case 119: // expr_binary: expr "<<" expr -#line 568 "parser.ypp" +#line 562 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2668 "parser.cpp" +#line 2667 "parser.cpp" break; case 120: // expr_binary: expr ">>" expr -#line 570 "parser.ypp" +#line 564 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2674 "parser.cpp" +#line 2673 "parser.cpp" break; case 121: // expr_binary: expr "+" expr -#line 572 "parser.ypp" +#line 566 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2680 "parser.cpp" +#line 2679 "parser.cpp" break; case 122: // expr_binary: expr "-" expr -#line 574 "parser.ypp" +#line 568 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2686 "parser.cpp" +#line 2685 "parser.cpp" break; case 123: // expr_binary: expr "*" expr -#line 576 "parser.ypp" +#line 570 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2692 "parser.cpp" +#line 2691 "parser.cpp" break; case 124: // expr_binary: expr "/" expr -#line 578 "parser.ypp" +#line 572 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2698 "parser.cpp" +#line 2697 "parser.cpp" break; case 125: // expr_binary: expr "%" expr -#line 580 "parser.ypp" +#line 574 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2704 "parser.cpp" +#line 2703 "parser.cpp" break; case 126: // expr_primitive: expr_complement -#line 584 "parser.ypp" +#line 578 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_complement::ptr > ()); } -#line 2710 "parser.cpp" +#line 2709 "parser.cpp" break; case 127: // expr_primitive: expr_not -#line 585 "parser.ypp" +#line 579 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_not::ptr > ()); } -#line 2716 "parser.cpp" +#line 2715 "parser.cpp" break; case 128: // expr_primitive: expr_call -#line 586 "parser.ypp" +#line 580 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 2722 "parser.cpp" +#line 2721 "parser.cpp" break; case 129: // expr_primitive: expr_method -#line 587 "parser.ypp" +#line 581 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 2728 "parser.cpp" +#line 2727 "parser.cpp" break; case 130: // expr_primitive: expr_add_array -#line 588 "parser.ypp" +#line 582 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_add_array::ptr > ()); } -#line 2734 "parser.cpp" +#line 2733 "parser.cpp" break; case 131: // expr_primitive: expr_reference -#line 589 "parser.ypp" +#line 583 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_reference::ptr > ()); } -#line 2740 "parser.cpp" +#line 2739 "parser.cpp" break; case 132: // expr_primitive: expr_array -#line 590 "parser.ypp" +#line 584 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 2746 "parser.cpp" +#line 2745 "parser.cpp" break; case 133: // expr_primitive: expr_field -#line 591 "parser.ypp" +#line 585 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 2752 "parser.cpp" +#line 2751 "parser.cpp" break; case 134: // expr_primitive: expr_size -#line 592 "parser.ypp" +#line 586 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_size::ptr > ()); } -#line 2758 "parser.cpp" +#line 2757 "parser.cpp" break; case 135: // expr_primitive: expr_paren -#line 593 "parser.ypp" +#line 587 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_paren::ptr > ()); } -#line 2764 "parser.cpp" +#line 2763 "parser.cpp" break; case 136: // expr_primitive: expr_thisthread -#line 594 "parser.ypp" +#line 588 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_thisthread::ptr > ()); } -#line 2770 "parser.cpp" +#line 2769 "parser.cpp" break; case 137: // expr_primitive: expr_empty_array -#line 595 "parser.ypp" +#line 589 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_empty_array::ptr > ()); } -#line 2776 "parser.cpp" +#line 2775 "parser.cpp" break; case 138: // expr_primitive: expr_undefined -#line 596 "parser.ypp" +#line 590 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_undefined::ptr > ()); } -#line 2782 "parser.cpp" +#line 2781 "parser.cpp" break; case 139: // expr_primitive: expr_game -#line 597 "parser.ypp" +#line 591 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 2788 "parser.cpp" +#line 2787 "parser.cpp" break; case 140: // expr_primitive: expr_self -#line 598 "parser.ypp" +#line 592 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 2794 "parser.cpp" +#line 2793 "parser.cpp" break; case 141: // expr_primitive: expr_anim -#line 599 "parser.ypp" +#line 593 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 2800 "parser.cpp" +#line 2799 "parser.cpp" break; case 142: // expr_primitive: expr_level -#line 600 "parser.ypp" +#line 594 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 2806 "parser.cpp" +#line 2805 "parser.cpp" break; case 143: // expr_primitive: expr_animation -#line 601 "parser.ypp" +#line 595 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animation::ptr > ()); } -#line 2812 "parser.cpp" +#line 2811 "parser.cpp" break; case 144: // expr_primitive: expr_animtree -#line 602 "parser.ypp" +#line 596 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animtree::ptr > ()); } -#line 2818 "parser.cpp" +#line 2817 "parser.cpp" break; case 145: // expr_primitive: expr_identifier -#line 603 "parser.ypp" +#line 597 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 2824 "parser.cpp" +#line 2823 "parser.cpp" break; case 146: // expr_primitive: expr_istring -#line 604 "parser.ypp" +#line 598 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istring::ptr > ()); } -#line 2830 "parser.cpp" +#line 2829 "parser.cpp" break; case 147: // expr_primitive: expr_string -#line 605 "parser.ypp" +#line 599 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_string::ptr > ()); } -#line 2836 "parser.cpp" +#line 2835 "parser.cpp" break; case 148: // expr_primitive: expr_color -#line 606 "parser.ypp" +#line 600 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_color::ptr > ()); } -#line 2842 "parser.cpp" +#line 2841 "parser.cpp" break; case 149: // expr_primitive: expr_vector -#line 607 "parser.ypp" +#line 601 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_vector::ptr > ()); } -#line 2848 "parser.cpp" +#line 2847 "parser.cpp" break; case 150: // expr_primitive: expr_float -#line 608 "parser.ypp" +#line 602 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_float::ptr > ()); } -#line 2854 "parser.cpp" +#line 2853 "parser.cpp" break; case 151: // expr_primitive: expr_integer -#line 609 "parser.ypp" +#line 603 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_integer::ptr > ()); } -#line 2860 "parser.cpp" +#line 2859 "parser.cpp" break; case 152: // expr_primitive: expr_false -#line 610 "parser.ypp" +#line 604 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_false::ptr > ()); } -#line 2866 "parser.cpp" +#line 2865 "parser.cpp" break; case 153: // expr_primitive: expr_true -#line 611 "parser.ypp" +#line 605 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_true::ptr > ()); } -#line 2872 "parser.cpp" +#line 2871 "parser.cpp" break; case 154: // expr_complement: "~" expr -#line 616 "parser.ypp" +#line 610 "parser.ypp" { yylhs.value.as < ast::expr_complement::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2878 "parser.cpp" +#line 2877 "parser.cpp" break; case 155: // expr_not: "!" expr -#line 621 "parser.ypp" +#line 615 "parser.ypp" { yylhs.value.as < ast::expr_not::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2884 "parser.cpp" +#line 2883 "parser.cpp" break; case 156: // expr_call: expr_function -#line 625 "parser.ypp" +#line 619 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2890 "parser.cpp" +#line 2889 "parser.cpp" break; case 157: // expr_call: expr_pointer -#line 626 "parser.ypp" +#line 620 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2896 "parser.cpp" +#line 2895 "parser.cpp" break; case 158: // expr_method: expr_object expr_function -#line 629 "parser.ypp" +#line 623 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2902 "parser.cpp" +#line 2901 "parser.cpp" break; case 159: // expr_method: expr_object expr_pointer -#line 630 "parser.ypp" +#line 624 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2908 "parser.cpp" +#line 2907 "parser.cpp" break; case 160: // expr_function: expr_identifier "(" expr_arguments ")" -#line 635 "parser.ypp" +#line 629 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2914 "parser.cpp" +#line 2913 "parser.cpp" break; case 161: // expr_function: expr_path "::" expr_identifier "(" expr_arguments ")" -#line 637 "parser.ypp" +#line 631 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2920 "parser.cpp" +#line 2919 "parser.cpp" break; case 162: // expr_function: "thread" expr_identifier "(" expr_arguments ")" -#line 639 "parser.ypp" +#line 633 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2926 "parser.cpp" +#line 2925 "parser.cpp" break; case 163: // expr_function: "thread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 641 "parser.ypp" +#line 635 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2932 "parser.cpp" +#line 2931 "parser.cpp" break; case 164: // expr_function: "childthread" expr_identifier "(" expr_arguments ")" -#line 643 "parser.ypp" +#line 637 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2938 "parser.cpp" +#line 2937 "parser.cpp" break; case 165: // expr_function: "childthread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 645 "parser.ypp" +#line 639 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2944 "parser.cpp" +#line 2943 "parser.cpp" break; case 166: // expr_pointer: "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 650 "parser.ypp" +#line 644 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2950 "parser.cpp" +#line 2949 "parser.cpp" break; case 167: // expr_pointer: "thread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 652 "parser.ypp" +#line 646 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2956 "parser.cpp" +#line 2955 "parser.cpp" break; case 168: // expr_pointer: "childthread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 654 "parser.ypp" +#line 648 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2962 "parser.cpp" +#line 2961 "parser.cpp" break; case 169: // expr_pointer: "call" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 656 "parser.ypp" +#line 650 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::builtin); } -#line 2968 "parser.cpp" +#line 2967 "parser.cpp" break; case 170: // expr_add_array: "[" expr_arguments_no_empty "]" -#line 661 "parser.ypp" +#line 655 "parser.ypp" { yylhs.value.as < ast::expr_add_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ())); } -#line 2974 "parser.cpp" +#line 2973 "parser.cpp" break; case 171: // expr_parameters: expr_parameters "," expr_identifier -#line 666 "parser.ypp" +#line 660 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 2980 "parser.cpp" +#line 2979 "parser.cpp" break; case 172: // expr_parameters: expr_identifier -#line 668 "parser.ypp" +#line 662 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 2986 "parser.cpp" +#line 2985 "parser.cpp" break; case 173: // expr_parameters: %empty -#line 670 "parser.ypp" +#line 664 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); } -#line 2992 "parser.cpp" +#line 2991 "parser.cpp" break; case 174: // expr_arguments: expr_arguments_no_empty -#line 675 "parser.ypp" +#line 669 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[0].value.as < ast::expr_arguments::ptr > ()); } -#line 2998 "parser.cpp" +#line 2997 "parser.cpp" break; case 175: // expr_arguments: %empty -#line 677 "parser.ypp" +#line 671 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); } -#line 3004 "parser.cpp" +#line 3003 "parser.cpp" break; case 176: // expr_arguments_no_empty: expr_arguments "," expr -#line 682 "parser.ypp" +#line 676 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ()); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3010 "parser.cpp" +#line 3009 "parser.cpp" break; case 177: // expr_arguments_no_empty: expr -#line 684 "parser.ypp" +#line 678 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3016 "parser.cpp" +#line 3015 "parser.cpp" break; case 178: // expr_reference: "::" expr_identifier -#line 689 "parser.ypp" +#line 683 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3022 "parser.cpp" +#line 3021 "parser.cpp" break; case 179: // expr_reference: expr_path "::" expr_identifier -#line 691 "parser.ypp" +#line 685 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_path::ptr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3028 "parser.cpp" +#line 3027 "parser.cpp" break; case 180: // expr_array: expr_object "[" expr "]" -#line 696 "parser.ypp" +#line 690 "parser.ypp" { yylhs.value.as < ast::expr_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3034 "parser.cpp" +#line 3033 "parser.cpp" break; case 181: // expr_field: expr_object "." expr_identifier -#line 701 "parser.ypp" +#line 695 "parser.ypp" { yylhs.value.as < ast::expr_field::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3040 "parser.cpp" +#line 3039 "parser.cpp" break; case 182: // expr_size: expr_object ".size" -#line 706 "parser.ypp" +#line 700 "parser.ypp" { yylhs.value.as < ast::expr_size::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3046 "parser.cpp" +#line 3045 "parser.cpp" break; case 183: // expr_paren: "(" expr ")" -#line 711 "parser.ypp" +#line 705 "parser.ypp" { yylhs.value.as < ast::expr_paren::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3052 "parser.cpp" +#line 3051 "parser.cpp" break; case 184: // expr_object: expr_call -#line 715 "parser.ypp" +#line 709 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 3058 "parser.cpp" +#line 3057 "parser.cpp" break; case 185: // expr_object: expr_method -#line 716 "parser.ypp" +#line 710 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 3064 "parser.cpp" +#line 3063 "parser.cpp" break; case 186: // expr_object: expr_array -#line 717 "parser.ypp" +#line 711 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 3070 "parser.cpp" +#line 3069 "parser.cpp" break; case 187: // expr_object: expr_field -#line 718 "parser.ypp" +#line 712 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 3076 "parser.cpp" +#line 3075 "parser.cpp" break; case 188: // expr_object: expr_game -#line 719 "parser.ypp" +#line 713 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 3082 "parser.cpp" +#line 3081 "parser.cpp" break; case 189: // expr_object: expr_self -#line 720 "parser.ypp" +#line 714 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 3088 "parser.cpp" +#line 3087 "parser.cpp" break; case 190: // expr_object: expr_anim -#line 721 "parser.ypp" +#line 715 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 3094 "parser.cpp" +#line 3093 "parser.cpp" break; case 191: // expr_object: expr_level -#line 722 "parser.ypp" +#line 716 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 3100 "parser.cpp" +#line 3099 "parser.cpp" break; case 192: // expr_object: expr_identifier -#line 723 "parser.ypp" +#line 717 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 3106 "parser.cpp" +#line 3105 "parser.cpp" break; case 193: // expr_thisthread: "thisthread" -#line 728 "parser.ypp" +#line 722 "parser.ypp" { yylhs.value.as < ast::expr_thisthread::ptr > () = std::make_unique(yylhs.location); } -#line 3112 "parser.cpp" +#line 3111 "parser.cpp" break; case 194: // expr_empty_array: "[" "]" -#line 733 "parser.ypp" +#line 727 "parser.ypp" { yylhs.value.as < ast::expr_empty_array::ptr > () = std::make_unique(yylhs.location); } -#line 3118 "parser.cpp" +#line 3117 "parser.cpp" break; case 195: // expr_undefined: "undefined" -#line 738 "parser.ypp" +#line 732 "parser.ypp" { yylhs.value.as < ast::expr_undefined::ptr > () = std::make_unique(yylhs.location); } -#line 3124 "parser.cpp" +#line 3123 "parser.cpp" break; case 196: // expr_game: "game" -#line 743 "parser.ypp" +#line 737 "parser.ypp" { yylhs.value.as < ast::expr_game::ptr > () = std::make_unique(yylhs.location); } -#line 3130 "parser.cpp" +#line 3129 "parser.cpp" break; case 197: // expr_self: "self" -#line 748 "parser.ypp" +#line 742 "parser.ypp" { yylhs.value.as < ast::expr_self::ptr > () = std::make_unique(yylhs.location); } -#line 3136 "parser.cpp" +#line 3135 "parser.cpp" break; case 198: // expr_anim: "anim" -#line 753 "parser.ypp" +#line 747 "parser.ypp" { yylhs.value.as < ast::expr_anim::ptr > () = std::make_unique(yylhs.location); } -#line 3142 "parser.cpp" +#line 3141 "parser.cpp" break; case 199: // expr_level: "level" -#line 758 "parser.ypp" +#line 752 "parser.ypp" { yylhs.value.as < ast::expr_level::ptr > () = std::make_unique(yylhs.location); } -#line 3148 "parser.cpp" +#line 3147 "parser.cpp" break; case 200: // expr_animation: "%" "identifier" -#line 763 "parser.ypp" +#line 757 "parser.ypp" { yylhs.value.as < ast::expr_animation::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3154 "parser.cpp" +#line 3153 "parser.cpp" break; case 201: // expr_animtree: "#animtree" -#line 768 "parser.ypp" +#line 762 "parser.ypp" { yylhs.value.as < ast::expr_animtree::ptr > () = std::make_unique(yylhs.location); } -#line 3160 "parser.cpp" +#line 3159 "parser.cpp" break; case 202: // expr_identifier: "identifier" -#line 773 "parser.ypp" +#line 767 "parser.ypp" { yylhs.value.as < ast::expr_identifier::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3166 "parser.cpp" +#line 3165 "parser.cpp" break; case 203: // expr_path: "path" -#line 778 "parser.ypp" +#line 772 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3172 "parser.cpp" +#line 3171 "parser.cpp" break; case 204: // expr_path: expr_identifier -#line 780 "parser.ypp" +#line 774 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < ast::expr_identifier::ptr > ()->value); } -#line 3178 "parser.cpp" +#line 3177 "parser.cpp" break; case 205: // expr_istring: "localized string" -#line 785 "parser.ypp" +#line 779 "parser.ypp" { yylhs.value.as < ast::expr_istring::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3184 "parser.cpp" +#line 3183 "parser.cpp" break; case 206: // expr_string: "string literal" -#line 790 "parser.ypp" +#line 784 "parser.ypp" { yylhs.value.as < ast::expr_string::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3190 "parser.cpp" +#line 3189 "parser.cpp" break; case 207: // expr_color: "color" -#line 795 "parser.ypp" +#line 789 "parser.ypp" { yylhs.value.as < ast::expr_color::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3196 "parser.cpp" +#line 3195 "parser.cpp" break; case 208: // expr_vector: "(" expr "," expr "," expr ")" -#line 800 "parser.ypp" +#line 794 "parser.ypp" { yylhs.value.as < ast::expr_vector::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3202 "parser.cpp" +#line 3201 "parser.cpp" break; case 209: // expr_float: "-" "float" -#line 805 "parser.ypp" +#line 799 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3208 "parser.cpp" +#line 3207 "parser.cpp" break; case 210: // expr_float: "float" -#line 807 "parser.ypp" +#line 801 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3214 "parser.cpp" +#line 3213 "parser.cpp" break; case 211: // expr_integer: "-" "integer" -#line 812 "parser.ypp" +#line 806 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3220 "parser.cpp" +#line 3219 "parser.cpp" break; case 212: // expr_integer: "integer" -#line 814 "parser.ypp" +#line 808 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3226 "parser.cpp" +#line 3225 "parser.cpp" break; case 213: // expr_false: "false" -#line 819 "parser.ypp" +#line 813 "parser.ypp" { yylhs.value.as < ast::expr_false::ptr > () = std::make_unique(yylhs.location); } -#line 3232 "parser.cpp" +#line 3231 "parser.cpp" break; case 214: // expr_true: "true" -#line 824 "parser.ypp" +#line 818 "parser.ypp" { yylhs.value.as < ast::expr_true::ptr > () = std::make_unique(yylhs.location); } -#line 3238 "parser.cpp" +#line 3237 "parser.cpp" break; -#line 3242 "parser.cpp" +#line 3241 "parser.cpp" default: break; @@ -4426,28 +4425,28 @@ namespace xsk { namespace gsc { namespace iw5 { const short parser::yyrline_[] = { - 0, 249, 249, 250, 254, 256, 258, 260, 262, 264, - 269, 273, 278, 279, 280, 281, 282, 286, 291, 296, - 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, - 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, - 321, 322, 323, 324, 325, 329, 330, 334, 335, 339, - 341, 346, 348, 350, 353, 357, 359, 364, 366, 368, - 373, 378, 380, 385, 390, 392, 397, 399, 404, 409, - 414, 419, 424, 429, 434, 436, 441, 446, 448, 453, - 458, 463, 468, 470, 475, 480, 485, 490, 491, 492, - 496, 497, 501, 503, 505, 507, 509, 511, 513, 515, - 517, 519, 521, 526, 528, 533, 535, 540, 545, 547, - 549, 551, 553, 555, 557, 559, 561, 563, 565, 567, - 569, 571, 573, 575, 577, 579, 584, 585, 586, 587, - 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, - 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, - 608, 609, 610, 611, 615, 620, 625, 626, 629, 630, - 634, 636, 638, 640, 642, 644, 649, 651, 653, 655, - 660, 665, 667, 670, 674, 677, 681, 683, 688, 690, - 695, 700, 705, 710, 715, 716, 717, 718, 719, 720, - 721, 722, 723, 727, 732, 737, 742, 747, 752, 757, - 762, 767, 772, 777, 779, 784, 789, 794, 799, 804, - 806, 811, 813, 818, 823 + 0, 243, 243, 244, 248, 250, 252, 254, 256, 258, + 263, 267, 272, 273, 274, 275, 276, 280, 285, 290, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 323, 324, 328, 329, 333, + 335, 340, 342, 344, 347, 351, 353, 358, 360, 362, + 367, 372, 374, 379, 384, 386, 391, 393, 398, 403, + 408, 413, 418, 423, 428, 430, 435, 440, 442, 447, + 452, 457, 462, 464, 469, 474, 479, 484, 485, 486, + 490, 491, 495, 497, 499, 501, 503, 505, 507, 509, + 511, 513, 515, 520, 522, 527, 529, 534, 539, 541, + 543, 545, 547, 549, 551, 553, 555, 557, 559, 561, + 563, 565, 567, 569, 571, 573, 578, 579, 580, 581, + 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, + 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, + 602, 603, 604, 605, 609, 614, 619, 620, 623, 624, + 628, 630, 632, 634, 636, 638, 643, 645, 647, 649, + 654, 659, 661, 664, 668, 671, 675, 677, 682, 684, + 689, 694, 699, 704, 709, 710, 711, 712, 713, 714, + 715, 716, 717, 721, 726, 731, 736, 741, 746, 751, + 756, 761, 766, 771, 773, 778, 783, 788, 793, 798, + 800, 805, 807, 812, 817 }; void @@ -4480,9 +4479,9 @@ namespace xsk { namespace gsc { namespace iw5 { #line 13 "parser.ypp" } } } // xsk::gsc::iw5 -#line 4484 "parser.cpp" +#line 4483 "parser.cpp" -#line 827 "parser.ypp" +#line 821 "parser.ypp" void xsk::gsc::iw5::parser::error(const xsk::gsc::location& loc, const std::string& msg) diff --git a/src/iw5/xsk/parser.hpp b/src/iw5/xsk/parser.hpp index 11f0806c..65005cf7 100644 --- a/src/iw5/xsk/parser.hpp +++ b/src/iw5/xsk/parser.hpp @@ -45,13 +45,12 @@ #ifndef YY_IW5_PARSER_HPP_INCLUDED # define YY_IW5_PARSER_HPP_INCLUDED // "%code requires" blocks. -#line 33 "parser.ypp" +#line 28 "parser.ypp" #include "iw5.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::iw5 { class lexer; } -#line 55 "parser.hpp" +#line 54 "parser.hpp" # include # include // std::abort @@ -194,7 +193,7 @@ typedef void *yyscan_t; #line 13 "parser.ypp" namespace xsk { namespace gsc { namespace iw5 { -#line 198 "parser.hpp" +#line 197 "parser.hpp" @@ -2657,7 +2656,7 @@ switch (yykind) }; /// Build a parser object. - parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); + parser (xsk::gsc::iw5::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); virtual ~parser (); #if 201103L <= YY_CPLUSPLUS @@ -4613,8 +4612,7 @@ switch (yykind) // User arguments. - yyscan_t yyscanner; - xsk::gsc::context* ctx; + xsk::gsc::iw5::lexer& lexer; xsk::gsc::ast::program::ptr& ast; }; @@ -5291,7 +5289,7 @@ switch (yykind) #line 13 "parser.ypp" } } } // xsk::gsc::iw5 -#line 5295 "parser.hpp" +#line 5293 "parser.hpp" diff --git a/src/iw5/xsk/resolver.cpp b/src/iw5/xsk/resolver.cpp index a1eb021f..e78435f9 100644 --- a/src/iw5/xsk/resolver.cpp +++ b/src/iw5/xsk/resolver.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -264,6 +264,35 @@ auto resolver::make_token(std::string_view str) -> std::string return data; } +std::function(const std::string&)> read_callback = nullptr; +std::unordered_map> files; + +auto resolver::file_data(const std::string& name) -> std::tuple +{ + const auto& itr = files.find(name); + + if(itr != files.end()) + { + return { &itr->first ,reinterpret_cast(itr->second.data()), itr->second.size() }; + } + + auto data = read_callback(name); + + const auto& res = files.insert({ name, std::move(data)}); + + if(res.second) + { + return { &res.first->first, reinterpret_cast(res.first->second.data()), res.first->second.size() }; + } + + throw error("couldn't open gsc file '" + name + "'"); +} + +void resolver::set_reader(std::function(const std::string&)> callback) +{ + read_callback = callback; +} + const std::array, 153> opcode_list {{ { 0x00, "END" }, diff --git a/src/iw5/xsk/resolver.hpp b/src/iw5/xsk/resolver.hpp index 2a95e727..b3ef441d 100644 --- a/src/iw5/xsk/resolver.hpp +++ b/src/iw5/xsk/resolver.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -33,6 +33,8 @@ public: static void add_method(const std::string& name, std::uint16_t id); static auto make_token(std::string_view str) -> std::string; + static auto file_data(const std::string& name) -> std::tuple; + static void set_reader(std::function(const std::string&)> callback); }; } // namespace xsk::gsc::iw5 diff --git a/src/iw6/stdafx.cpp b/src/iw6/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/iw6/stdafx.cpp +++ b/src/iw6/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/stdafx.hpp b/src/iw6/stdafx.hpp index 5c43f9de..195f9c93 100644 --- a/src/iw6/stdafx.hpp +++ b/src/iw6/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/xsk/assembler.cpp b/src/iw6/xsk/assembler.cpp index f23ee46b..dd906f96 100644 --- a/src/iw6/xsk/assembler.cpp +++ b/src/iw6/xsk/assembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/xsk/assembler.hpp b/src/iw6/xsk/assembler.hpp index d08fd936..c04157f3 100644 --- a/src/iw6/xsk/assembler.hpp +++ b/src/iw6/xsk/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/xsk/compiler.cpp b/src/iw6/xsk/compiler.cpp index a0cd1735..e1cdcc63 100644 --- a/src/iw6/xsk/compiler.cpp +++ b/src/iw6/xsk/compiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,7 +19,6 @@ auto compiler::output() -> std::vector void compiler::compile(const std::string& file, std::vector& data) { filename_ = file; - sources_.clear(); auto prog = parse_buffer(filename_, data); @@ -33,39 +32,19 @@ void compiler::read_callback(std::function(const std:: auto compiler::parse_buffer(const std::string& file, std::vector& data) -> ast::program::ptr { - yyscan_t scanner; - context ctx; ast::program::ptr result(nullptr); - ctx.header_top = 0; - ctx.mode = mode_; - ctx.read_callback = read_callback_; - ctx.sources = &sources_; - ctx.loc.initialize(&file); + resolver::set_reader(read_callback_); - // Add the two NULL terminators, required by flex. - data.push_back(0); - data.push_back(0); + lexer lexer(file, reinterpret_cast(data.data()), data.size()); - if (iw6_lex_init(&scanner)) - { - throw comp_error(ctx.loc, "An unknown error ocurred while starting lexer context."); - } - - ctx.scanner = scanner; - - YY_BUFFER_STATE yybuffer = iw6__scan_buffer(reinterpret_cast(data.data()), data.size(), scanner); - - parser parser(scanner, &ctx, result); + parser parser(lexer, result); if (parser.parse() || result == nullptr) { - throw comp_error(ctx.loc, "An unknown error ocurred while parsing gsc file."); + throw comp_error(xsk::gsc::location(&file), "An unknown error ocurred while parsing gsc file."); } - iw6__delete_buffer(yybuffer, scanner); - iw6_lex_destroy(scanner); - return result; } diff --git a/src/iw6/xsk/compiler.hpp b/src/iw6/xsk/compiler.hpp index d7906829..ceee6ba5 100644 --- a/src/iw6/xsk/compiler.hpp +++ b/src/iw6/xsk/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -25,7 +25,6 @@ class compiler : public gsc::compiler std::vector animtrees_; std::unordered_map constants_; std::function(const std::string&)> read_callback_; - std::vector sources_; std::vector break_blks_; std::vector continue_blks_; bool can_break_; diff --git a/src/iw6/xsk/decompiler.cpp b/src/iw6/xsk/decompiler.cpp index 9475cd8d..0875fe80 100644 --- a/src/iw6/xsk/decompiler.cpp +++ b/src/iw6/xsk/decompiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/xsk/decompiler.hpp b/src/iw6/xsk/decompiler.hpp index 3d09c52f..8330fc3a 100644 --- a/src/iw6/xsk/decompiler.hpp +++ b/src/iw6/xsk/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/xsk/disassembler.cpp b/src/iw6/xsk/disassembler.cpp index ab6a787e..6f5aa1a3 100644 --- a/src/iw6/xsk/disassembler.cpp +++ b/src/iw6/xsk/disassembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/xsk/disassembler.hpp b/src/iw6/xsk/disassembler.hpp index 80b126fa..ee980c71 100644 --- a/src/iw6/xsk/disassembler.hpp +++ b/src/iw6/xsk/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/xsk/iw6.cpp b/src/iw6/xsk/iw6.cpp index f18c10de..7a71dbf6 100644 --- a/src/iw6/xsk/iw6.cpp +++ b/src/iw6/xsk/iw6.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/xsk/iw6.hpp b/src/iw6/xsk/iw6.hpp index e27e12da..d4ced453 100644 --- a/src/iw6/xsk/iw6.hpp +++ b/src/iw6/xsk/iw6.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw6/xsk/lexer.cpp b/src/iw6/xsk/lexer.cpp index f262e5d1..36e368ad 100644 --- a/src/iw6/xsk/lexer.cpp +++ b/src/iw6/xsk/lexer.cpp @@ -1,3030 +1,986 @@ -#line 1 "lexer.cpp" -#include "stdafx.hpp" -#include "iw6.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw6_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw6_pop_header(xsk::gsc::context* ctx); - -#line 9 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define iw6__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer iw6__create_buffer -#endif - -#ifdef yy_delete_buffer -#define iw6__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer iw6__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define iw6__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer iw6__scan_buffer -#endif - -#ifdef yy_scan_string -#define iw6__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string iw6__scan_string -#endif - -#ifdef yy_scan_bytes -#define iw6__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes iw6__scan_bytes -#endif - -#ifdef yy_init_buffer -#define iw6__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer iw6__init_buffer -#endif - -#ifdef yy_flush_buffer -#define iw6__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer iw6__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define iw6__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state iw6__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define iw6__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer iw6__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define iw6_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state iw6_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define iw6_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state iw6_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define iw6_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack iw6_ensure_buffer_stack -#endif - -#ifdef yylex -#define iw6_lex_ALREADY_DEFINED -#else -#define yylex iw6_lex -#endif - -#ifdef yyrestart -#define iw6_restart_ALREADY_DEFINED -#else -#define yyrestart iw6_restart -#endif - -#ifdef yylex_init -#define iw6_lex_init_ALREADY_DEFINED -#else -#define yylex_init iw6_lex_init -#endif - -#ifdef yylex_init_extra -#define iw6_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra iw6_lex_init_extra -#endif - -#ifdef yylex_destroy -#define iw6_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy iw6_lex_destroy -#endif - -#ifdef yyget_debug -#define iw6_get_debug_ALREADY_DEFINED -#else -#define yyget_debug iw6_get_debug -#endif - -#ifdef yyset_debug -#define iw6_set_debug_ALREADY_DEFINED -#else -#define yyset_debug iw6_set_debug -#endif - -#ifdef yyget_extra -#define iw6_get_extra_ALREADY_DEFINED -#else -#define yyget_extra iw6_get_extra -#endif - -#ifdef yyset_extra -#define iw6_set_extra_ALREADY_DEFINED -#else -#define yyset_extra iw6_set_extra -#endif - -#ifdef yyget_in -#define iw6_get_in_ALREADY_DEFINED -#else -#define yyget_in iw6_get_in -#endif - -#ifdef yyset_in -#define iw6_set_in_ALREADY_DEFINED -#else -#define yyset_in iw6_set_in -#endif - -#ifdef yyget_out -#define iw6_get_out_ALREADY_DEFINED -#else -#define yyget_out iw6_get_out -#endif - -#ifdef yyset_out -#define iw6_set_out_ALREADY_DEFINED -#else -#define yyset_out iw6_set_out -#endif - -#ifdef yyget_leng -#define iw6_get_leng_ALREADY_DEFINED -#else -#define yyget_leng iw6_get_leng -#endif - -#ifdef yyget_text -#define iw6_get_text_ALREADY_DEFINED -#else -#define yyget_text iw6_get_text -#endif - -#ifdef yyget_lineno -#define iw6_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno iw6_get_lineno -#endif - -#ifdef yyset_lineno -#define iw6_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno iw6_set_lineno -#endif - -#ifdef yyget_column -#define iw6_get_column_ALREADY_DEFINED -#else -#define yyget_column iw6_get_column -#endif - -#ifdef yyset_column -#define iw6_set_column_ALREADY_DEFINED -#else -#define yyset_column iw6_set_column -#endif - -#ifdef yywrap -#define iw6_wrap_ALREADY_DEFINED -#else -#define yywrap iw6_wrap -#endif - -#ifdef yyalloc -#define iw6_alloc_ALREADY_DEFINED -#else -#define yyalloc iw6_alloc -#endif - -#ifdef yyrealloc -#define iw6_realloc_ALREADY_DEFINED -#else -#define yyrealloc iw6_realloc -#endif - -#ifdef yyfree -#define iw6_free_ALREADY_DEFINED -#else -#define yyfree iw6_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin , yyscanner ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define iw6_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); -static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 111 -#define YY_END_OF_BUFFER 112 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[328] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 112, 110, - 1, 2, 94, 110, 110, 93, 97, 110, 54, 55, - 91, 89, 60, 90, 61, 92, 109, 109, 63, 64, - 78, 88, 79, 65, 100, 58, 59, 98, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, - 100, 100, 100, 100, 56, 96, 57, 95, 5, 6, - 5, 12, 13, 12, 110, 91, 92, 75, 0, 102, - 0, 15, 0, 0, 0, 0, 84, 0, 73, 0, - 86, 0, 0, 8, 82, 66, 80, 67, 81, 105, - 0, 11, 4, 3, 83, 105, 109, 106, 0, 0, - - 0, 0, 62, 70, 76, 74, 77, 71, 100, 87, - 100, 100, 100, 100, 100, 100, 28, 100, 100, 100, - 100, 100, 26, 32, 100, 100, 100, 100, 100, 100, - 100, 100, 100, 100, 100, 85, 72, 7, 14, 10, - 9, 0, 102, 0, 0, 0, 0, 0, 0, 101, - 0, 0, 0, 0, 102, 0, 105, 0, 3, 105, - 105, 106, 107, 108, 99, 68, 69, 100, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 30, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, - 100, 103, 0, 0, 0, 0, 0, 101, 0, 0, - - 101, 0, 0, 52, 100, 45, 34, 100, 100, 100, - 27, 100, 100, 100, 50, 100, 100, 100, 100, 51, - 100, 100, 100, 46, 100, 22, 100, 0, 0, 0, - 0, 0, 49, 36, 100, 100, 100, 20, 47, 100, - 53, 100, 100, 100, 100, 100, 100, 100, 100, 29, - 0, 0, 0, 0, 0, 100, 100, 100, 100, 100, - 21, 100, 100, 38, 33, 100, 42, 100, 100, 104, - 0, 0, 16, 0, 100, 100, 100, 35, 31, 100, - 100, 100, 100, 100, 0, 17, 0, 100, 100, 37, - 100, 41, 100, 100, 23, 19, 0, 100, 100, 100, - - 100, 48, 100, 100, 0, 39, 100, 40, 44, 100, - 100, 0, 43, 100, 100, 0, 100, 100, 0, 100, - 24, 0, 100, 18, 100, 25, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, - 25, 26, 27, 1, 28, 29, 28, 28, 28, 28, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 31, 30, 30, - 32, 33, 34, 35, 36, 1, 37, 38, 39, 40, - - 41, 42, 43, 44, 45, 30, 46, 47, 48, 49, - 50, 51, 30, 52, 53, 54, 55, 56, 57, 31, - 58, 59, 60, 61, 62, 63, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[64] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 5, 5, 5, - 5, 1, 1, 1, 1, 1, 1, 5, 5, 6, - 6, 1, 7, 1, 1, 6, 5, 5, 5, 5, - 5, 5, 6, 6, 8, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 8, 6, 6, 6, 6, 1, - 1, 1, 1 - } ; - -static const flex_int16_t yy_base[348] = - { 0, - 0, 0, 61, 62, 63, 64, 65, 66, 702, 703, - 703, 703, 676, 63, 58, 675, 76, 67, 703, 703, - 62, 67, 703, 73, 86, 85, 96, 102, 677, 703, - 65, 673, 68, 703, 664, 703, 703, 671, 75, 76, - 93, 99, 98, 105, 111, 108, 78, 103, 100, 113, - 118, 125, 123, 127, 703, 136, 703, 703, 703, 703, - 678, 703, 703, 677, 145, 668, 161, 703, 158, 703, - 163, 703, 0, 643, 642, 637, 703, 160, 703, 161, - 703, 165, 176, 703, 703, 703, 703, 703, 703, 183, - 644, 703, 703, 0, 703, 187, 194, 200, 195, 216, - - 234, 0, 703, 663, 703, 703, 703, 662, 653, 703, - 143, 148, 184, 147, 150, 197, 652, 189, 203, 191, - 193, 208, 651, 650, 190, 207, 214, 211, 233, 215, - 225, 224, 245, 236, 249, 703, 703, 703, 703, 703, - 703, 254, 263, 281, 0, 637, 148, 636, 278, 703, - 285, 280, 288, 283, 284, 292, 703, 621, 0, 284, - 703, 311, 290, 0, 646, 703, 703, 267, 287, 265, - 266, 286, 289, 301, 295, 302, 304, 306, 307, 308, - 309, 313, 312, 317, 318, 320, 323, 325, 327, 328, - 329, 0, 630, 630, 631, 626, 358, 360, 366, 361, - - 365, 372, 633, 640, 53, 639, 638, 344, 345, 346, - 637, 347, 354, 352, 636, 350, 367, 370, 355, 635, - 353, 369, 371, 634, 377, 378, 379, 0, 612, 610, - 615, 620, 703, 380, 381, 384, 382, 629, 628, 383, - 627, 385, 401, 388, 392, 394, 407, 408, 411, 626, - 0, 606, 617, 615, 619, 395, 413, 393, 397, 416, - 621, 417, 419, 620, 619, 421, 618, 422, 428, 703, - 609, 608, 703, 611, 429, 426, 431, 614, 613, 433, - 430, 436, 446, 434, 604, 703, 595, 447, 449, 610, - 450, 609, 451, 452, 456, 703, 596, 432, 460, 458, - - 461, 607, 466, 469, 591, 588, 470, 579, 537, 472, - 467, 505, 525, 475, 478, 478, 479, 480, 488, 481, - 495, 486, 482, 703, 486, 492, 703, 531, 539, 547, - 552, 560, 566, 570, 578, 511, 586, 594, 602, 610, - 614, 419, 622, 630, 305, 246, 179 - } ; - -static const flex_int16_t yy_def[348] = - { 0, - 327, 1, 328, 328, 329, 329, 1, 1, 327, 327, - 327, 327, 327, 330, 331, 327, 327, 332, 327, 327, - 327, 327, 327, 327, 327, 327, 333, 333, 327, 327, - 327, 327, 327, 327, 334, 327, 327, 327, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 331, 327, 327, 327, 330, 327, - 335, 327, 336, 336, 327, 327, 327, 337, 327, 338, - 327, 332, 339, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 340, 327, 327, 333, 333, 333, 333, - - 333, 341, 327, 327, 327, 327, 327, 327, 334, 327, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 327, 327, 327, 327, 327, - 327, 330, 330, 335, 342, 327, 327, 327, 337, 327, - 343, 338, 344, 332, 332, 339, 327, 327, 340, 327, - 327, 333, 333, 101, 341, 327, 327, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 345, 327, 327, 327, 327, 337, 337, 343, 338, - - 338, 344, 327, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 346, 327, 327, - 327, 327, 327, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 347, 327, 327, 327, 327, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 327, - 327, 327, 327, 327, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 327, 327, 327, 334, 334, 334, - 334, 334, 334, 334, 334, 327, 327, 334, 334, 334, - - 334, 334, 334, 334, 327, 334, 334, 334, 334, 334, - 334, 327, 334, 334, 334, 327, 334, 334, 327, 334, - 334, 327, 334, 327, 334, 334, 0, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327 - } ; - -static const flex_int16_t yy_nxt[767] = - { 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, - 28, 29, 30, 31, 32, 33, 34, 35, 35, 35, - 35, 36, 10, 37, 38, 35, 39, 40, 41, 42, - 43, 44, 45, 35, 46, 35, 47, 35, 48, 35, - 49, 50, 51, 52, 53, 35, 54, 35, 35, 55, - 56, 57, 58, 60, 60, 63, 63, 70, 64, 64, - 65, 65, 61, 61, 72, 70, 66, 66, 84, 86, - 78, 67, 67, 79, 80, 102, 85, 88, 104, 105, - 92, 87, 107, 108, 74, 71, 93, 89, 234, 83, - - 81, 94, 75, 90, 90, 90, 90, 102, 102, 95, - 102, 96, 76, 97, 98, 98, 97, 96, 125, 97, - 97, 97, 97, 111, 100, 102, 101, 112, 102, 113, - 102, 102, 102, 100, 102, 102, 114, 102, 91, 116, - 102, 120, 115, 102, 118, 102, 119, 122, 117, 123, - 102, 127, 126, 128, 121, 102, 124, 102, 129, 102, - 136, 140, 70, 134, 150, 69, 141, 143, 131, 150, - 135, 133, 93, 70, 130, 102, 132, 94, 82, 102, - 102, 74, 102, 270, 155, 95, 194, 168, 169, 75, - 71, 172, 151, 153, 195, 144, 137, 83, 173, 76, - - 90, 90, 90, 90, 160, 160, 160, 160, 156, 96, - 327, 97, 97, 97, 97, 96, 102, 162, 162, 162, - 97, 102, 102, 102, 157, 102, 102, 102, 161, 102, - 170, 327, 102, 163, 163, 102, 171, 177, 174, 102, - 102, 175, 176, 102, 178, 180, 102, 102, 102, 327, - 251, 164, 164, 164, 164, 179, 102, 102, 70, 185, - 181, 164, 164, 182, 183, 102, 102, 70, 102, 186, - 164, 164, 164, 164, 164, 164, 187, 102, 188, 184, - 190, 102, 150, 69, 189, 143, 71, 149, 150, 198, - 152, 70, 70, 191, 82, 71, 201, 102, 102, 102, - - 155, 160, 160, 160, 160, 327, 207, 163, 163, 228, - 151, 206, 153, 144, 204, 83, 83, 199, 102, 102, - 202, 102, 102, 205, 156, 161, 96, 102, 162, 162, - 162, 97, 208, 102, 102, 211, 102, 210, 102, 102, - 102, 102, 209, 102, 102, 102, 214, 215, 216, 102, - 102, 212, 102, 217, 218, 102, 213, 102, 220, 102, - 102, 102, 150, 223, 150, 224, 219, 225, 149, 150, - 198, 221, 222, 150, 152, 227, 102, 102, 102, 102, - 201, 226, 102, 235, 102, 102, 102, 102, 240, 236, - 151, 245, 151, 153, 239, 238, 241, 153, 199, 102, - - 237, 102, 102, 102, 202, 243, 244, 247, 242, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 248, 250, - 102, 260, 246, 192, 102, 102, 102, 102, 259, 102, - 256, 249, 258, 102, 257, 265, 264, 266, 262, 102, - 102, 263, 261, 102, 275, 102, 267, 277, 102, 102, - 278, 102, 268, 102, 102, 269, 276, 280, 102, 279, - 102, 102, 102, 102, 102, 102, 102, 281, 102, 292, - 283, 290, 282, 288, 284, 291, 293, 289, 102, 102, - 295, 102, 102, 102, 102, 306, 294, 301, 102, 299, - 102, 302, 102, 102, 300, 298, 307, 303, 102, 102, - - 309, 102, 102, 304, 102, 311, 308, 102, 314, 313, - 102, 102, 102, 102, 102, 145, 318, 310, 102, 320, - 315, 323, 317, 321, 102, 326, 324, 102, 322, 319, - 325, 59, 59, 59, 59, 59, 59, 59, 59, 62, - 62, 62, 62, 62, 62, 62, 62, 69, 69, 69, - 69, 69, 69, 69, 69, 73, 73, 102, 316, 73, - 82, 82, 82, 82, 82, 82, 82, 82, 99, 102, - 99, 99, 99, 99, 109, 109, 109, 109, 142, 142, - 142, 142, 142, 142, 142, 142, 149, 149, 149, 149, - 149, 149, 149, 149, 152, 152, 152, 152, 152, 152, - - 152, 152, 154, 154, 154, 154, 154, 154, 154, 154, - 159, 102, 159, 159, 159, 159, 159, 159, 165, 165, - 102, 165, 197, 197, 197, 197, 197, 197, 197, 197, - 200, 200, 200, 200, 200, 200, 200, 200, 312, 102, - 305, 102, 102, 297, 296, 102, 102, 287, 286, 285, - 102, 102, 102, 102, 274, 273, 272, 271, 102, 102, - 102, 102, 255, 254, 253, 252, 102, 102, 102, 102, - 102, 102, 102, 233, 232, 231, 230, 229, 102, 203, - 196, 193, 102, 102, 102, 102, 167, 166, 158, 148, - 147, 146, 85, 139, 138, 110, 102, 106, 103, 77, - - 68, 327, 9, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327 - } ; - -static const flex_int16_t yy_chk[767] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 5, 6, 14, 5, 6, - 7, 8, 3, 4, 15, 18, 7, 8, 21, 22, - 17, 7, 8, 17, 17, 205, 21, 24, 31, 31, - 26, 22, 33, 33, 15, 14, 26, 24, 205, 18, - - 17, 26, 15, 25, 25, 25, 25, 39, 40, 26, - 47, 27, 15, 27, 27, 27, 27, 28, 47, 28, - 28, 28, 28, 39, 27, 41, 27, 40, 27, 41, - 43, 42, 49, 27, 28, 48, 41, 44, 25, 42, - 46, 44, 41, 45, 43, 50, 43, 45, 42, 46, - 51, 49, 48, 50, 44, 53, 46, 52, 51, 54, - 56, 65, 69, 54, 78, 71, 67, 71, 52, 80, - 54, 53, 67, 82, 51, 111, 52, 67, 83, 114, - 112, 65, 115, 347, 83, 67, 147, 111, 112, 65, - 69, 114, 78, 80, 147, 71, 56, 82, 115, 65, - - 90, 90, 90, 90, 96, 96, 96, 96, 83, 97, - 99, 97, 97, 97, 97, 98, 113, 98, 98, 98, - 98, 118, 125, 120, 90, 121, 97, 99, 96, 116, - 113, 100, 98, 100, 100, 119, 113, 120, 116, 126, - 122, 118, 119, 128, 121, 125, 127, 130, 100, 101, - 346, 101, 101, 101, 101, 122, 132, 131, 142, 130, - 126, 101, 101, 127, 128, 129, 101, 143, 134, 131, - 101, 101, 101, 101, 101, 101, 131, 133, 132, 129, - 134, 135, 149, 144, 133, 144, 142, 151, 152, 151, - 153, 154, 155, 135, 156, 143, 153, 170, 171, 168, - - 156, 160, 160, 160, 160, 163, 171, 163, 163, 345, - 149, 170, 152, 144, 168, 154, 155, 151, 172, 169, - 153, 173, 163, 169, 156, 160, 162, 175, 162, 162, - 162, 162, 172, 174, 176, 175, 177, 174, 178, 179, - 180, 181, 173, 162, 183, 182, 178, 179, 180, 184, - 185, 176, 186, 181, 182, 187, 177, 188, 184, 189, - 190, 191, 197, 187, 198, 188, 183, 189, 199, 200, - 199, 185, 186, 201, 202, 191, 208, 209, 210, 212, - 202, 190, 216, 208, 214, 221, 213, 219, 214, 209, - 197, 221, 198, 200, 213, 212, 216, 201, 199, 217, - - 210, 222, 218, 223, 202, 218, 219, 223, 217, 225, - 226, 227, 234, 235, 237, 240, 236, 242, 225, 227, - 244, 240, 222, 342, 245, 258, 246, 256, 237, 259, - 234, 226, 236, 243, 235, 245, 244, 246, 243, 247, - 248, 243, 242, 249, 256, 257, 247, 258, 260, 262, - 259, 263, 248, 266, 268, 249, 257, 262, 276, 260, - 269, 275, 281, 277, 298, 280, 284, 263, 282, 281, - 268, 277, 266, 275, 269, 280, 282, 276, 283, 288, - 284, 289, 291, 293, 294, 298, 283, 293, 295, 289, - 300, 294, 299, 301, 291, 288, 299, 295, 303, 311, - - 301, 304, 307, 295, 310, 304, 300, 314, 310, 307, - 315, 317, 318, 320, 323, 336, 315, 303, 325, 317, - 311, 320, 314, 318, 326, 325, 322, 321, 319, 316, - 323, 328, 328, 328, 328, 328, 328, 328, 328, 329, - 329, 329, 329, 329, 329, 329, 329, 330, 330, 330, - 330, 330, 330, 330, 330, 331, 331, 313, 312, 331, - 332, 332, 332, 332, 332, 332, 332, 332, 333, 309, - 333, 333, 333, 333, 334, 334, 334, 334, 335, 335, - 335, 335, 335, 335, 335, 335, 337, 337, 337, 337, - 337, 337, 337, 337, 338, 338, 338, 338, 338, 338, - - 338, 338, 339, 339, 339, 339, 339, 339, 339, 339, - 340, 308, 340, 340, 340, 340, 340, 340, 341, 341, - 306, 341, 343, 343, 343, 343, 343, 343, 343, 343, - 344, 344, 344, 344, 344, 344, 344, 344, 305, 302, - 297, 292, 290, 287, 285, 279, 278, 274, 272, 271, - 267, 265, 264, 261, 255, 254, 253, 252, 250, 241, - 239, 238, 232, 231, 230, 229, 224, 220, 215, 211, - 207, 206, 204, 203, 196, 195, 194, 193, 165, 158, - 148, 146, 124, 123, 117, 109, 108, 104, 91, 76, - 75, 74, 66, 64, 61, 38, 35, 32, 29, 16, - - 13, 9, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.lpp" -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ -#define YY_NO_INPUT 1 -#define YY_NO_UNISTD_H 1 - -#line 25 "lexer.lpp" -#define YY_USER_ACTION ctx->loc.columns(yyleng); -#line 928 "lexer.cpp" - -#line 930 "lexer.cpp" - -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#include "stdafx.hpp" +#include "iw6.hpp" +#include "parser.hpp" +#include "lexer.hpp" + +xsk::gsc::iw6::parser::symbol_type IW6lex(xsk::gsc::iw6::lexer& lexer) +{ + return lexer.lex(); +} + +namespace xsk::gsc::iw6 +{ + +enum class keyword +{ +/* KW_pre_define, + KW_pre_undef, + KW_pre_ifdef, + KW_pre_ifndef, + KW_pre_if, + KW_pre_elif, + KW_pre_else, + KW_pre_endif,*/ + KW_pre_inline, + KW_pre_include, + KW_pre_using_animtree, + KW_pre_animtree, + KW_endon, + KW_notify, + KW_wait, + KW_waittill, + KW_waittillmatch, + KW_waittillframeend, + KW_if, + KW_else, + KW_do, + KW_while, + KW_for, + KW_foreach, + KW_in, + KW_switch, + KW_case, + KW_default, + KW_break, + KW_continue, + KW_return, + KW_breakpoint, + KW_prof_begin, + KW_prof_end, + KW_thread, + KW_childthread, + KW_thisthread, + KW_call, + KW_true, + KW_false, + KW_undefined, + KW_dotsize, + KW_game, + KW_self, + KW_anim, + KW_level, + KW_INVALID, +}; + +buffer::buffer() : size(1024), length(0) +{ + data = static_cast(std::malloc(size)); +} + +buffer::~buffer() +{ + if(data) std::free(data); +} + +bool buffer::push(char c) +{ + if(length >= size) { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals ( yyscan_t yyscanner ); - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef YY_NO_UNPUT - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( yyscan_t yyscanner ); -#else -static int input ( yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_load_buffer_state( yyscanner ); - } - - { -#line 44 "lexer.lpp" - - - -#line 48 "lexer.lpp" - ctx->loc.step(); - - -#line 1199 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 328 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 327 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 51 "lexer.lpp" -{ ctx->loc.step(); } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 52 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 54 "lexer.lpp" - - YY_BREAK -case 4: -YY_RULE_SETUP -#line 56 "lexer.lpp" -{ BEGIN(COMMENT_STATE); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 57 "lexer.lpp" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 58 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(COMMENT_STATE): -#line 60 "lexer.lpp" -{ throw iw6::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "lexer.lpp" -{ throw iw6::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 63 "lexer.lpp" -{ throw iw6::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 64 "lexer.lpp" -{ BEGIN(INITIAL); return iw6::parser::make_DEVEND(ctx->loc); } - YY_BREAK -case YY_STATE_EOF(DEV_ON_STATE): -#line 65 "lexer.lpp" -{ throw iw6::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 67 "lexer.lpp" -{ BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return iw6::parser::make_DEVBEGIN(ctx->loc); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 68 "lexer.lpp" - - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 69 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 70 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(DEV_OFF_STATE): -#line 71 "lexer.lpp" -{ throw iw6::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.lpp" -{ throw iw6::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 74 "lexer.lpp" -{ return iw6::parser::make_INLINE(ctx->loc); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 75 "lexer.lpp" -{ return iw6::parser::make_INCLUDE(ctx->loc); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 76 "lexer.lpp" -{ return iw6::parser::make_USINGTREE(ctx->loc); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 77 "lexer.lpp" -{ return iw6::parser::make_ANIMTREE(ctx->loc); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 78 "lexer.lpp" -{ return iw6::parser::make_ENDON(ctx->loc); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 79 "lexer.lpp" -{ return iw6::parser::make_NOTIFY(ctx->loc); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 80 "lexer.lpp" -{ return iw6::parser::make_WAIT(ctx->loc); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 81 "lexer.lpp" -{ return iw6::parser::make_WAITTILL(ctx->loc); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 82 "lexer.lpp" -{ return iw6::parser::make_WAITTILLMATCH(ctx->loc); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 83 "lexer.lpp" -{ return iw6::parser::make_WAITTILLFRAMEEND(ctx->loc); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 84 "lexer.lpp" -{ return iw6::parser::make_IF(ctx->loc); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 85 "lexer.lpp" -{ return iw6::parser::make_ELSE(ctx->loc); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 86 "lexer.lpp" -{ return iw6::parser::make_DO(ctx->loc); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 87 "lexer.lpp" -{ return iw6::parser::make_WHILE(ctx->loc); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 88 "lexer.lpp" -{ return iw6::parser::make_FOR(ctx->loc); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 89 "lexer.lpp" -{ return iw6::parser::make_FOREACH(ctx->loc); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 90 "lexer.lpp" -{ return iw6::parser::make_IN(ctx->loc); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 91 "lexer.lpp" -{ return iw6::parser::make_SWITCH(ctx->loc); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 92 "lexer.lpp" -{ return iw6::parser::make_CASE(ctx->loc); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 93 "lexer.lpp" -{ return iw6::parser::make_DEFAULT(ctx->loc); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 94 "lexer.lpp" -{ return iw6::parser::make_BREAK(ctx->loc); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 95 "lexer.lpp" -{ return iw6::parser::make_CONTINUE(ctx->loc); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 96 "lexer.lpp" -{ return iw6::parser::make_RETURN(ctx->loc); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 97 "lexer.lpp" -{ return iw6::parser::make_BREAKPOINT(ctx->loc); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 98 "lexer.lpp" -{ return iw6::parser::make_PROFBEGIN(ctx->loc); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 99 "lexer.lpp" -{ return iw6::parser::make_PROFEND(ctx->loc); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 100 "lexer.lpp" -{ return iw6::parser::make_THREAD(ctx->loc); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 101 "lexer.lpp" -{ return iw6::parser::make_CHILDTHREAD(ctx->loc); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 102 "lexer.lpp" -{ return iw6::parser::make_THISTHREAD(ctx->loc); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 103 "lexer.lpp" -{ return iw6::parser::make_CALL(ctx->loc); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 104 "lexer.lpp" -{ return iw6::parser::make_TRUE(ctx->loc); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 105 "lexer.lpp" -{ return iw6::parser::make_FALSE(ctx->loc); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 106 "lexer.lpp" -{ return iw6::parser::make_UNDEFINED(ctx->loc); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 107 "lexer.lpp" -{ return iw6::parser::make_SIZE(ctx->loc); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 108 "lexer.lpp" -{ return iw6::parser::make_GAME(ctx->loc); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 109 "lexer.lpp" -{ return iw6::parser::make_SELF(ctx->loc); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 110 "lexer.lpp" -{ return iw6::parser::make_ANIM(ctx->loc); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 111 "lexer.lpp" -{ return iw6::parser::make_LEVEL(ctx->loc); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 112 "lexer.lpp" -{ return iw6::parser::make_LPAREN(ctx->loc); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 113 "lexer.lpp" -{ return iw6::parser::make_RPAREN(ctx->loc); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 114 "lexer.lpp" -{ return iw6::parser::make_LBRACE(ctx->loc); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 115 "lexer.lpp" -{ return iw6::parser::make_RBRACE(ctx->loc); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 116 "lexer.lpp" -{ return iw6::parser::make_LBRACKET(ctx->loc); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 117 "lexer.lpp" -{ return iw6::parser::make_RBRACKET(ctx->loc); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 118 "lexer.lpp" -{ return iw6::parser::make_COMMA(ctx->loc); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 119 "lexer.lpp" -{ return iw6::parser::make_DOT(ctx->loc); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 120 "lexer.lpp" -{ return iw6::parser::make_DOUBLECOLON(ctx->loc); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 121 "lexer.lpp" -{ return iw6::parser::make_COLON(ctx->loc); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 122 "lexer.lpp" -{ return iw6::parser::make_SEMICOLON(ctx->loc); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 123 "lexer.lpp" -{ return iw6::parser::make_QMARK(ctx->loc); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 124 "lexer.lpp" -{ return iw6::parser::make_INCREMENT(ctx->loc); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 125 "lexer.lpp" -{ return iw6::parser::make_DECREMENT(ctx->loc); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 126 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_LSHIFT(ctx->loc); } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 127 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_RSHIFT(ctx->loc); } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 128 "lexer.lpp" -{ return iw6::parser::make_LSHIFT(ctx->loc); } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 129 "lexer.lpp" -{ return iw6::parser::make_RSHIFT(ctx->loc); } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 130 "lexer.lpp" -{ return iw6::parser::make_OR(ctx->loc); } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 131 "lexer.lpp" -{ return iw6::parser::make_AND(ctx->loc); } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 132 "lexer.lpp" -{ return iw6::parser::make_EQUALITY(ctx->loc); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 133 "lexer.lpp" -{ return iw6::parser::make_INEQUALITY(ctx->loc); } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 134 "lexer.lpp" -{ return iw6::parser::make_LESS_EQUAL(ctx->loc); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 135 "lexer.lpp" -{ return iw6::parser::make_GREATER_EQUAL(ctx->loc); } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 136 "lexer.lpp" -{ return iw6::parser::make_LESS(ctx->loc); } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 137 "lexer.lpp" -{ return iw6::parser::make_GREATER(ctx->loc); } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 138 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_ADD(ctx->loc); } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 139 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_SUB(ctx->loc); } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 140 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_MUL(ctx->loc); } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 141 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_DIV(ctx->loc); } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 142 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_MOD(ctx->loc); } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 143 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_BW_OR(ctx->loc); } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 144 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_BW_AND(ctx->loc); } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 145 "lexer.lpp" -{ return iw6::parser::make_ASSIGN_BW_EXOR(ctx->loc); } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 146 "lexer.lpp" -{ return iw6::parser::make_ASSIGN(ctx->loc); } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 147 "lexer.lpp" -{ return iw6::parser::make_ADD(ctx->loc); } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 148 "lexer.lpp" -{ return iw6::parser::make_SUB(ctx->loc); } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 149 "lexer.lpp" -{ return iw6::parser::make_MUL(ctx->loc); } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 150 "lexer.lpp" -{ return iw6::parser::make_DIV(ctx->loc); } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 151 "lexer.lpp" -{ return iw6::parser::make_MOD(ctx->loc); } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 152 "lexer.lpp" -{ return iw6::parser::make_NOT(ctx->loc); } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 153 "lexer.lpp" -{ return iw6::parser::make_COMPLEMENT(ctx->loc); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 154 "lexer.lpp" -{ return iw6::parser::make_BITWISE_OR(ctx->loc); } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 155 "lexer.lpp" -{ return iw6::parser::make_BITWISE_AND(ctx->loc); } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 156 "lexer.lpp" -{ return iw6::parser::make_BITWISE_EXOR(ctx->loc); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 157 "lexer.lpp" -{ return iw6::parser::make_PATH(xsk::gsc::iw6::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 158 "lexer.lpp" -{ return iw6::parser::make_IDENTIFIER(xsk::gsc::iw6::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 101: -/* rule 101 can match eol */ -YY_RULE_SETUP -#line 159 "lexer.lpp" -{ return iw6::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 102: -/* rule 102 can match eol */ -YY_RULE_SETUP -#line 160 "lexer.lpp" -{ return iw6::parser::make_STRING(std::string(yytext), ctx->loc); } - YY_BREAK -case 103: -YY_RULE_SETUP -#line 161 "lexer.lpp" -{ return iw6::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 104: -YY_RULE_SETUP -#line 162 "lexer.lpp" -{ return iw6::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 105: -YY_RULE_SETUP -#line 163 "lexer.lpp" -{ return iw6::parser::make_FLOAT(std::string(yytext), ctx->loc); } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 164 "lexer.lpp" -{ return iw6::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 165 "lexer.lpp" -{ return iw6::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 166 "lexer.lpp" -{ return iw6::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 167 "lexer.lpp" -{ return iw6::parser::make_INTEGER(std::string(yytext), ctx->loc); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 168 "lexer.lpp" -{ if(ctx->header_top > 0) iw6_pop_header(ctx); else return iw6::parser::make_IW6EOF(ctx->loc); } - YY_BREAK -case 110: -/* rule 110 can match eol */ -YY_RULE_SETUP -#line 169 "lexer.lpp" -{ throw iw6::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - YY_BREAK -case 111: -YY_RULE_SETUP -#line 171 "lexer.lpp" -ECHO; - YY_BREAK -#line 1829 "lexer.cpp" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap( yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin , yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + auto nsize = size * 2; + auto ndata = reinterpret_cast(std::malloc(nsize)); + + if(!ndata) return false; + + std::memmove(ndata, data, size); + std::free(data); + size = nsize; + data = ndata; + } + data[length++] = c; + return true; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 328 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; } -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +void reader::init(const char* data, size_t size) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 328 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 327); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + if(data && size) + { + state = reader::ok; + buffer_pos = data; + bytes_remaining = size; + last_byte = 0; + current_byte = *data; + } + else + { + state = reader::end; + buffer_pos = 0; + bytes_remaining = 0; + last_byte = 0; + current_byte = 0; + } } -#ifndef YY_NO_UNPUT - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - +void reader::advance() { - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + ++buffer_pos; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin , yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); - yy_load_buffer_state( yyscanner ); + if(bytes_remaining-- == 1) + { + state = reader::end; + bytes_remaining = 0; + last_byte = current_byte; + current_byte = 0; + } + else + { + last_byte = current_byte; + current_byte = *buffer_pos; + } } -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +lexer::lexer(const std::string& name, const char* data, size_t size) : in_dev_state_(false), loc_(xsk::gsc::location(&name)), + mode_(build::dev), header_top_(0), locs_(std::stack()), readers_(std::stack()) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + reader_.init(data, size); } -static void yy_load_buffer_state (yyscan_t yyscanner) +void lexer::push_header(const std::string& file) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + try + { + if (header_top_++ >= 10) + throw xsk::gsc::error("maximum gsh depth exceeded '10'"); + + auto data = resolver::file_data(file + ".gsh"); + + readers_.push(reader_); + locs_.push(loc_); + loc_.initialize(std::get<0>(data)); + reader_.init(std::get<1>(data), std::get<2>(data)); + } + catch (const std::exception& e) + { + throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); + } } -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +void lexer::pop_header() { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file , yyscanner); - - return b; + header_top_--; + loc_ = locs_.top(); + locs_.pop(); + reader_ = readers_.top(); + readers_.pop(); } -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void lexer::restrict_header(const xsk::gsc::location& loc) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf , yyscanner ); - - yyfree( (void *) b , yyscanner ); + if (header_top_ > 0) + { + throw comp_error(loc, "not allowed inside a gsh file"); + } } -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - +auto lexer::lex() -> xsk::gsc::iw6::parser::symbol_type { - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + buffer_.length = 0; + loc_.step(); - yy_flush_buffer( b , yyscanner); + while (true) + { + if (reader_.state == reader::end) + { + if (in_dev_state_) + throw iw6::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + if(header_top_ > 0) + pop_header(); + else + return iw6::parser::make_IW6EOF(loc_); + } - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + reader_.advance(); + auto& last = reader_.last_byte; + auto& curr = reader_.current_byte; + + switch (last) + { + case ' ': + case '\t': + case '\r': + loc_.step(); + continue; + case '\n': + loc_.lines(); + loc_.step(); + continue; + case '/': + if(reader_.state == reader::end || (curr != '/' && curr != '*' && curr != '#' && curr != '=')) + return iw6::parser::make_DIV(loc_); + + reader_.advance(); + + if (last == '=') + return iw6::parser::make_ASSIGN_DIV(loc_); + + if (last == '#') + { + if (in_dev_state_) + { + throw iw6::parser::syntax_error(loc_, "cannot recurse devblock ('/#')"); + } + else if (mode_ == xsk::gsc::build::dev) + { + in_dev_state_ = true; + return iw6::parser::make_DEVBEGIN(loc_); + } + else + { + while (true) + { + if (reader_.state == reader::end) + { + throw iw6::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '#' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + } + else if (last == '*') + { + while (true) + { + if (reader_.state == reader::end) + { + throw iw6::parser::syntax_error(loc_, "unmatched multiline comment start ('/*')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '*' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + else if (last == '/') + { + while (true) + { + if (reader_.state == reader::end || curr == '\n') + break; + + reader_.advance(); + } + } + continue; + case '#': + if (curr == '/') + { + if (!in_dev_state_) + throw iw6::parser::syntax_error(loc_, "unmatched devblock end ('#/')"); + + in_dev_state_ = false; + reader_.advance(); + return iw6::parser::make_DEVEND(loc_); + } + + buffer_.push(last); + while (reader_.state == reader::ok) + { + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + { + if (auto len = buffer_.length; len == 4 || len == 7) + { + auto data = buffer_.data; + auto color = true; + for (auto i = 1; i < len; i++) + { + if ((data[i] < 48 || data[i] > 57) && (data[i] < 65 || data[i] > 70) && (data[i] < 97 || data[i] > 102)) + { + color = false; + break; + } + } + + if (color) return iw6::parser::make_COLOR(std::string(++data, --len), loc_); + } + + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); + + if (key == keyword::KW_INVALID) + throw iw6::parser::syntax_error(loc_, utils::string::va("unknown preprocessor directive ('%s')", "#")); + + if (keyword_is_token(key)) + return keyword_token(key); + + // call preprocessor(key); + } + continue; + case '*': + if (reader_.state == reader::end || (curr != '/' && curr != '=')) + return iw6::parser::make_MUL(loc_); + + reader_.advance(); + + if (curr == '/') + throw iw6::parser::syntax_error(loc_, "unmatched multiline comment end ('*/')"); + + return iw6::parser::make_ASSIGN_MUL(loc_); + case '"': + case '\'': + return read_string(last, false); + case '.': + return read_dotsize(); + case '(': + return iw6::parser::make_LPAREN(loc_); + case ')': + return iw6::parser::make_RPAREN(loc_); + case '{': + return iw6::parser::make_LBRACE(loc_); + case '}': + return iw6::parser::make_RBRACE(loc_); + case '[': + return iw6::parser::make_LBRACKET(loc_); + case ']': + return iw6::parser::make_RBRACKET(loc_); + case ',': + return iw6::parser::make_COMMA(loc_); + case ';': + return iw6::parser::make_SEMICOLON(loc_); + case ':': + if (curr != ':') + return iw6::parser::make_COLON(loc_); + reader_.advance(); + return iw6::parser::make_DOUBLECOLON(loc_); + case '?': + return iw6::parser::make_QMARK(loc_); + case '=': + if (curr != '=') + return iw6::parser::make_ASSIGN(loc_); + reader_.advance(); + return iw6::parser::make_EQUALITY(loc_); + case '+': + if (curr != '+' && curr != '=') + return iw6::parser::make_ADD(loc_); + reader_.advance(); + return (last == '+') ? iw6::parser::make_INCREMENT(loc_) : iw6::parser::make_ASSIGN_ADD(loc_); + case '-': + if (curr != '-' && curr != '=') + return iw6::parser::make_SUB(loc_); + reader_.advance(); + return (last == '-') ? iw6::parser::make_DECREMENT(loc_) : iw6::parser::make_ASSIGN_SUB(loc_); + case '%': + if (curr != '=') + return iw6::parser::make_MOD(loc_); + reader_.advance(); + return iw6::parser::make_ASSIGN_MOD(loc_); + case '|': + if (curr != '|' && curr != '=') + return iw6::parser::make_BITWISE_OR(loc_); + reader_.advance(); + return (last == '|') ? iw6::parser::make_OR(loc_) : iw6::parser::make_ASSIGN_BW_OR(loc_); + case '&': + if (curr != '&' && curr != '=' && curr != '"' && curr != '\'') + return iw6::parser::make_BITWISE_AND(loc_); + reader_.advance(); + if (last == '"' || last == '\'') + return read_string(last, true); + return (last == '&') ? iw6::parser::make_AND(loc_) : iw6::parser::make_ASSIGN_BW_AND(loc_); + case '^': + if (curr != '=') + return iw6::parser::make_BITWISE_EXOR(loc_); + reader_.advance(); + return iw6::parser::make_ASSIGN_BW_EXOR(loc_); + case '!': + if (curr != '=') + return iw6::parser::make_NOT(loc_); + reader_.advance(); + return iw6::parser::make_INEQUALITY(loc_); + case '~': + return iw6::parser::make_COMPLEMENT(loc_); + case '<': + if (curr != '<' && curr != '=') + return iw6::parser::make_LESS(loc_); + reader_.advance(); + if (last == '<') + { + reader_.advance(); + return (last == '=') ? iw6::parser::make_ASSIGN_LSHIFT(loc_) : iw6::parser::make_LSHIFT(loc_); + } + return iw6::parser::make_LESS_EQUAL(loc_); + case '>': + if (curr != '>' && curr != '=') + return iw6::parser::make_GREATER(loc_); + reader_.advance(); + if (last == '>') + { + reader_.advance(); + return (last == '=') ? iw6::parser::make_ASSIGN_RSHIFT(loc_) : iw6::parser::make_RSHIFT(loc_); + } + return iw6::parser::make_GREATER_EQUAL(loc_); + default: + if (last >= '0' && last <= '9') + return lexer::read_number(last); + else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z') + return lexer::read_word(last); + + throw iw6::parser::syntax_error(loc_, utils::string::va("bad token: \'%c\'", last)); + } + } +} + +auto lexer::read_string(char quote, bool localize) -> xsk::gsc::iw6::parser::symbol_type +{ + if (localize) + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + reader_.advance(); + + if (last == '\n') + throw iw6::parser::syntax_error(loc_, "unterminated string"); + + if (last == '\\') // process scapes + { + // TODO: + } + + if (last != '\\' && curr == quote) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); } - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b , yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n , yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n , yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int _line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = _line_number; -} - -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column (int _column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = _column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int _bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = _bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (reader_.state == reader::end) + { + throw iw6::parser::syntax_error(loc_, utils::string::va("unmatched string start ('%s')", (quote == '"') ? "\"" : "\\'")); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + if (localize) + return iw6::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + return iw6::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_); +} + +auto lexer::read_number(char first) -> xsk::gsc::iw6::parser::symbol_type +{ + if (first == '.') + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = true; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw iw6::parser::syntax_error(loc_, "invalid number '.'"); + } + if (data[i] == 'f' && i != len - 1) + throw iw6::parser::syntax_error(loc_, "invalid number 'f'"); + } + + return iw6::parser::make_FLOAT(std::string(data, len), loc_); + } + else + { + auto curr = reader_.current_byte; + + if (first == '0' && curr == 'o') + { + buffer_.push(first); + buffer_.push('o'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'o')) + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'o' && last == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr > 47 && curr < 56)) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid octal literal!"); + + return iw6::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data + 2), loc_); + } + else if (first == '0' && curr == 'b') + { + buffer_.push(first); + buffer_.push('b'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'b')) + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'b' && last == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (curr != '0' && curr != '1') + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid binary literal!"); + + return iw6::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_); + } + else if (first == '0' && curr == 'x') + { + buffer_.push(first); + buffer_.push('x'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'x')) + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'x' && last == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!((curr > 47 && curr < 58) || (curr > 64 && curr < 71) || (curr > 96 && curr < 103))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid hexadecimal literal!"); + + return iw6::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_); + } + else + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw6::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = false; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw iw6::parser::syntax_error(loc_, "invalid number '.'"); + + dot = true; + } + if (data[i] == 'f' && i != len - 1) + throw iw6::parser::syntax_error(loc_, "invalid number 'f'"); + } + + if (dot || data[len - 1] == 'f') + return iw6::parser::make_FLOAT(std::string(data, len), loc_); + + return iw6::parser::make_INTEGER(std::string(data, len), loc_); + } + } +} + +auto lexer::read_word(char first) -> xsk::gsc::iw6::parser::symbol_type +{ + auto path = false; + + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto curr = reader_.current_byte; + + if (!(curr == '\\' || curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (curr == '\\') + { + if (reader_.last_byte == '\\') + throw iw6::parser::syntax_error(loc_, "invalid path '\\\\'"); + + path = true; + curr = '/'; + } + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); - return yy_init_globals ( *ptr_yy_globals ); -} + if (key != keyword::KW_INVALID) + return keyword_token(key); -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; + if (path) + { + if (buffer_.data[buffer_.length - 1] == '/') + throw iw6::parser::syntax_error(loc_, "invalid path end '\\'"); - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + return iw6::parser::make_PATH(xsk::gsc::iw6::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + return iw6::parser::make_IDENTIFIER(xsk::gsc::iw6::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); +} - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; +auto lexer::read_dotsize() -> xsk::gsc::iw6::parser::symbol_type +{ + auto curr = reader_.current_byte; + + if (curr > 47 && curr < 58) + { + return lexer::read_number('.'); + } + else if (curr == '_' || curr > 64 && curr < 91 || curr > 96 && curr < 123) + { + reader save; + save.state = reader_.state; + save.bytes_remaining = reader_.bytes_remaining; + save.buffer_pos = reader_.buffer_pos; + save.last_byte = reader_.last_byte; + save.current_byte = reader_.current_byte; + + while (reader_.state == reader::ok) + { + curr = reader_.current_byte; + + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (std::string_view(buffer_.data, buffer_.length) == "size") + { + return iw6::parser::make_SIZE(loc_); + } + + reader_.state = save.state; + reader_.bytes_remaining = save.bytes_remaining; + reader_.buffer_pos = save.buffer_pos; + reader_.last_byte = save.last_byte; + reader_.current_byte = save.current_byte; + + return iw6::parser::make_DOT(loc_); + + } + else return iw6::parser::make_DOT(loc_); +} + +auto lexer::keyword_token(keyword k) -> xsk::gsc::iw6::parser::symbol_type +{ + switch (k) + { + case keyword::KW_pre_inline: + return iw6::parser::make_INLINE(loc_); + case keyword::KW_pre_include: + return iw6::parser::make_INCLUDE(loc_); + case keyword::KW_pre_using_animtree: + return iw6::parser::make_USINGTREE(loc_); + case keyword::KW_pre_animtree: + return iw6::parser::make_ANIMTREE(loc_); + case keyword::KW_endon: + return iw6::parser::make_ENDON(loc_); + case keyword::KW_notify: + return iw6::parser::make_NOTIFY(loc_); + case keyword::KW_wait: + return iw6::parser::make_WAIT(loc_); + case keyword::KW_waittill: + return iw6::parser::make_WAITTILL(loc_); + case keyword::KW_waittillmatch: + return iw6::parser::make_WAITTILLMATCH(loc_); + case keyword::KW_waittillframeend: + return iw6::parser::make_WAITTILLFRAMEEND(loc_); + case keyword::KW_if: + return iw6::parser::make_IF(loc_); + case keyword::KW_else: + return iw6::parser::make_ELSE(loc_); + case keyword::KW_do: + return iw6::parser::make_DO(loc_); + case keyword::KW_while: + return iw6::parser::make_WHILE(loc_); + case keyword::KW_for: + return iw6::parser::make_FOR(loc_); + case keyword::KW_foreach: + return iw6::parser::make_FOREACH(loc_); + case keyword::KW_in: + return iw6::parser::make_IN(loc_); + case keyword::KW_switch: + return iw6::parser::make_SWITCH(loc_); + case keyword::KW_case: + return iw6::parser::make_CASE(loc_); + case keyword::KW_default: + return iw6::parser::make_DEFAULT(loc_); + case keyword::KW_break: + return iw6::parser::make_BREAK(loc_); + case keyword::KW_continue: + return iw6::parser::make_CONTINUE(loc_); + case keyword::KW_return: + return iw6::parser::make_RETURN(loc_); + case keyword::KW_breakpoint: + return iw6::parser::make_BREAKPOINT(loc_); + case keyword::KW_prof_begin: + return iw6::parser::make_PROFBEGIN(loc_); + case keyword::KW_prof_end: + return iw6::parser::make_PROFEND(loc_); + case keyword::KW_thread: + return iw6::parser::make_THREAD(loc_); + case keyword::KW_childthread: + return iw6::parser::make_CHILDTHREAD(loc_); + case keyword::KW_thisthread: + return iw6::parser::make_THISTHREAD(loc_); + case keyword::KW_call: + return iw6::parser::make_CALL(loc_); + case keyword::KW_true: + return iw6::parser::make_TRUE(loc_); + case keyword::KW_false: + return iw6::parser::make_FALSE(loc_); + case keyword::KW_undefined: + return iw6::parser::make_UNDEFINED(loc_); + case keyword::KW_dotsize: + return iw6::parser::make_SIZE(loc_); + case keyword::KW_game: + return iw6::parser::make_GAME(loc_); + case keyword::KW_self: + return iw6::parser::make_SELF(loc_); + case keyword::KW_anim: + return iw6::parser::make_ANIM(loc_); + case keyword::KW_level: + return iw6::parser::make_LEVEL(loc_); + default: + throw error("gsc lexer: INVALID KEYWORD TOKEN!"); + } +} + +auto lexer::keyword_is_token(keyword k) -> bool +{ + switch (k) + { +/* case keyword::KW_pre_define: + case keyword::KW_pre_undef: + case keyword::KW_pre_ifdef: + case keyword::KW_pre_ifndef: + case keyword::KW_pre_if: + case keyword::KW_pre_elif: + case keyword::KW_pre_else: + case keyword::KW_pre_endif:*/ + case keyword::KW_INVALID: + return false; + default: + return true; + } +} + +auto lexer::get_keyword(std::string_view str) -> keyword +{ + auto itr = keywords.find(str); + + if(itr != keywords.end()) + { + return itr->second; } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + return keyword::KW_INVALID; } -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack , yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack , yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s , yyscan_t yyscanner) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 171 "lexer.lpp" - - -void iw6_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void iw6_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} +std::unordered_map lexer::keywords +{{ +/* { "#define", keyword::KW_pre_define }, + { "#undef", keyword::KW_pre_undef }, + { "#ifdef", keyword::KW_pre_ifdef }, + { "#ifndef", keyword::KW_pre_ifndef }, + { "#if", keyword::KW_pre_if }, + { "#elif", keyword::KW_pre_elif }, + { "#else", keyword::KW_pre_else }, + { "#endif", keyword::KW_pre_endif },*/ + { "#inline", keyword::KW_pre_inline }, + { "#include", keyword::KW_pre_include }, + { "#using_animtree", keyword::KW_pre_using_animtree }, + { "#animtree", keyword::KW_pre_animtree }, + { "endon", keyword::KW_endon }, + { "notify", keyword::KW_notify }, + { "wait", keyword::KW_wait }, + { "waittill", keyword::KW_waittill }, + { "waittillmatch", keyword::KW_waittillmatch }, + { "waittillframeend", keyword::KW_waittillframeend }, + { "if", keyword::KW_if }, + { "else", keyword::KW_else }, + { "do", keyword::KW_do }, + { "while", keyword::KW_while }, + { "for", keyword::KW_for }, + { "foreach", keyword::KW_foreach }, + { "in", keyword::KW_in }, + { "switch", keyword::KW_switch }, + { "case", keyword::KW_case }, + { "default", keyword::KW_default }, + { "break", keyword::KW_break }, + { "continue", keyword::KW_continue }, + { "return", keyword::KW_return }, + { "breakpoint", keyword::KW_breakpoint }, + { "prof_begin", keyword::KW_prof_begin }, + { "prof_end", keyword::KW_prof_end }, + { "thread", keyword::KW_thread }, + { "childthread", keyword::KW_childthread }, + { "thisthread", keyword::KW_thisthread }, + { "call", keyword::KW_call }, + { "true", keyword::KW_true }, + { "false", keyword::KW_false }, + { "undefined", keyword::KW_undefined }, + { ".size", keyword::KW_dotsize }, + { "game", keyword::KW_game }, + { "self", keyword::KW_self }, + { "anim", keyword::KW_anim }, + { "level", keyword::KW_level }, +}}; +} // namespace xsk::gsc::iw6 diff --git a/src/iw6/xsk/lexer.hpp b/src/iw6/xsk/lexer.hpp index ecca4add..4e37eea0 100644 --- a/src/iw6/xsk/lexer.hpp +++ b/src/iw6/xsk/lexer.hpp @@ -1,711 +1,79 @@ -#ifndef iw6_HEADER_H -#define iw6_HEADER_H 1 -#define iw6_IN_HEADER 1 - -#line 5 "lexer.hpp" -#include "stdafx.hpp" -#include "iw6.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw6_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw6_pop_header(xsk::gsc::context* ctx); - -#line 13 "lexer.hpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define iw6__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer iw6__create_buffer -#endif - -#ifdef yy_delete_buffer -#define iw6__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer iw6__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define iw6__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer iw6__scan_buffer -#endif - -#ifdef yy_scan_string -#define iw6__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string iw6__scan_string -#endif - -#ifdef yy_scan_bytes -#define iw6__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes iw6__scan_bytes -#endif - -#ifdef yy_init_buffer -#define iw6__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer iw6__init_buffer -#endif - -#ifdef yy_flush_buffer -#define iw6__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer iw6__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define iw6__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state iw6__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define iw6__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer iw6__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define iw6_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state iw6_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define iw6_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state iw6_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define iw6_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack iw6_ensure_buffer_stack -#endif - -#ifdef yylex -#define iw6_lex_ALREADY_DEFINED -#else -#define yylex iw6_lex -#endif - -#ifdef yyrestart -#define iw6_restart_ALREADY_DEFINED -#else -#define yyrestart iw6_restart -#endif - -#ifdef yylex_init -#define iw6_lex_init_ALREADY_DEFINED -#else -#define yylex_init iw6_lex_init -#endif - -#ifdef yylex_init_extra -#define iw6_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra iw6_lex_init_extra -#endif - -#ifdef yylex_destroy -#define iw6_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy iw6_lex_destroy -#endif - -#ifdef yyget_debug -#define iw6_get_debug_ALREADY_DEFINED -#else -#define yyget_debug iw6_get_debug -#endif - -#ifdef yyset_debug -#define iw6_set_debug_ALREADY_DEFINED -#else -#define yyset_debug iw6_set_debug -#endif - -#ifdef yyget_extra -#define iw6_get_extra_ALREADY_DEFINED -#else -#define yyget_extra iw6_get_extra -#endif - -#ifdef yyset_extra -#define iw6_set_extra_ALREADY_DEFINED -#else -#define yyset_extra iw6_set_extra -#endif - -#ifdef yyget_in -#define iw6_get_in_ALREADY_DEFINED -#else -#define yyget_in iw6_get_in -#endif - -#ifdef yyset_in -#define iw6_set_in_ALREADY_DEFINED -#else -#define yyset_in iw6_set_in -#endif - -#ifdef yyget_out -#define iw6_get_out_ALREADY_DEFINED -#else -#define yyget_out iw6_get_out -#endif - -#ifdef yyset_out -#define iw6_set_out_ALREADY_DEFINED -#else -#define yyset_out iw6_set_out -#endif - -#ifdef yyget_leng -#define iw6_get_leng_ALREADY_DEFINED -#else -#define yyget_leng iw6_get_leng -#endif - -#ifdef yyget_text -#define iw6_get_text_ALREADY_DEFINED -#else -#define yyget_text iw6_get_text -#endif - -#ifdef yyget_lineno -#define iw6_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno iw6_get_lineno -#endif - -#ifdef yyset_lineno -#define iw6_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno iw6_set_lineno -#endif - -#ifdef yyget_column -#define iw6_get_column_ALREADY_DEFINED -#else -#define yyget_column iw6_get_column -#endif - -#ifdef yyset_column -#define iw6_set_column_ALREADY_DEFINED -#else -#define yyset_column iw6_set_column -#endif - -#ifdef yywrap -#define iw6_wrap_ALREADY_DEFINED -#else -#define yywrap iw6_wrap -#endif - -#ifdef yyalloc -#define iw6_alloc_ALREADY_DEFINED -#else -#define yyalloc iw6_alloc -#endif - -#ifdef yyrealloc -#define iw6_realloc_ALREADY_DEFINED -#else -#define yyrealloc iw6_realloc -#endif - -#ifdef yyfree -#define iw6_free_ALREADY_DEFINED -#else -#define yyfree iw6_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define iw6_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#ifndef iw6__create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef iw6__delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef iw6__scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef iw6__scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef iw6__scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef iw6__init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef iw6__flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef iw6__load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef iw6__switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef iw6_push_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef iw6_pop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef iw6_ensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef iw6_lex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef iw6_restart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef iw6_lex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef iw6_lex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef iw6_lex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef iw6_get_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef iw6_set_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef iw6_get_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef iw6_set_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef iw6_get_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef iw6_set_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef iw6_get_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef iw6_set_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef iw6_get_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef iw6_get_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef iw6_get_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef iw6_set_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef iw6_get_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef iw6_set_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef iw6_wrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef iw6_get_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef iw6_set_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef iw6_get_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef iw6_set_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef iw6_alloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef iw6_realloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef iw6_free_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef iw6_text_ALREADY_DEFINED -#undef yytext -#endif -#ifndef iw6_leng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef iw6_in_ALREADY_DEFINED -#undef yyin -#endif -#ifndef iw6_out_ALREADY_DEFINED -#undef yyout -#endif -#ifndef iw6__flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef iw6_lineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef iw6_tables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef iw6_tables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef iw6_TABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 171 "lexer.lpp" - - -#line 709 "lexer.hpp" -#undef iw6_IN_HEADER -#endif /* iw6_HEADER_H */ +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#pragma once + +#include "iw6.hpp" + +namespace xsk::gsc::iw6 +{ + +enum class keyword; + +struct buffer +{ + int size; + int length; + char* data; + + buffer(); + ~buffer(); + bool push(char c); +}; + +struct reader +{ + enum states { end, ok }; + + states state; + int bytes_remaining; + const char* buffer_pos; + char last_byte; + char current_byte; + + reader(); + + reader& operator=(const reader& r) + { + std::memcpy(this, &r, sizeof(reader)); + return *this; + } + + void init(const char* data, size_t size); + void advance(); +}; + +class lexer +{ +private: + reader reader_; + buffer buffer_; + location loc_; + build mode_; + bool in_dev_state_; + std::stack locs_; + std::stack readers_; + std::uint32_t header_top_; + +public: + lexer(const std::string& name, const char* data, size_t size); + auto lex() -> xsk::gsc::iw6::parser::symbol_type; + void push_header(const std::string& file); + void pop_header(); + void restrict_header(const xsk::gsc::location& loc); + +private: + auto read_string(char quote, bool localize) -> xsk::gsc::iw6::parser::symbol_type; + auto read_number(char first) -> xsk::gsc::iw6::parser::symbol_type; + auto read_word(char first) -> xsk::gsc::iw6::parser::symbol_type; + auto read_dotsize() -> xsk::gsc::iw6::parser::symbol_type; + auto keyword_token(keyword k) -> xsk::gsc::iw6::parser::symbol_type; + static auto keyword_is_token(keyword k) -> bool; + static auto get_keyword(std::string_view str) -> keyword; + + static std::unordered_map keywords; +}; + +} // namespace xsk::gsc::iw6 diff --git a/src/iw6/xsk/parser.cpp b/src/iw6/xsk/parser.cpp index ca284c80..62c7d76a 100644 --- a/src/iw6/xsk/parser.cpp +++ b/src/iw6/xsk/parser.cpp @@ -35,13 +35,13 @@ // private implementation details that can be changed or removed. // "%code top" blocks. -#line 40 "parser.ypp" +#line 34 "parser.ypp" #include "stdafx.hpp" #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::iw6::parser::symbol_type IW6lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::iw6::parser::symbol_type IW6lex(xsk::gsc::iw6::lexer& lexer); #line 47 "parser.cpp" @@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace iw6 { #line 149 "parser.cpp" /// Build a parser object. - parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) + parser::parser (xsk::gsc::iw6::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) #if IW6DEBUG : yydebug_ (false), yycdebug_ (&std::cerr), @@ -156,8 +156,7 @@ namespace xsk { namespace gsc { namespace iw6 { : #endif yy_lac_established_ (false), - yyscanner (yyscanner_yyarg), - ctx (ctx_yyarg), + lexer (lexer_yyarg), ast (ast_yyarg) {} @@ -1577,7 +1576,7 @@ namespace xsk { namespace gsc { namespace iw6 { try #endif // YY_EXCEPTIONS { - symbol_type yylookahead (yylex (yyscanner, ctx)); + symbol_type yylookahead (yylex (lexer)); yyla.move (yylookahead); } #if YY_EXCEPTIONS @@ -1960,1285 +1959,1285 @@ namespace xsk { namespace gsc { namespace iw6 { switch (yyn) { case 2: // root: program -#line 249 "parser.ypp" +#line 243 "parser.ypp" { ast = std::move(yystack_[0].value.as < ast::program::ptr > ()); } -#line 1966 "parser.cpp" +#line 1965 "parser.cpp" break; case 3: // root: %empty -#line 250 "parser.ypp" +#line 244 "parser.ypp" { ast = std::make_unique(yylhs.location); } -#line 1972 "parser.cpp" +#line 1971 "parser.cpp" break; case 4: // program: program inline -#line 255 "parser.ypp" +#line 249 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); } -#line 1978 "parser.cpp" +#line 1977 "parser.cpp" break; case 5: // program: program include -#line 257 "parser.ypp" +#line 251 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 1984 "parser.cpp" +#line 1983 "parser.cpp" break; case 6: // program: program declaration -#line 259 "parser.ypp" +#line 253 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 1990 "parser.cpp" +#line 1989 "parser.cpp" break; case 7: // program: inline -#line 261 "parser.ypp" +#line 255 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); } -#line 1996 "parser.cpp" +#line 1995 "parser.cpp" break; case 8: // program: include -#line 263 "parser.ypp" +#line 257 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2002 "parser.cpp" +#line 2001 "parser.cpp" break; case 9: // program: declaration -#line 265 "parser.ypp" +#line 259 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2008 "parser.cpp" +#line 2007 "parser.cpp" break; case 10: // inline: "#inline" expr_path ";" -#line 269 "parser.ypp" - { iw6_push_header(ctx, yystack_[1].value.as < ast::expr_path::ptr > ()->value); } -#line 2014 "parser.cpp" +#line 263 "parser.ypp" + { lexer.push_header(yystack_[1].value.as < ast::expr_path::ptr > ()->value); } +#line 2013 "parser.cpp" break; case 11: // include: "#include" expr_path ";" -#line 274 "parser.ypp" +#line 268 "parser.ypp" { yylhs.value.as < ast::include::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_path::ptr > ())); } -#line 2020 "parser.cpp" +#line 2019 "parser.cpp" break; case 12: // declaration: "/#" -#line 278 "parser.ypp" +#line 272 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_begin = std::make_unique(yylhs.location); } -#line 2026 "parser.cpp" +#line 2025 "parser.cpp" break; case 13: // declaration: "#/" -#line 279 "parser.ypp" +#line 273 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_end = std::make_unique(yylhs.location); } -#line 2032 "parser.cpp" +#line 2031 "parser.cpp" break; case 14: // declaration: decl_usingtree -#line 280 "parser.ypp" +#line 274 "parser.ypp" { yylhs.value.as < ast::decl > ().as_usingtree = std::move(yystack_[0].value.as < ast::decl_usingtree::ptr > ()); } -#line 2038 "parser.cpp" +#line 2037 "parser.cpp" break; case 15: // declaration: decl_constant -#line 281 "parser.ypp" +#line 275 "parser.ypp" { yylhs.value.as < ast::decl > ().as_constant = std::move(yystack_[0].value.as < ast::decl_constant::ptr > ()); } -#line 2044 "parser.cpp" +#line 2043 "parser.cpp" break; case 16: // declaration: decl_thread -#line 282 "parser.ypp" +#line 276 "parser.ypp" { yylhs.value.as < ast::decl > ().as_thread = std::move(yystack_[0].value.as < ast::decl_thread::ptr > ()); } -#line 2050 "parser.cpp" +#line 2049 "parser.cpp" break; case 17: // decl_usingtree: "#using_animtree" "(" expr_string ")" ";" -#line 287 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } -#line 2056 "parser.cpp" +#line 281 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } +#line 2055 "parser.cpp" break; case 18: // decl_constant: expr_identifier "=" expr ";" -#line 292 "parser.ypp" +#line 286 "parser.ypp" { yylhs.value.as < ast::decl_constant::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2062 "parser.cpp" +#line 2061 "parser.cpp" break; case 19: // decl_thread: expr_identifier "(" expr_parameters ")" stmt_block -#line 297 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2068 "parser.cpp" +#line 291 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } +#line 2067 "parser.cpp" break; case 20: // stmt: stmt_dev -#line 301 "parser.ypp" +#line 295 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2074 "parser.cpp" +#line 2073 "parser.cpp" break; case 21: // stmt: stmt_block -#line 302 "parser.ypp" +#line 296 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2080 "parser.cpp" +#line 2079 "parser.cpp" break; case 22: // stmt: stmt_call -#line 303 "parser.ypp" +#line 297 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_call = std::move(yystack_[0].value.as < ast::stmt_call::ptr > ()); } -#line 2086 "parser.cpp" +#line 2085 "parser.cpp" break; case 23: // stmt: stmt_assign -#line 304 "parser.ypp" +#line 298 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_assign = std::move(yystack_[0].value.as < ast::stmt_assign::ptr > ()); } -#line 2092 "parser.cpp" +#line 2091 "parser.cpp" break; case 24: // stmt: stmt_endon -#line 305 "parser.ypp" +#line 299 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_endon = std::move(yystack_[0].value.as < ast::stmt_endon::ptr > ()); } -#line 2098 "parser.cpp" +#line 2097 "parser.cpp" break; case 25: // stmt: stmt_notify -#line 306 "parser.ypp" +#line 300 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_notify = std::move(yystack_[0].value.as < ast::stmt_notify::ptr > ()); } -#line 2104 "parser.cpp" +#line 2103 "parser.cpp" break; case 26: // stmt: stmt_wait -#line 307 "parser.ypp" +#line 301 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_wait = std::move(yystack_[0].value.as < ast::stmt_wait::ptr > ()); } -#line 2110 "parser.cpp" +#line 2109 "parser.cpp" break; case 27: // stmt: stmt_waittill -#line 308 "parser.ypp" +#line 302 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittill = std::move(yystack_[0].value.as < ast::stmt_waittill::ptr > ()); } -#line 2116 "parser.cpp" +#line 2115 "parser.cpp" break; case 28: // stmt: stmt_waittillmatch -#line 309 "parser.ypp" +#line 303 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillmatch = std::move(yystack_[0].value.as < ast::stmt_waittillmatch::ptr > ()); } -#line 2122 "parser.cpp" +#line 2121 "parser.cpp" break; case 29: // stmt: stmt_waittillframeend -#line 310 "parser.ypp" +#line 304 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillframeend = std::move(yystack_[0].value.as < ast::stmt_waittillframeend::ptr > ()); } -#line 2128 "parser.cpp" +#line 2127 "parser.cpp" break; case 30: // stmt: stmt_if -#line 311 "parser.ypp" +#line 305 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_if = std::move(yystack_[0].value.as < ast::stmt_if::ptr > ()); } -#line 2134 "parser.cpp" +#line 2133 "parser.cpp" break; case 31: // stmt: stmt_ifelse -#line 312 "parser.ypp" +#line 306 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_ifelse = std::move(yystack_[0].value.as < ast::stmt_ifelse::ptr > ()); } -#line 2140 "parser.cpp" +#line 2139 "parser.cpp" break; case 32: // stmt: stmt_while -#line 313 "parser.ypp" +#line 307 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_while = std::move(yystack_[0].value.as < ast::stmt_while::ptr > ()); } -#line 2146 "parser.cpp" +#line 2145 "parser.cpp" break; case 33: // stmt: stmt_dowhile -#line 314 "parser.ypp" +#line 308 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_dowhile = std::move(yystack_[0].value.as < ast::stmt_dowhile::ptr > ()); } -#line 2152 "parser.cpp" +#line 2151 "parser.cpp" break; case 34: // stmt: stmt_for -#line 315 "parser.ypp" +#line 309 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_for = std::move(yystack_[0].value.as < ast::stmt_for::ptr > ()); } -#line 2158 "parser.cpp" +#line 2157 "parser.cpp" break; case 35: // stmt: stmt_foreach -#line 316 "parser.ypp" +#line 310 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_foreach = std::move(yystack_[0].value.as < ast::stmt_foreach::ptr > ()); } -#line 2164 "parser.cpp" +#line 2163 "parser.cpp" break; case 36: // stmt: stmt_switch -#line 317 "parser.ypp" +#line 311 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_switch = std::move(yystack_[0].value.as < ast::stmt_switch::ptr > ()); } -#line 2170 "parser.cpp" +#line 2169 "parser.cpp" break; case 37: // stmt: stmt_case -#line 318 "parser.ypp" +#line 312 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_case = std::move(yystack_[0].value.as < ast::stmt_case::ptr > ()); } -#line 2176 "parser.cpp" +#line 2175 "parser.cpp" break; case 38: // stmt: stmt_default -#line 319 "parser.ypp" +#line 313 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_default = std::move(yystack_[0].value.as < ast::stmt_default::ptr > ()); } -#line 2182 "parser.cpp" +#line 2181 "parser.cpp" break; case 39: // stmt: stmt_break -#line 320 "parser.ypp" +#line 314 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_break = std::move(yystack_[0].value.as < ast::stmt_break::ptr > ()); } -#line 2188 "parser.cpp" +#line 2187 "parser.cpp" break; case 40: // stmt: stmt_continue -#line 321 "parser.ypp" +#line 315 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_continue = std::move(yystack_[0].value.as < ast::stmt_continue::ptr > ()); } -#line 2194 "parser.cpp" +#line 2193 "parser.cpp" break; case 41: // stmt: stmt_return -#line 322 "parser.ypp" +#line 316 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_return = std::move(yystack_[0].value.as < ast::stmt_return::ptr > ()); } -#line 2200 "parser.cpp" +#line 2199 "parser.cpp" break; case 42: // stmt: stmt_breakpoint -#line 323 "parser.ypp" +#line 317 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_breakpoint = std::move(yystack_[0].value.as < ast::stmt_breakpoint::ptr > ()); } -#line 2206 "parser.cpp" +#line 2205 "parser.cpp" break; case 43: // stmt: stmt_prof_begin -#line 324 "parser.ypp" +#line 318 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_begin = std::move(yystack_[0].value.as < ast::stmt_prof_begin::ptr > ()); } -#line 2212 "parser.cpp" +#line 2211 "parser.cpp" break; case 44: // stmt: stmt_prof_end -#line 325 "parser.ypp" +#line 319 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_end = std::move(yystack_[0].value.as < ast::stmt_prof_end::ptr > ()); } -#line 2218 "parser.cpp" +#line 2217 "parser.cpp" break; case 45: // stmt_dev: "/#" stmt_list "#/" -#line 329 "parser.ypp" +#line 323 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2224 "parser.cpp" +#line 2223 "parser.cpp" break; case 46: // stmt_dev: "/#" "#/" -#line 330 "parser.ypp" +#line 324 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2230 "parser.cpp" +#line 2229 "parser.cpp" break; case 47: // stmt_block: "{" stmt_list "}" -#line 334 "parser.ypp" +#line 328 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2236 "parser.cpp" +#line 2235 "parser.cpp" break; case 48: // stmt_block: "{" "}" -#line 335 "parser.ypp" +#line 329 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2242 "parser.cpp" +#line 2241 "parser.cpp" break; case 49: // stmt_list: stmt_list stmt -#line 340 "parser.ypp" +#line 334 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2248 "parser.cpp" +#line 2247 "parser.cpp" break; case 50: // stmt_list: stmt -#line 342 "parser.ypp" +#line 336 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2254 "parser.cpp" +#line 2253 "parser.cpp" break; case 51: // stmt_expr: expr_assign -#line 347 "parser.ypp" +#line 341 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2260 "parser.cpp" +#line 2259 "parser.cpp" break; case 52: // stmt_expr: expr_increment -#line 349 "parser.ypp" +#line 343 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2266 "parser.cpp" +#line 2265 "parser.cpp" break; case 53: // stmt_expr: expr_decrement -#line 351 "parser.ypp" +#line 345 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2272 "parser.cpp" +#line 2271 "parser.cpp" break; case 54: // stmt_expr: %empty -#line 353 "parser.ypp" +#line 347 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2278 "parser.cpp" +#line 2277 "parser.cpp" break; case 55: // stmt_call: expr_call ";" -#line 358 "parser.ypp" +#line 352 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_call::ptr > ()))); } -#line 2284 "parser.cpp" +#line 2283 "parser.cpp" break; case 56: // stmt_call: expr_method ";" -#line 360 "parser.ypp" +#line 354 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_method::ptr > ()))); } -#line 2290 "parser.cpp" +#line 2289 "parser.cpp" break; case 57: // stmt_assign: expr_assign ";" -#line 365 "parser.ypp" +#line 359 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2296 "parser.cpp" +#line 2295 "parser.cpp" break; case 58: // stmt_assign: expr_increment ";" -#line 367 "parser.ypp" +#line 361 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2302 "parser.cpp" +#line 2301 "parser.cpp" break; case 59: // stmt_assign: expr_decrement ";" -#line 369 "parser.ypp" +#line 363 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2308 "parser.cpp" +#line 2307 "parser.cpp" break; case 60: // stmt_endon: expr_object "endon" "(" expr ")" ";" -#line 374 "parser.ypp" +#line 368 "parser.ypp" { yylhs.value.as < ast::stmt_endon::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ())); } -#line 2314 "parser.cpp" +#line 2313 "parser.cpp" break; case 61: // stmt_notify: expr_object "notify" "(" expr "," expr_arguments_no_empty ")" ";" -#line 379 "parser.ypp" +#line 373 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2320 "parser.cpp" +#line 2319 "parser.cpp" break; case 62: // stmt_notify: expr_object "notify" "(" expr ")" ";" -#line 381 "parser.ypp" +#line 375 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2326 "parser.cpp" +#line 2325 "parser.cpp" break; case 63: // stmt_wait: "wait" expr ";" -#line 386 "parser.ypp" +#line 380 "parser.ypp" { yylhs.value.as < ast::stmt_wait::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2332 "parser.cpp" +#line 2331 "parser.cpp" break; case 64: // stmt_waittill: expr_object "waittill" "(" expr "," expr_arguments_no_empty ")" ";" -#line 391 "parser.ypp" +#line 385 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2338 "parser.cpp" +#line 2337 "parser.cpp" break; case 65: // stmt_waittill: expr_object "waittill" "(" expr ")" ";" -#line 393 "parser.ypp" +#line 387 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2344 "parser.cpp" +#line 2343 "parser.cpp" break; case 66: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr "," expr_arguments_no_empty ")" ";" -#line 398 "parser.ypp" +#line 392 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2350 "parser.cpp" +#line 2349 "parser.cpp" break; case 67: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr ")" ";" -#line 400 "parser.ypp" +#line 394 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2356 "parser.cpp" +#line 2355 "parser.cpp" break; case 68: // stmt_waittillframeend: "waittillframeend" ";" -#line 405 "parser.ypp" +#line 399 "parser.ypp" { yylhs.value.as < ast::stmt_waittillframeend::ptr > () = std::make_unique(yylhs.location); } -#line 2362 "parser.cpp" +#line 2361 "parser.cpp" break; case 69: // stmt_if: "if" "(" expr ")" stmt -#line 410 "parser.ypp" +#line 404 "parser.ypp" { yylhs.value.as < ast::stmt_if::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2368 "parser.cpp" +#line 2367 "parser.cpp" break; case 70: // stmt_ifelse: "if" "(" expr ")" stmt "else" stmt -#line 415 "parser.ypp" +#line 409 "parser.ypp" { yylhs.value.as < ast::stmt_ifelse::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::stmt > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2374 "parser.cpp" +#line 2373 "parser.cpp" break; case 71: // stmt_while: "while" "(" expr ")" stmt -#line 420 "parser.ypp" +#line 414 "parser.ypp" { yylhs.value.as < ast::stmt_while::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2380 "parser.cpp" +#line 2379 "parser.cpp" break; case 72: // stmt_dowhile: "do" stmt "while" "(" expr ")" ";" -#line 425 "parser.ypp" +#line 419 "parser.ypp" { yylhs.value.as < ast::stmt_dowhile::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[5].value.as < ast::stmt > ())); } -#line 2386 "parser.cpp" +#line 2385 "parser.cpp" break; case 73: // stmt_for: "for" "(" stmt_expr ";" expr_or_empty ";" stmt_expr ")" stmt -#line 430 "parser.ypp" +#line 424 "parser.ypp" { yylhs.value.as < ast::stmt_for::ptr > () = std::make_unique(yylhs.location, ast::stmt(std::move(yystack_[6].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[4].value.as < ast::expr > ()), ast::stmt(std::move(yystack_[2].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2392 "parser.cpp" +#line 2391 "parser.cpp" break; case 74: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt -#line 435 "parser.ypp" +#line 429 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2398 "parser.cpp" +#line 2397 "parser.cpp" break; case 75: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt -#line 437 "parser.ypp" +#line 431 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[6].value.as < ast::expr_identifier::ptr > ())), ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2404 "parser.cpp" +#line 2403 "parser.cpp" break; case 76: // stmt_switch: "switch" "(" expr ")" stmt_block -#line 442 "parser.ypp" +#line 436 "parser.ypp" { yylhs.value.as < ast::stmt_switch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2410 "parser.cpp" +#line 2409 "parser.cpp" break; case 77: // stmt_case: "case" expr_integer ":" -#line 447 "parser.ypp" +#line 441 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_integer::ptr > ())), std::make_unique(yylhs.location)); } -#line 2416 "parser.cpp" +#line 2415 "parser.cpp" break; case 78: // stmt_case: "case" expr_string ":" -#line 449 "parser.ypp" +#line 443 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_string::ptr > ())), std::make_unique(yylhs.location)); } -#line 2422 "parser.cpp" +#line 2421 "parser.cpp" break; case 79: // stmt_default: "default" ":" -#line 454 "parser.ypp" +#line 448 "parser.ypp" { yylhs.value.as < ast::stmt_default::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2428 "parser.cpp" +#line 2427 "parser.cpp" break; case 80: // stmt_break: "break" ";" -#line 459 "parser.ypp" +#line 453 "parser.ypp" { yylhs.value.as < ast::stmt_break::ptr > () = std::make_unique(yylhs.location); } -#line 2434 "parser.cpp" +#line 2433 "parser.cpp" break; case 81: // stmt_continue: "continue" ";" -#line 464 "parser.ypp" +#line 458 "parser.ypp" { yylhs.value.as < ast::stmt_continue::ptr > () = std::make_unique(yylhs.location); } -#line 2440 "parser.cpp" +#line 2439 "parser.cpp" break; case 82: // stmt_return: "return" expr ";" -#line 469 "parser.ypp" +#line 463 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2446 "parser.cpp" +#line 2445 "parser.cpp" break; case 83: // stmt_return: "return" ";" -#line 471 "parser.ypp" +#line 465 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2452 "parser.cpp" +#line 2451 "parser.cpp" break; case 84: // stmt_breakpoint: "breakpoint" ";" -#line 476 "parser.ypp" +#line 470 "parser.ypp" { yylhs.value.as < ast::stmt_breakpoint::ptr > () = std::make_unique(yylhs.location); } -#line 2458 "parser.cpp" +#line 2457 "parser.cpp" break; case 85: // stmt_prof_begin: "prof_begin" "(" expr_arguments ")" ";" -#line 481 "parser.ypp" +#line 475 "parser.ypp" { yylhs.value.as < ast::stmt_prof_begin::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2464 "parser.cpp" +#line 2463 "parser.cpp" break; case 86: // stmt_prof_end: "prof_end" "(" expr_arguments ")" ";" -#line 486 "parser.ypp" +#line 480 "parser.ypp" { yylhs.value.as < ast::stmt_prof_end::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2470 "parser.cpp" +#line 2469 "parser.cpp" break; case 87: // expr: expr_ternary -#line 490 "parser.ypp" +#line 484 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2476 "parser.cpp" +#line 2475 "parser.cpp" break; case 88: // expr: expr_binary -#line 491 "parser.ypp" +#line 485 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2482 "parser.cpp" +#line 2481 "parser.cpp" break; case 89: // expr: expr_primitive -#line 492 "parser.ypp" +#line 486 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2488 "parser.cpp" +#line 2487 "parser.cpp" break; case 90: // expr_or_empty: expr -#line 496 "parser.ypp" +#line 490 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2494 "parser.cpp" +#line 2493 "parser.cpp" break; case 91: // expr_or_empty: %empty -#line 497 "parser.ypp" +#line 491 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location); } -#line 2500 "parser.cpp" +#line 2499 "parser.cpp" break; case 92: // expr_assign: expr_object "=" expr -#line 502 "parser.ypp" +#line 496 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2506 "parser.cpp" +#line 2505 "parser.cpp" break; case 93: // expr_assign: expr_object "|=" expr -#line 504 "parser.ypp" +#line 498 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2512 "parser.cpp" +#line 2511 "parser.cpp" break; case 94: // expr_assign: expr_object "&=" expr -#line 506 "parser.ypp" +#line 500 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2518 "parser.cpp" +#line 2517 "parser.cpp" break; case 95: // expr_assign: expr_object "^=" expr -#line 508 "parser.ypp" +#line 502 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2524 "parser.cpp" +#line 2523 "parser.cpp" break; case 96: // expr_assign: expr_object "<<=" expr -#line 510 "parser.ypp" +#line 504 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()),std::move( yystack_[0].value.as < ast::expr > ())); } -#line 2530 "parser.cpp" +#line 2529 "parser.cpp" break; case 97: // expr_assign: expr_object ">>=" expr -#line 512 "parser.ypp" +#line 506 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2536 "parser.cpp" +#line 2535 "parser.cpp" break; case 98: // expr_assign: expr_object "+=" expr -#line 514 "parser.ypp" +#line 508 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2542 "parser.cpp" +#line 2541 "parser.cpp" break; case 99: // expr_assign: expr_object "-=" expr -#line 516 "parser.ypp" +#line 510 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2548 "parser.cpp" +#line 2547 "parser.cpp" break; case 100: // expr_assign: expr_object "*=" expr -#line 518 "parser.ypp" +#line 512 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2554 "parser.cpp" +#line 2553 "parser.cpp" break; case 101: // expr_assign: expr_object "/=" expr -#line 520 "parser.ypp" +#line 514 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2560 "parser.cpp" +#line 2559 "parser.cpp" break; case 102: // expr_assign: expr_object "%=" expr -#line 522 "parser.ypp" +#line 516 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2566 "parser.cpp" +#line 2565 "parser.cpp" break; case 103: // expr_increment: "++" expr_object -#line 527 "parser.ypp" +#line 521 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2572 "parser.cpp" +#line 2571 "parser.cpp" break; case 104: // expr_increment: expr_object "++" -#line 529 "parser.ypp" +#line 523 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2578 "parser.cpp" +#line 2577 "parser.cpp" break; case 105: // expr_decrement: "--" expr_object -#line 534 "parser.ypp" +#line 528 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2584 "parser.cpp" +#line 2583 "parser.cpp" break; case 106: // expr_decrement: expr_object "--" -#line 536 "parser.ypp" +#line 530 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2590 "parser.cpp" +#line 2589 "parser.cpp" break; case 107: // expr_ternary: expr "?" expr ":" expr -#line 541 "parser.ypp" +#line 535 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2596 "parser.cpp" +#line 2595 "parser.cpp" break; case 108: // expr_binary: expr "||" expr -#line 546 "parser.ypp" +#line 540 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2602 "parser.cpp" +#line 2601 "parser.cpp" break; case 109: // expr_binary: expr "&&" expr -#line 548 "parser.ypp" +#line 542 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2608 "parser.cpp" +#line 2607 "parser.cpp" break; case 110: // expr_binary: expr "==" expr -#line 550 "parser.ypp" +#line 544 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2614 "parser.cpp" +#line 2613 "parser.cpp" break; case 111: // expr_binary: expr "!=" expr -#line 552 "parser.ypp" +#line 546 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2620 "parser.cpp" +#line 2619 "parser.cpp" break; case 112: // expr_binary: expr "<=" expr -#line 554 "parser.ypp" +#line 548 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2626 "parser.cpp" +#line 2625 "parser.cpp" break; case 113: // expr_binary: expr ">=" expr -#line 556 "parser.ypp" +#line 550 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2632 "parser.cpp" +#line 2631 "parser.cpp" break; case 114: // expr_binary: expr "<" expr -#line 558 "parser.ypp" +#line 552 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2638 "parser.cpp" +#line 2637 "parser.cpp" break; case 115: // expr_binary: expr ">" expr -#line 560 "parser.ypp" +#line 554 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2644 "parser.cpp" +#line 2643 "parser.cpp" break; case 116: // expr_binary: expr "|" expr -#line 562 "parser.ypp" +#line 556 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2650 "parser.cpp" +#line 2649 "parser.cpp" break; case 117: // expr_binary: expr "&" expr -#line 564 "parser.ypp" +#line 558 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2656 "parser.cpp" +#line 2655 "parser.cpp" break; case 118: // expr_binary: expr "^" expr -#line 566 "parser.ypp" +#line 560 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2662 "parser.cpp" +#line 2661 "parser.cpp" break; case 119: // expr_binary: expr "<<" expr -#line 568 "parser.ypp" +#line 562 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2668 "parser.cpp" +#line 2667 "parser.cpp" break; case 120: // expr_binary: expr ">>" expr -#line 570 "parser.ypp" +#line 564 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2674 "parser.cpp" +#line 2673 "parser.cpp" break; case 121: // expr_binary: expr "+" expr -#line 572 "parser.ypp" +#line 566 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2680 "parser.cpp" +#line 2679 "parser.cpp" break; case 122: // expr_binary: expr "-" expr -#line 574 "parser.ypp" +#line 568 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2686 "parser.cpp" +#line 2685 "parser.cpp" break; case 123: // expr_binary: expr "*" expr -#line 576 "parser.ypp" +#line 570 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2692 "parser.cpp" +#line 2691 "parser.cpp" break; case 124: // expr_binary: expr "/" expr -#line 578 "parser.ypp" +#line 572 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2698 "parser.cpp" +#line 2697 "parser.cpp" break; case 125: // expr_binary: expr "%" expr -#line 580 "parser.ypp" +#line 574 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2704 "parser.cpp" +#line 2703 "parser.cpp" break; case 126: // expr_primitive: expr_complement -#line 584 "parser.ypp" +#line 578 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_complement::ptr > ()); } -#line 2710 "parser.cpp" +#line 2709 "parser.cpp" break; case 127: // expr_primitive: expr_not -#line 585 "parser.ypp" +#line 579 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_not::ptr > ()); } -#line 2716 "parser.cpp" +#line 2715 "parser.cpp" break; case 128: // expr_primitive: expr_call -#line 586 "parser.ypp" +#line 580 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 2722 "parser.cpp" +#line 2721 "parser.cpp" break; case 129: // expr_primitive: expr_method -#line 587 "parser.ypp" +#line 581 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 2728 "parser.cpp" +#line 2727 "parser.cpp" break; case 130: // expr_primitive: expr_add_array -#line 588 "parser.ypp" +#line 582 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_add_array::ptr > ()); } -#line 2734 "parser.cpp" +#line 2733 "parser.cpp" break; case 131: // expr_primitive: expr_reference -#line 589 "parser.ypp" +#line 583 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_reference::ptr > ()); } -#line 2740 "parser.cpp" +#line 2739 "parser.cpp" break; case 132: // expr_primitive: expr_array -#line 590 "parser.ypp" +#line 584 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 2746 "parser.cpp" +#line 2745 "parser.cpp" break; case 133: // expr_primitive: expr_field -#line 591 "parser.ypp" +#line 585 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 2752 "parser.cpp" +#line 2751 "parser.cpp" break; case 134: // expr_primitive: expr_size -#line 592 "parser.ypp" +#line 586 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_size::ptr > ()); } -#line 2758 "parser.cpp" +#line 2757 "parser.cpp" break; case 135: // expr_primitive: expr_paren -#line 593 "parser.ypp" +#line 587 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_paren::ptr > ()); } -#line 2764 "parser.cpp" +#line 2763 "parser.cpp" break; case 136: // expr_primitive: expr_thisthread -#line 594 "parser.ypp" +#line 588 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_thisthread::ptr > ()); } -#line 2770 "parser.cpp" +#line 2769 "parser.cpp" break; case 137: // expr_primitive: expr_empty_array -#line 595 "parser.ypp" +#line 589 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_empty_array::ptr > ()); } -#line 2776 "parser.cpp" +#line 2775 "parser.cpp" break; case 138: // expr_primitive: expr_undefined -#line 596 "parser.ypp" +#line 590 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_undefined::ptr > ()); } -#line 2782 "parser.cpp" +#line 2781 "parser.cpp" break; case 139: // expr_primitive: expr_game -#line 597 "parser.ypp" +#line 591 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 2788 "parser.cpp" +#line 2787 "parser.cpp" break; case 140: // expr_primitive: expr_self -#line 598 "parser.ypp" +#line 592 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 2794 "parser.cpp" +#line 2793 "parser.cpp" break; case 141: // expr_primitive: expr_anim -#line 599 "parser.ypp" +#line 593 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 2800 "parser.cpp" +#line 2799 "parser.cpp" break; case 142: // expr_primitive: expr_level -#line 600 "parser.ypp" +#line 594 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 2806 "parser.cpp" +#line 2805 "parser.cpp" break; case 143: // expr_primitive: expr_animation -#line 601 "parser.ypp" +#line 595 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animation::ptr > ()); } -#line 2812 "parser.cpp" +#line 2811 "parser.cpp" break; case 144: // expr_primitive: expr_animtree -#line 602 "parser.ypp" +#line 596 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animtree::ptr > ()); } -#line 2818 "parser.cpp" +#line 2817 "parser.cpp" break; case 145: // expr_primitive: expr_identifier -#line 603 "parser.ypp" +#line 597 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 2824 "parser.cpp" +#line 2823 "parser.cpp" break; case 146: // expr_primitive: expr_istring -#line 604 "parser.ypp" +#line 598 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istring::ptr > ()); } -#line 2830 "parser.cpp" +#line 2829 "parser.cpp" break; case 147: // expr_primitive: expr_string -#line 605 "parser.ypp" +#line 599 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_string::ptr > ()); } -#line 2836 "parser.cpp" +#line 2835 "parser.cpp" break; case 148: // expr_primitive: expr_color -#line 606 "parser.ypp" +#line 600 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_color::ptr > ()); } -#line 2842 "parser.cpp" +#line 2841 "parser.cpp" break; case 149: // expr_primitive: expr_vector -#line 607 "parser.ypp" +#line 601 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_vector::ptr > ()); } -#line 2848 "parser.cpp" +#line 2847 "parser.cpp" break; case 150: // expr_primitive: expr_float -#line 608 "parser.ypp" +#line 602 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_float::ptr > ()); } -#line 2854 "parser.cpp" +#line 2853 "parser.cpp" break; case 151: // expr_primitive: expr_integer -#line 609 "parser.ypp" +#line 603 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_integer::ptr > ()); } -#line 2860 "parser.cpp" +#line 2859 "parser.cpp" break; case 152: // expr_primitive: expr_false -#line 610 "parser.ypp" +#line 604 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_false::ptr > ()); } -#line 2866 "parser.cpp" +#line 2865 "parser.cpp" break; case 153: // expr_primitive: expr_true -#line 611 "parser.ypp" +#line 605 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_true::ptr > ()); } -#line 2872 "parser.cpp" +#line 2871 "parser.cpp" break; case 154: // expr_complement: "~" expr -#line 616 "parser.ypp" +#line 610 "parser.ypp" { yylhs.value.as < ast::expr_complement::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2878 "parser.cpp" +#line 2877 "parser.cpp" break; case 155: // expr_not: "!" expr -#line 621 "parser.ypp" +#line 615 "parser.ypp" { yylhs.value.as < ast::expr_not::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2884 "parser.cpp" +#line 2883 "parser.cpp" break; case 156: // expr_call: expr_function -#line 625 "parser.ypp" +#line 619 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2890 "parser.cpp" +#line 2889 "parser.cpp" break; case 157: // expr_call: expr_pointer -#line 626 "parser.ypp" +#line 620 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2896 "parser.cpp" +#line 2895 "parser.cpp" break; case 158: // expr_method: expr_object expr_function -#line 629 "parser.ypp" +#line 623 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2902 "parser.cpp" +#line 2901 "parser.cpp" break; case 159: // expr_method: expr_object expr_pointer -#line 630 "parser.ypp" +#line 624 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2908 "parser.cpp" +#line 2907 "parser.cpp" break; case 160: // expr_function: expr_identifier "(" expr_arguments ")" -#line 635 "parser.ypp" +#line 629 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2914 "parser.cpp" +#line 2913 "parser.cpp" break; case 161: // expr_function: expr_path "::" expr_identifier "(" expr_arguments ")" -#line 637 "parser.ypp" +#line 631 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2920 "parser.cpp" +#line 2919 "parser.cpp" break; case 162: // expr_function: "thread" expr_identifier "(" expr_arguments ")" -#line 639 "parser.ypp" +#line 633 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2926 "parser.cpp" +#line 2925 "parser.cpp" break; case 163: // expr_function: "thread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 641 "parser.ypp" +#line 635 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2932 "parser.cpp" +#line 2931 "parser.cpp" break; case 164: // expr_function: "childthread" expr_identifier "(" expr_arguments ")" -#line 643 "parser.ypp" +#line 637 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2938 "parser.cpp" +#line 2937 "parser.cpp" break; case 165: // expr_function: "childthread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 645 "parser.ypp" +#line 639 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2944 "parser.cpp" +#line 2943 "parser.cpp" break; case 166: // expr_pointer: "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 650 "parser.ypp" +#line 644 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2950 "parser.cpp" +#line 2949 "parser.cpp" break; case 167: // expr_pointer: "thread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 652 "parser.ypp" +#line 646 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2956 "parser.cpp" +#line 2955 "parser.cpp" break; case 168: // expr_pointer: "childthread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 654 "parser.ypp" +#line 648 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2962 "parser.cpp" +#line 2961 "parser.cpp" break; case 169: // expr_pointer: "call" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 656 "parser.ypp" +#line 650 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::builtin); } -#line 2968 "parser.cpp" +#line 2967 "parser.cpp" break; case 170: // expr_add_array: "[" expr_arguments_no_empty "]" -#line 661 "parser.ypp" +#line 655 "parser.ypp" { yylhs.value.as < ast::expr_add_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ())); } -#line 2974 "parser.cpp" +#line 2973 "parser.cpp" break; case 171: // expr_parameters: expr_parameters "," expr_identifier -#line 666 "parser.ypp" +#line 660 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 2980 "parser.cpp" +#line 2979 "parser.cpp" break; case 172: // expr_parameters: expr_identifier -#line 668 "parser.ypp" +#line 662 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 2986 "parser.cpp" +#line 2985 "parser.cpp" break; case 173: // expr_parameters: %empty -#line 670 "parser.ypp" +#line 664 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); } -#line 2992 "parser.cpp" +#line 2991 "parser.cpp" break; case 174: // expr_arguments: expr_arguments_no_empty -#line 675 "parser.ypp" +#line 669 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[0].value.as < ast::expr_arguments::ptr > ()); } -#line 2998 "parser.cpp" +#line 2997 "parser.cpp" break; case 175: // expr_arguments: %empty -#line 677 "parser.ypp" +#line 671 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); } -#line 3004 "parser.cpp" +#line 3003 "parser.cpp" break; case 176: // expr_arguments_no_empty: expr_arguments "," expr -#line 682 "parser.ypp" +#line 676 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ()); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3010 "parser.cpp" +#line 3009 "parser.cpp" break; case 177: // expr_arguments_no_empty: expr -#line 684 "parser.ypp" +#line 678 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3016 "parser.cpp" +#line 3015 "parser.cpp" break; case 178: // expr_reference: "::" expr_identifier -#line 689 "parser.ypp" +#line 683 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3022 "parser.cpp" +#line 3021 "parser.cpp" break; case 179: // expr_reference: expr_path "::" expr_identifier -#line 691 "parser.ypp" +#line 685 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_path::ptr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3028 "parser.cpp" +#line 3027 "parser.cpp" break; case 180: // expr_array: expr_object "[" expr "]" -#line 696 "parser.ypp" +#line 690 "parser.ypp" { yylhs.value.as < ast::expr_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3034 "parser.cpp" +#line 3033 "parser.cpp" break; case 181: // expr_field: expr_object "." expr_identifier -#line 701 "parser.ypp" +#line 695 "parser.ypp" { yylhs.value.as < ast::expr_field::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3040 "parser.cpp" +#line 3039 "parser.cpp" break; case 182: // expr_size: expr_object ".size" -#line 706 "parser.ypp" +#line 700 "parser.ypp" { yylhs.value.as < ast::expr_size::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3046 "parser.cpp" +#line 3045 "parser.cpp" break; case 183: // expr_paren: "(" expr ")" -#line 711 "parser.ypp" +#line 705 "parser.ypp" { yylhs.value.as < ast::expr_paren::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3052 "parser.cpp" +#line 3051 "parser.cpp" break; case 184: // expr_object: expr_call -#line 715 "parser.ypp" +#line 709 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 3058 "parser.cpp" +#line 3057 "parser.cpp" break; case 185: // expr_object: expr_method -#line 716 "parser.ypp" +#line 710 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 3064 "parser.cpp" +#line 3063 "parser.cpp" break; case 186: // expr_object: expr_array -#line 717 "parser.ypp" +#line 711 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 3070 "parser.cpp" +#line 3069 "parser.cpp" break; case 187: // expr_object: expr_field -#line 718 "parser.ypp" +#line 712 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 3076 "parser.cpp" +#line 3075 "parser.cpp" break; case 188: // expr_object: expr_game -#line 719 "parser.ypp" +#line 713 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 3082 "parser.cpp" +#line 3081 "parser.cpp" break; case 189: // expr_object: expr_self -#line 720 "parser.ypp" +#line 714 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 3088 "parser.cpp" +#line 3087 "parser.cpp" break; case 190: // expr_object: expr_anim -#line 721 "parser.ypp" +#line 715 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 3094 "parser.cpp" +#line 3093 "parser.cpp" break; case 191: // expr_object: expr_level -#line 722 "parser.ypp" +#line 716 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 3100 "parser.cpp" +#line 3099 "parser.cpp" break; case 192: // expr_object: expr_identifier -#line 723 "parser.ypp" +#line 717 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 3106 "parser.cpp" +#line 3105 "parser.cpp" break; case 193: // expr_thisthread: "thisthread" -#line 728 "parser.ypp" +#line 722 "parser.ypp" { yylhs.value.as < ast::expr_thisthread::ptr > () = std::make_unique(yylhs.location); } -#line 3112 "parser.cpp" +#line 3111 "parser.cpp" break; case 194: // expr_empty_array: "[" "]" -#line 733 "parser.ypp" +#line 727 "parser.ypp" { yylhs.value.as < ast::expr_empty_array::ptr > () = std::make_unique(yylhs.location); } -#line 3118 "parser.cpp" +#line 3117 "parser.cpp" break; case 195: // expr_undefined: "undefined" -#line 738 "parser.ypp" +#line 732 "parser.ypp" { yylhs.value.as < ast::expr_undefined::ptr > () = std::make_unique(yylhs.location); } -#line 3124 "parser.cpp" +#line 3123 "parser.cpp" break; case 196: // expr_game: "game" -#line 743 "parser.ypp" +#line 737 "parser.ypp" { yylhs.value.as < ast::expr_game::ptr > () = std::make_unique(yylhs.location); } -#line 3130 "parser.cpp" +#line 3129 "parser.cpp" break; case 197: // expr_self: "self" -#line 748 "parser.ypp" +#line 742 "parser.ypp" { yylhs.value.as < ast::expr_self::ptr > () = std::make_unique(yylhs.location); } -#line 3136 "parser.cpp" +#line 3135 "parser.cpp" break; case 198: // expr_anim: "anim" -#line 753 "parser.ypp" +#line 747 "parser.ypp" { yylhs.value.as < ast::expr_anim::ptr > () = std::make_unique(yylhs.location); } -#line 3142 "parser.cpp" +#line 3141 "parser.cpp" break; case 199: // expr_level: "level" -#line 758 "parser.ypp" +#line 752 "parser.ypp" { yylhs.value.as < ast::expr_level::ptr > () = std::make_unique(yylhs.location); } -#line 3148 "parser.cpp" +#line 3147 "parser.cpp" break; case 200: // expr_animation: "%" "identifier" -#line 763 "parser.ypp" +#line 757 "parser.ypp" { yylhs.value.as < ast::expr_animation::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3154 "parser.cpp" +#line 3153 "parser.cpp" break; case 201: // expr_animtree: "#animtree" -#line 768 "parser.ypp" +#line 762 "parser.ypp" { yylhs.value.as < ast::expr_animtree::ptr > () = std::make_unique(yylhs.location); } -#line 3160 "parser.cpp" +#line 3159 "parser.cpp" break; case 202: // expr_identifier: "identifier" -#line 773 "parser.ypp" +#line 767 "parser.ypp" { yylhs.value.as < ast::expr_identifier::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3166 "parser.cpp" +#line 3165 "parser.cpp" break; case 203: // expr_path: "path" -#line 778 "parser.ypp" +#line 772 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3172 "parser.cpp" +#line 3171 "parser.cpp" break; case 204: // expr_path: expr_identifier -#line 780 "parser.ypp" +#line 774 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < ast::expr_identifier::ptr > ()->value); } -#line 3178 "parser.cpp" +#line 3177 "parser.cpp" break; case 205: // expr_istring: "localized string" -#line 785 "parser.ypp" +#line 779 "parser.ypp" { yylhs.value.as < ast::expr_istring::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3184 "parser.cpp" +#line 3183 "parser.cpp" break; case 206: // expr_string: "string literal" -#line 790 "parser.ypp" +#line 784 "parser.ypp" { yylhs.value.as < ast::expr_string::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3190 "parser.cpp" +#line 3189 "parser.cpp" break; case 207: // expr_color: "color" -#line 795 "parser.ypp" +#line 789 "parser.ypp" { yylhs.value.as < ast::expr_color::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3196 "parser.cpp" +#line 3195 "parser.cpp" break; case 208: // expr_vector: "(" expr "," expr "," expr ")" -#line 800 "parser.ypp" +#line 794 "parser.ypp" { yylhs.value.as < ast::expr_vector::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3202 "parser.cpp" +#line 3201 "parser.cpp" break; case 209: // expr_float: "-" "float" -#line 805 "parser.ypp" +#line 799 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3208 "parser.cpp" +#line 3207 "parser.cpp" break; case 210: // expr_float: "float" -#line 807 "parser.ypp" +#line 801 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3214 "parser.cpp" +#line 3213 "parser.cpp" break; case 211: // expr_integer: "-" "integer" -#line 812 "parser.ypp" +#line 806 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3220 "parser.cpp" +#line 3219 "parser.cpp" break; case 212: // expr_integer: "integer" -#line 814 "parser.ypp" +#line 808 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3226 "parser.cpp" +#line 3225 "parser.cpp" break; case 213: // expr_false: "false" -#line 819 "parser.ypp" +#line 813 "parser.ypp" { yylhs.value.as < ast::expr_false::ptr > () = std::make_unique(yylhs.location); } -#line 3232 "parser.cpp" +#line 3231 "parser.cpp" break; case 214: // expr_true: "true" -#line 824 "parser.ypp" +#line 818 "parser.ypp" { yylhs.value.as < ast::expr_true::ptr > () = std::make_unique(yylhs.location); } -#line 3238 "parser.cpp" +#line 3237 "parser.cpp" break; -#line 3242 "parser.cpp" +#line 3241 "parser.cpp" default: break; @@ -4426,28 +4425,28 @@ namespace xsk { namespace gsc { namespace iw6 { const short parser::yyrline_[] = { - 0, 249, 249, 250, 254, 256, 258, 260, 262, 264, - 269, 273, 278, 279, 280, 281, 282, 286, 291, 296, - 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, - 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, - 321, 322, 323, 324, 325, 329, 330, 334, 335, 339, - 341, 346, 348, 350, 353, 357, 359, 364, 366, 368, - 373, 378, 380, 385, 390, 392, 397, 399, 404, 409, - 414, 419, 424, 429, 434, 436, 441, 446, 448, 453, - 458, 463, 468, 470, 475, 480, 485, 490, 491, 492, - 496, 497, 501, 503, 505, 507, 509, 511, 513, 515, - 517, 519, 521, 526, 528, 533, 535, 540, 545, 547, - 549, 551, 553, 555, 557, 559, 561, 563, 565, 567, - 569, 571, 573, 575, 577, 579, 584, 585, 586, 587, - 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, - 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, - 608, 609, 610, 611, 615, 620, 625, 626, 629, 630, - 634, 636, 638, 640, 642, 644, 649, 651, 653, 655, - 660, 665, 667, 670, 674, 677, 681, 683, 688, 690, - 695, 700, 705, 710, 715, 716, 717, 718, 719, 720, - 721, 722, 723, 727, 732, 737, 742, 747, 752, 757, - 762, 767, 772, 777, 779, 784, 789, 794, 799, 804, - 806, 811, 813, 818, 823 + 0, 243, 243, 244, 248, 250, 252, 254, 256, 258, + 263, 267, 272, 273, 274, 275, 276, 280, 285, 290, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 323, 324, 328, 329, 333, + 335, 340, 342, 344, 347, 351, 353, 358, 360, 362, + 367, 372, 374, 379, 384, 386, 391, 393, 398, 403, + 408, 413, 418, 423, 428, 430, 435, 440, 442, 447, + 452, 457, 462, 464, 469, 474, 479, 484, 485, 486, + 490, 491, 495, 497, 499, 501, 503, 505, 507, 509, + 511, 513, 515, 520, 522, 527, 529, 534, 539, 541, + 543, 545, 547, 549, 551, 553, 555, 557, 559, 561, + 563, 565, 567, 569, 571, 573, 578, 579, 580, 581, + 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, + 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, + 602, 603, 604, 605, 609, 614, 619, 620, 623, 624, + 628, 630, 632, 634, 636, 638, 643, 645, 647, 649, + 654, 659, 661, 664, 668, 671, 675, 677, 682, 684, + 689, 694, 699, 704, 709, 710, 711, 712, 713, 714, + 715, 716, 717, 721, 726, 731, 736, 741, 746, 751, + 756, 761, 766, 771, 773, 778, 783, 788, 793, 798, + 800, 805, 807, 812, 817 }; void @@ -4480,9 +4479,9 @@ namespace xsk { namespace gsc { namespace iw6 { #line 13 "parser.ypp" } } } // xsk::gsc::iw6 -#line 4484 "parser.cpp" +#line 4483 "parser.cpp" -#line 827 "parser.ypp" +#line 821 "parser.ypp" void xsk::gsc::iw6::parser::error(const xsk::gsc::location& loc, const std::string& msg) diff --git a/src/iw6/xsk/parser.hpp b/src/iw6/xsk/parser.hpp index 9b39da74..719e1c89 100644 --- a/src/iw6/xsk/parser.hpp +++ b/src/iw6/xsk/parser.hpp @@ -45,13 +45,12 @@ #ifndef YY_IW6_PARSER_HPP_INCLUDED # define YY_IW6_PARSER_HPP_INCLUDED // "%code requires" blocks. -#line 33 "parser.ypp" +#line 28 "parser.ypp" #include "iw6.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::iw6::parser::symbol_type IW6lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::iw6 { class lexer; } -#line 55 "parser.hpp" +#line 54 "parser.hpp" # include # include // std::abort @@ -194,7 +193,7 @@ typedef void *yyscan_t; #line 13 "parser.ypp" namespace xsk { namespace gsc { namespace iw6 { -#line 198 "parser.hpp" +#line 197 "parser.hpp" @@ -2657,7 +2656,7 @@ switch (yykind) }; /// Build a parser object. - parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); + parser (xsk::gsc::iw6::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); virtual ~parser (); #if 201103L <= YY_CPLUSPLUS @@ -4613,8 +4612,7 @@ switch (yykind) // User arguments. - yyscan_t yyscanner; - xsk::gsc::context* ctx; + xsk::gsc::iw6::lexer& lexer; xsk::gsc::ast::program::ptr& ast; }; @@ -5291,7 +5289,7 @@ switch (yykind) #line 13 "parser.ypp" } } } // xsk::gsc::iw6 -#line 5295 "parser.hpp" +#line 5293 "parser.hpp" diff --git a/src/iw6/xsk/resolver.cpp b/src/iw6/xsk/resolver.cpp index 4aece493..5068ae66 100644 --- a/src/iw6/xsk/resolver.cpp +++ b/src/iw6/xsk/resolver.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -206,6 +206,35 @@ auto resolver::make_token(std::string_view str) -> std::string return data; } +std::function(const std::string&)> read_callback = nullptr; +std::unordered_map> files; + +auto resolver::file_data(const std::string& name) -> std::tuple +{ + const auto& itr = files.find(name); + + if(itr != files.end()) + { + return { &itr->first ,reinterpret_cast(itr->second.data()), itr->second.size() }; + } + + auto data = read_callback(name); + + const auto& res = files.insert({ name, std::move(data)}); + + if(res.second) + { + return { &res.first->first, reinterpret_cast(res.first->second.data()), res.first->second.size() }; + } + + throw error("couldn't open gsc file '" + name + "'"); +} + +void resolver::set_reader(std::function(const std::string&)> callback) +{ + read_callback = callback; +} + const std::array, 153> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/iw6/xsk/resolver.hpp b/src/iw6/xsk/resolver.hpp index 999a9447..5e9efdd6 100644 --- a/src/iw6/xsk/resolver.hpp +++ b/src/iw6/xsk/resolver.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -30,6 +30,8 @@ public: static auto find_method(const std::string& name) -> bool; static auto make_token(std::string_view str) -> std::string; + static auto file_data(const std::string& name) -> std::tuple; + static void set_reader(std::function(const std::string&)> callback); }; } // namespace xsk::gsc::iw6 diff --git a/src/iw7/stdafx.cpp b/src/iw7/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/iw7/stdafx.cpp +++ b/src/iw7/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/stdafx.hpp b/src/iw7/stdafx.hpp index d387156e..de83a629 100644 --- a/src/iw7/stdafx.hpp +++ b/src/iw7/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/xsk/assembler.cpp b/src/iw7/xsk/assembler.cpp index d6011ef1..f52c4c5e 100644 --- a/src/iw7/xsk/assembler.cpp +++ b/src/iw7/xsk/assembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/xsk/assembler.hpp b/src/iw7/xsk/assembler.hpp index 2b94e3ac..fe10317a 100644 --- a/src/iw7/xsk/assembler.hpp +++ b/src/iw7/xsk/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/xsk/compiler.cpp b/src/iw7/xsk/compiler.cpp index ba2ca8e4..8da065d0 100644 --- a/src/iw7/xsk/compiler.cpp +++ b/src/iw7/xsk/compiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,7 +19,6 @@ auto compiler::output() -> std::vector void compiler::compile(const std::string& file, std::vector& data) { filename_ = file; - sources_.clear(); auto prog = parse_buffer(filename_, data); @@ -33,39 +32,19 @@ void compiler::read_callback(std::function(const std:: auto compiler::parse_buffer(const std::string& file, std::vector& data) -> ast::program::ptr { - yyscan_t scanner; - context ctx; ast::program::ptr result(nullptr); - ctx.header_top = 0; - ctx.mode = mode_; - ctx.read_callback = read_callback_; - ctx.sources = &sources_; - ctx.loc.initialize(&file); + resolver::set_reader(read_callback_); - // Add the two NULL terminators, required by flex. - data.push_back(0); - data.push_back(0); + lexer lexer(file, reinterpret_cast(data.data()), data.size()); - if (iw7_lex_init(&scanner)) - { - throw comp_error(ctx.loc, "An unknown error ocurred while starting lexer context."); - } - - ctx.scanner = scanner; - - YY_BUFFER_STATE yybuffer = iw7__scan_buffer(reinterpret_cast(data.data()), data.size(), scanner); - - parser parser(scanner, &ctx, result); + parser parser(lexer, result); if (parser.parse() || result == nullptr) { - throw comp_error(ctx.loc, "An unknown error ocurred while parsing gsc file."); + throw comp_error(xsk::gsc::location(&file), "An unknown error ocurred while parsing gsc file."); } - iw7__delete_buffer(yybuffer, scanner); - iw7_lex_destroy(scanner); - return result; } diff --git a/src/iw7/xsk/compiler.hpp b/src/iw7/xsk/compiler.hpp index 1d613500..1022d009 100644 --- a/src/iw7/xsk/compiler.hpp +++ b/src/iw7/xsk/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -25,7 +25,6 @@ class compiler : public gsc::compiler std::vector animtrees_; std::unordered_map constants_; std::function(const std::string&)> read_callback_; - std::vector sources_; std::vector break_blks_; std::vector continue_blks_; bool can_break_; diff --git a/src/iw7/xsk/decompiler.cpp b/src/iw7/xsk/decompiler.cpp index 1f14af60..371d4710 100644 --- a/src/iw7/xsk/decompiler.cpp +++ b/src/iw7/xsk/decompiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/xsk/decompiler.hpp b/src/iw7/xsk/decompiler.hpp index 44b31df5..ad96ace2 100644 --- a/src/iw7/xsk/decompiler.hpp +++ b/src/iw7/xsk/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/xsk/disassembler.cpp b/src/iw7/xsk/disassembler.cpp index db3da0c6..24559d5b 100644 --- a/src/iw7/xsk/disassembler.cpp +++ b/src/iw7/xsk/disassembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/xsk/disassembler.hpp b/src/iw7/xsk/disassembler.hpp index eefe365c..174da2cd 100644 --- a/src/iw7/xsk/disassembler.hpp +++ b/src/iw7/xsk/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/xsk/iw7.cpp b/src/iw7/xsk/iw7.cpp index e15f10c2..632e4b5b 100644 --- a/src/iw7/xsk/iw7.cpp +++ b/src/iw7/xsk/iw7.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/xsk/iw7.hpp b/src/iw7/xsk/iw7.hpp index 33ec87eb..18b02f23 100644 --- a/src/iw7/xsk/iw7.hpp +++ b/src/iw7/xsk/iw7.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw7/xsk/lexer.cpp b/src/iw7/xsk/lexer.cpp index a04137e2..fb7d12c7 100644 --- a/src/iw7/xsk/lexer.cpp +++ b/src/iw7/xsk/lexer.cpp @@ -1,3030 +1,986 @@ -#line 1 "lexer.cpp" -#include "stdafx.hpp" -#include "iw7.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw7_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw7_pop_header(xsk::gsc::context* ctx); - -#line 9 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define iw7__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer iw7__create_buffer -#endif - -#ifdef yy_delete_buffer -#define iw7__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer iw7__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define iw7__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer iw7__scan_buffer -#endif - -#ifdef yy_scan_string -#define iw7__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string iw7__scan_string -#endif - -#ifdef yy_scan_bytes -#define iw7__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes iw7__scan_bytes -#endif - -#ifdef yy_init_buffer -#define iw7__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer iw7__init_buffer -#endif - -#ifdef yy_flush_buffer -#define iw7__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer iw7__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define iw7__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state iw7__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define iw7__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer iw7__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define iw7_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state iw7_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define iw7_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state iw7_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define iw7_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack iw7_ensure_buffer_stack -#endif - -#ifdef yylex -#define iw7_lex_ALREADY_DEFINED -#else -#define yylex iw7_lex -#endif - -#ifdef yyrestart -#define iw7_restart_ALREADY_DEFINED -#else -#define yyrestart iw7_restart -#endif - -#ifdef yylex_init -#define iw7_lex_init_ALREADY_DEFINED -#else -#define yylex_init iw7_lex_init -#endif - -#ifdef yylex_init_extra -#define iw7_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra iw7_lex_init_extra -#endif - -#ifdef yylex_destroy -#define iw7_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy iw7_lex_destroy -#endif - -#ifdef yyget_debug -#define iw7_get_debug_ALREADY_DEFINED -#else -#define yyget_debug iw7_get_debug -#endif - -#ifdef yyset_debug -#define iw7_set_debug_ALREADY_DEFINED -#else -#define yyset_debug iw7_set_debug -#endif - -#ifdef yyget_extra -#define iw7_get_extra_ALREADY_DEFINED -#else -#define yyget_extra iw7_get_extra -#endif - -#ifdef yyset_extra -#define iw7_set_extra_ALREADY_DEFINED -#else -#define yyset_extra iw7_set_extra -#endif - -#ifdef yyget_in -#define iw7_get_in_ALREADY_DEFINED -#else -#define yyget_in iw7_get_in -#endif - -#ifdef yyset_in -#define iw7_set_in_ALREADY_DEFINED -#else -#define yyset_in iw7_set_in -#endif - -#ifdef yyget_out -#define iw7_get_out_ALREADY_DEFINED -#else -#define yyget_out iw7_get_out -#endif - -#ifdef yyset_out -#define iw7_set_out_ALREADY_DEFINED -#else -#define yyset_out iw7_set_out -#endif - -#ifdef yyget_leng -#define iw7_get_leng_ALREADY_DEFINED -#else -#define yyget_leng iw7_get_leng -#endif - -#ifdef yyget_text -#define iw7_get_text_ALREADY_DEFINED -#else -#define yyget_text iw7_get_text -#endif - -#ifdef yyget_lineno -#define iw7_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno iw7_get_lineno -#endif - -#ifdef yyset_lineno -#define iw7_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno iw7_set_lineno -#endif - -#ifdef yyget_column -#define iw7_get_column_ALREADY_DEFINED -#else -#define yyget_column iw7_get_column -#endif - -#ifdef yyset_column -#define iw7_set_column_ALREADY_DEFINED -#else -#define yyset_column iw7_set_column -#endif - -#ifdef yywrap -#define iw7_wrap_ALREADY_DEFINED -#else -#define yywrap iw7_wrap -#endif - -#ifdef yyalloc -#define iw7_alloc_ALREADY_DEFINED -#else -#define yyalloc iw7_alloc -#endif - -#ifdef yyrealloc -#define iw7_realloc_ALREADY_DEFINED -#else -#define yyrealloc iw7_realloc -#endif - -#ifdef yyfree -#define iw7_free_ALREADY_DEFINED -#else -#define yyfree iw7_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin , yyscanner ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define iw7_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); -static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 111 -#define YY_END_OF_BUFFER 112 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[328] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 112, 110, - 1, 2, 94, 110, 110, 93, 97, 110, 54, 55, - 91, 89, 60, 90, 61, 92, 109, 109, 63, 64, - 78, 88, 79, 65, 100, 58, 59, 98, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, - 100, 100, 100, 100, 56, 96, 57, 95, 5, 6, - 5, 12, 13, 12, 110, 91, 92, 75, 0, 102, - 0, 15, 0, 0, 0, 0, 84, 0, 73, 0, - 86, 0, 0, 8, 82, 66, 80, 67, 81, 105, - 0, 11, 4, 3, 83, 105, 109, 106, 0, 0, - - 0, 0, 62, 70, 76, 74, 77, 71, 100, 87, - 100, 100, 100, 100, 100, 100, 28, 100, 100, 100, - 100, 100, 26, 32, 100, 100, 100, 100, 100, 100, - 100, 100, 100, 100, 100, 85, 72, 7, 14, 10, - 9, 0, 102, 0, 0, 0, 0, 0, 0, 101, - 0, 0, 0, 0, 102, 0, 105, 0, 3, 105, - 105, 106, 107, 108, 99, 68, 69, 100, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 30, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, - 100, 103, 0, 0, 0, 0, 0, 101, 0, 0, - - 101, 0, 0, 52, 100, 45, 34, 100, 100, 100, - 27, 100, 100, 100, 50, 100, 100, 100, 100, 51, - 100, 100, 100, 46, 100, 22, 100, 0, 0, 0, - 0, 0, 49, 36, 100, 100, 100, 20, 47, 100, - 53, 100, 100, 100, 100, 100, 100, 100, 100, 29, - 0, 0, 0, 0, 0, 100, 100, 100, 100, 100, - 21, 100, 100, 38, 33, 100, 42, 100, 100, 104, - 0, 0, 16, 0, 100, 100, 100, 35, 31, 100, - 100, 100, 100, 100, 0, 17, 0, 100, 100, 37, - 100, 41, 100, 100, 23, 19, 0, 100, 100, 100, - - 100, 48, 100, 100, 0, 39, 100, 40, 44, 100, - 100, 0, 43, 100, 100, 0, 100, 100, 0, 100, - 24, 0, 100, 18, 100, 25, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, - 25, 26, 27, 1, 28, 29, 28, 28, 28, 28, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 31, 30, 30, - 32, 33, 34, 35, 36, 1, 37, 38, 39, 40, - - 41, 42, 43, 44, 45, 30, 46, 47, 48, 49, - 50, 51, 30, 52, 53, 54, 55, 56, 57, 31, - 58, 59, 60, 61, 62, 63, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[64] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 5, 5, 5, - 5, 1, 1, 1, 1, 1, 1, 5, 5, 6, - 6, 1, 7, 1, 1, 6, 5, 5, 5, 5, - 5, 5, 6, 6, 8, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 8, 6, 6, 6, 6, 1, - 1, 1, 1 - } ; - -static const flex_int16_t yy_base[348] = - { 0, - 0, 0, 61, 62, 63, 64, 65, 66, 702, 703, - 703, 703, 676, 63, 58, 675, 76, 67, 703, 703, - 62, 67, 703, 73, 86, 85, 96, 102, 677, 703, - 65, 673, 68, 703, 664, 703, 703, 671, 75, 76, - 93, 99, 98, 105, 111, 108, 78, 103, 100, 113, - 118, 125, 123, 127, 703, 136, 703, 703, 703, 703, - 678, 703, 703, 677, 145, 668, 161, 703, 158, 703, - 163, 703, 0, 643, 642, 637, 703, 160, 703, 161, - 703, 165, 176, 703, 703, 703, 703, 703, 703, 183, - 644, 703, 703, 0, 703, 187, 194, 200, 195, 216, - - 234, 0, 703, 663, 703, 703, 703, 662, 653, 703, - 143, 148, 184, 147, 150, 197, 652, 189, 203, 191, - 193, 208, 651, 650, 190, 207, 214, 211, 233, 215, - 225, 224, 245, 236, 249, 703, 703, 703, 703, 703, - 703, 254, 263, 281, 0, 637, 148, 636, 278, 703, - 285, 280, 288, 283, 284, 292, 703, 621, 0, 284, - 703, 311, 290, 0, 646, 703, 703, 267, 287, 265, - 266, 286, 289, 301, 295, 302, 304, 306, 307, 308, - 309, 313, 312, 317, 318, 320, 323, 325, 327, 328, - 329, 0, 630, 630, 631, 626, 358, 360, 366, 361, - - 365, 372, 633, 640, 53, 639, 638, 344, 345, 346, - 637, 347, 354, 352, 636, 350, 367, 370, 355, 635, - 353, 369, 371, 634, 377, 378, 379, 0, 612, 610, - 615, 620, 703, 380, 381, 384, 382, 629, 628, 383, - 627, 385, 401, 388, 392, 394, 407, 408, 411, 626, - 0, 606, 617, 615, 619, 395, 413, 393, 397, 416, - 621, 417, 419, 620, 619, 421, 618, 422, 428, 703, - 609, 608, 703, 611, 429, 426, 431, 614, 613, 433, - 430, 436, 446, 434, 604, 703, 595, 447, 449, 610, - 450, 609, 451, 452, 456, 703, 596, 432, 460, 458, - - 461, 607, 466, 469, 591, 588, 470, 579, 537, 472, - 467, 505, 525, 475, 478, 478, 479, 480, 488, 481, - 495, 486, 482, 703, 486, 492, 703, 531, 539, 547, - 552, 560, 566, 570, 578, 511, 586, 594, 602, 610, - 614, 419, 622, 630, 305, 246, 179 - } ; - -static const flex_int16_t yy_def[348] = - { 0, - 327, 1, 328, 328, 329, 329, 1, 1, 327, 327, - 327, 327, 327, 330, 331, 327, 327, 332, 327, 327, - 327, 327, 327, 327, 327, 327, 333, 333, 327, 327, - 327, 327, 327, 327, 334, 327, 327, 327, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 331, 327, 327, 327, 330, 327, - 335, 327, 336, 336, 327, 327, 327, 337, 327, 338, - 327, 332, 339, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 340, 327, 327, 333, 333, 333, 333, - - 333, 341, 327, 327, 327, 327, 327, 327, 334, 327, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 327, 327, 327, 327, 327, - 327, 330, 330, 335, 342, 327, 327, 327, 337, 327, - 343, 338, 344, 332, 332, 339, 327, 327, 340, 327, - 327, 333, 333, 101, 341, 327, 327, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 345, 327, 327, 327, 327, 337, 337, 343, 338, - - 338, 344, 327, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 346, 327, 327, - 327, 327, 327, 334, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, - 347, 327, 327, 327, 327, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 334, 334, 334, 334, 334, 327, - 327, 327, 327, 327, 334, 334, 334, 334, 334, 334, - 334, 334, 334, 334, 327, 327, 327, 334, 334, 334, - 334, 334, 334, 334, 334, 327, 327, 334, 334, 334, - - 334, 334, 334, 334, 327, 334, 334, 334, 334, 334, - 334, 327, 334, 334, 334, 327, 334, 334, 327, 334, - 334, 327, 334, 327, 334, 334, 0, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327 - } ; - -static const flex_int16_t yy_nxt[767] = - { 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, - 28, 29, 30, 31, 32, 33, 34, 35, 35, 35, - 35, 36, 10, 37, 38, 35, 39, 40, 41, 42, - 43, 44, 45, 35, 46, 35, 47, 35, 48, 35, - 49, 50, 51, 52, 53, 35, 54, 35, 35, 55, - 56, 57, 58, 60, 60, 63, 63, 70, 64, 64, - 65, 65, 61, 61, 72, 70, 66, 66, 84, 86, - 78, 67, 67, 79, 80, 102, 85, 88, 104, 105, - 92, 87, 107, 108, 74, 71, 93, 89, 234, 83, - - 81, 94, 75, 90, 90, 90, 90, 102, 102, 95, - 102, 96, 76, 97, 98, 98, 97, 96, 125, 97, - 97, 97, 97, 111, 100, 102, 101, 112, 102, 113, - 102, 102, 102, 100, 102, 102, 114, 102, 91, 116, - 102, 120, 115, 102, 118, 102, 119, 122, 117, 123, - 102, 127, 126, 128, 121, 102, 124, 102, 129, 102, - 136, 140, 70, 134, 150, 69, 141, 143, 131, 150, - 135, 133, 93, 70, 130, 102, 132, 94, 82, 102, - 102, 74, 102, 270, 155, 95, 194, 168, 169, 75, - 71, 172, 151, 153, 195, 144, 137, 83, 173, 76, - - 90, 90, 90, 90, 160, 160, 160, 160, 156, 96, - 327, 97, 97, 97, 97, 96, 102, 162, 162, 162, - 97, 102, 102, 102, 157, 102, 102, 102, 161, 102, - 170, 327, 102, 163, 163, 102, 171, 177, 174, 102, - 102, 175, 176, 102, 178, 180, 102, 102, 102, 327, - 251, 164, 164, 164, 164, 179, 102, 102, 70, 185, - 181, 164, 164, 182, 183, 102, 102, 70, 102, 186, - 164, 164, 164, 164, 164, 164, 187, 102, 188, 184, - 190, 102, 150, 69, 189, 143, 71, 149, 150, 198, - 152, 70, 70, 191, 82, 71, 201, 102, 102, 102, - - 155, 160, 160, 160, 160, 327, 207, 163, 163, 228, - 151, 206, 153, 144, 204, 83, 83, 199, 102, 102, - 202, 102, 102, 205, 156, 161, 96, 102, 162, 162, - 162, 97, 208, 102, 102, 211, 102, 210, 102, 102, - 102, 102, 209, 102, 102, 102, 214, 215, 216, 102, - 102, 212, 102, 217, 218, 102, 213, 102, 220, 102, - 102, 102, 150, 223, 150, 224, 219, 225, 149, 150, - 198, 221, 222, 150, 152, 227, 102, 102, 102, 102, - 201, 226, 102, 235, 102, 102, 102, 102, 240, 236, - 151, 245, 151, 153, 239, 238, 241, 153, 199, 102, - - 237, 102, 102, 102, 202, 243, 244, 247, 242, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 248, 250, - 102, 260, 246, 192, 102, 102, 102, 102, 259, 102, - 256, 249, 258, 102, 257, 265, 264, 266, 262, 102, - 102, 263, 261, 102, 275, 102, 267, 277, 102, 102, - 278, 102, 268, 102, 102, 269, 276, 280, 102, 279, - 102, 102, 102, 102, 102, 102, 102, 281, 102, 292, - 283, 290, 282, 288, 284, 291, 293, 289, 102, 102, - 295, 102, 102, 102, 102, 306, 294, 301, 102, 299, - 102, 302, 102, 102, 300, 298, 307, 303, 102, 102, - - 309, 102, 102, 304, 102, 311, 308, 102, 314, 313, - 102, 102, 102, 102, 102, 145, 318, 310, 102, 320, - 315, 323, 317, 321, 102, 326, 324, 102, 322, 319, - 325, 59, 59, 59, 59, 59, 59, 59, 59, 62, - 62, 62, 62, 62, 62, 62, 62, 69, 69, 69, - 69, 69, 69, 69, 69, 73, 73, 102, 316, 73, - 82, 82, 82, 82, 82, 82, 82, 82, 99, 102, - 99, 99, 99, 99, 109, 109, 109, 109, 142, 142, - 142, 142, 142, 142, 142, 142, 149, 149, 149, 149, - 149, 149, 149, 149, 152, 152, 152, 152, 152, 152, - - 152, 152, 154, 154, 154, 154, 154, 154, 154, 154, - 159, 102, 159, 159, 159, 159, 159, 159, 165, 165, - 102, 165, 197, 197, 197, 197, 197, 197, 197, 197, - 200, 200, 200, 200, 200, 200, 200, 200, 312, 102, - 305, 102, 102, 297, 296, 102, 102, 287, 286, 285, - 102, 102, 102, 102, 274, 273, 272, 271, 102, 102, - 102, 102, 255, 254, 253, 252, 102, 102, 102, 102, - 102, 102, 102, 233, 232, 231, 230, 229, 102, 203, - 196, 193, 102, 102, 102, 102, 167, 166, 158, 148, - 147, 146, 85, 139, 138, 110, 102, 106, 103, 77, - - 68, 327, 9, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327 - } ; - -static const flex_int16_t yy_chk[767] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 5, 6, 14, 5, 6, - 7, 8, 3, 4, 15, 18, 7, 8, 21, 22, - 17, 7, 8, 17, 17, 205, 21, 24, 31, 31, - 26, 22, 33, 33, 15, 14, 26, 24, 205, 18, - - 17, 26, 15, 25, 25, 25, 25, 39, 40, 26, - 47, 27, 15, 27, 27, 27, 27, 28, 47, 28, - 28, 28, 28, 39, 27, 41, 27, 40, 27, 41, - 43, 42, 49, 27, 28, 48, 41, 44, 25, 42, - 46, 44, 41, 45, 43, 50, 43, 45, 42, 46, - 51, 49, 48, 50, 44, 53, 46, 52, 51, 54, - 56, 65, 69, 54, 78, 71, 67, 71, 52, 80, - 54, 53, 67, 82, 51, 111, 52, 67, 83, 114, - 112, 65, 115, 347, 83, 67, 147, 111, 112, 65, - 69, 114, 78, 80, 147, 71, 56, 82, 115, 65, - - 90, 90, 90, 90, 96, 96, 96, 96, 83, 97, - 99, 97, 97, 97, 97, 98, 113, 98, 98, 98, - 98, 118, 125, 120, 90, 121, 97, 99, 96, 116, - 113, 100, 98, 100, 100, 119, 113, 120, 116, 126, - 122, 118, 119, 128, 121, 125, 127, 130, 100, 101, - 346, 101, 101, 101, 101, 122, 132, 131, 142, 130, - 126, 101, 101, 127, 128, 129, 101, 143, 134, 131, - 101, 101, 101, 101, 101, 101, 131, 133, 132, 129, - 134, 135, 149, 144, 133, 144, 142, 151, 152, 151, - 153, 154, 155, 135, 156, 143, 153, 170, 171, 168, - - 156, 160, 160, 160, 160, 163, 171, 163, 163, 345, - 149, 170, 152, 144, 168, 154, 155, 151, 172, 169, - 153, 173, 163, 169, 156, 160, 162, 175, 162, 162, - 162, 162, 172, 174, 176, 175, 177, 174, 178, 179, - 180, 181, 173, 162, 183, 182, 178, 179, 180, 184, - 185, 176, 186, 181, 182, 187, 177, 188, 184, 189, - 190, 191, 197, 187, 198, 188, 183, 189, 199, 200, - 199, 185, 186, 201, 202, 191, 208, 209, 210, 212, - 202, 190, 216, 208, 214, 221, 213, 219, 214, 209, - 197, 221, 198, 200, 213, 212, 216, 201, 199, 217, - - 210, 222, 218, 223, 202, 218, 219, 223, 217, 225, - 226, 227, 234, 235, 237, 240, 236, 242, 225, 227, - 244, 240, 222, 342, 245, 258, 246, 256, 237, 259, - 234, 226, 236, 243, 235, 245, 244, 246, 243, 247, - 248, 243, 242, 249, 256, 257, 247, 258, 260, 262, - 259, 263, 248, 266, 268, 249, 257, 262, 276, 260, - 269, 275, 281, 277, 298, 280, 284, 263, 282, 281, - 268, 277, 266, 275, 269, 280, 282, 276, 283, 288, - 284, 289, 291, 293, 294, 298, 283, 293, 295, 289, - 300, 294, 299, 301, 291, 288, 299, 295, 303, 311, - - 301, 304, 307, 295, 310, 304, 300, 314, 310, 307, - 315, 317, 318, 320, 323, 336, 315, 303, 325, 317, - 311, 320, 314, 318, 326, 325, 322, 321, 319, 316, - 323, 328, 328, 328, 328, 328, 328, 328, 328, 329, - 329, 329, 329, 329, 329, 329, 329, 330, 330, 330, - 330, 330, 330, 330, 330, 331, 331, 313, 312, 331, - 332, 332, 332, 332, 332, 332, 332, 332, 333, 309, - 333, 333, 333, 333, 334, 334, 334, 334, 335, 335, - 335, 335, 335, 335, 335, 335, 337, 337, 337, 337, - 337, 337, 337, 337, 338, 338, 338, 338, 338, 338, - - 338, 338, 339, 339, 339, 339, 339, 339, 339, 339, - 340, 308, 340, 340, 340, 340, 340, 340, 341, 341, - 306, 341, 343, 343, 343, 343, 343, 343, 343, 343, - 344, 344, 344, 344, 344, 344, 344, 344, 305, 302, - 297, 292, 290, 287, 285, 279, 278, 274, 272, 271, - 267, 265, 264, 261, 255, 254, 253, 252, 250, 241, - 239, 238, 232, 231, 230, 229, 224, 220, 215, 211, - 207, 206, 204, 203, 196, 195, 194, 193, 165, 158, - 148, 146, 124, 123, 117, 109, 108, 104, 91, 76, - 75, 74, 66, 64, 61, 38, 35, 32, 29, 16, - - 13, 9, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, - 327, 327, 327, 327, 327, 327 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.lpp" -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ -#define YY_NO_INPUT 1 -#define YY_NO_UNISTD_H 1 - -#line 25 "lexer.lpp" -#define YY_USER_ACTION ctx->loc.columns(yyleng); -#line 928 "lexer.cpp" - -#line 930 "lexer.cpp" - -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#include "stdafx.hpp" +#include "iw7.hpp" +#include "parser.hpp" +#include "lexer.hpp" + +xsk::gsc::iw7::parser::symbol_type IW7lex(xsk::gsc::iw7::lexer& lexer) +{ + return lexer.lex(); +} + +namespace xsk::gsc::iw7 +{ + +enum class keyword +{ +/* KW_pre_define, + KW_pre_undef, + KW_pre_ifdef, + KW_pre_ifndef, + KW_pre_if, + KW_pre_elif, + KW_pre_else, + KW_pre_endif,*/ + KW_pre_inline, + KW_pre_include, + KW_pre_using_animtree, + KW_pre_animtree, + KW_endon, + KW_notify, + KW_wait, + KW_waittill, + KW_waittillmatch, + KW_waittillframeend, + KW_if, + KW_else, + KW_do, + KW_while, + KW_for, + KW_foreach, + KW_in, + KW_switch, + KW_case, + KW_default, + KW_break, + KW_continue, + KW_return, + KW_breakpoint, + KW_prof_begin, + KW_prof_end, + KW_thread, + KW_childthread, + KW_thisthread, + KW_call, + KW_true, + KW_false, + KW_undefined, + KW_dotsize, + KW_game, + KW_self, + KW_anim, + KW_level, + KW_INVALID, +}; + +buffer::buffer() : size(1024), length(0) +{ + data = static_cast(std::malloc(size)); +} + +buffer::~buffer() +{ + if(data) std::free(data); +} + +bool buffer::push(char c) +{ + if(length >= size) { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals ( yyscan_t yyscanner ); - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef YY_NO_UNPUT - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( yyscan_t yyscanner ); -#else -static int input ( yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_load_buffer_state( yyscanner ); - } - - { -#line 44 "lexer.lpp" - - - -#line 48 "lexer.lpp" - ctx->loc.step(); - - -#line 1199 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 328 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 327 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 51 "lexer.lpp" -{ ctx->loc.step(); } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 52 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 54 "lexer.lpp" - - YY_BREAK -case 4: -YY_RULE_SETUP -#line 56 "lexer.lpp" -{ BEGIN(COMMENT_STATE); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 57 "lexer.lpp" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 58 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(COMMENT_STATE): -#line 60 "lexer.lpp" -{ throw iw7::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "lexer.lpp" -{ throw iw7::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 63 "lexer.lpp" -{ throw iw7::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 64 "lexer.lpp" -{ BEGIN(INITIAL); return iw7::parser::make_DEVEND(ctx->loc); } - YY_BREAK -case YY_STATE_EOF(DEV_ON_STATE): -#line 65 "lexer.lpp" -{ throw iw7::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 67 "lexer.lpp" -{ BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return iw7::parser::make_DEVBEGIN(ctx->loc); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 68 "lexer.lpp" - - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 69 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 70 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(DEV_OFF_STATE): -#line 71 "lexer.lpp" -{ throw iw7::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.lpp" -{ throw iw7::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 74 "lexer.lpp" -{ return iw7::parser::make_INLINE(ctx->loc); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 75 "lexer.lpp" -{ return iw7::parser::make_INCLUDE(ctx->loc); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 76 "lexer.lpp" -{ return iw7::parser::make_USINGTREE(ctx->loc); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 77 "lexer.lpp" -{ return iw7::parser::make_ANIMTREE(ctx->loc); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 78 "lexer.lpp" -{ return iw7::parser::make_ENDON(ctx->loc); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 79 "lexer.lpp" -{ return iw7::parser::make_NOTIFY(ctx->loc); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 80 "lexer.lpp" -{ return iw7::parser::make_WAIT(ctx->loc); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 81 "lexer.lpp" -{ return iw7::parser::make_WAITTILL(ctx->loc); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 82 "lexer.lpp" -{ return iw7::parser::make_WAITTILLMATCH(ctx->loc); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 83 "lexer.lpp" -{ return iw7::parser::make_WAITTILLFRAMEEND(ctx->loc); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 84 "lexer.lpp" -{ return iw7::parser::make_IF(ctx->loc); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 85 "lexer.lpp" -{ return iw7::parser::make_ELSE(ctx->loc); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 86 "lexer.lpp" -{ return iw7::parser::make_DO(ctx->loc); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 87 "lexer.lpp" -{ return iw7::parser::make_WHILE(ctx->loc); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 88 "lexer.lpp" -{ return iw7::parser::make_FOR(ctx->loc); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 89 "lexer.lpp" -{ return iw7::parser::make_FOREACH(ctx->loc); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 90 "lexer.lpp" -{ return iw7::parser::make_IN(ctx->loc); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 91 "lexer.lpp" -{ return iw7::parser::make_SWITCH(ctx->loc); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 92 "lexer.lpp" -{ return iw7::parser::make_CASE(ctx->loc); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 93 "lexer.lpp" -{ return iw7::parser::make_DEFAULT(ctx->loc); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 94 "lexer.lpp" -{ return iw7::parser::make_BREAK(ctx->loc); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 95 "lexer.lpp" -{ return iw7::parser::make_CONTINUE(ctx->loc); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 96 "lexer.lpp" -{ return iw7::parser::make_RETURN(ctx->loc); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 97 "lexer.lpp" -{ return iw7::parser::make_BREAKPOINT(ctx->loc); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 98 "lexer.lpp" -{ return iw7::parser::make_PROFBEGIN(ctx->loc); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 99 "lexer.lpp" -{ return iw7::parser::make_PROFEND(ctx->loc); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 100 "lexer.lpp" -{ return iw7::parser::make_THREAD(ctx->loc); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 101 "lexer.lpp" -{ return iw7::parser::make_CHILDTHREAD(ctx->loc); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 102 "lexer.lpp" -{ return iw7::parser::make_THISTHREAD(ctx->loc); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 103 "lexer.lpp" -{ return iw7::parser::make_CALL(ctx->loc); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 104 "lexer.lpp" -{ return iw7::parser::make_TRUE(ctx->loc); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 105 "lexer.lpp" -{ return iw7::parser::make_FALSE(ctx->loc); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 106 "lexer.lpp" -{ return iw7::parser::make_UNDEFINED(ctx->loc); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 107 "lexer.lpp" -{ return iw7::parser::make_SIZE(ctx->loc); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 108 "lexer.lpp" -{ return iw7::parser::make_GAME(ctx->loc); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 109 "lexer.lpp" -{ return iw7::parser::make_SELF(ctx->loc); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 110 "lexer.lpp" -{ return iw7::parser::make_ANIM(ctx->loc); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 111 "lexer.lpp" -{ return iw7::parser::make_LEVEL(ctx->loc); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 112 "lexer.lpp" -{ return iw7::parser::make_LPAREN(ctx->loc); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 113 "lexer.lpp" -{ return iw7::parser::make_RPAREN(ctx->loc); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 114 "lexer.lpp" -{ return iw7::parser::make_LBRACE(ctx->loc); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 115 "lexer.lpp" -{ return iw7::parser::make_RBRACE(ctx->loc); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 116 "lexer.lpp" -{ return iw7::parser::make_LBRACKET(ctx->loc); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 117 "lexer.lpp" -{ return iw7::parser::make_RBRACKET(ctx->loc); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 118 "lexer.lpp" -{ return iw7::parser::make_COMMA(ctx->loc); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 119 "lexer.lpp" -{ return iw7::parser::make_DOT(ctx->loc); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 120 "lexer.lpp" -{ return iw7::parser::make_DOUBLECOLON(ctx->loc); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 121 "lexer.lpp" -{ return iw7::parser::make_COLON(ctx->loc); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 122 "lexer.lpp" -{ return iw7::parser::make_SEMICOLON(ctx->loc); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 123 "lexer.lpp" -{ return iw7::parser::make_QMARK(ctx->loc); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 124 "lexer.lpp" -{ return iw7::parser::make_INCREMENT(ctx->loc); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 125 "lexer.lpp" -{ return iw7::parser::make_DECREMENT(ctx->loc); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 126 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_LSHIFT(ctx->loc); } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 127 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_RSHIFT(ctx->loc); } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 128 "lexer.lpp" -{ return iw7::parser::make_LSHIFT(ctx->loc); } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 129 "lexer.lpp" -{ return iw7::parser::make_RSHIFT(ctx->loc); } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 130 "lexer.lpp" -{ return iw7::parser::make_OR(ctx->loc); } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 131 "lexer.lpp" -{ return iw7::parser::make_AND(ctx->loc); } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 132 "lexer.lpp" -{ return iw7::parser::make_EQUALITY(ctx->loc); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 133 "lexer.lpp" -{ return iw7::parser::make_INEQUALITY(ctx->loc); } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 134 "lexer.lpp" -{ return iw7::parser::make_LESS_EQUAL(ctx->loc); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 135 "lexer.lpp" -{ return iw7::parser::make_GREATER_EQUAL(ctx->loc); } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 136 "lexer.lpp" -{ return iw7::parser::make_LESS(ctx->loc); } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 137 "lexer.lpp" -{ return iw7::parser::make_GREATER(ctx->loc); } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 138 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_ADD(ctx->loc); } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 139 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_SUB(ctx->loc); } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 140 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_MUL(ctx->loc); } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 141 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_DIV(ctx->loc); } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 142 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_MOD(ctx->loc); } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 143 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_BW_OR(ctx->loc); } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 144 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_BW_AND(ctx->loc); } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 145 "lexer.lpp" -{ return iw7::parser::make_ASSIGN_BW_EXOR(ctx->loc); } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 146 "lexer.lpp" -{ return iw7::parser::make_ASSIGN(ctx->loc); } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 147 "lexer.lpp" -{ return iw7::parser::make_ADD(ctx->loc); } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 148 "lexer.lpp" -{ return iw7::parser::make_SUB(ctx->loc); } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 149 "lexer.lpp" -{ return iw7::parser::make_MUL(ctx->loc); } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 150 "lexer.lpp" -{ return iw7::parser::make_DIV(ctx->loc); } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 151 "lexer.lpp" -{ return iw7::parser::make_MOD(ctx->loc); } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 152 "lexer.lpp" -{ return iw7::parser::make_NOT(ctx->loc); } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 153 "lexer.lpp" -{ return iw7::parser::make_COMPLEMENT(ctx->loc); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 154 "lexer.lpp" -{ return iw7::parser::make_BITWISE_OR(ctx->loc); } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 155 "lexer.lpp" -{ return iw7::parser::make_BITWISE_AND(ctx->loc); } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 156 "lexer.lpp" -{ return iw7::parser::make_BITWISE_EXOR(ctx->loc); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 157 "lexer.lpp" -{ return iw7::parser::make_PATH(xsk::gsc::iw7::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 158 "lexer.lpp" -{ return iw7::parser::make_IDENTIFIER(xsk::gsc::iw7::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 101: -/* rule 101 can match eol */ -YY_RULE_SETUP -#line 159 "lexer.lpp" -{ return iw7::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 102: -/* rule 102 can match eol */ -YY_RULE_SETUP -#line 160 "lexer.lpp" -{ return iw7::parser::make_STRING(std::string(yytext), ctx->loc); } - YY_BREAK -case 103: -YY_RULE_SETUP -#line 161 "lexer.lpp" -{ return iw7::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 104: -YY_RULE_SETUP -#line 162 "lexer.lpp" -{ return iw7::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 105: -YY_RULE_SETUP -#line 163 "lexer.lpp" -{ return iw7::parser::make_FLOAT(std::string(yytext), ctx->loc); } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 164 "lexer.lpp" -{ return iw7::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 165 "lexer.lpp" -{ return iw7::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 166 "lexer.lpp" -{ return iw7::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 167 "lexer.lpp" -{ return iw7::parser::make_INTEGER(std::string(yytext), ctx->loc); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 168 "lexer.lpp" -{ if(ctx->header_top > 0) iw7_pop_header(ctx); else return iw7::parser::make_IW7EOF(ctx->loc); } - YY_BREAK -case 110: -/* rule 110 can match eol */ -YY_RULE_SETUP -#line 169 "lexer.lpp" -{ throw iw7::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - YY_BREAK -case 111: -YY_RULE_SETUP -#line 171 "lexer.lpp" -ECHO; - YY_BREAK -#line 1829 "lexer.cpp" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap( yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin , yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + auto nsize = size * 2; + auto ndata = reinterpret_cast(std::malloc(nsize)); + + if(!ndata) return false; + + std::memmove(ndata, data, size); + std::free(data); + size = nsize; + data = ndata; + } + data[length++] = c; + return true; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 328 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; } -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +void reader::init(const char* data, size_t size) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 328 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 327); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + if(data && size) + { + state = reader::ok; + buffer_pos = data; + bytes_remaining = size; + last_byte = 0; + current_byte = *data; + } + else + { + state = reader::end; + buffer_pos = 0; + bytes_remaining = 0; + last_byte = 0; + current_byte = 0; + } } -#ifndef YY_NO_UNPUT - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - +void reader::advance() { - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + ++buffer_pos; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin , yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); - yy_load_buffer_state( yyscanner ); + if(bytes_remaining-- == 1) + { + state = reader::end; + bytes_remaining = 0; + last_byte = current_byte; + current_byte = 0; + } + else + { + last_byte = current_byte; + current_byte = *buffer_pos; + } } -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +lexer::lexer(const std::string& name, const char* data, size_t size) : in_dev_state_(false), loc_(xsk::gsc::location(&name)), + mode_(build::dev), header_top_(0), locs_(std::stack()), readers_(std::stack()) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + reader_.init(data, size); } -static void yy_load_buffer_state (yyscan_t yyscanner) +void lexer::push_header(const std::string& file) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + try + { + if (header_top_++ >= 10) + throw xsk::gsc::error("maximum gsh depth exceeded '10'"); + + auto data = resolver::file_data(file + ".gsh"); + + readers_.push(reader_); + locs_.push(loc_); + loc_.initialize(std::get<0>(data)); + reader_.init(std::get<1>(data), std::get<2>(data)); + } + catch (const std::exception& e) + { + throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); + } } -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +void lexer::pop_header() { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file , yyscanner); - - return b; + header_top_--; + loc_ = locs_.top(); + locs_.pop(); + reader_ = readers_.top(); + readers_.pop(); } -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void lexer::restrict_header(const xsk::gsc::location& loc) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf , yyscanner ); - - yyfree( (void *) b , yyscanner ); + if (header_top_ > 0) + { + throw comp_error(loc, "not allowed inside a gsh file"); + } } -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - +auto lexer::lex() -> xsk::gsc::iw7::parser::symbol_type { - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + buffer_.length = 0; + loc_.step(); - yy_flush_buffer( b , yyscanner); + while (true) + { + if (reader_.state == reader::end) + { + if (in_dev_state_) + throw iw7::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + if(header_top_ > 0) + pop_header(); + else + return iw7::parser::make_IW7EOF(loc_); + } - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + reader_.advance(); + auto& last = reader_.last_byte; + auto& curr = reader_.current_byte; + + switch (last) + { + case ' ': + case '\t': + case '\r': + loc_.step(); + continue; + case '\n': + loc_.lines(); + loc_.step(); + continue; + case '/': + if(reader_.state == reader::end || (curr != '/' && curr != '*' && curr != '#' && curr != '=')) + return iw7::parser::make_DIV(loc_); + + reader_.advance(); + + if (last == '=') + return iw7::parser::make_ASSIGN_DIV(loc_); + + if (last == '#') + { + if (in_dev_state_) + { + throw iw7::parser::syntax_error(loc_, "cannot recurse devblock ('/#')"); + } + else if (mode_ == xsk::gsc::build::dev) + { + in_dev_state_ = true; + return iw7::parser::make_DEVBEGIN(loc_); + } + else + { + while (true) + { + if (reader_.state == reader::end) + { + throw iw7::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '#' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + } + else if (last == '*') + { + while (true) + { + if (reader_.state == reader::end) + { + throw iw7::parser::syntax_error(loc_, "unmatched multiline comment start ('/*')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '*' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + else if (last == '/') + { + while (true) + { + if (reader_.state == reader::end || curr == '\n') + break; + + reader_.advance(); + } + } + continue; + case '#': + if (curr == '/') + { + if (!in_dev_state_) + throw iw7::parser::syntax_error(loc_, "unmatched devblock end ('#/')"); + + in_dev_state_ = false; + reader_.advance(); + return iw7::parser::make_DEVEND(loc_); + } + + buffer_.push(last); + while (reader_.state == reader::ok) + { + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + { + if (auto len = buffer_.length; len == 4 || len == 7) + { + auto data = buffer_.data; + auto color = true; + for (auto i = 1; i < len; i++) + { + if ((data[i] < 48 || data[i] > 57) && (data[i] < 65 || data[i] > 70) && (data[i] < 97 || data[i] > 102)) + { + color = false; + break; + } + } + + if (color) return iw7::parser::make_COLOR(std::string(++data, --len), loc_); + } + + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); + + if (key == keyword::KW_INVALID) + throw iw7::parser::syntax_error(loc_, utils::string::va("unknown preprocessor directive ('%s')", "#")); + + if (keyword_is_token(key)) + return keyword_token(key); + + // call preprocessor(key); + } + continue; + case '*': + if (reader_.state == reader::end || (curr != '/' && curr != '=')) + return iw7::parser::make_MUL(loc_); + + reader_.advance(); + + if (curr == '/') + throw iw7::parser::syntax_error(loc_, "unmatched multiline comment end ('*/')"); + + return iw7::parser::make_ASSIGN_MUL(loc_); + case '"': + case '\'': + return read_string(last, false); + case '.': + return read_dotsize(); + case '(': + return iw7::parser::make_LPAREN(loc_); + case ')': + return iw7::parser::make_RPAREN(loc_); + case '{': + return iw7::parser::make_LBRACE(loc_); + case '}': + return iw7::parser::make_RBRACE(loc_); + case '[': + return iw7::parser::make_LBRACKET(loc_); + case ']': + return iw7::parser::make_RBRACKET(loc_); + case ',': + return iw7::parser::make_COMMA(loc_); + case ';': + return iw7::parser::make_SEMICOLON(loc_); + case ':': + if (curr != ':') + return iw7::parser::make_COLON(loc_); + reader_.advance(); + return iw7::parser::make_DOUBLECOLON(loc_); + case '?': + return iw7::parser::make_QMARK(loc_); + case '=': + if (curr != '=') + return iw7::parser::make_ASSIGN(loc_); + reader_.advance(); + return iw7::parser::make_EQUALITY(loc_); + case '+': + if (curr != '+' && curr != '=') + return iw7::parser::make_ADD(loc_); + reader_.advance(); + return (last == '+') ? iw7::parser::make_INCREMENT(loc_) : iw7::parser::make_ASSIGN_ADD(loc_); + case '-': + if (curr != '-' && curr != '=') + return iw7::parser::make_SUB(loc_); + reader_.advance(); + return (last == '-') ? iw7::parser::make_DECREMENT(loc_) : iw7::parser::make_ASSIGN_SUB(loc_); + case '%': + if (curr != '=') + return iw7::parser::make_MOD(loc_); + reader_.advance(); + return iw7::parser::make_ASSIGN_MOD(loc_); + case '|': + if (curr != '|' && curr != '=') + return iw7::parser::make_BITWISE_OR(loc_); + reader_.advance(); + return (last == '|') ? iw7::parser::make_OR(loc_) : iw7::parser::make_ASSIGN_BW_OR(loc_); + case '&': + if (curr != '&' && curr != '=' && curr != '"' && curr != '\'') + return iw7::parser::make_BITWISE_AND(loc_); + reader_.advance(); + if (last == '"' || last == '\'') + return read_string(last, true); + return (last == '&') ? iw7::parser::make_AND(loc_) : iw7::parser::make_ASSIGN_BW_AND(loc_); + case '^': + if (curr != '=') + return iw7::parser::make_BITWISE_EXOR(loc_); + reader_.advance(); + return iw7::parser::make_ASSIGN_BW_EXOR(loc_); + case '!': + if (curr != '=') + return iw7::parser::make_NOT(loc_); + reader_.advance(); + return iw7::parser::make_INEQUALITY(loc_); + case '~': + return iw7::parser::make_COMPLEMENT(loc_); + case '<': + if (curr != '<' && curr != '=') + return iw7::parser::make_LESS(loc_); + reader_.advance(); + if (last == '<') + { + reader_.advance(); + return (last == '=') ? iw7::parser::make_ASSIGN_LSHIFT(loc_) : iw7::parser::make_LSHIFT(loc_); + } + return iw7::parser::make_LESS_EQUAL(loc_); + case '>': + if (curr != '>' && curr != '=') + return iw7::parser::make_GREATER(loc_); + reader_.advance(); + if (last == '>') + { + reader_.advance(); + return (last == '=') ? iw7::parser::make_ASSIGN_RSHIFT(loc_) : iw7::parser::make_RSHIFT(loc_); + } + return iw7::parser::make_GREATER_EQUAL(loc_); + default: + if (last >= '0' && last <= '9') + return lexer::read_number(last); + else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z') + return lexer::read_word(last); + + throw iw7::parser::syntax_error(loc_, utils::string::va("bad token: \'%c\'", last)); + } + } +} + +auto lexer::read_string(char quote, bool localize) -> xsk::gsc::iw7::parser::symbol_type +{ + if (localize) + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + reader_.advance(); + + if (last == '\n') + throw iw7::parser::syntax_error(loc_, "unterminated string"); + + if (last == '\\') // process scapes + { + // TODO: + } + + if (last != '\\' && curr == quote) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); } - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b , yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n , yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n , yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int _line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = _line_number; -} - -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column (int _column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = _column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int _bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = _bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (reader_.state == reader::end) + { + throw iw7::parser::syntax_error(loc_, utils::string::va("unmatched string start ('%s')", (quote == '"') ? "\"" : "\\'")); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + if (localize) + return iw7::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + return iw7::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_); +} + +auto lexer::read_number(char first) -> xsk::gsc::iw7::parser::symbol_type +{ + if (first == '.') + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = true; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw iw7::parser::syntax_error(loc_, "invalid number '.'"); + } + if (data[i] == 'f' && i != len - 1) + throw iw7::parser::syntax_error(loc_, "invalid number 'f'"); + } + + return iw7::parser::make_FLOAT(std::string(data, len), loc_); + } + else + { + auto curr = reader_.current_byte; + + if (first == '0' && curr == 'o') + { + buffer_.push(first); + buffer_.push('o'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'o')) + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'o' && last == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr > 47 && curr < 56)) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid octal literal!"); + + return iw7::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data + 2), loc_); + } + else if (first == '0' && curr == 'b') + { + buffer_.push(first); + buffer_.push('b'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'b')) + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'b' && last == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (curr != '0' && curr != '1') + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid binary literal!"); + + return iw7::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_); + } + else if (first == '0' && curr == 'x') + { + buffer_.push(first); + buffer_.push('x'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'x')) + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'x' && last == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!((curr > 47 && curr < 58) || (curr > 64 && curr < 71) || (curr > 96 && curr < 103))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid hexadecimal literal!"); + + return iw7::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_); + } + else + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw7::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = false; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw iw7::parser::syntax_error(loc_, "invalid number '.'"); + + dot = true; + } + if (data[i] == 'f' && i != len - 1) + throw iw7::parser::syntax_error(loc_, "invalid number 'f'"); + } + + if (dot || data[len - 1] == 'f') + return iw7::parser::make_FLOAT(std::string(data, len), loc_); + + return iw7::parser::make_INTEGER(std::string(data, len), loc_); + } + } +} + +auto lexer::read_word(char first) -> xsk::gsc::iw7::parser::symbol_type +{ + auto path = false; + + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto curr = reader_.current_byte; + + if (!(curr == '\\' || curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (curr == '\\') + { + if (reader_.last_byte == '\\') + throw iw7::parser::syntax_error(loc_, "invalid path '\\\\'"); + + path = true; + curr = '/'; + } + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); - return yy_init_globals ( *ptr_yy_globals ); -} + if (key != keyword::KW_INVALID) + return keyword_token(key); -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; + if (path) + { + if (buffer_.data[buffer_.length - 1] == '/') + throw iw7::parser::syntax_error(loc_, "invalid path end '\\'"); - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + return iw7::parser::make_PATH(xsk::gsc::iw7::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + return iw7::parser::make_IDENTIFIER(xsk::gsc::iw7::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); +} - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; +auto lexer::read_dotsize() -> xsk::gsc::iw7::parser::symbol_type +{ + auto curr = reader_.current_byte; + + if (curr > 47 && curr < 58) + { + return lexer::read_number('.'); + } + else if (curr == '_' || curr > 64 && curr < 91 || curr > 96 && curr < 123) + { + reader save; + save.state = reader_.state; + save.bytes_remaining = reader_.bytes_remaining; + save.buffer_pos = reader_.buffer_pos; + save.last_byte = reader_.last_byte; + save.current_byte = reader_.current_byte; + + while (reader_.state == reader::ok) + { + curr = reader_.current_byte; + + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (std::string_view(buffer_.data, buffer_.length) == "size") + { + return iw7::parser::make_SIZE(loc_); + } + + reader_.state = save.state; + reader_.bytes_remaining = save.bytes_remaining; + reader_.buffer_pos = save.buffer_pos; + reader_.last_byte = save.last_byte; + reader_.current_byte = save.current_byte; + + return iw7::parser::make_DOT(loc_); + + } + else return iw7::parser::make_DOT(loc_); +} + +auto lexer::keyword_token(keyword k) -> xsk::gsc::iw7::parser::symbol_type +{ + switch (k) + { + case keyword::KW_pre_inline: + return iw7::parser::make_INLINE(loc_); + case keyword::KW_pre_include: + return iw7::parser::make_INCLUDE(loc_); + case keyword::KW_pre_using_animtree: + return iw7::parser::make_USINGTREE(loc_); + case keyword::KW_pre_animtree: + return iw7::parser::make_ANIMTREE(loc_); + case keyword::KW_endon: + return iw7::parser::make_ENDON(loc_); + case keyword::KW_notify: + return iw7::parser::make_NOTIFY(loc_); + case keyword::KW_wait: + return iw7::parser::make_WAIT(loc_); + case keyword::KW_waittill: + return iw7::parser::make_WAITTILL(loc_); + case keyword::KW_waittillmatch: + return iw7::parser::make_WAITTILLMATCH(loc_); + case keyword::KW_waittillframeend: + return iw7::parser::make_WAITTILLFRAMEEND(loc_); + case keyword::KW_if: + return iw7::parser::make_IF(loc_); + case keyword::KW_else: + return iw7::parser::make_ELSE(loc_); + case keyword::KW_do: + return iw7::parser::make_DO(loc_); + case keyword::KW_while: + return iw7::parser::make_WHILE(loc_); + case keyword::KW_for: + return iw7::parser::make_FOR(loc_); + case keyword::KW_foreach: + return iw7::parser::make_FOREACH(loc_); + case keyword::KW_in: + return iw7::parser::make_IN(loc_); + case keyword::KW_switch: + return iw7::parser::make_SWITCH(loc_); + case keyword::KW_case: + return iw7::parser::make_CASE(loc_); + case keyword::KW_default: + return iw7::parser::make_DEFAULT(loc_); + case keyword::KW_break: + return iw7::parser::make_BREAK(loc_); + case keyword::KW_continue: + return iw7::parser::make_CONTINUE(loc_); + case keyword::KW_return: + return iw7::parser::make_RETURN(loc_); + case keyword::KW_breakpoint: + return iw7::parser::make_BREAKPOINT(loc_); + case keyword::KW_prof_begin: + return iw7::parser::make_PROFBEGIN(loc_); + case keyword::KW_prof_end: + return iw7::parser::make_PROFEND(loc_); + case keyword::KW_thread: + return iw7::parser::make_THREAD(loc_); + case keyword::KW_childthread: + return iw7::parser::make_CHILDTHREAD(loc_); + case keyword::KW_thisthread: + return iw7::parser::make_THISTHREAD(loc_); + case keyword::KW_call: + return iw7::parser::make_CALL(loc_); + case keyword::KW_true: + return iw7::parser::make_TRUE(loc_); + case keyword::KW_false: + return iw7::parser::make_FALSE(loc_); + case keyword::KW_undefined: + return iw7::parser::make_UNDEFINED(loc_); + case keyword::KW_dotsize: + return iw7::parser::make_SIZE(loc_); + case keyword::KW_game: + return iw7::parser::make_GAME(loc_); + case keyword::KW_self: + return iw7::parser::make_SELF(loc_); + case keyword::KW_anim: + return iw7::parser::make_ANIM(loc_); + case keyword::KW_level: + return iw7::parser::make_LEVEL(loc_); + default: + throw error("gsc lexer: INVALID KEYWORD TOKEN!"); + } +} + +auto lexer::keyword_is_token(keyword k) -> bool +{ + switch (k) + { +/* case keyword::KW_pre_define: + case keyword::KW_pre_undef: + case keyword::KW_pre_ifdef: + case keyword::KW_pre_ifndef: + case keyword::KW_pre_if: + case keyword::KW_pre_elif: + case keyword::KW_pre_else: + case keyword::KW_pre_endif:*/ + case keyword::KW_INVALID: + return false; + default: + return true; + } +} + +auto lexer::get_keyword(std::string_view str) -> keyword +{ + auto itr = keywords.find(str); + + if(itr != keywords.end()) + { + return itr->second; } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + return keyword::KW_INVALID; } -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack , yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack , yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s , yyscan_t yyscanner) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 171 "lexer.lpp" - - -void iw7_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void iw7_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} +std::unordered_map lexer::keywords +{{ +/* { "#define", keyword::KW_pre_define }, + { "#undef", keyword::KW_pre_undef }, + { "#ifdef", keyword::KW_pre_ifdef }, + { "#ifndef", keyword::KW_pre_ifndef }, + { "#if", keyword::KW_pre_if }, + { "#elif", keyword::KW_pre_elif }, + { "#else", keyword::KW_pre_else }, + { "#endif", keyword::KW_pre_endif },*/ + { "#inline", keyword::KW_pre_inline }, + { "#include", keyword::KW_pre_include }, + { "#using_animtree", keyword::KW_pre_using_animtree }, + { "#animtree", keyword::KW_pre_animtree }, + { "endon", keyword::KW_endon }, + { "notify", keyword::KW_notify }, + { "wait", keyword::KW_wait }, + { "waittill", keyword::KW_waittill }, + { "waittillmatch", keyword::KW_waittillmatch }, + { "waittillframeend", keyword::KW_waittillframeend }, + { "if", keyword::KW_if }, + { "else", keyword::KW_else }, + { "do", keyword::KW_do }, + { "while", keyword::KW_while }, + { "for", keyword::KW_for }, + { "foreach", keyword::KW_foreach }, + { "in", keyword::KW_in }, + { "switch", keyword::KW_switch }, + { "case", keyword::KW_case }, + { "default", keyword::KW_default }, + { "break", keyword::KW_break }, + { "continue", keyword::KW_continue }, + { "return", keyword::KW_return }, + { "breakpoint", keyword::KW_breakpoint }, + { "prof_begin", keyword::KW_prof_begin }, + { "prof_end", keyword::KW_prof_end }, + { "thread", keyword::KW_thread }, + { "childthread", keyword::KW_childthread }, + { "thisthread", keyword::KW_thisthread }, + { "call", keyword::KW_call }, + { "true", keyword::KW_true }, + { "false", keyword::KW_false }, + { "undefined", keyword::KW_undefined }, + { ".size", keyword::KW_dotsize }, + { "game", keyword::KW_game }, + { "self", keyword::KW_self }, + { "anim", keyword::KW_anim }, + { "level", keyword::KW_level }, +}}; +} // namespace xsk::gsc::iw7 diff --git a/src/iw7/xsk/lexer.hpp b/src/iw7/xsk/lexer.hpp index df078b4a..f1aea198 100644 --- a/src/iw7/xsk/lexer.hpp +++ b/src/iw7/xsk/lexer.hpp @@ -1,711 +1,79 @@ -#ifndef iw7_HEADER_H -#define iw7_HEADER_H 1 -#define iw7_IN_HEADER 1 - -#line 5 "lexer.hpp" -#include "stdafx.hpp" -#include "iw7.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw7_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw7_pop_header(xsk::gsc::context* ctx); - -#line 13 "lexer.hpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define iw7__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer iw7__create_buffer -#endif - -#ifdef yy_delete_buffer -#define iw7__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer iw7__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define iw7__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer iw7__scan_buffer -#endif - -#ifdef yy_scan_string -#define iw7__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string iw7__scan_string -#endif - -#ifdef yy_scan_bytes -#define iw7__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes iw7__scan_bytes -#endif - -#ifdef yy_init_buffer -#define iw7__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer iw7__init_buffer -#endif - -#ifdef yy_flush_buffer -#define iw7__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer iw7__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define iw7__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state iw7__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define iw7__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer iw7__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define iw7_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state iw7_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define iw7_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state iw7_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define iw7_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack iw7_ensure_buffer_stack -#endif - -#ifdef yylex -#define iw7_lex_ALREADY_DEFINED -#else -#define yylex iw7_lex -#endif - -#ifdef yyrestart -#define iw7_restart_ALREADY_DEFINED -#else -#define yyrestart iw7_restart -#endif - -#ifdef yylex_init -#define iw7_lex_init_ALREADY_DEFINED -#else -#define yylex_init iw7_lex_init -#endif - -#ifdef yylex_init_extra -#define iw7_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra iw7_lex_init_extra -#endif - -#ifdef yylex_destroy -#define iw7_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy iw7_lex_destroy -#endif - -#ifdef yyget_debug -#define iw7_get_debug_ALREADY_DEFINED -#else -#define yyget_debug iw7_get_debug -#endif - -#ifdef yyset_debug -#define iw7_set_debug_ALREADY_DEFINED -#else -#define yyset_debug iw7_set_debug -#endif - -#ifdef yyget_extra -#define iw7_get_extra_ALREADY_DEFINED -#else -#define yyget_extra iw7_get_extra -#endif - -#ifdef yyset_extra -#define iw7_set_extra_ALREADY_DEFINED -#else -#define yyset_extra iw7_set_extra -#endif - -#ifdef yyget_in -#define iw7_get_in_ALREADY_DEFINED -#else -#define yyget_in iw7_get_in -#endif - -#ifdef yyset_in -#define iw7_set_in_ALREADY_DEFINED -#else -#define yyset_in iw7_set_in -#endif - -#ifdef yyget_out -#define iw7_get_out_ALREADY_DEFINED -#else -#define yyget_out iw7_get_out -#endif - -#ifdef yyset_out -#define iw7_set_out_ALREADY_DEFINED -#else -#define yyset_out iw7_set_out -#endif - -#ifdef yyget_leng -#define iw7_get_leng_ALREADY_DEFINED -#else -#define yyget_leng iw7_get_leng -#endif - -#ifdef yyget_text -#define iw7_get_text_ALREADY_DEFINED -#else -#define yyget_text iw7_get_text -#endif - -#ifdef yyget_lineno -#define iw7_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno iw7_get_lineno -#endif - -#ifdef yyset_lineno -#define iw7_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno iw7_set_lineno -#endif - -#ifdef yyget_column -#define iw7_get_column_ALREADY_DEFINED -#else -#define yyget_column iw7_get_column -#endif - -#ifdef yyset_column -#define iw7_set_column_ALREADY_DEFINED -#else -#define yyset_column iw7_set_column -#endif - -#ifdef yywrap -#define iw7_wrap_ALREADY_DEFINED -#else -#define yywrap iw7_wrap -#endif - -#ifdef yyalloc -#define iw7_alloc_ALREADY_DEFINED -#else -#define yyalloc iw7_alloc -#endif - -#ifdef yyrealloc -#define iw7_realloc_ALREADY_DEFINED -#else -#define yyrealloc iw7_realloc -#endif - -#ifdef yyfree -#define iw7_free_ALREADY_DEFINED -#else -#define yyfree iw7_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define iw7_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#ifndef iw7__create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef iw7__delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef iw7__scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef iw7__scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef iw7__scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef iw7__init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef iw7__flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef iw7__load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef iw7__switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef iw7_push_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef iw7_pop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef iw7_ensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef iw7_lex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef iw7_restart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef iw7_lex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef iw7_lex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef iw7_lex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef iw7_get_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef iw7_set_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef iw7_get_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef iw7_set_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef iw7_get_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef iw7_set_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef iw7_get_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef iw7_set_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef iw7_get_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef iw7_get_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef iw7_get_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef iw7_set_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef iw7_get_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef iw7_set_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef iw7_wrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef iw7_get_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef iw7_set_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef iw7_get_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef iw7_set_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef iw7_alloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef iw7_realloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef iw7_free_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef iw7_text_ALREADY_DEFINED -#undef yytext -#endif -#ifndef iw7_leng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef iw7_in_ALREADY_DEFINED -#undef yyin -#endif -#ifndef iw7_out_ALREADY_DEFINED -#undef yyout -#endif -#ifndef iw7__flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef iw7_lineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef iw7_tables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef iw7_tables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef iw7_TABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 171 "lexer.lpp" - - -#line 709 "lexer.hpp" -#undef iw7_IN_HEADER -#endif /* iw7_HEADER_H */ +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#pragma once + +#include "iw7.hpp" + +namespace xsk::gsc::iw7 +{ + +enum class keyword; + +struct buffer +{ + int size; + int length; + char* data; + + buffer(); + ~buffer(); + bool push(char c); +}; + +struct reader +{ + enum states { end, ok }; + + states state; + int bytes_remaining; + const char* buffer_pos; + char last_byte; + char current_byte; + + reader(); + + reader& operator=(const reader& r) + { + std::memcpy(this, &r, sizeof(reader)); + return *this; + } + + void init(const char* data, size_t size); + void advance(); +}; + +class lexer +{ +private: + reader reader_; + buffer buffer_; + location loc_; + build mode_; + bool in_dev_state_; + std::stack locs_; + std::stack readers_; + std::uint32_t header_top_; + +public: + lexer(const std::string& name, const char* data, size_t size); + auto lex() -> xsk::gsc::iw7::parser::symbol_type; + void push_header(const std::string& file); + void pop_header(); + void restrict_header(const xsk::gsc::location& loc); + +private: + auto read_string(char quote, bool localize) -> xsk::gsc::iw7::parser::symbol_type; + auto read_number(char first) -> xsk::gsc::iw7::parser::symbol_type; + auto read_word(char first) -> xsk::gsc::iw7::parser::symbol_type; + auto read_dotsize() -> xsk::gsc::iw7::parser::symbol_type; + auto keyword_token(keyword k) -> xsk::gsc::iw7::parser::symbol_type; + static auto keyword_is_token(keyword k) -> bool; + static auto get_keyword(std::string_view str) -> keyword; + + static std::unordered_map keywords; +}; + +} // namespace xsk::gsc::iw7 diff --git a/src/iw7/xsk/parser.cpp b/src/iw7/xsk/parser.cpp index 6ef244a1..892dd8d4 100644 --- a/src/iw7/xsk/parser.cpp +++ b/src/iw7/xsk/parser.cpp @@ -35,13 +35,13 @@ // private implementation details that can be changed or removed. // "%code top" blocks. -#line 40 "parser.ypp" +#line 34 "parser.ypp" #include "stdafx.hpp" #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::iw7::parser::symbol_type IW7lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::iw7::parser::symbol_type IW7lex(xsk::gsc::iw7::lexer& lexer); #line 47 "parser.cpp" @@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace iw7 { #line 149 "parser.cpp" /// Build a parser object. - parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) + parser::parser (xsk::gsc::iw7::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) #if IW7DEBUG : yydebug_ (false), yycdebug_ (&std::cerr), @@ -156,8 +156,7 @@ namespace xsk { namespace gsc { namespace iw7 { : #endif yy_lac_established_ (false), - yyscanner (yyscanner_yyarg), - ctx (ctx_yyarg), + lexer (lexer_yyarg), ast (ast_yyarg) {} @@ -1577,7 +1576,7 @@ namespace xsk { namespace gsc { namespace iw7 { try #endif // YY_EXCEPTIONS { - symbol_type yylookahead (yylex (yyscanner, ctx)); + symbol_type yylookahead (yylex (lexer)); yyla.move (yylookahead); } #if YY_EXCEPTIONS @@ -1960,1285 +1959,1285 @@ namespace xsk { namespace gsc { namespace iw7 { switch (yyn) { case 2: // root: program -#line 249 "parser.ypp" +#line 243 "parser.ypp" { ast = std::move(yystack_[0].value.as < ast::program::ptr > ()); } -#line 1966 "parser.cpp" +#line 1965 "parser.cpp" break; case 3: // root: %empty -#line 250 "parser.ypp" +#line 244 "parser.ypp" { ast = std::make_unique(yylhs.location); } -#line 1972 "parser.cpp" +#line 1971 "parser.cpp" break; case 4: // program: program inline -#line 255 "parser.ypp" +#line 249 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); } -#line 1978 "parser.cpp" +#line 1977 "parser.cpp" break; case 5: // program: program include -#line 257 "parser.ypp" +#line 251 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 1984 "parser.cpp" +#line 1983 "parser.cpp" break; case 6: // program: program declaration -#line 259 "parser.ypp" +#line 253 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 1990 "parser.cpp" +#line 1989 "parser.cpp" break; case 7: // program: inline -#line 261 "parser.ypp" +#line 255 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); } -#line 1996 "parser.cpp" +#line 1995 "parser.cpp" break; case 8: // program: include -#line 263 "parser.ypp" +#line 257 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2002 "parser.cpp" +#line 2001 "parser.cpp" break; case 9: // program: declaration -#line 265 "parser.ypp" +#line 259 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2008 "parser.cpp" +#line 2007 "parser.cpp" break; case 10: // inline: "#inline" expr_path ";" -#line 269 "parser.ypp" - { iw7_push_header(ctx, yystack_[1].value.as < ast::expr_path::ptr > ()->value); } -#line 2014 "parser.cpp" +#line 263 "parser.ypp" + { lexer.push_header(yystack_[1].value.as < ast::expr_path::ptr > ()->value); } +#line 2013 "parser.cpp" break; case 11: // include: "#include" expr_path ";" -#line 274 "parser.ypp" +#line 268 "parser.ypp" { yylhs.value.as < ast::include::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_path::ptr > ())); } -#line 2020 "parser.cpp" +#line 2019 "parser.cpp" break; case 12: // declaration: "/#" -#line 278 "parser.ypp" +#line 272 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_begin = std::make_unique(yylhs.location); } -#line 2026 "parser.cpp" +#line 2025 "parser.cpp" break; case 13: // declaration: "#/" -#line 279 "parser.ypp" +#line 273 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_end = std::make_unique(yylhs.location); } -#line 2032 "parser.cpp" +#line 2031 "parser.cpp" break; case 14: // declaration: decl_usingtree -#line 280 "parser.ypp" +#line 274 "parser.ypp" { yylhs.value.as < ast::decl > ().as_usingtree = std::move(yystack_[0].value.as < ast::decl_usingtree::ptr > ()); } -#line 2038 "parser.cpp" +#line 2037 "parser.cpp" break; case 15: // declaration: decl_constant -#line 281 "parser.ypp" +#line 275 "parser.ypp" { yylhs.value.as < ast::decl > ().as_constant = std::move(yystack_[0].value.as < ast::decl_constant::ptr > ()); } -#line 2044 "parser.cpp" +#line 2043 "parser.cpp" break; case 16: // declaration: decl_thread -#line 282 "parser.ypp" +#line 276 "parser.ypp" { yylhs.value.as < ast::decl > ().as_thread = std::move(yystack_[0].value.as < ast::decl_thread::ptr > ()); } -#line 2050 "parser.cpp" +#line 2049 "parser.cpp" break; case 17: // decl_usingtree: "#using_animtree" "(" expr_string ")" ";" -#line 287 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } -#line 2056 "parser.cpp" +#line 281 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } +#line 2055 "parser.cpp" break; case 18: // decl_constant: expr_identifier "=" expr ";" -#line 292 "parser.ypp" +#line 286 "parser.ypp" { yylhs.value.as < ast::decl_constant::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2062 "parser.cpp" +#line 2061 "parser.cpp" break; case 19: // decl_thread: expr_identifier "(" expr_parameters ")" stmt_block -#line 297 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2068 "parser.cpp" +#line 291 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } +#line 2067 "parser.cpp" break; case 20: // stmt: stmt_dev -#line 301 "parser.ypp" +#line 295 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2074 "parser.cpp" +#line 2073 "parser.cpp" break; case 21: // stmt: stmt_block -#line 302 "parser.ypp" +#line 296 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2080 "parser.cpp" +#line 2079 "parser.cpp" break; case 22: // stmt: stmt_call -#line 303 "parser.ypp" +#line 297 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_call = std::move(yystack_[0].value.as < ast::stmt_call::ptr > ()); } -#line 2086 "parser.cpp" +#line 2085 "parser.cpp" break; case 23: // stmt: stmt_assign -#line 304 "parser.ypp" +#line 298 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_assign = std::move(yystack_[0].value.as < ast::stmt_assign::ptr > ()); } -#line 2092 "parser.cpp" +#line 2091 "parser.cpp" break; case 24: // stmt: stmt_endon -#line 305 "parser.ypp" +#line 299 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_endon = std::move(yystack_[0].value.as < ast::stmt_endon::ptr > ()); } -#line 2098 "parser.cpp" +#line 2097 "parser.cpp" break; case 25: // stmt: stmt_notify -#line 306 "parser.ypp" +#line 300 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_notify = std::move(yystack_[0].value.as < ast::stmt_notify::ptr > ()); } -#line 2104 "parser.cpp" +#line 2103 "parser.cpp" break; case 26: // stmt: stmt_wait -#line 307 "parser.ypp" +#line 301 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_wait = std::move(yystack_[0].value.as < ast::stmt_wait::ptr > ()); } -#line 2110 "parser.cpp" +#line 2109 "parser.cpp" break; case 27: // stmt: stmt_waittill -#line 308 "parser.ypp" +#line 302 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittill = std::move(yystack_[0].value.as < ast::stmt_waittill::ptr > ()); } -#line 2116 "parser.cpp" +#line 2115 "parser.cpp" break; case 28: // stmt: stmt_waittillmatch -#line 309 "parser.ypp" +#line 303 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillmatch = std::move(yystack_[0].value.as < ast::stmt_waittillmatch::ptr > ()); } -#line 2122 "parser.cpp" +#line 2121 "parser.cpp" break; case 29: // stmt: stmt_waittillframeend -#line 310 "parser.ypp" +#line 304 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillframeend = std::move(yystack_[0].value.as < ast::stmt_waittillframeend::ptr > ()); } -#line 2128 "parser.cpp" +#line 2127 "parser.cpp" break; case 30: // stmt: stmt_if -#line 311 "parser.ypp" +#line 305 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_if = std::move(yystack_[0].value.as < ast::stmt_if::ptr > ()); } -#line 2134 "parser.cpp" +#line 2133 "parser.cpp" break; case 31: // stmt: stmt_ifelse -#line 312 "parser.ypp" +#line 306 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_ifelse = std::move(yystack_[0].value.as < ast::stmt_ifelse::ptr > ()); } -#line 2140 "parser.cpp" +#line 2139 "parser.cpp" break; case 32: // stmt: stmt_while -#line 313 "parser.ypp" +#line 307 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_while = std::move(yystack_[0].value.as < ast::stmt_while::ptr > ()); } -#line 2146 "parser.cpp" +#line 2145 "parser.cpp" break; case 33: // stmt: stmt_dowhile -#line 314 "parser.ypp" +#line 308 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_dowhile = std::move(yystack_[0].value.as < ast::stmt_dowhile::ptr > ()); } -#line 2152 "parser.cpp" +#line 2151 "parser.cpp" break; case 34: // stmt: stmt_for -#line 315 "parser.ypp" +#line 309 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_for = std::move(yystack_[0].value.as < ast::stmt_for::ptr > ()); } -#line 2158 "parser.cpp" +#line 2157 "parser.cpp" break; case 35: // stmt: stmt_foreach -#line 316 "parser.ypp" +#line 310 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_foreach = std::move(yystack_[0].value.as < ast::stmt_foreach::ptr > ()); } -#line 2164 "parser.cpp" +#line 2163 "parser.cpp" break; case 36: // stmt: stmt_switch -#line 317 "parser.ypp" +#line 311 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_switch = std::move(yystack_[0].value.as < ast::stmt_switch::ptr > ()); } -#line 2170 "parser.cpp" +#line 2169 "parser.cpp" break; case 37: // stmt: stmt_case -#line 318 "parser.ypp" +#line 312 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_case = std::move(yystack_[0].value.as < ast::stmt_case::ptr > ()); } -#line 2176 "parser.cpp" +#line 2175 "parser.cpp" break; case 38: // stmt: stmt_default -#line 319 "parser.ypp" +#line 313 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_default = std::move(yystack_[0].value.as < ast::stmt_default::ptr > ()); } -#line 2182 "parser.cpp" +#line 2181 "parser.cpp" break; case 39: // stmt: stmt_break -#line 320 "parser.ypp" +#line 314 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_break = std::move(yystack_[0].value.as < ast::stmt_break::ptr > ()); } -#line 2188 "parser.cpp" +#line 2187 "parser.cpp" break; case 40: // stmt: stmt_continue -#line 321 "parser.ypp" +#line 315 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_continue = std::move(yystack_[0].value.as < ast::stmt_continue::ptr > ()); } -#line 2194 "parser.cpp" +#line 2193 "parser.cpp" break; case 41: // stmt: stmt_return -#line 322 "parser.ypp" +#line 316 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_return = std::move(yystack_[0].value.as < ast::stmt_return::ptr > ()); } -#line 2200 "parser.cpp" +#line 2199 "parser.cpp" break; case 42: // stmt: stmt_breakpoint -#line 323 "parser.ypp" +#line 317 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_breakpoint = std::move(yystack_[0].value.as < ast::stmt_breakpoint::ptr > ()); } -#line 2206 "parser.cpp" +#line 2205 "parser.cpp" break; case 43: // stmt: stmt_prof_begin -#line 324 "parser.ypp" +#line 318 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_begin = std::move(yystack_[0].value.as < ast::stmt_prof_begin::ptr > ()); } -#line 2212 "parser.cpp" +#line 2211 "parser.cpp" break; case 44: // stmt: stmt_prof_end -#line 325 "parser.ypp" +#line 319 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_end = std::move(yystack_[0].value.as < ast::stmt_prof_end::ptr > ()); } -#line 2218 "parser.cpp" +#line 2217 "parser.cpp" break; case 45: // stmt_dev: "/#" stmt_list "#/" -#line 329 "parser.ypp" +#line 323 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2224 "parser.cpp" +#line 2223 "parser.cpp" break; case 46: // stmt_dev: "/#" "#/" -#line 330 "parser.ypp" +#line 324 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2230 "parser.cpp" +#line 2229 "parser.cpp" break; case 47: // stmt_block: "{" stmt_list "}" -#line 334 "parser.ypp" +#line 328 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2236 "parser.cpp" +#line 2235 "parser.cpp" break; case 48: // stmt_block: "{" "}" -#line 335 "parser.ypp" +#line 329 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2242 "parser.cpp" +#line 2241 "parser.cpp" break; case 49: // stmt_list: stmt_list stmt -#line 340 "parser.ypp" +#line 334 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2248 "parser.cpp" +#line 2247 "parser.cpp" break; case 50: // stmt_list: stmt -#line 342 "parser.ypp" +#line 336 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2254 "parser.cpp" +#line 2253 "parser.cpp" break; case 51: // stmt_expr: expr_assign -#line 347 "parser.ypp" +#line 341 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2260 "parser.cpp" +#line 2259 "parser.cpp" break; case 52: // stmt_expr: expr_increment -#line 349 "parser.ypp" +#line 343 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2266 "parser.cpp" +#line 2265 "parser.cpp" break; case 53: // stmt_expr: expr_decrement -#line 351 "parser.ypp" +#line 345 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2272 "parser.cpp" +#line 2271 "parser.cpp" break; case 54: // stmt_expr: %empty -#line 353 "parser.ypp" +#line 347 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2278 "parser.cpp" +#line 2277 "parser.cpp" break; case 55: // stmt_call: expr_call ";" -#line 358 "parser.ypp" +#line 352 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_call::ptr > ()))); } -#line 2284 "parser.cpp" +#line 2283 "parser.cpp" break; case 56: // stmt_call: expr_method ";" -#line 360 "parser.ypp" +#line 354 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_method::ptr > ()))); } -#line 2290 "parser.cpp" +#line 2289 "parser.cpp" break; case 57: // stmt_assign: expr_assign ";" -#line 365 "parser.ypp" +#line 359 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2296 "parser.cpp" +#line 2295 "parser.cpp" break; case 58: // stmt_assign: expr_increment ";" -#line 367 "parser.ypp" +#line 361 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2302 "parser.cpp" +#line 2301 "parser.cpp" break; case 59: // stmt_assign: expr_decrement ";" -#line 369 "parser.ypp" +#line 363 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2308 "parser.cpp" +#line 2307 "parser.cpp" break; case 60: // stmt_endon: expr_object "endon" "(" expr ")" ";" -#line 374 "parser.ypp" +#line 368 "parser.ypp" { yylhs.value.as < ast::stmt_endon::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ())); } -#line 2314 "parser.cpp" +#line 2313 "parser.cpp" break; case 61: // stmt_notify: expr_object "notify" "(" expr "," expr_arguments_no_empty ")" ";" -#line 379 "parser.ypp" +#line 373 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2320 "parser.cpp" +#line 2319 "parser.cpp" break; case 62: // stmt_notify: expr_object "notify" "(" expr ")" ";" -#line 381 "parser.ypp" +#line 375 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2326 "parser.cpp" +#line 2325 "parser.cpp" break; case 63: // stmt_wait: "wait" expr ";" -#line 386 "parser.ypp" +#line 380 "parser.ypp" { yylhs.value.as < ast::stmt_wait::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2332 "parser.cpp" +#line 2331 "parser.cpp" break; case 64: // stmt_waittill: expr_object "waittill" "(" expr "," expr_arguments_no_empty ")" ";" -#line 391 "parser.ypp" +#line 385 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2338 "parser.cpp" +#line 2337 "parser.cpp" break; case 65: // stmt_waittill: expr_object "waittill" "(" expr ")" ";" -#line 393 "parser.ypp" +#line 387 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2344 "parser.cpp" +#line 2343 "parser.cpp" break; case 66: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr "," expr_arguments_no_empty ")" ";" -#line 398 "parser.ypp" +#line 392 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2350 "parser.cpp" +#line 2349 "parser.cpp" break; case 67: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr ")" ";" -#line 400 "parser.ypp" +#line 394 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2356 "parser.cpp" +#line 2355 "parser.cpp" break; case 68: // stmt_waittillframeend: "waittillframeend" ";" -#line 405 "parser.ypp" +#line 399 "parser.ypp" { yylhs.value.as < ast::stmt_waittillframeend::ptr > () = std::make_unique(yylhs.location); } -#line 2362 "parser.cpp" +#line 2361 "parser.cpp" break; case 69: // stmt_if: "if" "(" expr ")" stmt -#line 410 "parser.ypp" +#line 404 "parser.ypp" { yylhs.value.as < ast::stmt_if::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2368 "parser.cpp" +#line 2367 "parser.cpp" break; case 70: // stmt_ifelse: "if" "(" expr ")" stmt "else" stmt -#line 415 "parser.ypp" +#line 409 "parser.ypp" { yylhs.value.as < ast::stmt_ifelse::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::stmt > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2374 "parser.cpp" +#line 2373 "parser.cpp" break; case 71: // stmt_while: "while" "(" expr ")" stmt -#line 420 "parser.ypp" +#line 414 "parser.ypp" { yylhs.value.as < ast::stmt_while::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2380 "parser.cpp" +#line 2379 "parser.cpp" break; case 72: // stmt_dowhile: "do" stmt "while" "(" expr ")" ";" -#line 425 "parser.ypp" +#line 419 "parser.ypp" { yylhs.value.as < ast::stmt_dowhile::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[5].value.as < ast::stmt > ())); } -#line 2386 "parser.cpp" +#line 2385 "parser.cpp" break; case 73: // stmt_for: "for" "(" stmt_expr ";" expr_or_empty ";" stmt_expr ")" stmt -#line 430 "parser.ypp" +#line 424 "parser.ypp" { yylhs.value.as < ast::stmt_for::ptr > () = std::make_unique(yylhs.location, ast::stmt(std::move(yystack_[6].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[4].value.as < ast::expr > ()), ast::stmt(std::move(yystack_[2].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2392 "parser.cpp" +#line 2391 "parser.cpp" break; case 74: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt -#line 435 "parser.ypp" +#line 429 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2398 "parser.cpp" +#line 2397 "parser.cpp" break; case 75: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt -#line 437 "parser.ypp" +#line 431 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[6].value.as < ast::expr_identifier::ptr > ())), ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2404 "parser.cpp" +#line 2403 "parser.cpp" break; case 76: // stmt_switch: "switch" "(" expr ")" stmt_block -#line 442 "parser.ypp" +#line 436 "parser.ypp" { yylhs.value.as < ast::stmt_switch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2410 "parser.cpp" +#line 2409 "parser.cpp" break; case 77: // stmt_case: "case" expr_integer ":" -#line 447 "parser.ypp" +#line 441 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_integer::ptr > ())), std::make_unique(yylhs.location)); } -#line 2416 "parser.cpp" +#line 2415 "parser.cpp" break; case 78: // stmt_case: "case" expr_string ":" -#line 449 "parser.ypp" +#line 443 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_string::ptr > ())), std::make_unique(yylhs.location)); } -#line 2422 "parser.cpp" +#line 2421 "parser.cpp" break; case 79: // stmt_default: "default" ":" -#line 454 "parser.ypp" +#line 448 "parser.ypp" { yylhs.value.as < ast::stmt_default::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2428 "parser.cpp" +#line 2427 "parser.cpp" break; case 80: // stmt_break: "break" ";" -#line 459 "parser.ypp" +#line 453 "parser.ypp" { yylhs.value.as < ast::stmt_break::ptr > () = std::make_unique(yylhs.location); } -#line 2434 "parser.cpp" +#line 2433 "parser.cpp" break; case 81: // stmt_continue: "continue" ";" -#line 464 "parser.ypp" +#line 458 "parser.ypp" { yylhs.value.as < ast::stmt_continue::ptr > () = std::make_unique(yylhs.location); } -#line 2440 "parser.cpp" +#line 2439 "parser.cpp" break; case 82: // stmt_return: "return" expr ";" -#line 469 "parser.ypp" +#line 463 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2446 "parser.cpp" +#line 2445 "parser.cpp" break; case 83: // stmt_return: "return" ";" -#line 471 "parser.ypp" +#line 465 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2452 "parser.cpp" +#line 2451 "parser.cpp" break; case 84: // stmt_breakpoint: "breakpoint" ";" -#line 476 "parser.ypp" +#line 470 "parser.ypp" { yylhs.value.as < ast::stmt_breakpoint::ptr > () = std::make_unique(yylhs.location); } -#line 2458 "parser.cpp" +#line 2457 "parser.cpp" break; case 85: // stmt_prof_begin: "prof_begin" "(" expr_arguments ")" ";" -#line 481 "parser.ypp" +#line 475 "parser.ypp" { yylhs.value.as < ast::stmt_prof_begin::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2464 "parser.cpp" +#line 2463 "parser.cpp" break; case 86: // stmt_prof_end: "prof_end" "(" expr_arguments ")" ";" -#line 486 "parser.ypp" +#line 480 "parser.ypp" { yylhs.value.as < ast::stmt_prof_end::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2470 "parser.cpp" +#line 2469 "parser.cpp" break; case 87: // expr: expr_ternary -#line 490 "parser.ypp" +#line 484 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2476 "parser.cpp" +#line 2475 "parser.cpp" break; case 88: // expr: expr_binary -#line 491 "parser.ypp" +#line 485 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2482 "parser.cpp" +#line 2481 "parser.cpp" break; case 89: // expr: expr_primitive -#line 492 "parser.ypp" +#line 486 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2488 "parser.cpp" +#line 2487 "parser.cpp" break; case 90: // expr_or_empty: expr -#line 496 "parser.ypp" +#line 490 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2494 "parser.cpp" +#line 2493 "parser.cpp" break; case 91: // expr_or_empty: %empty -#line 497 "parser.ypp" +#line 491 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location); } -#line 2500 "parser.cpp" +#line 2499 "parser.cpp" break; case 92: // expr_assign: expr_object "=" expr -#line 502 "parser.ypp" +#line 496 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2506 "parser.cpp" +#line 2505 "parser.cpp" break; case 93: // expr_assign: expr_object "|=" expr -#line 504 "parser.ypp" +#line 498 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2512 "parser.cpp" +#line 2511 "parser.cpp" break; case 94: // expr_assign: expr_object "&=" expr -#line 506 "parser.ypp" +#line 500 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2518 "parser.cpp" +#line 2517 "parser.cpp" break; case 95: // expr_assign: expr_object "^=" expr -#line 508 "parser.ypp" +#line 502 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2524 "parser.cpp" +#line 2523 "parser.cpp" break; case 96: // expr_assign: expr_object "<<=" expr -#line 510 "parser.ypp" +#line 504 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()),std::move( yystack_[0].value.as < ast::expr > ())); } -#line 2530 "parser.cpp" +#line 2529 "parser.cpp" break; case 97: // expr_assign: expr_object ">>=" expr -#line 512 "parser.ypp" +#line 506 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2536 "parser.cpp" +#line 2535 "parser.cpp" break; case 98: // expr_assign: expr_object "+=" expr -#line 514 "parser.ypp" +#line 508 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2542 "parser.cpp" +#line 2541 "parser.cpp" break; case 99: // expr_assign: expr_object "-=" expr -#line 516 "parser.ypp" +#line 510 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2548 "parser.cpp" +#line 2547 "parser.cpp" break; case 100: // expr_assign: expr_object "*=" expr -#line 518 "parser.ypp" +#line 512 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2554 "parser.cpp" +#line 2553 "parser.cpp" break; case 101: // expr_assign: expr_object "/=" expr -#line 520 "parser.ypp" +#line 514 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2560 "parser.cpp" +#line 2559 "parser.cpp" break; case 102: // expr_assign: expr_object "%=" expr -#line 522 "parser.ypp" +#line 516 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2566 "parser.cpp" +#line 2565 "parser.cpp" break; case 103: // expr_increment: "++" expr_object -#line 527 "parser.ypp" +#line 521 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2572 "parser.cpp" +#line 2571 "parser.cpp" break; case 104: // expr_increment: expr_object "++" -#line 529 "parser.ypp" +#line 523 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2578 "parser.cpp" +#line 2577 "parser.cpp" break; case 105: // expr_decrement: "--" expr_object -#line 534 "parser.ypp" +#line 528 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2584 "parser.cpp" +#line 2583 "parser.cpp" break; case 106: // expr_decrement: expr_object "--" -#line 536 "parser.ypp" +#line 530 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2590 "parser.cpp" +#line 2589 "parser.cpp" break; case 107: // expr_ternary: expr "?" expr ":" expr -#line 541 "parser.ypp" +#line 535 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2596 "parser.cpp" +#line 2595 "parser.cpp" break; case 108: // expr_binary: expr "||" expr -#line 546 "parser.ypp" +#line 540 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2602 "parser.cpp" +#line 2601 "parser.cpp" break; case 109: // expr_binary: expr "&&" expr -#line 548 "parser.ypp" +#line 542 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2608 "parser.cpp" +#line 2607 "parser.cpp" break; case 110: // expr_binary: expr "==" expr -#line 550 "parser.ypp" +#line 544 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2614 "parser.cpp" +#line 2613 "parser.cpp" break; case 111: // expr_binary: expr "!=" expr -#line 552 "parser.ypp" +#line 546 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2620 "parser.cpp" +#line 2619 "parser.cpp" break; case 112: // expr_binary: expr "<=" expr -#line 554 "parser.ypp" +#line 548 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2626 "parser.cpp" +#line 2625 "parser.cpp" break; case 113: // expr_binary: expr ">=" expr -#line 556 "parser.ypp" +#line 550 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2632 "parser.cpp" +#line 2631 "parser.cpp" break; case 114: // expr_binary: expr "<" expr -#line 558 "parser.ypp" +#line 552 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2638 "parser.cpp" +#line 2637 "parser.cpp" break; case 115: // expr_binary: expr ">" expr -#line 560 "parser.ypp" +#line 554 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2644 "parser.cpp" +#line 2643 "parser.cpp" break; case 116: // expr_binary: expr "|" expr -#line 562 "parser.ypp" +#line 556 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2650 "parser.cpp" +#line 2649 "parser.cpp" break; case 117: // expr_binary: expr "&" expr -#line 564 "parser.ypp" +#line 558 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2656 "parser.cpp" +#line 2655 "parser.cpp" break; case 118: // expr_binary: expr "^" expr -#line 566 "parser.ypp" +#line 560 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2662 "parser.cpp" +#line 2661 "parser.cpp" break; case 119: // expr_binary: expr "<<" expr -#line 568 "parser.ypp" +#line 562 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2668 "parser.cpp" +#line 2667 "parser.cpp" break; case 120: // expr_binary: expr ">>" expr -#line 570 "parser.ypp" +#line 564 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2674 "parser.cpp" +#line 2673 "parser.cpp" break; case 121: // expr_binary: expr "+" expr -#line 572 "parser.ypp" +#line 566 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2680 "parser.cpp" +#line 2679 "parser.cpp" break; case 122: // expr_binary: expr "-" expr -#line 574 "parser.ypp" +#line 568 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2686 "parser.cpp" +#line 2685 "parser.cpp" break; case 123: // expr_binary: expr "*" expr -#line 576 "parser.ypp" +#line 570 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2692 "parser.cpp" +#line 2691 "parser.cpp" break; case 124: // expr_binary: expr "/" expr -#line 578 "parser.ypp" +#line 572 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2698 "parser.cpp" +#line 2697 "parser.cpp" break; case 125: // expr_binary: expr "%" expr -#line 580 "parser.ypp" +#line 574 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2704 "parser.cpp" +#line 2703 "parser.cpp" break; case 126: // expr_primitive: expr_complement -#line 584 "parser.ypp" +#line 578 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_complement::ptr > ()); } -#line 2710 "parser.cpp" +#line 2709 "parser.cpp" break; case 127: // expr_primitive: expr_not -#line 585 "parser.ypp" +#line 579 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_not::ptr > ()); } -#line 2716 "parser.cpp" +#line 2715 "parser.cpp" break; case 128: // expr_primitive: expr_call -#line 586 "parser.ypp" +#line 580 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 2722 "parser.cpp" +#line 2721 "parser.cpp" break; case 129: // expr_primitive: expr_method -#line 587 "parser.ypp" +#line 581 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 2728 "parser.cpp" +#line 2727 "parser.cpp" break; case 130: // expr_primitive: expr_add_array -#line 588 "parser.ypp" +#line 582 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_add_array::ptr > ()); } -#line 2734 "parser.cpp" +#line 2733 "parser.cpp" break; case 131: // expr_primitive: expr_reference -#line 589 "parser.ypp" +#line 583 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_reference::ptr > ()); } -#line 2740 "parser.cpp" +#line 2739 "parser.cpp" break; case 132: // expr_primitive: expr_array -#line 590 "parser.ypp" +#line 584 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 2746 "parser.cpp" +#line 2745 "parser.cpp" break; case 133: // expr_primitive: expr_field -#line 591 "parser.ypp" +#line 585 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 2752 "parser.cpp" +#line 2751 "parser.cpp" break; case 134: // expr_primitive: expr_size -#line 592 "parser.ypp" +#line 586 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_size::ptr > ()); } -#line 2758 "parser.cpp" +#line 2757 "parser.cpp" break; case 135: // expr_primitive: expr_paren -#line 593 "parser.ypp" +#line 587 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_paren::ptr > ()); } -#line 2764 "parser.cpp" +#line 2763 "parser.cpp" break; case 136: // expr_primitive: expr_thisthread -#line 594 "parser.ypp" +#line 588 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_thisthread::ptr > ()); } -#line 2770 "parser.cpp" +#line 2769 "parser.cpp" break; case 137: // expr_primitive: expr_empty_array -#line 595 "parser.ypp" +#line 589 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_empty_array::ptr > ()); } -#line 2776 "parser.cpp" +#line 2775 "parser.cpp" break; case 138: // expr_primitive: expr_undefined -#line 596 "parser.ypp" +#line 590 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_undefined::ptr > ()); } -#line 2782 "parser.cpp" +#line 2781 "parser.cpp" break; case 139: // expr_primitive: expr_game -#line 597 "parser.ypp" +#line 591 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 2788 "parser.cpp" +#line 2787 "parser.cpp" break; case 140: // expr_primitive: expr_self -#line 598 "parser.ypp" +#line 592 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 2794 "parser.cpp" +#line 2793 "parser.cpp" break; case 141: // expr_primitive: expr_anim -#line 599 "parser.ypp" +#line 593 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 2800 "parser.cpp" +#line 2799 "parser.cpp" break; case 142: // expr_primitive: expr_level -#line 600 "parser.ypp" +#line 594 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 2806 "parser.cpp" +#line 2805 "parser.cpp" break; case 143: // expr_primitive: expr_animation -#line 601 "parser.ypp" +#line 595 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animation::ptr > ()); } -#line 2812 "parser.cpp" +#line 2811 "parser.cpp" break; case 144: // expr_primitive: expr_animtree -#line 602 "parser.ypp" +#line 596 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animtree::ptr > ()); } -#line 2818 "parser.cpp" +#line 2817 "parser.cpp" break; case 145: // expr_primitive: expr_identifier -#line 603 "parser.ypp" +#line 597 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 2824 "parser.cpp" +#line 2823 "parser.cpp" break; case 146: // expr_primitive: expr_istring -#line 604 "parser.ypp" +#line 598 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istring::ptr > ()); } -#line 2830 "parser.cpp" +#line 2829 "parser.cpp" break; case 147: // expr_primitive: expr_string -#line 605 "parser.ypp" +#line 599 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_string::ptr > ()); } -#line 2836 "parser.cpp" +#line 2835 "parser.cpp" break; case 148: // expr_primitive: expr_color -#line 606 "parser.ypp" +#line 600 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_color::ptr > ()); } -#line 2842 "parser.cpp" +#line 2841 "parser.cpp" break; case 149: // expr_primitive: expr_vector -#line 607 "parser.ypp" +#line 601 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_vector::ptr > ()); } -#line 2848 "parser.cpp" +#line 2847 "parser.cpp" break; case 150: // expr_primitive: expr_float -#line 608 "parser.ypp" +#line 602 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_float::ptr > ()); } -#line 2854 "parser.cpp" +#line 2853 "parser.cpp" break; case 151: // expr_primitive: expr_integer -#line 609 "parser.ypp" +#line 603 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_integer::ptr > ()); } -#line 2860 "parser.cpp" +#line 2859 "parser.cpp" break; case 152: // expr_primitive: expr_false -#line 610 "parser.ypp" +#line 604 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_false::ptr > ()); } -#line 2866 "parser.cpp" +#line 2865 "parser.cpp" break; case 153: // expr_primitive: expr_true -#line 611 "parser.ypp" +#line 605 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_true::ptr > ()); } -#line 2872 "parser.cpp" +#line 2871 "parser.cpp" break; case 154: // expr_complement: "~" expr -#line 616 "parser.ypp" +#line 610 "parser.ypp" { yylhs.value.as < ast::expr_complement::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2878 "parser.cpp" +#line 2877 "parser.cpp" break; case 155: // expr_not: "!" expr -#line 621 "parser.ypp" +#line 615 "parser.ypp" { yylhs.value.as < ast::expr_not::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2884 "parser.cpp" +#line 2883 "parser.cpp" break; case 156: // expr_call: expr_function -#line 625 "parser.ypp" +#line 619 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2890 "parser.cpp" +#line 2889 "parser.cpp" break; case 157: // expr_call: expr_pointer -#line 626 "parser.ypp" +#line 620 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2896 "parser.cpp" +#line 2895 "parser.cpp" break; case 158: // expr_method: expr_object expr_function -#line 629 "parser.ypp" +#line 623 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2902 "parser.cpp" +#line 2901 "parser.cpp" break; case 159: // expr_method: expr_object expr_pointer -#line 630 "parser.ypp" +#line 624 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2908 "parser.cpp" +#line 2907 "parser.cpp" break; case 160: // expr_function: expr_identifier "(" expr_arguments ")" -#line 635 "parser.ypp" +#line 629 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2914 "parser.cpp" +#line 2913 "parser.cpp" break; case 161: // expr_function: expr_path "::" expr_identifier "(" expr_arguments ")" -#line 637 "parser.ypp" +#line 631 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2920 "parser.cpp" +#line 2919 "parser.cpp" break; case 162: // expr_function: "thread" expr_identifier "(" expr_arguments ")" -#line 639 "parser.ypp" +#line 633 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2926 "parser.cpp" +#line 2925 "parser.cpp" break; case 163: // expr_function: "thread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 641 "parser.ypp" +#line 635 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2932 "parser.cpp" +#line 2931 "parser.cpp" break; case 164: // expr_function: "childthread" expr_identifier "(" expr_arguments ")" -#line 643 "parser.ypp" +#line 637 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2938 "parser.cpp" +#line 2937 "parser.cpp" break; case 165: // expr_function: "childthread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 645 "parser.ypp" +#line 639 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2944 "parser.cpp" +#line 2943 "parser.cpp" break; case 166: // expr_pointer: "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 650 "parser.ypp" +#line 644 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2950 "parser.cpp" +#line 2949 "parser.cpp" break; case 167: // expr_pointer: "thread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 652 "parser.ypp" +#line 646 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2956 "parser.cpp" +#line 2955 "parser.cpp" break; case 168: // expr_pointer: "childthread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 654 "parser.ypp" +#line 648 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2962 "parser.cpp" +#line 2961 "parser.cpp" break; case 169: // expr_pointer: "call" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 656 "parser.ypp" +#line 650 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::builtin); } -#line 2968 "parser.cpp" +#line 2967 "parser.cpp" break; case 170: // expr_add_array: "[" expr_arguments_no_empty "]" -#line 661 "parser.ypp" +#line 655 "parser.ypp" { yylhs.value.as < ast::expr_add_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ())); } -#line 2974 "parser.cpp" +#line 2973 "parser.cpp" break; case 171: // expr_parameters: expr_parameters "," expr_identifier -#line 666 "parser.ypp" +#line 660 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 2980 "parser.cpp" +#line 2979 "parser.cpp" break; case 172: // expr_parameters: expr_identifier -#line 668 "parser.ypp" +#line 662 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 2986 "parser.cpp" +#line 2985 "parser.cpp" break; case 173: // expr_parameters: %empty -#line 670 "parser.ypp" +#line 664 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); } -#line 2992 "parser.cpp" +#line 2991 "parser.cpp" break; case 174: // expr_arguments: expr_arguments_no_empty -#line 675 "parser.ypp" +#line 669 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[0].value.as < ast::expr_arguments::ptr > ()); } -#line 2998 "parser.cpp" +#line 2997 "parser.cpp" break; case 175: // expr_arguments: %empty -#line 677 "parser.ypp" +#line 671 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); } -#line 3004 "parser.cpp" +#line 3003 "parser.cpp" break; case 176: // expr_arguments_no_empty: expr_arguments "," expr -#line 682 "parser.ypp" +#line 676 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ()); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3010 "parser.cpp" +#line 3009 "parser.cpp" break; case 177: // expr_arguments_no_empty: expr -#line 684 "parser.ypp" +#line 678 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3016 "parser.cpp" +#line 3015 "parser.cpp" break; case 178: // expr_reference: "::" expr_identifier -#line 689 "parser.ypp" +#line 683 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3022 "parser.cpp" +#line 3021 "parser.cpp" break; case 179: // expr_reference: expr_path "::" expr_identifier -#line 691 "parser.ypp" +#line 685 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_path::ptr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3028 "parser.cpp" +#line 3027 "parser.cpp" break; case 180: // expr_array: expr_object "[" expr "]" -#line 696 "parser.ypp" +#line 690 "parser.ypp" { yylhs.value.as < ast::expr_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3034 "parser.cpp" +#line 3033 "parser.cpp" break; case 181: // expr_field: expr_object "." expr_identifier -#line 701 "parser.ypp" +#line 695 "parser.ypp" { yylhs.value.as < ast::expr_field::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3040 "parser.cpp" +#line 3039 "parser.cpp" break; case 182: // expr_size: expr_object ".size" -#line 706 "parser.ypp" +#line 700 "parser.ypp" { yylhs.value.as < ast::expr_size::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3046 "parser.cpp" +#line 3045 "parser.cpp" break; case 183: // expr_paren: "(" expr ")" -#line 711 "parser.ypp" +#line 705 "parser.ypp" { yylhs.value.as < ast::expr_paren::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3052 "parser.cpp" +#line 3051 "parser.cpp" break; case 184: // expr_object: expr_call -#line 715 "parser.ypp" +#line 709 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 3058 "parser.cpp" +#line 3057 "parser.cpp" break; case 185: // expr_object: expr_method -#line 716 "parser.ypp" +#line 710 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 3064 "parser.cpp" +#line 3063 "parser.cpp" break; case 186: // expr_object: expr_array -#line 717 "parser.ypp" +#line 711 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 3070 "parser.cpp" +#line 3069 "parser.cpp" break; case 187: // expr_object: expr_field -#line 718 "parser.ypp" +#line 712 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 3076 "parser.cpp" +#line 3075 "parser.cpp" break; case 188: // expr_object: expr_game -#line 719 "parser.ypp" +#line 713 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 3082 "parser.cpp" +#line 3081 "parser.cpp" break; case 189: // expr_object: expr_self -#line 720 "parser.ypp" +#line 714 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 3088 "parser.cpp" +#line 3087 "parser.cpp" break; case 190: // expr_object: expr_anim -#line 721 "parser.ypp" +#line 715 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 3094 "parser.cpp" +#line 3093 "parser.cpp" break; case 191: // expr_object: expr_level -#line 722 "parser.ypp" +#line 716 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 3100 "parser.cpp" +#line 3099 "parser.cpp" break; case 192: // expr_object: expr_identifier -#line 723 "parser.ypp" +#line 717 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 3106 "parser.cpp" +#line 3105 "parser.cpp" break; case 193: // expr_thisthread: "thisthread" -#line 728 "parser.ypp" +#line 722 "parser.ypp" { yylhs.value.as < ast::expr_thisthread::ptr > () = std::make_unique(yylhs.location); } -#line 3112 "parser.cpp" +#line 3111 "parser.cpp" break; case 194: // expr_empty_array: "[" "]" -#line 733 "parser.ypp" +#line 727 "parser.ypp" { yylhs.value.as < ast::expr_empty_array::ptr > () = std::make_unique(yylhs.location); } -#line 3118 "parser.cpp" +#line 3117 "parser.cpp" break; case 195: // expr_undefined: "undefined" -#line 738 "parser.ypp" +#line 732 "parser.ypp" { yylhs.value.as < ast::expr_undefined::ptr > () = std::make_unique(yylhs.location); } -#line 3124 "parser.cpp" +#line 3123 "parser.cpp" break; case 196: // expr_game: "game" -#line 743 "parser.ypp" +#line 737 "parser.ypp" { yylhs.value.as < ast::expr_game::ptr > () = std::make_unique(yylhs.location); } -#line 3130 "parser.cpp" +#line 3129 "parser.cpp" break; case 197: // expr_self: "self" -#line 748 "parser.ypp" +#line 742 "parser.ypp" { yylhs.value.as < ast::expr_self::ptr > () = std::make_unique(yylhs.location); } -#line 3136 "parser.cpp" +#line 3135 "parser.cpp" break; case 198: // expr_anim: "anim" -#line 753 "parser.ypp" +#line 747 "parser.ypp" { yylhs.value.as < ast::expr_anim::ptr > () = std::make_unique(yylhs.location); } -#line 3142 "parser.cpp" +#line 3141 "parser.cpp" break; case 199: // expr_level: "level" -#line 758 "parser.ypp" +#line 752 "parser.ypp" { yylhs.value.as < ast::expr_level::ptr > () = std::make_unique(yylhs.location); } -#line 3148 "parser.cpp" +#line 3147 "parser.cpp" break; case 200: // expr_animation: "%" "identifier" -#line 763 "parser.ypp" +#line 757 "parser.ypp" { yylhs.value.as < ast::expr_animation::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3154 "parser.cpp" +#line 3153 "parser.cpp" break; case 201: // expr_animtree: "#animtree" -#line 768 "parser.ypp" +#line 762 "parser.ypp" { yylhs.value.as < ast::expr_animtree::ptr > () = std::make_unique(yylhs.location); } -#line 3160 "parser.cpp" +#line 3159 "parser.cpp" break; case 202: // expr_identifier: "identifier" -#line 773 "parser.ypp" +#line 767 "parser.ypp" { yylhs.value.as < ast::expr_identifier::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3166 "parser.cpp" +#line 3165 "parser.cpp" break; case 203: // expr_path: "path" -#line 778 "parser.ypp" +#line 772 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3172 "parser.cpp" +#line 3171 "parser.cpp" break; case 204: // expr_path: expr_identifier -#line 780 "parser.ypp" +#line 774 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < ast::expr_identifier::ptr > ()->value); } -#line 3178 "parser.cpp" +#line 3177 "parser.cpp" break; case 205: // expr_istring: "localized string" -#line 785 "parser.ypp" +#line 779 "parser.ypp" { yylhs.value.as < ast::expr_istring::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3184 "parser.cpp" +#line 3183 "parser.cpp" break; case 206: // expr_string: "string literal" -#line 790 "parser.ypp" +#line 784 "parser.ypp" { yylhs.value.as < ast::expr_string::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3190 "parser.cpp" +#line 3189 "parser.cpp" break; case 207: // expr_color: "color" -#line 795 "parser.ypp" +#line 789 "parser.ypp" { yylhs.value.as < ast::expr_color::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3196 "parser.cpp" +#line 3195 "parser.cpp" break; case 208: // expr_vector: "(" expr "," expr "," expr ")" -#line 800 "parser.ypp" +#line 794 "parser.ypp" { yylhs.value.as < ast::expr_vector::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3202 "parser.cpp" +#line 3201 "parser.cpp" break; case 209: // expr_float: "-" "float" -#line 805 "parser.ypp" +#line 799 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3208 "parser.cpp" +#line 3207 "parser.cpp" break; case 210: // expr_float: "float" -#line 807 "parser.ypp" +#line 801 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3214 "parser.cpp" +#line 3213 "parser.cpp" break; case 211: // expr_integer: "-" "integer" -#line 812 "parser.ypp" +#line 806 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3220 "parser.cpp" +#line 3219 "parser.cpp" break; case 212: // expr_integer: "integer" -#line 814 "parser.ypp" +#line 808 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3226 "parser.cpp" +#line 3225 "parser.cpp" break; case 213: // expr_false: "false" -#line 819 "parser.ypp" +#line 813 "parser.ypp" { yylhs.value.as < ast::expr_false::ptr > () = std::make_unique(yylhs.location); } -#line 3232 "parser.cpp" +#line 3231 "parser.cpp" break; case 214: // expr_true: "true" -#line 824 "parser.ypp" +#line 818 "parser.ypp" { yylhs.value.as < ast::expr_true::ptr > () = std::make_unique(yylhs.location); } -#line 3238 "parser.cpp" +#line 3237 "parser.cpp" break; -#line 3242 "parser.cpp" +#line 3241 "parser.cpp" default: break; @@ -4426,28 +4425,28 @@ namespace xsk { namespace gsc { namespace iw7 { const short parser::yyrline_[] = { - 0, 249, 249, 250, 254, 256, 258, 260, 262, 264, - 269, 273, 278, 279, 280, 281, 282, 286, 291, 296, - 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, - 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, - 321, 322, 323, 324, 325, 329, 330, 334, 335, 339, - 341, 346, 348, 350, 353, 357, 359, 364, 366, 368, - 373, 378, 380, 385, 390, 392, 397, 399, 404, 409, - 414, 419, 424, 429, 434, 436, 441, 446, 448, 453, - 458, 463, 468, 470, 475, 480, 485, 490, 491, 492, - 496, 497, 501, 503, 505, 507, 509, 511, 513, 515, - 517, 519, 521, 526, 528, 533, 535, 540, 545, 547, - 549, 551, 553, 555, 557, 559, 561, 563, 565, 567, - 569, 571, 573, 575, 577, 579, 584, 585, 586, 587, - 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, - 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, - 608, 609, 610, 611, 615, 620, 625, 626, 629, 630, - 634, 636, 638, 640, 642, 644, 649, 651, 653, 655, - 660, 665, 667, 670, 674, 677, 681, 683, 688, 690, - 695, 700, 705, 710, 715, 716, 717, 718, 719, 720, - 721, 722, 723, 727, 732, 737, 742, 747, 752, 757, - 762, 767, 772, 777, 779, 784, 789, 794, 799, 804, - 806, 811, 813, 818, 823 + 0, 243, 243, 244, 248, 250, 252, 254, 256, 258, + 263, 267, 272, 273, 274, 275, 276, 280, 285, 290, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 323, 324, 328, 329, 333, + 335, 340, 342, 344, 347, 351, 353, 358, 360, 362, + 367, 372, 374, 379, 384, 386, 391, 393, 398, 403, + 408, 413, 418, 423, 428, 430, 435, 440, 442, 447, + 452, 457, 462, 464, 469, 474, 479, 484, 485, 486, + 490, 491, 495, 497, 499, 501, 503, 505, 507, 509, + 511, 513, 515, 520, 522, 527, 529, 534, 539, 541, + 543, 545, 547, 549, 551, 553, 555, 557, 559, 561, + 563, 565, 567, 569, 571, 573, 578, 579, 580, 581, + 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, + 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, + 602, 603, 604, 605, 609, 614, 619, 620, 623, 624, + 628, 630, 632, 634, 636, 638, 643, 645, 647, 649, + 654, 659, 661, 664, 668, 671, 675, 677, 682, 684, + 689, 694, 699, 704, 709, 710, 711, 712, 713, 714, + 715, 716, 717, 721, 726, 731, 736, 741, 746, 751, + 756, 761, 766, 771, 773, 778, 783, 788, 793, 798, + 800, 805, 807, 812, 817 }; void @@ -4480,9 +4479,9 @@ namespace xsk { namespace gsc { namespace iw7 { #line 13 "parser.ypp" } } } // xsk::gsc::iw7 -#line 4484 "parser.cpp" +#line 4483 "parser.cpp" -#line 827 "parser.ypp" +#line 821 "parser.ypp" void xsk::gsc::iw7::parser::error(const xsk::gsc::location& loc, const std::string& msg) diff --git a/src/iw7/xsk/parser.hpp b/src/iw7/xsk/parser.hpp index 295a8daa..79fbc5e3 100644 --- a/src/iw7/xsk/parser.hpp +++ b/src/iw7/xsk/parser.hpp @@ -45,13 +45,12 @@ #ifndef YY_IW7_PARSER_HPP_INCLUDED # define YY_IW7_PARSER_HPP_INCLUDED // "%code requires" blocks. -#line 33 "parser.ypp" +#line 28 "parser.ypp" #include "iw7.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::iw7::parser::symbol_type IW7lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::iw7 { class lexer; } -#line 55 "parser.hpp" +#line 54 "parser.hpp" # include # include // std::abort @@ -194,7 +193,7 @@ typedef void *yyscan_t; #line 13 "parser.ypp" namespace xsk { namespace gsc { namespace iw7 { -#line 198 "parser.hpp" +#line 197 "parser.hpp" @@ -2657,7 +2656,7 @@ switch (yykind) }; /// Build a parser object. - parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); + parser (xsk::gsc::iw7::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); virtual ~parser (); #if 201103L <= YY_CPLUSPLUS @@ -4613,8 +4612,7 @@ switch (yykind) // User arguments. - yyscan_t yyscanner; - xsk::gsc::context* ctx; + xsk::gsc::iw7::lexer& lexer; xsk::gsc::ast::program::ptr& ast; }; @@ -5291,7 +5289,7 @@ switch (yykind) #line 13 "parser.ypp" } } } // xsk::gsc::iw7 -#line 5295 "parser.hpp" +#line 5293 "parser.hpp" diff --git a/src/iw7/xsk/resolver.cpp b/src/iw7/xsk/resolver.cpp index cbdd9509..05c47d44 100644 --- a/src/iw7/xsk/resolver.cpp +++ b/src/iw7/xsk/resolver.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -206,6 +206,35 @@ auto resolver::make_token(std::string_view str) -> std::string return data; } +std::function(const std::string&)> read_callback = nullptr; +std::unordered_map> files; + +auto resolver::file_data(const std::string& name) -> std::tuple +{ + const auto& itr = files.find(name); + + if(itr != files.end()) + { + return { &itr->first ,reinterpret_cast(itr->second.data()), itr->second.size() }; + } + + auto data = read_callback(name); + + const auto& res = files.insert({ name, std::move(data)}); + + if(res.second) + { + return { &res.first->first, reinterpret_cast(res.first->second.data()), res.first->second.size() }; + } + + throw error("couldn't open gsc file '" + name + "'"); +} + +void resolver::set_reader(std::function(const std::string&)> callback) +{ + read_callback = callback; +} + const std::array, 153> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/iw7/xsk/resolver.hpp b/src/iw7/xsk/resolver.hpp index 2e920b04..26de5160 100644 --- a/src/iw7/xsk/resolver.hpp +++ b/src/iw7/xsk/resolver.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -30,6 +30,8 @@ public: static auto find_method(const std::string& name) -> bool; static auto make_token(std::string_view str) -> std::string; + static auto file_data(const std::string& name) -> std::tuple; + static void set_reader(std::function(const std::string&)> callback); }; } // namespace xsk::gsc::iw7 diff --git a/src/iw8/stdafx.cpp b/src/iw8/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/iw8/stdafx.cpp +++ b/src/iw8/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/stdafx.hpp b/src/iw8/stdafx.hpp index fd3fbc45..f1ce5884 100644 --- a/src/iw8/stdafx.hpp +++ b/src/iw8/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/xsk/assembler.cpp b/src/iw8/xsk/assembler.cpp index ede195d4..f0e9e173 100644 --- a/src/iw8/xsk/assembler.cpp +++ b/src/iw8/xsk/assembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/xsk/assembler.hpp b/src/iw8/xsk/assembler.hpp index 80b80b55..63bd2665 100644 --- a/src/iw8/xsk/assembler.hpp +++ b/src/iw8/xsk/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/xsk/compiler.cpp b/src/iw8/xsk/compiler.cpp index 517cc06e..ae6e303a 100644 --- a/src/iw8/xsk/compiler.cpp +++ b/src/iw8/xsk/compiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,7 +19,6 @@ auto compiler::output() -> std::vector void compiler::compile(const std::string& file, std::vector& data) { filename_ = file; - sources_.clear(); auto prog = parse_buffer(filename_, data); @@ -33,38 +32,20 @@ void compiler::read_callback(std::function(const std:: auto compiler::parse_buffer(const std::string& file, std::vector& data) -> ast::program::ptr { - yyscan_t scanner; - context ctx; ast::program::ptr result(nullptr); - ctx.header_top = 0; - ctx.mode = mode_; - ctx.read_callback = read_callback_; - ctx.sources = &sources_; - ctx.loc.initialize(&file); + resolver::set_reader(read_callback_); - // Add the two NULL terminators, required by flex. - data.push_back(0); - data.push_back(0); + lexer lexer(file, reinterpret_cast(data.data()), data.size()); - if (iw8_lex_init(&scanner)) - { - throw comp_error(ctx.loc, "An unknown error ocurred while starting lexer context."); - } - - ctx.scanner = scanner; - - YY_BUFFER_STATE yybuffer = iw8__scan_buffer(reinterpret_cast(data.data()), data.size(), scanner); - - parser parser(scanner, &ctx, result); + parser parser(lexer, result); if (parser.parse() || result == nullptr) { - throw comp_error(ctx.loc, "An unknown error ocurred while parsing gsc file."); + throw comp_error(xsk::gsc::location(&file), "An unknown error ocurred while parsing gsc file."); } - iw8__delete_buffer(yybuffer, scanner); - iw8_lex_destroy(scanner); + std::cout << result->print(); return result; } diff --git a/src/iw8/xsk/compiler.hpp b/src/iw8/xsk/compiler.hpp index 4ea6868a..42f3a781 100644 --- a/src/iw8/xsk/compiler.hpp +++ b/src/iw8/xsk/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -25,7 +25,6 @@ class compiler : public gsc::compiler std::vector animtrees_; std::unordered_map constants_; std::function(const std::string&)> read_callback_; - std::vector sources_; std::vector break_blks_; std::vector continue_blks_; bool can_break_; diff --git a/src/iw8/xsk/decompiler.cpp b/src/iw8/xsk/decompiler.cpp index a920d1d8..7aefa324 100644 --- a/src/iw8/xsk/decompiler.cpp +++ b/src/iw8/xsk/decompiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/xsk/decompiler.hpp b/src/iw8/xsk/decompiler.hpp index 32412de3..4b32d9df 100644 --- a/src/iw8/xsk/decompiler.hpp +++ b/src/iw8/xsk/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/xsk/disassembler.cpp b/src/iw8/xsk/disassembler.cpp index a774bb43..0c4dd1f2 100644 --- a/src/iw8/xsk/disassembler.cpp +++ b/src/iw8/xsk/disassembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/xsk/disassembler.hpp b/src/iw8/xsk/disassembler.hpp index 006d136a..7c106d39 100644 --- a/src/iw8/xsk/disassembler.hpp +++ b/src/iw8/xsk/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/xsk/iw8.cpp b/src/iw8/xsk/iw8.cpp index a216ede7..0a45c279 100644 --- a/src/iw8/xsk/iw8.cpp +++ b/src/iw8/xsk/iw8.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/xsk/iw8.hpp b/src/iw8/xsk/iw8.hpp index 0ecabd28..01a1c269 100644 --- a/src/iw8/xsk/iw8.hpp +++ b/src/iw8/xsk/iw8.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/iw8/xsk/lexer.cpp b/src/iw8/xsk/lexer.cpp index 87108ebe..c3844bd6 100644 --- a/src/iw8/xsk/lexer.cpp +++ b/src/iw8/xsk/lexer.cpp @@ -1,3068 +1,1009 @@ -#line 1 "lexer.cpp" -#include "stdafx.hpp" -#include "iw8.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw8_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw8_pop_header(xsk::gsc::context* ctx); - -#line 9 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define iw8__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer iw8__create_buffer -#endif - -#ifdef yy_delete_buffer -#define iw8__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer iw8__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define iw8__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer iw8__scan_buffer -#endif - -#ifdef yy_scan_string -#define iw8__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string iw8__scan_string -#endif - -#ifdef yy_scan_bytes -#define iw8__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes iw8__scan_bytes -#endif - -#ifdef yy_init_buffer -#define iw8__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer iw8__init_buffer -#endif - -#ifdef yy_flush_buffer -#define iw8__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer iw8__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define iw8__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state iw8__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define iw8__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer iw8__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define iw8_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state iw8_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define iw8_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state iw8_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define iw8_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack iw8_ensure_buffer_stack -#endif - -#ifdef yylex -#define iw8_lex_ALREADY_DEFINED -#else -#define yylex iw8_lex -#endif - -#ifdef yyrestart -#define iw8_restart_ALREADY_DEFINED -#else -#define yyrestart iw8_restart -#endif - -#ifdef yylex_init -#define iw8_lex_init_ALREADY_DEFINED -#else -#define yylex_init iw8_lex_init -#endif - -#ifdef yylex_init_extra -#define iw8_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra iw8_lex_init_extra -#endif - -#ifdef yylex_destroy -#define iw8_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy iw8_lex_destroy -#endif - -#ifdef yyget_debug -#define iw8_get_debug_ALREADY_DEFINED -#else -#define yyget_debug iw8_get_debug -#endif - -#ifdef yyset_debug -#define iw8_set_debug_ALREADY_DEFINED -#else -#define yyset_debug iw8_set_debug -#endif - -#ifdef yyget_extra -#define iw8_get_extra_ALREADY_DEFINED -#else -#define yyget_extra iw8_get_extra -#endif - -#ifdef yyset_extra -#define iw8_set_extra_ALREADY_DEFINED -#else -#define yyset_extra iw8_set_extra -#endif - -#ifdef yyget_in -#define iw8_get_in_ALREADY_DEFINED -#else -#define yyget_in iw8_get_in -#endif - -#ifdef yyset_in -#define iw8_set_in_ALREADY_DEFINED -#else -#define yyset_in iw8_set_in -#endif - -#ifdef yyget_out -#define iw8_get_out_ALREADY_DEFINED -#else -#define yyget_out iw8_get_out -#endif - -#ifdef yyset_out -#define iw8_set_out_ALREADY_DEFINED -#else -#define yyset_out iw8_set_out -#endif - -#ifdef yyget_leng -#define iw8_get_leng_ALREADY_DEFINED -#else -#define yyget_leng iw8_get_leng -#endif - -#ifdef yyget_text -#define iw8_get_text_ALREADY_DEFINED -#else -#define yyget_text iw8_get_text -#endif - -#ifdef yyget_lineno -#define iw8_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno iw8_get_lineno -#endif - -#ifdef yyset_lineno -#define iw8_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno iw8_set_lineno -#endif - -#ifdef yyget_column -#define iw8_get_column_ALREADY_DEFINED -#else -#define yyget_column iw8_get_column -#endif - -#ifdef yyset_column -#define iw8_set_column_ALREADY_DEFINED -#else -#define yyset_column iw8_set_column -#endif - -#ifdef yywrap -#define iw8_wrap_ALREADY_DEFINED -#else -#define yywrap iw8_wrap -#endif - -#ifdef yyalloc -#define iw8_alloc_ALREADY_DEFINED -#else -#define yyalloc iw8_alloc -#endif - -#ifdef yyrealloc -#define iw8_realloc_ALREADY_DEFINED -#else -#define yyrealloc iw8_realloc -#endif - -#ifdef yyfree -#define iw8_free_ALREADY_DEFINED -#else -#define yyfree iw8_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin , yyscanner ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define iw8_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); -static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 114 -#define YY_END_OF_BUFFER 115 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[346] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 115, 113, - 1, 2, 97, 113, 113, 96, 100, 113, 57, 58, - 94, 92, 63, 93, 64, 95, 112, 112, 66, 67, - 81, 91, 82, 68, 103, 103, 61, 62, 101, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 59, 99, 60, 98, 5, - 6, 5, 12, 13, 12, 113, 94, 95, 78, 0, - 105, 0, 15, 0, 0, 0, 0, 87, 0, 76, - 0, 89, 0, 0, 8, 85, 69, 83, 70, 84, - 108, 0, 11, 4, 3, 86, 108, 112, 109, 0, - - 0, 0, 0, 65, 73, 79, 77, 80, 74, 103, - 103, 90, 103, 103, 103, 103, 103, 103, 29, 103, - 103, 103, 103, 103, 27, 33, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 88, 75, 7, - 14, 10, 9, 0, 105, 0, 0, 0, 0, 0, - 0, 104, 0, 0, 0, 0, 105, 0, 108, 0, - 3, 108, 108, 109, 110, 111, 102, 71, 72, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 31, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 106, 0, 0, 0, 0, - - 0, 104, 0, 0, 104, 0, 0, 103, 103, 53, - 103, 46, 35, 103, 103, 103, 28, 103, 103, 103, - 51, 103, 103, 103, 103, 52, 103, 103, 103, 47, - 103, 22, 103, 0, 0, 0, 0, 0, 50, 103, - 103, 37, 103, 103, 103, 20, 48, 103, 54, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 30, 0, - 0, 0, 0, 0, 103, 56, 103, 103, 103, 103, - 103, 21, 103, 103, 39, 34, 103, 43, 103, 103, - 103, 107, 0, 0, 16, 0, 103, 103, 103, 103, - 36, 32, 103, 103, 103, 103, 103, 103, 0, 17, - - 0, 103, 103, 103, 38, 103, 42, 103, 103, 103, - 23, 19, 0, 55, 103, 103, 103, 103, 49, 26, - 103, 103, 0, 40, 103, 41, 45, 103, 103, 0, - 44, 103, 103, 0, 103, 103, 0, 103, 24, 0, - 103, 18, 103, 25, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, - 25, 26, 27, 1, 28, 29, 28, 30, 31, 32, - 33, 33, 34, 33, 33, 33, 33, 35, 33, 33, - 33, 36, 37, 38, 39, 33, 33, 40, 33, 33, - 41, 42, 43, 44, 45, 1, 46, 47, 48, 49, - - 50, 51, 52, 53, 54, 33, 55, 56, 57, 58, - 59, 60, 33, 61, 62, 63, 64, 65, 66, 40, - 67, 68, 69, 70, 71, 72, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[73] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 5, 5, 5, - 5, 1, 1, 1, 1, 1, 1, 5, 5, 5, - 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, - 1, 7, 1, 1, 6, 5, 5, 5, 5, 5, - 5, 6, 6, 8, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 8, 6, 6, 6, 6, 1, 1, - 1, 1 - } ; - -static const flex_int16_t yy_base[366] = - { 0, - 0, 0, 70, 71, 72, 73, 74, 75, 763, 764, - 764, 764, 737, 72, 67, 736, 80, 81, 764, 764, - 76, 81, 764, 82, 90, 110, 99, 124, 738, 764, - 71, 734, 73, 764, 716, 87, 764, 764, 732, 90, - 92, 105, 112, 114, 91, 58, 118, 88, 115, 117, - 123, 125, 126, 119, 139, 764, 138, 764, 764, 764, - 764, 739, 764, 764, 738, 165, 729, 177, 764, 179, - 764, 183, 764, 0, 695, 694, 689, 764, 185, 764, - 94, 764, 184, 192, 764, 764, 764, 764, 764, 764, - 179, 696, 764, 764, 0, 764, 185, 196, 221, 180, - - 191, 248, 0, 764, 724, 764, 764, 764, 723, 705, - 223, 764, 178, 181, 193, 202, 201, 203, 704, 186, - 208, 70, 209, 205, 703, 702, 60, 210, 216, 218, - 229, 246, 247, 182, 242, 250, 251, 764, 764, 764, - 764, 764, 764, 269, 277, 304, 0, 689, 254, 688, - 278, 764, 309, 294, 312, 297, 307, 314, 764, 673, - 0, 306, 764, 313, 319, 0, 698, 764, 764, 310, - 286, 288, 298, 306, 300, 311, 301, 317, 316, 323, - 326, 327, 328, 329, 330, 332, 331, 334, 333, 338, - 339, 344, 348, 345, 349, 0, 682, 682, 683, 678, - - 387, 388, 394, 392, 393, 400, 685, 372, 368, 692, - 364, 691, 690, 369, 370, 373, 689, 375, 371, 374, - 688, 383, 380, 396, 384, 687, 398, 385, 401, 686, - 402, 407, 409, 0, 664, 662, 667, 672, 764, 418, - 419, 413, 412, 420, 415, 681, 680, 426, 679, 414, - 435, 421, 423, 438, 441, 442, 425, 445, 678, 0, - 658, 669, 667, 671, 453, 673, 447, 450, 451, 455, - 452, 672, 458, 456, 671, 670, 459, 669, 465, 467, - 460, 764, 660, 659, 764, 662, 479, 470, 475, 477, - 665, 664, 480, 484, 488, 489, 483, 486, 655, 764, - - 646, 504, 493, 495, 661, 501, 643, 502, 505, 499, - 508, 764, 622, 592, 510, 514, 516, 515, 581, 580, - 519, 520, 537, 551, 521, 550, 549, 525, 526, 527, - 544, 527, 530, 521, 533, 534, 454, 535, 424, 414, - 537, 764, 539, 386, 764, 595, 603, 611, 616, 624, - 630, 634, 642, 313, 650, 658, 666, 674, 678, 308, - 686, 694, 282, 213, 208 - } ; - -static const flex_int16_t yy_def[366] = - { 0, - 345, 1, 346, 346, 347, 347, 1, 1, 345, 345, - 345, 345, 345, 348, 349, 345, 345, 350, 345, 345, - 345, 345, 345, 345, 345, 345, 351, 351, 345, 345, - 345, 345, 345, 345, 352, 352, 345, 345, 345, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 349, 345, 345, 345, 348, - 345, 353, 345, 354, 354, 345, 345, 345, 355, 345, - 356, 345, 350, 357, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 358, 345, 345, 351, 351, 351, - - 351, 351, 359, 345, 345, 345, 345, 345, 345, 352, - 352, 345, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 345, 345, 345, - 345, 345, 345, 348, 348, 353, 360, 345, 345, 345, - 355, 345, 361, 356, 362, 350, 350, 357, 345, 345, - 358, 345, 345, 351, 351, 102, 359, 345, 345, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 363, 345, 345, 345, 345, - - 355, 355, 361, 356, 356, 362, 345, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 364, 345, 345, 345, 345, 345, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 365, - 345, 345, 345, 345, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 345, 345, 345, 345, 345, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 345, 345, - - 345, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 345, 345, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 345, 352, 352, 352, 352, 352, 352, 345, - 352, 352, 352, 345, 352, 352, 345, 352, 352, 345, - 352, 345, 352, 352, 0, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345 - } ; - -static const flex_int16_t yy_nxt[837] = - { 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, - 28, 29, 30, 31, 32, 33, 34, 35, 35, 35, - 35, 35, 35, 36, 35, 35, 35, 35, 35, 35, - 37, 10, 38, 39, 35, 40, 41, 42, 43, 44, - 45, 46, 35, 47, 35, 48, 35, 49, 35, 50, - 51, 52, 53, 54, 35, 55, 35, 35, 56, 57, - 58, 59, 61, 61, 64, 64, 71, 65, 65, 66, - 66, 62, 62, 73, 79, 67, 67, 80, 81, 71, - 68, 68, 85, 87, 105, 106, 89, 108, 109, 103, - - 86, 103, 152, 124, 82, 88, 90, 91, 91, 91, - 91, 103, 75, 72, 97, 93, 98, 99, 99, 98, - 76, 94, 84, 111, 184, 181, 95, 101, 103, 103, - 77, 103, 103, 103, 96, 155, 122, 127, 102, 97, - 103, 98, 98, 98, 98, 101, 103, 113, 111, 123, - 115, 92, 114, 103, 111, 103, 103, 116, 103, 103, - 103, 118, 138, 117, 103, 103, 103, 103, 125, 120, - 119, 121, 130, 128, 131, 126, 135, 129, 133, 111, - 103, 142, 143, 71, 136, 70, 134, 145, 94, 152, - 132, 137, 71, 95, 83, 345, 91, 91, 91, 91, - - 157, 96, 162, 162, 162, 162, 345, 139, 165, 165, - 75, 97, 282, 98, 98, 98, 98, 260, 76, 103, - 72, 103, 103, 103, 146, 84, 153, 103, 77, 159, - 173, 172, 103, 158, 103, 163, 97, 103, 164, 164, - 164, 98, 103, 103, 103, 192, 103, 179, 174, 103, - 103, 103, 170, 178, 175, 176, 180, 103, 177, 103, - 171, 183, 103, 345, 103, 166, 166, 166, 166, 182, - 103, 170, 185, 71, 186, 166, 166, 166, 166, 166, - 187, 71, 152, 103, 188, 171, 234, 103, 103, 103, - 193, 103, 103, 166, 166, 166, 166, 166, 166, 189, - - 190, 198, 152, 194, 195, 71, 70, 191, 145, 199, - 72, 151, 196, 202, 154, 71, 83, 147, 72, 153, - 205, 209, 157, 162, 162, 162, 162, 103, 97, 103, - 164, 164, 164, 98, 345, 155, 165, 165, 84, 103, - 208, 103, 103, 211, 210, 146, 209, 103, 84, 213, - 203, 103, 103, 206, 103, 158, 163, 103, 103, 208, - 103, 212, 216, 215, 103, 217, 214, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 220, 221, 222, 103, - 103, 218, 224, 223, 226, 103, 103, 219, 229, 103, - 103, 152, 152, 230, 225, 227, 151, 231, 202, 228, - - 152, 152, 154, 240, 233, 103, 241, 232, 205, 103, - 103, 103, 103, 103, 103, 103, 103, 243, 242, 248, - 247, 103, 240, 244, 103, 103, 103, 103, 153, 153, - 250, 241, 246, 155, 155, 203, 245, 103, 249, 103, - 251, 206, 103, 103, 252, 253, 255, 254, 103, 266, - 103, 265, 256, 103, 103, 103, 103, 257, 259, 103, - 103, 103, 103, 342, 103, 103, 103, 103, 266, 258, - 270, 265, 267, 271, 268, 276, 103, 269, 275, 103, - 272, 273, 103, 103, 274, 280, 103, 287, 103, 278, - 277, 103, 103, 103, 103, 279, 103, 103, 281, 103, - - 103, 103, 289, 340, 292, 288, 103, 293, 103, 302, - 287, 103, 297, 294, 290, 298, 103, 291, 103, 295, - 103, 103, 296, 303, 103, 103, 305, 103, 302, 103, - 103, 306, 307, 314, 103, 304, 103, 308, 309, 310, - 103, 311, 103, 103, 316, 103, 103, 318, 320, 103, - 315, 103, 314, 319, 317, 103, 103, 103, 321, 325, - 103, 103, 103, 327, 322, 329, 103, 103, 103, 331, - 332, 103, 324, 326, 103, 103, 103, 336, 103, 328, - 103, 337, 338, 335, 341, 103, 339, 344, 333, 334, - 103, 103, 103, 330, 343, 60, 60, 60, 60, 60, - - 60, 60, 60, 63, 63, 63, 63, 63, 63, 63, - 63, 70, 70, 70, 70, 70, 70, 70, 70, 74, - 74, 103, 103, 74, 83, 83, 83, 83, 83, 83, - 83, 83, 100, 103, 100, 100, 100, 100, 110, 110, - 110, 110, 144, 144, 144, 144, 144, 144, 144, 144, - 151, 151, 151, 151, 151, 151, 151, 151, 154, 154, - 154, 154, 154, 154, 154, 154, 156, 156, 156, 156, - 156, 156, 156, 156, 161, 323, 161, 161, 161, 161, - 161, 161, 167, 167, 103, 167, 201, 201, 201, 201, - 201, 201, 201, 201, 204, 204, 204, 204, 204, 204, - - 204, 204, 103, 313, 312, 103, 103, 301, 300, 299, - 103, 103, 103, 103, 103, 286, 285, 284, 283, 103, - 103, 103, 103, 264, 263, 262, 261, 103, 103, 103, - 103, 103, 103, 103, 239, 238, 237, 236, 235, 103, - 207, 200, 197, 103, 103, 103, 103, 169, 168, 160, - 150, 149, 148, 86, 141, 140, 112, 103, 107, 104, - 78, 69, 345, 9, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345 - } ; - -static const flex_int16_t yy_chk[837] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 4, 5, 6, 14, 5, 6, 7, - 8, 3, 4, 15, 17, 7, 8, 17, 17, 18, - 7, 8, 21, 22, 31, 31, 24, 33, 33, 46, - - 21, 127, 81, 46, 17, 22, 24, 25, 25, 25, - 25, 122, 15, 14, 27, 26, 27, 27, 27, 27, - 15, 26, 18, 36, 127, 122, 26, 27, 36, 48, - 15, 40, 45, 41, 26, 81, 45, 48, 27, 28, - 27, 28, 28, 28, 28, 27, 42, 40, 36, 45, - 42, 25, 41, 43, 47, 44, 49, 42, 50, 47, - 54, 43, 57, 42, 51, 28, 52, 53, 47, 44, - 43, 44, 51, 49, 52, 47, 54, 50, 53, 47, - 55, 66, 68, 70, 55, 72, 53, 72, 68, 79, - 52, 55, 83, 68, 84, 100, 91, 91, 91, 91, - - 84, 68, 97, 97, 97, 97, 101, 57, 101, 101, - 66, 98, 365, 98, 98, 98, 98, 364, 66, 113, - 70, 100, 114, 134, 72, 83, 79, 120, 66, 91, - 114, 113, 101, 84, 115, 97, 99, 98, 99, 99, - 99, 99, 117, 116, 118, 134, 124, 120, 115, 121, - 123, 128, 111, 118, 115, 116, 121, 129, 117, 130, - 111, 124, 99, 102, 111, 102, 102, 102, 102, 123, - 131, 111, 128, 144, 129, 102, 102, 102, 102, 102, - 130, 145, 151, 135, 131, 111, 363, 132, 133, 102, - 135, 136, 137, 102, 102, 102, 102, 102, 102, 132, - - 133, 149, 154, 136, 137, 156, 146, 133, 146, 149, - 144, 153, 360, 153, 155, 157, 158, 354, 145, 151, - 155, 171, 158, 162, 162, 162, 162, 171, 164, 172, - 164, 164, 164, 164, 165, 154, 165, 165, 156, 173, - 170, 175, 177, 173, 172, 146, 171, 174, 157, 175, - 153, 170, 176, 155, 164, 158, 162, 179, 178, 170, - 165, 174, 178, 177, 180, 179, 176, 181, 182, 183, - 184, 185, 187, 186, 189, 188, 182, 183, 184, 190, - 191, 180, 186, 185, 188, 192, 194, 181, 191, 193, - 195, 201, 202, 192, 187, 189, 203, 193, 203, 190, - - 204, 205, 206, 208, 195, 211, 209, 194, 206, 209, - 214, 215, 219, 208, 216, 220, 218, 214, 211, 220, - 219, 223, 208, 215, 222, 225, 228, 344, 201, 202, - 223, 209, 218, 204, 205, 203, 216, 224, 222, 227, - 224, 206, 229, 231, 225, 227, 229, 228, 232, 241, - 233, 240, 231, 243, 242, 250, 245, 232, 233, 240, - 241, 244, 252, 340, 253, 339, 257, 248, 241, 232, - 245, 240, 242, 248, 243, 253, 251, 244, 252, 254, - 250, 251, 255, 256, 251, 257, 258, 265, 267, 255, - 254, 268, 269, 271, 265, 256, 270, 274, 258, 273, - - 277, 281, 268, 337, 271, 267, 279, 273, 280, 287, - 265, 288, 280, 274, 269, 281, 289, 270, 290, 277, - 287, 293, 279, 288, 297, 294, 290, 298, 287, 295, - 296, 293, 294, 302, 303, 289, 304, 295, 296, 297, - 310, 298, 306, 308, 304, 302, 309, 308, 310, 311, - 303, 315, 302, 309, 306, 316, 318, 317, 311, 316, - 321, 322, 325, 318, 311, 322, 328, 329, 332, 325, - 328, 333, 315, 317, 335, 336, 338, 333, 341, 321, - 343, 334, 335, 332, 338, 331, 336, 343, 329, 330, - 327, 326, 324, 323, 341, 346, 346, 346, 346, 346, - - 346, 346, 346, 347, 347, 347, 347, 347, 347, 347, - 347, 348, 348, 348, 348, 348, 348, 348, 348, 349, - 349, 320, 319, 349, 350, 350, 350, 350, 350, 350, - 350, 350, 351, 314, 351, 351, 351, 351, 352, 352, - 352, 352, 353, 353, 353, 353, 353, 353, 353, 353, - 355, 355, 355, 355, 355, 355, 355, 355, 356, 356, - 356, 356, 356, 356, 356, 356, 357, 357, 357, 357, - 357, 357, 357, 357, 358, 313, 358, 358, 358, 358, - 358, 358, 359, 359, 307, 359, 361, 361, 361, 361, - 361, 361, 361, 361, 362, 362, 362, 362, 362, 362, - - 362, 362, 305, 301, 299, 292, 291, 286, 284, 283, - 278, 276, 275, 272, 266, 264, 263, 262, 261, 259, - 249, 247, 246, 238, 237, 236, 235, 230, 226, 221, - 217, 213, 212, 210, 207, 200, 199, 198, 197, 167, - 160, 150, 148, 126, 125, 119, 110, 109, 105, 92, - 77, 76, 75, 67, 65, 62, 39, 35, 32, 29, - 16, 13, 9, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.lpp" -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ -#define YY_NO_INPUT 1 -#define YY_NO_UNISTD_H 1 - -#line 25 "lexer.lpp" -#define YY_USER_ACTION ctx->loc.columns(yyleng); -#line 951 "lexer.cpp" - -#line 953 "lexer.cpp" - -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#include "stdafx.hpp" +#include "iw8.hpp" +#include "parser.hpp" +#include "lexer.hpp" + +xsk::gsc::iw8::parser::symbol_type IW8lex(xsk::gsc::iw8::lexer& lexer) +{ + return lexer.lex(); +} + +namespace xsk::gsc::iw8 +{ + +enum class keyword +{ +/* KW_pre_define, + KW_pre_undef, + KW_pre_ifdef, + KW_pre_ifndef, + KW_pre_if, + KW_pre_elif, + KW_pre_else, + KW_pre_endif,*/ + KW_pre_inline, + KW_pre_include, + KW_pre_using_animtree, + KW_pre_animtree, + KW_endon, + KW_notify, + KW_wait, + KW_waittill, + KW_waittillmatch, + KW_waittillframeend, + KW_waitframe, + KW_if, + KW_else, + KW_do, + KW_while, + KW_for, + KW_foreach, + KW_in, + KW_switch, + KW_case, + KW_default, + KW_break, + KW_continue, + KW_return, + KW_breakpoint, + KW_prof_begin, + KW_prof_end, + KW_thread, + KW_childthread, + KW_thisthread, + KW_call, + KW_true, + KW_false, + KW_undefined, + KW_dotsize, + KW_game, + KW_self, + KW_anim, + KW_level, + KW_isdefined, + KW_istrue, + KW_INVALID, +}; + +buffer::buffer() : size(1024), length(0) +{ + data = static_cast(std::malloc(size)); +} + +buffer::~buffer() +{ + if(data) std::free(data); +} + +bool buffer::push(char c) +{ + if(length >= size) { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals ( yyscan_t yyscanner ); - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef YY_NO_UNPUT - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( yyscan_t yyscanner ); -#else -static int input ( yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_load_buffer_state( yyscanner ); - } - - { -#line 44 "lexer.lpp" - - - -#line 48 "lexer.lpp" - ctx->loc.step(); - - -#line 1222 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 346 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 345 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 51 "lexer.lpp" -{ ctx->loc.step(); } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 52 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 54 "lexer.lpp" - - YY_BREAK -case 4: -YY_RULE_SETUP -#line 56 "lexer.lpp" -{ BEGIN(COMMENT_STATE); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 57 "lexer.lpp" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 58 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(COMMENT_STATE): -#line 60 "lexer.lpp" -{ throw iw8::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "lexer.lpp" -{ throw iw8::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 63 "lexer.lpp" -{ throw iw8::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 64 "lexer.lpp" -{ BEGIN(INITIAL); return iw8::parser::make_DEVEND(ctx->loc); } - YY_BREAK -case YY_STATE_EOF(DEV_ON_STATE): -#line 65 "lexer.lpp" -{ throw iw8::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 67 "lexer.lpp" -{ BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return iw8::parser::make_DEVBEGIN(ctx->loc); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 68 "lexer.lpp" - - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 69 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 70 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(DEV_OFF_STATE): -#line 71 "lexer.lpp" -{ throw iw8::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.lpp" -{ throw iw8::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 74 "lexer.lpp" -{ return iw8::parser::make_INLINE(ctx->loc); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 75 "lexer.lpp" -{ return iw8::parser::make_INCLUDE(ctx->loc); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 76 "lexer.lpp" -{ return iw8::parser::make_USINGTREE(ctx->loc); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 77 "lexer.lpp" -{ return iw8::parser::make_ANIMTREE(ctx->loc); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 78 "lexer.lpp" -{ return iw8::parser::make_ENDON(ctx->loc); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 79 "lexer.lpp" -{ return iw8::parser::make_NOTIFY(ctx->loc); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 80 "lexer.lpp" -{ return iw8::parser::make_WAIT(ctx->loc); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 81 "lexer.lpp" -{ return iw8::parser::make_WAITTILL(ctx->loc); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 82 "lexer.lpp" -{ return iw8::parser::make_WAITTILLMATCH(ctx->loc); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 83 "lexer.lpp" -{ return iw8::parser::make_WAITTILLFRAMEEND(ctx->loc); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 84 "lexer.lpp" -{ return iw8::parser::make_WAITFRAME(ctx->loc); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 85 "lexer.lpp" -{ return iw8::parser::make_IF(ctx->loc); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 86 "lexer.lpp" -{ return iw8::parser::make_ELSE(ctx->loc); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 87 "lexer.lpp" -{ return iw8::parser::make_DO(ctx->loc); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 88 "lexer.lpp" -{ return iw8::parser::make_WHILE(ctx->loc); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 89 "lexer.lpp" -{ return iw8::parser::make_FOR(ctx->loc); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 90 "lexer.lpp" -{ return iw8::parser::make_FOREACH(ctx->loc); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 91 "lexer.lpp" -{ return iw8::parser::make_IN(ctx->loc); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 92 "lexer.lpp" -{ return iw8::parser::make_SWITCH(ctx->loc); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 93 "lexer.lpp" -{ return iw8::parser::make_CASE(ctx->loc); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 94 "lexer.lpp" -{ return iw8::parser::make_DEFAULT(ctx->loc); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 95 "lexer.lpp" -{ return iw8::parser::make_BREAK(ctx->loc); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 96 "lexer.lpp" -{ return iw8::parser::make_CONTINUE(ctx->loc); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 97 "lexer.lpp" -{ return iw8::parser::make_RETURN(ctx->loc); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 98 "lexer.lpp" -{ return iw8::parser::make_BREAKPOINT(ctx->loc); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 99 "lexer.lpp" -{ return iw8::parser::make_PROFBEGIN(ctx->loc); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 100 "lexer.lpp" -{ return iw8::parser::make_PROFEND(ctx->loc); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 101 "lexer.lpp" -{ return iw8::parser::make_THREAD(ctx->loc); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 102 "lexer.lpp" -{ return iw8::parser::make_CHILDTHREAD(ctx->loc); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 103 "lexer.lpp" -{ return iw8::parser::make_THISTHREAD(ctx->loc); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 104 "lexer.lpp" -{ return iw8::parser::make_CALL(ctx->loc); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 105 "lexer.lpp" -{ return iw8::parser::make_TRUE(ctx->loc); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 106 "lexer.lpp" -{ return iw8::parser::make_FALSE(ctx->loc); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 107 "lexer.lpp" -{ return iw8::parser::make_UNDEFINED(ctx->loc); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 108 "lexer.lpp" -{ return iw8::parser::make_SIZE(ctx->loc); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 109 "lexer.lpp" -{ return iw8::parser::make_GAME(ctx->loc); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 110 "lexer.lpp" -{ return iw8::parser::make_SELF(ctx->loc); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 111 "lexer.lpp" -{ return iw8::parser::make_ANIM(ctx->loc); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 112 "lexer.lpp" -{ return iw8::parser::make_LEVEL(ctx->loc); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 113 "lexer.lpp" -{ return iw8::parser::make_ISDEFINED(ctx->loc); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 114 "lexer.lpp" -{ return iw8::parser::make_ISTRUE(ctx->loc); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 115 "lexer.lpp" -{ return iw8::parser::make_LPAREN(ctx->loc); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 116 "lexer.lpp" -{ return iw8::parser::make_RPAREN(ctx->loc); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 117 "lexer.lpp" -{ return iw8::parser::make_LBRACE(ctx->loc); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 118 "lexer.lpp" -{ return iw8::parser::make_RBRACE(ctx->loc); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 119 "lexer.lpp" -{ return iw8::parser::make_LBRACKET(ctx->loc); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 120 "lexer.lpp" -{ return iw8::parser::make_RBRACKET(ctx->loc); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 121 "lexer.lpp" -{ return iw8::parser::make_COMMA(ctx->loc); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 122 "lexer.lpp" -{ return iw8::parser::make_DOT(ctx->loc); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 123 "lexer.lpp" -{ return iw8::parser::make_DOUBLECOLON(ctx->loc); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 124 "lexer.lpp" -{ return iw8::parser::make_COLON(ctx->loc); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 125 "lexer.lpp" -{ return iw8::parser::make_SEMICOLON(ctx->loc); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 126 "lexer.lpp" -{ return iw8::parser::make_QMARK(ctx->loc); } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 127 "lexer.lpp" -{ return iw8::parser::make_INCREMENT(ctx->loc); } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 128 "lexer.lpp" -{ return iw8::parser::make_DECREMENT(ctx->loc); } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 129 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_LSHIFT(ctx->loc); } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 130 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_RSHIFT(ctx->loc); } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 131 "lexer.lpp" -{ return iw8::parser::make_LSHIFT(ctx->loc); } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 132 "lexer.lpp" -{ return iw8::parser::make_RSHIFT(ctx->loc); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 133 "lexer.lpp" -{ return iw8::parser::make_OR(ctx->loc); } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 134 "lexer.lpp" -{ return iw8::parser::make_AND(ctx->loc); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 135 "lexer.lpp" -{ return iw8::parser::make_EQUALITY(ctx->loc); } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 136 "lexer.lpp" -{ return iw8::parser::make_INEQUALITY(ctx->loc); } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 137 "lexer.lpp" -{ return iw8::parser::make_LESS_EQUAL(ctx->loc); } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 138 "lexer.lpp" -{ return iw8::parser::make_GREATER_EQUAL(ctx->loc); } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 139 "lexer.lpp" -{ return iw8::parser::make_LESS(ctx->loc); } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 140 "lexer.lpp" -{ return iw8::parser::make_GREATER(ctx->loc); } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 141 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_ADD(ctx->loc); } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 142 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_SUB(ctx->loc); } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 143 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_MUL(ctx->loc); } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 144 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_DIV(ctx->loc); } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 145 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_MOD(ctx->loc); } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 146 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_BW_OR(ctx->loc); } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 147 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_BW_AND(ctx->loc); } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 148 "lexer.lpp" -{ return iw8::parser::make_ASSIGN_BW_EXOR(ctx->loc); } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 149 "lexer.lpp" -{ return iw8::parser::make_ASSIGN(ctx->loc); } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 150 "lexer.lpp" -{ return iw8::parser::make_ADD(ctx->loc); } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 151 "lexer.lpp" -{ return iw8::parser::make_SUB(ctx->loc); } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 152 "lexer.lpp" -{ return iw8::parser::make_MUL(ctx->loc); } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 153 "lexer.lpp" -{ return iw8::parser::make_DIV(ctx->loc); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 154 "lexer.lpp" -{ return iw8::parser::make_MOD(ctx->loc); } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 155 "lexer.lpp" -{ return iw8::parser::make_NOT(ctx->loc); } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 156 "lexer.lpp" -{ return iw8::parser::make_COMPLEMENT(ctx->loc); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 157 "lexer.lpp" -{ return iw8::parser::make_BITWISE_OR(ctx->loc); } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 158 "lexer.lpp" -{ return iw8::parser::make_BITWISE_AND(ctx->loc); } - YY_BREAK -case 101: -YY_RULE_SETUP -#line 159 "lexer.lpp" -{ return iw8::parser::make_BITWISE_EXOR(ctx->loc); } - YY_BREAK -case 102: -YY_RULE_SETUP -#line 160 "lexer.lpp" -{ return iw8::parser::make_PATH(xsk::gsc::iw8::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 103: -YY_RULE_SETUP -#line 161 "lexer.lpp" -{ return iw8::parser::make_IDENTIFIER(xsk::gsc::iw8::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 104: -/* rule 104 can match eol */ -YY_RULE_SETUP -#line 162 "lexer.lpp" -{ return iw8::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 105: -/* rule 105 can match eol */ -YY_RULE_SETUP -#line 163 "lexer.lpp" -{ return iw8::parser::make_STRING(std::string(yytext), ctx->loc); } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 164 "lexer.lpp" -{ return iw8::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 165 "lexer.lpp" -{ return iw8::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 166 "lexer.lpp" -{ return iw8::parser::make_FLOAT(std::string(yytext), ctx->loc); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 167 "lexer.lpp" -{ return iw8::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } - YY_BREAK -case 110: -YY_RULE_SETUP -#line 168 "lexer.lpp" -{ return iw8::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } - YY_BREAK -case 111: -YY_RULE_SETUP -#line 169 "lexer.lpp" -{ return iw8::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } - YY_BREAK -case 112: -YY_RULE_SETUP -#line 170 "lexer.lpp" -{ return iw8::parser::make_INTEGER(std::string(yytext), ctx->loc); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 171 "lexer.lpp" -{ if(ctx->header_top > 0) iw8_pop_header(ctx); else return iw8::parser::make_IW8EOF(ctx->loc); } - YY_BREAK -case 113: -/* rule 113 can match eol */ -YY_RULE_SETUP -#line 172 "lexer.lpp" -{ throw iw8::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - YY_BREAK -case 114: -YY_RULE_SETUP -#line 174 "lexer.lpp" -ECHO; - YY_BREAK -#line 1867 "lexer.cpp" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap( yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin , yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + auto nsize = size * 2; + auto ndata = reinterpret_cast(std::malloc(nsize)); + + if(!ndata) return false; + + std::memmove(ndata, data, size); + std::free(data); + size = nsize; + data = ndata; + } + data[length++] = c; + return true; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 346 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; } -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +void reader::init(const char* data, size_t size) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 346 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 345); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + if(data && size) + { + state = reader::ok; + buffer_pos = data; + bytes_remaining = size; + last_byte = 0; + current_byte = *data; + } + else + { + state = reader::end; + buffer_pos = 0; + bytes_remaining = 0; + last_byte = 0; + current_byte = 0; + } } -#ifndef YY_NO_UNPUT - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - +void reader::advance() { - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + ++buffer_pos; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin , yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); - yy_load_buffer_state( yyscanner ); + if(bytes_remaining-- == 1) + { + state = reader::end; + bytes_remaining = 0; + last_byte = current_byte; + current_byte = 0; + } + else + { + last_byte = current_byte; + current_byte = *buffer_pos; + } } -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +lexer::lexer(const std::string& name, const char* data, size_t size) : in_dev_state_(false), loc_(xsk::gsc::location(&name)), + mode_(build::dev), header_top_(0), locs_(std::stack()), readers_(std::stack()) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + reader_.init(data, size); } -static void yy_load_buffer_state (yyscan_t yyscanner) +void lexer::push_header(const std::string& file) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + try + { + if (header_top_++ >= 10) + throw xsk::gsc::error("maximum gsh depth exceeded '10'"); + + auto data = resolver::file_data(file + ".gsh"); + + readers_.push(reader_); + locs_.push(loc_); + loc_.initialize(std::get<0>(data)); + reader_.init(std::get<1>(data), std::get<2>(data)); + } + catch (const std::exception& e) + { + throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); + } } -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +void lexer::pop_header() { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file , yyscanner); - - return b; + header_top_--; + loc_ = locs_.top(); + locs_.pop(); + reader_ = readers_.top(); + readers_.pop(); } -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void lexer::restrict_header(const xsk::gsc::location& loc) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf , yyscanner ); - - yyfree( (void *) b , yyscanner ); + if (header_top_ > 0) + { + throw comp_error(loc, "not allowed inside a gsh file"); + } } -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - +auto lexer::lex() -> xsk::gsc::iw8::parser::symbol_type { - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + buffer_.length = 0; + loc_.step(); - yy_flush_buffer( b , yyscanner); + while (true) + { + if (reader_.state == reader::end) + { + if (in_dev_state_) + throw iw8::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + if(header_top_ > 0) + pop_header(); + else + return iw8::parser::make_IW8EOF(loc_); + } - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + reader_.advance(); + auto& last = reader_.last_byte; + auto& curr = reader_.current_byte; + + switch (last) + { + case ' ': + case '\t': + case '\r': + loc_.step(); + continue; + case '\n': + loc_.lines(); + loc_.step(); + continue; + case '/': + if(reader_.state == reader::end || (curr != '/' && curr != '*' && curr != '#' && curr != '=')) + return iw8::parser::make_DIV(loc_); + + reader_.advance(); + + if (last == '=') + return iw8::parser::make_ASSIGN_DIV(loc_); + + if (last == '#') + { + if (in_dev_state_) + { + throw iw8::parser::syntax_error(loc_, "cannot recurse devblock ('/#')"); + } + else if (mode_ == xsk::gsc::build::dev) + { + in_dev_state_ = true; + return iw8::parser::make_DEVBEGIN(loc_); + } + else + { + while (true) + { + if (reader_.state == reader::end) + { + throw iw8::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '#' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + } + else if (last == '*') + { + while (true) + { + if (reader_.state == reader::end) + { + throw iw8::parser::syntax_error(loc_, "unmatched multiline comment start ('/*')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '*' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + else if (last == '/') + { + while (true) + { + if (reader_.state == reader::end || curr == '\n') + break; + + reader_.advance(); + } + } + continue; + case '#': + if (curr == '/') + { + if (!in_dev_state_) + throw iw8::parser::syntax_error(loc_, "unmatched devblock end ('#/')"); + + in_dev_state_ = false; + reader_.advance(); + return iw8::parser::make_DEVEND(loc_); + } + + buffer_.push(last); + while (reader_.state == reader::ok) + { + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + { + if (auto len = buffer_.length; len == 4 || len == 7) + { + auto data = buffer_.data; + auto color = true; + for (auto i = 1; i < len; i++) + { + if ((data[i] < 48 || data[i] > 57) && (data[i] < 65 || data[i] > 70) && (data[i] < 97 || data[i] > 102)) + { + color = false; + break; + } + } + + if (color) return iw8::parser::make_COLOR(std::string(++data, --len), loc_); + } + + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); + + if (key == keyword::KW_INVALID) + throw iw8::parser::syntax_error(loc_, utils::string::va("unknown preprocessor directive ('%s')", "#")); + + if (keyword_is_token(key)) + return keyword_token(key); + + // call preprocessor(key); + } + continue; + case '*': + if (reader_.state == reader::end || (curr != '/' && curr != '=')) + return iw8::parser::make_MUL(loc_); + + reader_.advance(); + + if (curr == '/') + throw iw8::parser::syntax_error(loc_, "unmatched multiline comment end ('*/')"); + + return iw8::parser::make_ASSIGN_MUL(loc_); + case '"': + case '\'': + return read_string(last, false); + case '.': + return read_dotsize(); + case '(': + return iw8::parser::make_LPAREN(loc_); + case ')': + return iw8::parser::make_RPAREN(loc_); + case '{': + return iw8::parser::make_LBRACE(loc_); + case '}': + return iw8::parser::make_RBRACE(loc_); + case '[': + return iw8::parser::make_LBRACKET(loc_); + case ']': + return iw8::parser::make_RBRACKET(loc_); + case ',': + return iw8::parser::make_COMMA(loc_); + case ';': + return iw8::parser::make_SEMICOLON(loc_); + case ':': + if (curr != ':') + return iw8::parser::make_COLON(loc_); + reader_.advance(); + return iw8::parser::make_DOUBLECOLON(loc_); + case '?': + return iw8::parser::make_QMARK(loc_); + case '=': + if (curr != '=') + return iw8::parser::make_ASSIGN(loc_); + reader_.advance(); + return iw8::parser::make_EQUALITY(loc_); + case '+': + if (curr != '+' && curr != '=') + return iw8::parser::make_ADD(loc_); + reader_.advance(); + return (last == '+') ? iw8::parser::make_INCREMENT(loc_) : iw8::parser::make_ASSIGN_ADD(loc_); + case '-': + if (curr != '-' && curr != '=') + return iw8::parser::make_SUB(loc_); + reader_.advance(); + return (last == '-') ? iw8::parser::make_DECREMENT(loc_) : iw8::parser::make_ASSIGN_SUB(loc_); + case '%': + if (curr != '=') + return iw8::parser::make_MOD(loc_); + reader_.advance(); + return iw8::parser::make_ASSIGN_MOD(loc_); + case '|': + if (curr != '|' && curr != '=') + return iw8::parser::make_BITWISE_OR(loc_); + reader_.advance(); + return (last == '|') ? iw8::parser::make_OR(loc_) : iw8::parser::make_ASSIGN_BW_OR(loc_); + case '&': + if (curr != '&' && curr != '=' && curr != '"' && curr != '\'') + return iw8::parser::make_BITWISE_AND(loc_); + reader_.advance(); + if (last == '"' || last == '\'') + return read_string(last, true); + return (last == '&') ? iw8::parser::make_AND(loc_) : iw8::parser::make_ASSIGN_BW_AND(loc_); + case '^': + if (curr != '=') + return iw8::parser::make_BITWISE_EXOR(loc_); + reader_.advance(); + return iw8::parser::make_ASSIGN_BW_EXOR(loc_); + case '!': + if (curr != '=') + return iw8::parser::make_NOT(loc_); + reader_.advance(); + return iw8::parser::make_INEQUALITY(loc_); + case '~': + return iw8::parser::make_COMPLEMENT(loc_); + case '<': + if (curr != '<' && curr != '=') + return iw8::parser::make_LESS(loc_); + reader_.advance(); + if (last == '<') + { + reader_.advance(); + return (last == '=') ? iw8::parser::make_ASSIGN_LSHIFT(loc_) : iw8::parser::make_LSHIFT(loc_); + } + return iw8::parser::make_LESS_EQUAL(loc_); + case '>': + if (curr != '>' && curr != '=') + return iw8::parser::make_GREATER(loc_); + reader_.advance(); + if (last == '>') + { + reader_.advance(); + return (last == '=') ? iw8::parser::make_ASSIGN_RSHIFT(loc_) : iw8::parser::make_RSHIFT(loc_); + } + return iw8::parser::make_GREATER_EQUAL(loc_); + default: + if (last >= '0' && last <= '9') + return lexer::read_number(last); + else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z') + return lexer::read_word(last); + + throw iw8::parser::syntax_error(loc_, utils::string::va("bad token: \'%c\'", last)); + } + } +} + +auto lexer::read_string(char quote, bool localize) -> xsk::gsc::iw8::parser::symbol_type +{ + if (localize) + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + reader_.advance(); + + if (last == '\n') + throw iw8::parser::syntax_error(loc_, "unterminated string"); + + if (last == '\\') // process scapes + { + // TODO: + } + + if (last != '\\' && curr == quote) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); } - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b , yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n , yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n , yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int _line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = _line_number; -} - -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column (int _column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = _column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int _bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = _bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (reader_.state == reader::end) + { + throw iw8::parser::syntax_error(loc_, utils::string::va("unmatched string start ('%s')", (quote == '"') ? "\"" : "\\'")); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + if (localize) + return iw8::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + return iw8::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_); +} + +auto lexer::read_number(char first) -> xsk::gsc::iw8::parser::symbol_type +{ + if (first == '.') + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = true; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw iw8::parser::syntax_error(loc_, "invalid number '.'"); + } + if (data[i] == 'f' && i != len - 1) + throw iw8::parser::syntax_error(loc_, "invalid number 'f'"); + } + + return iw8::parser::make_FLOAT(std::string(data, len), loc_); + } + else + { + auto curr = reader_.current_byte; + + if (first == '0' && curr == 'o') + { + buffer_.push(first); + buffer_.push('o'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'o')) + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'o' && last == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr > 47 && curr < 56)) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid octal literal!"); + + return iw8::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data + 2), loc_); + } + else if (first == '0' && curr == 'b') + { + buffer_.push(first); + buffer_.push('b'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'b')) + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'b' && last == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (curr != '0' && curr != '1') + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid binary literal!"); + + return iw8::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_); + } + else if (first == '0' && curr == 'x') + { + buffer_.push(first); + buffer_.push('x'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'x')) + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'x' && last == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!((curr > 47 && curr < 58) || (curr > 64 && curr < 71) || (curr > 96 && curr < 103))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid hexadecimal literal!"); + + return iw8::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_); + } + else + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw iw8::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = false; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw iw8::parser::syntax_error(loc_, "invalid number '.'"); + + dot = true; + } + if (data[i] == 'f' && i != len - 1) + throw iw8::parser::syntax_error(loc_, "invalid number 'f'"); + } + + if (dot || data[len - 1] == 'f') + return iw8::parser::make_FLOAT(std::string(data, len), loc_); + + return iw8::parser::make_INTEGER(std::string(data, len), loc_); + } + } +} + +auto lexer::read_word(char first) -> xsk::gsc::iw8::parser::symbol_type +{ + auto path = false; + + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto curr = reader_.current_byte; + + if (!(curr == '\\' || curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (curr == '\\') + { + if (reader_.last_byte == '\\') + throw iw8::parser::syntax_error(loc_, "invalid path '\\\\'"); + + path = true; + curr = '/'; + } + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + if(buffer_.data[0] != '_') + { + for(auto i = 0; i < buffer_.length; i++) + { + auto c = buffer_.data[i]; - return yy_init_globals ( *ptr_yy_globals ); -} - -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; - - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (c > 64 && c < 91) + buffer_.data[i] = c + 32; + } } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + if (key != keyword::KW_INVALID) + return keyword_token(key); + + if (path) + { + if (buffer_.data[buffer_.length - 1] == '/') + throw iw8::parser::syntax_error(loc_, "invalid path end '\\'"); + + return iw8::parser::make_PATH(xsk::gsc::iw8::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + return iw8::parser::make_IDENTIFIER(xsk::gsc::iw8::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } -static int yy_init_globals (yyscan_t yyscanner) +auto lexer::read_dotsize() -> xsk::gsc::iw8::parser::symbol_type { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ + auto curr = reader_.current_byte; - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; - yyg->yy_start = 0; + if (curr > 47 && curr < 58) + { + return lexer::read_number('.'); + } + else if (curr == '_' || curr > 64 && curr < 91 || curr > 96 && curr < 123) + { + reader save; + save.state = reader_.state; + save.bytes_remaining = reader_.bytes_remaining; + save.buffer_pos = reader_.buffer_pos; + save.last_byte = reader_.last_byte; + save.current_byte = reader_.current_byte; - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; + while (reader_.state == reader::ok) + { + curr = reader_.current_byte; -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123))) + break; - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (std::string_view(buffer_.data, buffer_.length) == "size") + { + return iw8::parser::make_SIZE(loc_); + } + + reader_.state = save.state; + reader_.bytes_remaining = save.bytes_remaining; + reader_.buffer_pos = save.buffer_pos; + reader_.last_byte = save.last_byte; + reader_.current_byte = save.current_byte; + + return iw8::parser::make_DOT(loc_); + + } + else return iw8::parser::make_DOT(loc_); } -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) +auto lexer::keyword_token(keyword k) -> xsk::gsc::iw8::parser::symbol_type { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack , yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack , yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; + switch (k) + { + case keyword::KW_pre_inline: + return iw8::parser::make_INLINE(loc_); + case keyword::KW_pre_include: + return iw8::parser::make_INCLUDE(loc_); + case keyword::KW_pre_using_animtree: + return iw8::parser::make_USINGTREE(loc_); + case keyword::KW_pre_animtree: + return iw8::parser::make_ANIMTREE(loc_); + case keyword::KW_endon: + return iw8::parser::make_ENDON(loc_); + case keyword::KW_notify: + return iw8::parser::make_NOTIFY(loc_); + case keyword::KW_wait: + return iw8::parser::make_WAIT(loc_); + case keyword::KW_waittill: + return iw8::parser::make_WAITTILL(loc_); + case keyword::KW_waittillmatch: + return iw8::parser::make_WAITTILLMATCH(loc_); + case keyword::KW_waittillframeend: + return iw8::parser::make_WAITTILLFRAMEEND(loc_); + case keyword::KW_waitframe: + return iw8::parser::make_WAITFRAME(loc_); + case keyword::KW_if: + return iw8::parser::make_IF(loc_); + case keyword::KW_else: + return iw8::parser::make_ELSE(loc_); + case keyword::KW_do: + return iw8::parser::make_DO(loc_); + case keyword::KW_while: + return iw8::parser::make_WHILE(loc_); + case keyword::KW_for: + return iw8::parser::make_FOR(loc_); + case keyword::KW_foreach: + return iw8::parser::make_FOREACH(loc_); + case keyword::KW_in: + return iw8::parser::make_IN(loc_); + case keyword::KW_switch: + return iw8::parser::make_SWITCH(loc_); + case keyword::KW_case: + return iw8::parser::make_CASE(loc_); + case keyword::KW_default: + return iw8::parser::make_DEFAULT(loc_); + case keyword::KW_break: + return iw8::parser::make_BREAK(loc_); + case keyword::KW_continue: + return iw8::parser::make_CONTINUE(loc_); + case keyword::KW_return: + return iw8::parser::make_RETURN(loc_); + case keyword::KW_breakpoint: + return iw8::parser::make_BREAKPOINT(loc_); + case keyword::KW_prof_begin: + return iw8::parser::make_PROFBEGIN(loc_); + case keyword::KW_prof_end: + return iw8::parser::make_PROFEND(loc_); + case keyword::KW_thread: + return iw8::parser::make_THREAD(loc_); + case keyword::KW_childthread: + return iw8::parser::make_CHILDTHREAD(loc_); + case keyword::KW_thisthread: + return iw8::parser::make_THISTHREAD(loc_); + case keyword::KW_call: + return iw8::parser::make_CALL(loc_); + case keyword::KW_true: + return iw8::parser::make_TRUE(loc_); + case keyword::KW_false: + return iw8::parser::make_FALSE(loc_); + case keyword::KW_undefined: + return iw8::parser::make_UNDEFINED(loc_); + case keyword::KW_dotsize: + return iw8::parser::make_SIZE(loc_); + case keyword::KW_game: + return iw8::parser::make_GAME(loc_); + case keyword::KW_self: + return iw8::parser::make_SELF(loc_); + case keyword::KW_anim: + return iw8::parser::make_ANIM(loc_); + case keyword::KW_level: + return iw8::parser::make_LEVEL(loc_); + case keyword::KW_isdefined: + return iw8::parser::make_ISDEFINED(loc_); + case keyword::KW_istrue: + return iw8::parser::make_ISTRUE(loc_); + default: + throw error("gsc lexer: INVALID KEYWORD TOKEN!"); + } } -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +auto lexer::keyword_is_token(keyword k) -> bool { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + switch (k) + { +/* case keyword::KW_pre_define: + case keyword::KW_pre_undef: + case keyword::KW_pre_ifdef: + case keyword::KW_pre_ifndef: + case keyword::KW_pre_if: + case keyword::KW_pre_elif: + case keyword::KW_pre_else: + case keyword::KW_pre_endif:*/ + case keyword::KW_INVALID: + return false; + default: + return true; + } } -#endif -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +auto lexer::get_keyword(std::string_view str) -> keyword { - int n; - for ( n = 0; s[n]; ++n ) - ; + auto itr = keywords.find(str); - return n; -} -#endif + if(itr != keywords.end()) + { + return itr->second; + } -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); + return keyword::KW_INVALID; } -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 174 "lexer.lpp" - - -void iw8_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void iw8_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} +std::unordered_map lexer::keywords +{{ +/* { "#define", keyword::KW_pre_define }, + { "#undef", keyword::KW_pre_undef }, + { "#ifdef", keyword::KW_pre_ifdef }, + { "#ifndef", keyword::KW_pre_ifndef }, + { "#if", keyword::KW_pre_if }, + { "#elif", keyword::KW_pre_elif }, + { "#else", keyword::KW_pre_else }, + { "#endif", keyword::KW_pre_endif },*/ + { "#inline", keyword::KW_pre_inline }, + { "#include", keyword::KW_pre_include }, + { "#using_animtree", keyword::KW_pre_using_animtree }, + { "#animtree", keyword::KW_pre_animtree }, + { "endon", keyword::KW_endon }, + { "notify", keyword::KW_notify }, + { "wait", keyword::KW_wait }, + { "waittill", keyword::KW_waittill }, + { "waittillmatch", keyword::KW_waittillmatch }, + { "waittillframeend", keyword::KW_waittillframeend }, + { "waitframe", keyword::KW_waitframe }, + { "if", keyword::KW_if }, + { "else", keyword::KW_else }, + { "do", keyword::KW_do }, + { "while", keyword::KW_while }, + { "for", keyword::KW_for }, + { "foreach", keyword::KW_foreach }, + { "in", keyword::KW_in }, + { "switch", keyword::KW_switch }, + { "case", keyword::KW_case }, + { "default", keyword::KW_default }, + { "break", keyword::KW_break }, + { "continue", keyword::KW_continue }, + { "return", keyword::KW_return }, + { "breakpoint", keyword::KW_breakpoint }, + { "prof_begin", keyword::KW_prof_begin }, + { "prof_end", keyword::KW_prof_end }, + { "thread", keyword::KW_thread }, + { "childthread", keyword::KW_childthread }, + { "thisthread", keyword::KW_thisthread }, + { "call", keyword::KW_call }, + { "true", keyword::KW_true }, + { "false", keyword::KW_false }, + { "undefined", keyword::KW_undefined }, + { ".size", keyword::KW_dotsize }, + { "game", keyword::KW_game }, + { "self", keyword::KW_self }, + { "anim", keyword::KW_anim }, + { "level", keyword::KW_level }, + { "isdefined", keyword::KW_isdefined }, + { "istrue", keyword::KW_istrue }, +}}; +} // namespace xsk::gsc::iw8 diff --git a/src/iw8/xsk/lexer.hpp b/src/iw8/xsk/lexer.hpp index 3675f05b..19d2fe8b 100644 --- a/src/iw8/xsk/lexer.hpp +++ b/src/iw8/xsk/lexer.hpp @@ -1,711 +1,79 @@ -#ifndef iw8_HEADER_H -#define iw8_HEADER_H 1 -#define iw8_IN_HEADER 1 - -#line 5 "lexer.hpp" -#include "stdafx.hpp" -#include "iw8.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void iw8_push_header(xsk::gsc::context* ctx, const std::string& file); -void iw8_pop_header(xsk::gsc::context* ctx); - -#line 13 "lexer.hpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define iw8__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer iw8__create_buffer -#endif - -#ifdef yy_delete_buffer -#define iw8__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer iw8__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define iw8__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer iw8__scan_buffer -#endif - -#ifdef yy_scan_string -#define iw8__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string iw8__scan_string -#endif - -#ifdef yy_scan_bytes -#define iw8__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes iw8__scan_bytes -#endif - -#ifdef yy_init_buffer -#define iw8__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer iw8__init_buffer -#endif - -#ifdef yy_flush_buffer -#define iw8__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer iw8__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define iw8__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state iw8__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define iw8__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer iw8__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define iw8_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state iw8_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define iw8_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state iw8_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define iw8_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack iw8_ensure_buffer_stack -#endif - -#ifdef yylex -#define iw8_lex_ALREADY_DEFINED -#else -#define yylex iw8_lex -#endif - -#ifdef yyrestart -#define iw8_restart_ALREADY_DEFINED -#else -#define yyrestart iw8_restart -#endif - -#ifdef yylex_init -#define iw8_lex_init_ALREADY_DEFINED -#else -#define yylex_init iw8_lex_init -#endif - -#ifdef yylex_init_extra -#define iw8_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra iw8_lex_init_extra -#endif - -#ifdef yylex_destroy -#define iw8_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy iw8_lex_destroy -#endif - -#ifdef yyget_debug -#define iw8_get_debug_ALREADY_DEFINED -#else -#define yyget_debug iw8_get_debug -#endif - -#ifdef yyset_debug -#define iw8_set_debug_ALREADY_DEFINED -#else -#define yyset_debug iw8_set_debug -#endif - -#ifdef yyget_extra -#define iw8_get_extra_ALREADY_DEFINED -#else -#define yyget_extra iw8_get_extra -#endif - -#ifdef yyset_extra -#define iw8_set_extra_ALREADY_DEFINED -#else -#define yyset_extra iw8_set_extra -#endif - -#ifdef yyget_in -#define iw8_get_in_ALREADY_DEFINED -#else -#define yyget_in iw8_get_in -#endif - -#ifdef yyset_in -#define iw8_set_in_ALREADY_DEFINED -#else -#define yyset_in iw8_set_in -#endif - -#ifdef yyget_out -#define iw8_get_out_ALREADY_DEFINED -#else -#define yyget_out iw8_get_out -#endif - -#ifdef yyset_out -#define iw8_set_out_ALREADY_DEFINED -#else -#define yyset_out iw8_set_out -#endif - -#ifdef yyget_leng -#define iw8_get_leng_ALREADY_DEFINED -#else -#define yyget_leng iw8_get_leng -#endif - -#ifdef yyget_text -#define iw8_get_text_ALREADY_DEFINED -#else -#define yyget_text iw8_get_text -#endif - -#ifdef yyget_lineno -#define iw8_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno iw8_get_lineno -#endif - -#ifdef yyset_lineno -#define iw8_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno iw8_set_lineno -#endif - -#ifdef yyget_column -#define iw8_get_column_ALREADY_DEFINED -#else -#define yyget_column iw8_get_column -#endif - -#ifdef yyset_column -#define iw8_set_column_ALREADY_DEFINED -#else -#define yyset_column iw8_set_column -#endif - -#ifdef yywrap -#define iw8_wrap_ALREADY_DEFINED -#else -#define yywrap iw8_wrap -#endif - -#ifdef yyalloc -#define iw8_alloc_ALREADY_DEFINED -#else -#define yyalloc iw8_alloc -#endif - -#ifdef yyrealloc -#define iw8_realloc_ALREADY_DEFINED -#else -#define yyrealloc iw8_realloc -#endif - -#ifdef yyfree -#define iw8_free_ALREADY_DEFINED -#else -#define yyfree iw8_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define iw8_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#ifndef iw8__create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef iw8__delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef iw8__scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef iw8__scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef iw8__scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef iw8__init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef iw8__flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef iw8__load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef iw8__switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef iw8_push_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef iw8_pop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef iw8_ensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef iw8_lex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef iw8_restart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef iw8_lex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef iw8_lex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef iw8_lex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef iw8_get_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef iw8_set_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef iw8_get_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef iw8_set_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef iw8_get_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef iw8_set_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef iw8_get_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef iw8_set_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef iw8_get_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef iw8_get_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef iw8_get_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef iw8_set_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef iw8_get_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef iw8_set_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef iw8_wrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef iw8_get_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef iw8_set_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef iw8_get_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef iw8_set_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef iw8_alloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef iw8_realloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef iw8_free_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef iw8_text_ALREADY_DEFINED -#undef yytext -#endif -#ifndef iw8_leng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef iw8_in_ALREADY_DEFINED -#undef yyin -#endif -#ifndef iw8_out_ALREADY_DEFINED -#undef yyout -#endif -#ifndef iw8__flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef iw8_lineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef iw8_tables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef iw8_tables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef iw8_TABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 174 "lexer.lpp" - - -#line 709 "lexer.hpp" -#undef iw8_IN_HEADER -#endif /* iw8_HEADER_H */ +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#pragma once + +#include "iw8.hpp" + +namespace xsk::gsc::iw8 +{ + +enum class keyword; + +struct buffer +{ + int size; + int length; + char* data; + + buffer(); + ~buffer(); + bool push(char c); +}; + +struct reader +{ + enum states { end, ok }; + + states state; + int bytes_remaining; + const char* buffer_pos; + char last_byte; + char current_byte; + + reader(); + + reader& operator=(const reader& r) + { + std::memcpy(this, &r, sizeof(reader)); + return *this; + } + + void init(const char* data, size_t size); + void advance(); +}; + +class lexer +{ +private: + reader reader_; + buffer buffer_; + location loc_; + build mode_; + bool in_dev_state_; + std::stack locs_; + std::stack readers_; + std::uint32_t header_top_; + +public: + lexer(const std::string& name, const char* data, size_t size); + auto lex() -> xsk::gsc::iw8::parser::symbol_type; + void push_header(const std::string& file); + void pop_header(); + void restrict_header(const xsk::gsc::location& loc); + +private: + auto read_string(char quote, bool localize) -> xsk::gsc::iw8::parser::symbol_type; + auto read_number(char first) -> xsk::gsc::iw8::parser::symbol_type; + auto read_word(char first) -> xsk::gsc::iw8::parser::symbol_type; + auto read_dotsize() -> xsk::gsc::iw8::parser::symbol_type; + auto keyword_token(keyword k) -> xsk::gsc::iw8::parser::symbol_type; + static auto keyword_is_token(keyword k) -> bool; + static auto get_keyword(std::string_view str) -> keyword; + + static std::unordered_map keywords; +}; + +} // namespace xsk::gsc::iw8 diff --git a/src/iw8/xsk/parser.cpp b/src/iw8/xsk/parser.cpp index b942472d..559db0b7 100644 --- a/src/iw8/xsk/parser.cpp +++ b/src/iw8/xsk/parser.cpp @@ -35,13 +35,13 @@ // private implementation details that can be changed or removed. // "%code top" blocks. -#line 40 "parser.ypp" +#line 34 "parser.ypp" #include "stdafx.hpp" #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::iw8::parser::symbol_type IW8lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::iw8::parser::symbol_type IW8lex(xsk::gsc::iw8::lexer& lexer); #line 47 "parser.cpp" @@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace iw8 { #line 149 "parser.cpp" /// Build a parser object. - parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) + parser::parser (xsk::gsc::iw8::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) #if IW8DEBUG : yydebug_ (false), yycdebug_ (&std::cerr), @@ -156,8 +156,7 @@ namespace xsk { namespace gsc { namespace iw8 { : #endif yy_lac_established_ (false), - yyscanner (yyscanner_yyarg), - ctx (ctx_yyarg), + lexer (lexer_yyarg), ast (ast_yyarg) {} @@ -1625,7 +1624,7 @@ namespace xsk { namespace gsc { namespace iw8 { try #endif // YY_EXCEPTIONS { - symbol_type yylookahead (yylex (yyscanner, ctx)); + symbol_type yylookahead (yylex (lexer)); yyla.move (yylookahead); } #if YY_EXCEPTIONS @@ -2020,1327 +2019,1327 @@ namespace xsk { namespace gsc { namespace iw8 { switch (yyn) { case 2: // root: program -#line 255 "parser.ypp" +#line 249 "parser.ypp" { ast = std::move(yystack_[0].value.as < ast::program::ptr > ()); } -#line 2026 "parser.cpp" +#line 2025 "parser.cpp" break; case 3: // root: %empty -#line 256 "parser.ypp" +#line 250 "parser.ypp" { ast = std::make_unique(yylhs.location); } -#line 2032 "parser.cpp" +#line 2031 "parser.cpp" break; case 4: // program: program inline -#line 261 "parser.ypp" +#line 255 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); } -#line 2038 "parser.cpp" +#line 2037 "parser.cpp" break; case 5: // program: program include -#line 263 "parser.ypp" +#line 257 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2044 "parser.cpp" +#line 2043 "parser.cpp" break; case 6: // program: program declaration -#line 265 "parser.ypp" +#line 259 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2050 "parser.cpp" +#line 2049 "parser.cpp" break; case 7: // program: inline -#line 267 "parser.ypp" +#line 261 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); } -#line 2056 "parser.cpp" +#line 2055 "parser.cpp" break; case 8: // program: include -#line 269 "parser.ypp" +#line 263 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2062 "parser.cpp" +#line 2061 "parser.cpp" break; case 9: // program: declaration -#line 271 "parser.ypp" +#line 265 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2068 "parser.cpp" +#line 2067 "parser.cpp" break; case 10: // inline: "#inline" expr_path ";" -#line 275 "parser.ypp" - { iw8_push_header(ctx, yystack_[1].value.as < ast::expr_path::ptr > ()->value); } -#line 2074 "parser.cpp" +#line 269 "parser.ypp" + { lexer.push_header(yystack_[1].value.as < ast::expr_path::ptr > ()->value); } +#line 2073 "parser.cpp" break; case 11: // include: "#include" expr_path ";" -#line 280 "parser.ypp" +#line 274 "parser.ypp" { yylhs.value.as < ast::include::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_path::ptr > ())); } -#line 2080 "parser.cpp" +#line 2079 "parser.cpp" break; case 12: // declaration: "/#" -#line 284 "parser.ypp" +#line 278 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_begin = std::make_unique(yylhs.location); } -#line 2086 "parser.cpp" +#line 2085 "parser.cpp" break; case 13: // declaration: "#/" -#line 285 "parser.ypp" +#line 279 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_end = std::make_unique(yylhs.location); } -#line 2092 "parser.cpp" +#line 2091 "parser.cpp" break; case 14: // declaration: decl_usingtree -#line 286 "parser.ypp" +#line 280 "parser.ypp" { yylhs.value.as < ast::decl > ().as_usingtree = std::move(yystack_[0].value.as < ast::decl_usingtree::ptr > ()); } -#line 2098 "parser.cpp" +#line 2097 "parser.cpp" break; case 15: // declaration: decl_constant -#line 287 "parser.ypp" +#line 281 "parser.ypp" { yylhs.value.as < ast::decl > ().as_constant = std::move(yystack_[0].value.as < ast::decl_constant::ptr > ()); } -#line 2104 "parser.cpp" +#line 2103 "parser.cpp" break; case 16: // declaration: decl_thread -#line 288 "parser.ypp" +#line 282 "parser.ypp" { yylhs.value.as < ast::decl > ().as_thread = std::move(yystack_[0].value.as < ast::decl_thread::ptr > ()); } -#line 2110 "parser.cpp" +#line 2109 "parser.cpp" break; case 17: // decl_usingtree: "#using_animtree" "(" expr_string ")" ";" -#line 293 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } -#line 2116 "parser.cpp" +#line 287 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } +#line 2115 "parser.cpp" break; case 18: // decl_constant: expr_identifier "=" expr ";" -#line 298 "parser.ypp" +#line 292 "parser.ypp" { yylhs.value.as < ast::decl_constant::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2122 "parser.cpp" +#line 2121 "parser.cpp" break; case 19: // decl_thread: expr_identifier "(" expr_parameters ")" stmt_block -#line 303 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2128 "parser.cpp" +#line 297 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } +#line 2127 "parser.cpp" break; case 20: // stmt: stmt_dev -#line 307 "parser.ypp" +#line 301 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2134 "parser.cpp" +#line 2133 "parser.cpp" break; case 21: // stmt: stmt_block -#line 308 "parser.ypp" +#line 302 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2140 "parser.cpp" +#line 2139 "parser.cpp" break; case 22: // stmt: stmt_call -#line 309 "parser.ypp" +#line 303 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_call = std::move(yystack_[0].value.as < ast::stmt_call::ptr > ()); } -#line 2146 "parser.cpp" +#line 2145 "parser.cpp" break; case 23: // stmt: stmt_assign -#line 310 "parser.ypp" +#line 304 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_assign = std::move(yystack_[0].value.as < ast::stmt_assign::ptr > ()); } -#line 2152 "parser.cpp" +#line 2151 "parser.cpp" break; case 24: // stmt: stmt_endon -#line 311 "parser.ypp" +#line 305 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_endon = std::move(yystack_[0].value.as < ast::stmt_endon::ptr > ()); } -#line 2158 "parser.cpp" +#line 2157 "parser.cpp" break; case 25: // stmt: stmt_notify -#line 312 "parser.ypp" +#line 306 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_notify = std::move(yystack_[0].value.as < ast::stmt_notify::ptr > ()); } -#line 2164 "parser.cpp" +#line 2163 "parser.cpp" break; case 26: // stmt: stmt_wait -#line 313 "parser.ypp" +#line 307 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_wait = std::move(yystack_[0].value.as < ast::stmt_wait::ptr > ()); } -#line 2170 "parser.cpp" +#line 2169 "parser.cpp" break; case 27: // stmt: stmt_waittill -#line 314 "parser.ypp" +#line 308 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittill = std::move(yystack_[0].value.as < ast::stmt_waittill::ptr > ()); } -#line 2176 "parser.cpp" +#line 2175 "parser.cpp" break; case 28: // stmt: stmt_waittillmatch -#line 315 "parser.ypp" +#line 309 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillmatch = std::move(yystack_[0].value.as < ast::stmt_waittillmatch::ptr > ()); } -#line 2182 "parser.cpp" +#line 2181 "parser.cpp" break; case 29: // stmt: stmt_waittillframeend -#line 316 "parser.ypp" +#line 310 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillframeend = std::move(yystack_[0].value.as < ast::stmt_waittillframeend::ptr > ()); } -#line 2188 "parser.cpp" +#line 2187 "parser.cpp" break; case 30: // stmt: stmt_waitframe -#line 317 "parser.ypp" +#line 311 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waitframe = std::move(yystack_[0].value.as < ast::stmt_waitframe::ptr > ()); } -#line 2194 "parser.cpp" +#line 2193 "parser.cpp" break; case 31: // stmt: stmt_if -#line 318 "parser.ypp" +#line 312 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_if = std::move(yystack_[0].value.as < ast::stmt_if::ptr > ()); } -#line 2200 "parser.cpp" +#line 2199 "parser.cpp" break; case 32: // stmt: stmt_ifelse -#line 319 "parser.ypp" +#line 313 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_ifelse = std::move(yystack_[0].value.as < ast::stmt_ifelse::ptr > ()); } -#line 2206 "parser.cpp" +#line 2205 "parser.cpp" break; case 33: // stmt: stmt_while -#line 320 "parser.ypp" +#line 314 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_while = std::move(yystack_[0].value.as < ast::stmt_while::ptr > ()); } -#line 2212 "parser.cpp" +#line 2211 "parser.cpp" break; case 34: // stmt: stmt_dowhile -#line 321 "parser.ypp" +#line 315 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_dowhile = std::move(yystack_[0].value.as < ast::stmt_dowhile::ptr > ()); } -#line 2218 "parser.cpp" +#line 2217 "parser.cpp" break; case 35: // stmt: stmt_for -#line 322 "parser.ypp" +#line 316 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_for = std::move(yystack_[0].value.as < ast::stmt_for::ptr > ()); } -#line 2224 "parser.cpp" +#line 2223 "parser.cpp" break; case 36: // stmt: stmt_foreach -#line 323 "parser.ypp" +#line 317 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_foreach = std::move(yystack_[0].value.as < ast::stmt_foreach::ptr > ()); } -#line 2230 "parser.cpp" +#line 2229 "parser.cpp" break; case 37: // stmt: stmt_switch -#line 324 "parser.ypp" +#line 318 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_switch = std::move(yystack_[0].value.as < ast::stmt_switch::ptr > ()); } -#line 2236 "parser.cpp" +#line 2235 "parser.cpp" break; case 38: // stmt: stmt_case -#line 325 "parser.ypp" +#line 319 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_case = std::move(yystack_[0].value.as < ast::stmt_case::ptr > ()); } -#line 2242 "parser.cpp" +#line 2241 "parser.cpp" break; case 39: // stmt: stmt_default -#line 326 "parser.ypp" +#line 320 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_default = std::move(yystack_[0].value.as < ast::stmt_default::ptr > ()); } -#line 2248 "parser.cpp" +#line 2247 "parser.cpp" break; case 40: // stmt: stmt_break -#line 327 "parser.ypp" +#line 321 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_break = std::move(yystack_[0].value.as < ast::stmt_break::ptr > ()); } -#line 2254 "parser.cpp" +#line 2253 "parser.cpp" break; case 41: // stmt: stmt_continue -#line 328 "parser.ypp" +#line 322 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_continue = std::move(yystack_[0].value.as < ast::stmt_continue::ptr > ()); } -#line 2260 "parser.cpp" +#line 2259 "parser.cpp" break; case 42: // stmt: stmt_return -#line 329 "parser.ypp" +#line 323 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_return = std::move(yystack_[0].value.as < ast::stmt_return::ptr > ()); } -#line 2266 "parser.cpp" +#line 2265 "parser.cpp" break; case 43: // stmt: stmt_breakpoint -#line 330 "parser.ypp" +#line 324 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_breakpoint = std::move(yystack_[0].value.as < ast::stmt_breakpoint::ptr > ()); } -#line 2272 "parser.cpp" +#line 2271 "parser.cpp" break; case 44: // stmt: stmt_prof_begin -#line 331 "parser.ypp" +#line 325 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_begin = std::move(yystack_[0].value.as < ast::stmt_prof_begin::ptr > ()); } -#line 2278 "parser.cpp" +#line 2277 "parser.cpp" break; case 45: // stmt: stmt_prof_end -#line 332 "parser.ypp" +#line 326 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_end = std::move(yystack_[0].value.as < ast::stmt_prof_end::ptr > ()); } -#line 2284 "parser.cpp" +#line 2283 "parser.cpp" break; case 46: // stmt_dev: "/#" stmt_list "#/" -#line 336 "parser.ypp" +#line 330 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2290 "parser.cpp" +#line 2289 "parser.cpp" break; case 47: // stmt_dev: "/#" "#/" -#line 337 "parser.ypp" +#line 331 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2296 "parser.cpp" +#line 2295 "parser.cpp" break; case 48: // stmt_block: "{" stmt_list "}" -#line 341 "parser.ypp" +#line 335 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2302 "parser.cpp" +#line 2301 "parser.cpp" break; case 49: // stmt_block: "{" "}" -#line 342 "parser.ypp" +#line 336 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2308 "parser.cpp" +#line 2307 "parser.cpp" break; case 50: // stmt_list: stmt_list stmt -#line 347 "parser.ypp" +#line 341 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2314 "parser.cpp" +#line 2313 "parser.cpp" break; case 51: // stmt_list: stmt -#line 349 "parser.ypp" +#line 343 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2320 "parser.cpp" +#line 2319 "parser.cpp" break; case 52: // stmt_expr: expr_assign -#line 354 "parser.ypp" +#line 348 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2326 "parser.cpp" +#line 2325 "parser.cpp" break; case 53: // stmt_expr: expr_increment -#line 356 "parser.ypp" +#line 350 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2332 "parser.cpp" +#line 2331 "parser.cpp" break; case 54: // stmt_expr: expr_decrement -#line 358 "parser.ypp" +#line 352 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2338 "parser.cpp" +#line 2337 "parser.cpp" break; case 55: // stmt_expr: %empty -#line 360 "parser.ypp" +#line 354 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2344 "parser.cpp" +#line 2343 "parser.cpp" break; case 56: // stmt_call: expr_call ";" -#line 365 "parser.ypp" +#line 359 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_call::ptr > ()))); } -#line 2350 "parser.cpp" +#line 2349 "parser.cpp" break; case 57: // stmt_call: expr_method ";" -#line 367 "parser.ypp" +#line 361 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_method::ptr > ()))); } -#line 2356 "parser.cpp" +#line 2355 "parser.cpp" break; case 58: // stmt_assign: expr_assign ";" -#line 372 "parser.ypp" +#line 366 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2362 "parser.cpp" +#line 2361 "parser.cpp" break; case 59: // stmt_assign: expr_increment ";" -#line 374 "parser.ypp" +#line 368 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2368 "parser.cpp" +#line 2367 "parser.cpp" break; case 60: // stmt_assign: expr_decrement ";" -#line 376 "parser.ypp" +#line 370 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2374 "parser.cpp" +#line 2373 "parser.cpp" break; case 61: // stmt_endon: expr_object "endon" "(" expr ")" ";" -#line 381 "parser.ypp" +#line 375 "parser.ypp" { yylhs.value.as < ast::stmt_endon::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ())); } -#line 2380 "parser.cpp" +#line 2379 "parser.cpp" break; case 62: // stmt_notify: expr_object "notify" "(" expr "," expr_arguments_no_empty ")" ";" -#line 386 "parser.ypp" +#line 380 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2386 "parser.cpp" +#line 2385 "parser.cpp" break; case 63: // stmt_notify: expr_object "notify" "(" expr ")" ";" -#line 388 "parser.ypp" +#line 382 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2392 "parser.cpp" +#line 2391 "parser.cpp" break; case 64: // stmt_wait: "wait" expr ";" -#line 393 "parser.ypp" +#line 387 "parser.ypp" { yylhs.value.as < ast::stmt_wait::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2398 "parser.cpp" +#line 2397 "parser.cpp" break; case 65: // stmt_waittill: expr_object "waittill" "(" expr "," expr_arguments_no_empty ")" ";" -#line 398 "parser.ypp" +#line 392 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2404 "parser.cpp" +#line 2403 "parser.cpp" break; case 66: // stmt_waittill: expr_object "waittill" "(" expr ")" ";" -#line 400 "parser.ypp" +#line 394 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2410 "parser.cpp" +#line 2409 "parser.cpp" break; case 67: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr "," expr_arguments_no_empty ")" ";" -#line 405 "parser.ypp" +#line 399 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2416 "parser.cpp" +#line 2415 "parser.cpp" break; case 68: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr ")" ";" -#line 407 "parser.ypp" +#line 401 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2422 "parser.cpp" +#line 2421 "parser.cpp" break; case 69: // stmt_waittillframeend: "waittillframeend" ";" -#line 412 "parser.ypp" +#line 406 "parser.ypp" { yylhs.value.as < ast::stmt_waittillframeend::ptr > () = std::make_unique(yylhs.location); } -#line 2428 "parser.cpp" +#line 2427 "parser.cpp" break; case 70: // stmt_waitframe: "waitframe" ";" -#line 417 "parser.ypp" +#line 411 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2434 "parser.cpp" +#line 2433 "parser.cpp" break; case 71: // stmt_waitframe: "waitframe" "(" ")" ";" -#line 419 "parser.ypp" +#line 413 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2440 "parser.cpp" +#line 2439 "parser.cpp" break; case 72: // stmt_if: "if" "(" expr ")" stmt -#line 424 "parser.ypp" +#line 418 "parser.ypp" { yylhs.value.as < ast::stmt_if::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2446 "parser.cpp" +#line 2445 "parser.cpp" break; case 73: // stmt_ifelse: "if" "(" expr ")" stmt "else" stmt -#line 429 "parser.ypp" +#line 423 "parser.ypp" { yylhs.value.as < ast::stmt_ifelse::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::stmt > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2452 "parser.cpp" +#line 2451 "parser.cpp" break; case 74: // stmt_while: "while" "(" expr ")" stmt -#line 434 "parser.ypp" +#line 428 "parser.ypp" { yylhs.value.as < ast::stmt_while::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2458 "parser.cpp" +#line 2457 "parser.cpp" break; case 75: // stmt_dowhile: "do" stmt "while" "(" expr ")" ";" -#line 439 "parser.ypp" +#line 433 "parser.ypp" { yylhs.value.as < ast::stmt_dowhile::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[5].value.as < ast::stmt > ())); } -#line 2464 "parser.cpp" +#line 2463 "parser.cpp" break; case 76: // stmt_for: "for" "(" stmt_expr ";" expr_or_empty ";" stmt_expr ")" stmt -#line 444 "parser.ypp" +#line 438 "parser.ypp" { yylhs.value.as < ast::stmt_for::ptr > () = std::make_unique(yylhs.location, ast::stmt(std::move(yystack_[6].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[4].value.as < ast::expr > ()), ast::stmt(std::move(yystack_[2].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2470 "parser.cpp" +#line 2469 "parser.cpp" break; case 77: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt -#line 449 "parser.ypp" +#line 443 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2476 "parser.cpp" +#line 2475 "parser.cpp" break; case 78: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt -#line 451 "parser.ypp" +#line 445 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[6].value.as < ast::expr_identifier::ptr > ())), ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2482 "parser.cpp" +#line 2481 "parser.cpp" break; case 79: // stmt_switch: "switch" "(" expr ")" stmt_block -#line 456 "parser.ypp" +#line 450 "parser.ypp" { yylhs.value.as < ast::stmt_switch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2488 "parser.cpp" +#line 2487 "parser.cpp" break; case 80: // stmt_case: "case" expr_integer ":" -#line 461 "parser.ypp" +#line 455 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_integer::ptr > ())), std::make_unique(yylhs.location)); } -#line 2494 "parser.cpp" +#line 2493 "parser.cpp" break; case 81: // stmt_case: "case" expr_string ":" -#line 463 "parser.ypp" +#line 457 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_string::ptr > ())), std::make_unique(yylhs.location)); } -#line 2500 "parser.cpp" +#line 2499 "parser.cpp" break; case 82: // stmt_default: "default" ":" -#line 468 "parser.ypp" +#line 462 "parser.ypp" { yylhs.value.as < ast::stmt_default::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2506 "parser.cpp" +#line 2505 "parser.cpp" break; case 83: // stmt_break: "break" ";" -#line 473 "parser.ypp" +#line 467 "parser.ypp" { yylhs.value.as < ast::stmt_break::ptr > () = std::make_unique(yylhs.location); } -#line 2512 "parser.cpp" +#line 2511 "parser.cpp" break; case 84: // stmt_continue: "continue" ";" -#line 478 "parser.ypp" +#line 472 "parser.ypp" { yylhs.value.as < ast::stmt_continue::ptr > () = std::make_unique(yylhs.location); } -#line 2518 "parser.cpp" +#line 2517 "parser.cpp" break; case 85: // stmt_return: "return" expr ";" -#line 483 "parser.ypp" +#line 477 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2524 "parser.cpp" +#line 2523 "parser.cpp" break; case 86: // stmt_return: "return" ";" -#line 485 "parser.ypp" +#line 479 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2530 "parser.cpp" +#line 2529 "parser.cpp" break; case 87: // stmt_breakpoint: "breakpoint" ";" -#line 490 "parser.ypp" +#line 484 "parser.ypp" { yylhs.value.as < ast::stmt_breakpoint::ptr > () = std::make_unique(yylhs.location); } -#line 2536 "parser.cpp" +#line 2535 "parser.cpp" break; case 88: // stmt_prof_begin: "prof_begin" "(" expr_arguments ")" ";" -#line 495 "parser.ypp" +#line 489 "parser.ypp" { yylhs.value.as < ast::stmt_prof_begin::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2542 "parser.cpp" +#line 2541 "parser.cpp" break; case 89: // stmt_prof_end: "prof_end" "(" expr_arguments ")" ";" -#line 500 "parser.ypp" +#line 494 "parser.ypp" { yylhs.value.as < ast::stmt_prof_end::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2548 "parser.cpp" +#line 2547 "parser.cpp" break; case 90: // expr: expr_ternary -#line 504 "parser.ypp" +#line 498 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2554 "parser.cpp" +#line 2553 "parser.cpp" break; case 91: // expr: expr_binary -#line 505 "parser.ypp" +#line 499 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2560 "parser.cpp" +#line 2559 "parser.cpp" break; case 92: // expr: expr_primitive -#line 506 "parser.ypp" +#line 500 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2566 "parser.cpp" +#line 2565 "parser.cpp" break; case 93: // expr_or_empty: expr -#line 510 "parser.ypp" +#line 504 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2572 "parser.cpp" +#line 2571 "parser.cpp" break; case 94: // expr_or_empty: %empty -#line 511 "parser.ypp" +#line 505 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location); } -#line 2578 "parser.cpp" +#line 2577 "parser.cpp" break; case 95: // expr_assign: expr_object "=" expr -#line 516 "parser.ypp" +#line 510 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2584 "parser.cpp" +#line 2583 "parser.cpp" break; case 96: // expr_assign: expr_object "|=" expr -#line 518 "parser.ypp" +#line 512 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2590 "parser.cpp" +#line 2589 "parser.cpp" break; case 97: // expr_assign: expr_object "&=" expr -#line 520 "parser.ypp" +#line 514 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2596 "parser.cpp" +#line 2595 "parser.cpp" break; case 98: // expr_assign: expr_object "^=" expr -#line 522 "parser.ypp" +#line 516 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2602 "parser.cpp" +#line 2601 "parser.cpp" break; case 99: // expr_assign: expr_object "<<=" expr -#line 524 "parser.ypp" +#line 518 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()),std::move( yystack_[0].value.as < ast::expr > ())); } -#line 2608 "parser.cpp" +#line 2607 "parser.cpp" break; case 100: // expr_assign: expr_object ">>=" expr -#line 526 "parser.ypp" +#line 520 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2614 "parser.cpp" +#line 2613 "parser.cpp" break; case 101: // expr_assign: expr_object "+=" expr -#line 528 "parser.ypp" +#line 522 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2620 "parser.cpp" +#line 2619 "parser.cpp" break; case 102: // expr_assign: expr_object "-=" expr -#line 530 "parser.ypp" +#line 524 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2626 "parser.cpp" +#line 2625 "parser.cpp" break; case 103: // expr_assign: expr_object "*=" expr -#line 532 "parser.ypp" +#line 526 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2632 "parser.cpp" +#line 2631 "parser.cpp" break; case 104: // expr_assign: expr_object "/=" expr -#line 534 "parser.ypp" +#line 528 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2638 "parser.cpp" +#line 2637 "parser.cpp" break; case 105: // expr_assign: expr_object "%=" expr -#line 536 "parser.ypp" +#line 530 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2644 "parser.cpp" +#line 2643 "parser.cpp" break; case 106: // expr_increment: "++" expr_object -#line 541 "parser.ypp" +#line 535 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2650 "parser.cpp" +#line 2649 "parser.cpp" break; case 107: // expr_increment: expr_object "++" -#line 543 "parser.ypp" +#line 537 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2656 "parser.cpp" +#line 2655 "parser.cpp" break; case 108: // expr_decrement: "--" expr_object -#line 548 "parser.ypp" +#line 542 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2662 "parser.cpp" +#line 2661 "parser.cpp" break; case 109: // expr_decrement: expr_object "--" -#line 550 "parser.ypp" +#line 544 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2668 "parser.cpp" +#line 2667 "parser.cpp" break; case 110: // expr_ternary: expr "?" expr ":" expr -#line 555 "parser.ypp" +#line 549 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2674 "parser.cpp" +#line 2673 "parser.cpp" break; case 111: // expr_binary: expr "||" expr -#line 560 "parser.ypp" +#line 554 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2680 "parser.cpp" +#line 2679 "parser.cpp" break; case 112: // expr_binary: expr "&&" expr -#line 562 "parser.ypp" +#line 556 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2686 "parser.cpp" +#line 2685 "parser.cpp" break; case 113: // expr_binary: expr "==" expr -#line 564 "parser.ypp" +#line 558 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2692 "parser.cpp" +#line 2691 "parser.cpp" break; case 114: // expr_binary: expr "!=" expr -#line 566 "parser.ypp" +#line 560 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2698 "parser.cpp" +#line 2697 "parser.cpp" break; case 115: // expr_binary: expr "<=" expr -#line 568 "parser.ypp" +#line 562 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2704 "parser.cpp" +#line 2703 "parser.cpp" break; case 116: // expr_binary: expr ">=" expr -#line 570 "parser.ypp" +#line 564 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2710 "parser.cpp" +#line 2709 "parser.cpp" break; case 117: // expr_binary: expr "<" expr -#line 572 "parser.ypp" +#line 566 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2716 "parser.cpp" +#line 2715 "parser.cpp" break; case 118: // expr_binary: expr ">" expr -#line 574 "parser.ypp" +#line 568 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2722 "parser.cpp" +#line 2721 "parser.cpp" break; case 119: // expr_binary: expr "|" expr -#line 576 "parser.ypp" +#line 570 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2728 "parser.cpp" +#line 2727 "parser.cpp" break; case 120: // expr_binary: expr "&" expr -#line 578 "parser.ypp" +#line 572 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2734 "parser.cpp" +#line 2733 "parser.cpp" break; case 121: // expr_binary: expr "^" expr -#line 580 "parser.ypp" +#line 574 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2740 "parser.cpp" +#line 2739 "parser.cpp" break; case 122: // expr_binary: expr "<<" expr -#line 582 "parser.ypp" +#line 576 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2746 "parser.cpp" +#line 2745 "parser.cpp" break; case 123: // expr_binary: expr ">>" expr -#line 584 "parser.ypp" +#line 578 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2752 "parser.cpp" +#line 2751 "parser.cpp" break; case 124: // expr_binary: expr "+" expr -#line 586 "parser.ypp" +#line 580 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2758 "parser.cpp" +#line 2757 "parser.cpp" break; case 125: // expr_binary: expr "-" expr -#line 588 "parser.ypp" +#line 582 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2764 "parser.cpp" +#line 2763 "parser.cpp" break; case 126: // expr_binary: expr "*" expr -#line 590 "parser.ypp" +#line 584 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2770 "parser.cpp" +#line 2769 "parser.cpp" break; case 127: // expr_binary: expr "/" expr -#line 592 "parser.ypp" +#line 586 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2776 "parser.cpp" +#line 2775 "parser.cpp" break; case 128: // expr_binary: expr "%" expr -#line 594 "parser.ypp" +#line 588 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2782 "parser.cpp" +#line 2781 "parser.cpp" break; case 129: // expr_primitive: expr_complement -#line 598 "parser.ypp" +#line 592 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_complement::ptr > ()); } -#line 2788 "parser.cpp" +#line 2787 "parser.cpp" break; case 130: // expr_primitive: expr_not -#line 599 "parser.ypp" +#line 593 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_not::ptr > ()); } -#line 2794 "parser.cpp" +#line 2793 "parser.cpp" break; case 131: // expr_primitive: expr_call -#line 600 "parser.ypp" +#line 594 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 2800 "parser.cpp" +#line 2799 "parser.cpp" break; case 132: // expr_primitive: expr_method -#line 601 "parser.ypp" +#line 595 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 2806 "parser.cpp" +#line 2805 "parser.cpp" break; case 133: // expr_primitive: expr_add_array -#line 602 "parser.ypp" +#line 596 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_add_array::ptr > ()); } -#line 2812 "parser.cpp" +#line 2811 "parser.cpp" break; case 134: // expr_primitive: expr_isdefined -#line 603 "parser.ypp" +#line 597 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_isdefined::ptr > ()); } -#line 2818 "parser.cpp" +#line 2817 "parser.cpp" break; case 135: // expr_primitive: expr_istrue -#line 604 "parser.ypp" +#line 598 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istrue::ptr > ()); } -#line 2824 "parser.cpp" +#line 2823 "parser.cpp" break; case 136: // expr_primitive: expr_reference -#line 605 "parser.ypp" +#line 599 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_reference::ptr > ()); } -#line 2830 "parser.cpp" +#line 2829 "parser.cpp" break; case 137: // expr_primitive: expr_array -#line 606 "parser.ypp" +#line 600 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 2836 "parser.cpp" +#line 2835 "parser.cpp" break; case 138: // expr_primitive: expr_field -#line 607 "parser.ypp" +#line 601 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 2842 "parser.cpp" +#line 2841 "parser.cpp" break; case 139: // expr_primitive: expr_size -#line 608 "parser.ypp" +#line 602 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_size::ptr > ()); } -#line 2848 "parser.cpp" +#line 2847 "parser.cpp" break; case 140: // expr_primitive: expr_paren -#line 609 "parser.ypp" +#line 603 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_paren::ptr > ()); } -#line 2854 "parser.cpp" +#line 2853 "parser.cpp" break; case 141: // expr_primitive: expr_thisthread -#line 610 "parser.ypp" +#line 604 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_thisthread::ptr > ()); } -#line 2860 "parser.cpp" +#line 2859 "parser.cpp" break; case 142: // expr_primitive: expr_empty_array -#line 611 "parser.ypp" +#line 605 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_empty_array::ptr > ()); } -#line 2866 "parser.cpp" +#line 2865 "parser.cpp" break; case 143: // expr_primitive: expr_undefined -#line 612 "parser.ypp" +#line 606 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_undefined::ptr > ()); } -#line 2872 "parser.cpp" +#line 2871 "parser.cpp" break; case 144: // expr_primitive: expr_game -#line 613 "parser.ypp" +#line 607 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 2878 "parser.cpp" +#line 2877 "parser.cpp" break; case 145: // expr_primitive: expr_self -#line 614 "parser.ypp" +#line 608 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 2884 "parser.cpp" +#line 2883 "parser.cpp" break; case 146: // expr_primitive: expr_anim -#line 615 "parser.ypp" +#line 609 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 2890 "parser.cpp" +#line 2889 "parser.cpp" break; case 147: // expr_primitive: expr_level -#line 616 "parser.ypp" +#line 610 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 2896 "parser.cpp" +#line 2895 "parser.cpp" break; case 148: // expr_primitive: expr_animation -#line 617 "parser.ypp" +#line 611 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animation::ptr > ()); } -#line 2902 "parser.cpp" +#line 2901 "parser.cpp" break; case 149: // expr_primitive: expr_animtree -#line 618 "parser.ypp" +#line 612 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animtree::ptr > ()); } -#line 2908 "parser.cpp" +#line 2907 "parser.cpp" break; case 150: // expr_primitive: expr_identifier -#line 619 "parser.ypp" +#line 613 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 2914 "parser.cpp" +#line 2913 "parser.cpp" break; case 151: // expr_primitive: expr_istring -#line 620 "parser.ypp" +#line 614 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istring::ptr > ()); } -#line 2920 "parser.cpp" +#line 2919 "parser.cpp" break; case 152: // expr_primitive: expr_string -#line 621 "parser.ypp" +#line 615 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_string::ptr > ()); } -#line 2926 "parser.cpp" +#line 2925 "parser.cpp" break; case 153: // expr_primitive: expr_color -#line 622 "parser.ypp" +#line 616 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_color::ptr > ()); } -#line 2932 "parser.cpp" +#line 2931 "parser.cpp" break; case 154: // expr_primitive: expr_vector -#line 623 "parser.ypp" +#line 617 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_vector::ptr > ()); } -#line 2938 "parser.cpp" +#line 2937 "parser.cpp" break; case 155: // expr_primitive: expr_float -#line 624 "parser.ypp" +#line 618 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_float::ptr > ()); } -#line 2944 "parser.cpp" +#line 2943 "parser.cpp" break; case 156: // expr_primitive: expr_integer -#line 625 "parser.ypp" +#line 619 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_integer::ptr > ()); } -#line 2950 "parser.cpp" +#line 2949 "parser.cpp" break; case 157: // expr_primitive: expr_false -#line 626 "parser.ypp" +#line 620 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_false::ptr > ()); } -#line 2956 "parser.cpp" +#line 2955 "parser.cpp" break; case 158: // expr_primitive: expr_true -#line 627 "parser.ypp" +#line 621 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_true::ptr > ()); } -#line 2962 "parser.cpp" +#line 2961 "parser.cpp" break; case 159: // expr_complement: "~" expr -#line 632 "parser.ypp" +#line 626 "parser.ypp" { yylhs.value.as < ast::expr_complement::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2968 "parser.cpp" +#line 2967 "parser.cpp" break; case 160: // expr_not: "!" expr -#line 637 "parser.ypp" +#line 631 "parser.ypp" { yylhs.value.as < ast::expr_not::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2974 "parser.cpp" +#line 2973 "parser.cpp" break; case 161: // expr_call: expr_function -#line 641 "parser.ypp" +#line 635 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2980 "parser.cpp" +#line 2979 "parser.cpp" break; case 162: // expr_call: expr_pointer -#line 642 "parser.ypp" +#line 636 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2986 "parser.cpp" +#line 2985 "parser.cpp" break; case 163: // expr_method: expr_object expr_function -#line 645 "parser.ypp" +#line 639 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2992 "parser.cpp" +#line 2991 "parser.cpp" break; case 164: // expr_method: expr_object expr_pointer -#line 646 "parser.ypp" +#line 640 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2998 "parser.cpp" +#line 2997 "parser.cpp" break; case 165: // expr_function: expr_identifier "(" expr_arguments ")" -#line 651 "parser.ypp" +#line 645 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 3004 "parser.cpp" +#line 3003 "parser.cpp" break; case 166: // expr_function: expr_path "::" expr_identifier "(" expr_arguments ")" -#line 653 "parser.ypp" +#line 647 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 3010 "parser.cpp" +#line 3009 "parser.cpp" break; case 167: // expr_function: "thread" expr_identifier "(" expr_arguments ")" -#line 655 "parser.ypp" +#line 649 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 3016 "parser.cpp" +#line 3015 "parser.cpp" break; case 168: // expr_function: "thread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 657 "parser.ypp" +#line 651 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 3022 "parser.cpp" +#line 3021 "parser.cpp" break; case 169: // expr_function: "childthread" expr_identifier "(" expr_arguments ")" -#line 659 "parser.ypp" +#line 653 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3028 "parser.cpp" +#line 3027 "parser.cpp" break; case 170: // expr_function: "childthread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 661 "parser.ypp" +#line 655 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3034 "parser.cpp" +#line 3033 "parser.cpp" break; case 171: // expr_pointer: "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 666 "parser.ypp" +#line 660 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 3040 "parser.cpp" +#line 3039 "parser.cpp" break; case 172: // expr_pointer: "thread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 668 "parser.ypp" +#line 662 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 3046 "parser.cpp" +#line 3045 "parser.cpp" break; case 173: // expr_pointer: "childthread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 670 "parser.ypp" +#line 664 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3052 "parser.cpp" +#line 3051 "parser.cpp" break; case 174: // expr_pointer: "call" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 672 "parser.ypp" +#line 666 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::builtin); } -#line 3058 "parser.cpp" +#line 3057 "parser.cpp" break; case 175: // expr_add_array: "[" expr_arguments_no_empty "]" -#line 677 "parser.ypp" +#line 671 "parser.ypp" { yylhs.value.as < ast::expr_add_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ())); } -#line 3064 "parser.cpp" +#line 3063 "parser.cpp" break; case 176: // expr_parameters: expr_parameters "," expr_identifier -#line 682 "parser.ypp" +#line 676 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3070 "parser.cpp" +#line 3069 "parser.cpp" break; case 177: // expr_parameters: expr_identifier -#line 684 "parser.ypp" +#line 678 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3076 "parser.cpp" +#line 3075 "parser.cpp" break; case 178: // expr_parameters: %empty -#line 686 "parser.ypp" +#line 680 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); } -#line 3082 "parser.cpp" +#line 3081 "parser.cpp" break; case 179: // expr_arguments: expr_arguments_no_empty -#line 691 "parser.ypp" +#line 685 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[0].value.as < ast::expr_arguments::ptr > ()); } -#line 3088 "parser.cpp" +#line 3087 "parser.cpp" break; case 180: // expr_arguments: %empty -#line 693 "parser.ypp" +#line 687 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); } -#line 3094 "parser.cpp" +#line 3093 "parser.cpp" break; case 181: // expr_arguments_no_empty: expr_arguments "," expr -#line 698 "parser.ypp" +#line 692 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ()); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3100 "parser.cpp" +#line 3099 "parser.cpp" break; case 182: // expr_arguments_no_empty: expr -#line 700 "parser.ypp" +#line 694 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3106 "parser.cpp" +#line 3105 "parser.cpp" break; case 183: // expr_isdefined: "isdefined" "(" expr ")" -#line 705 "parser.ypp" +#line 699 "parser.ypp" { yylhs.value.as < ast::expr_isdefined::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3112 "parser.cpp" +#line 3111 "parser.cpp" break; case 184: // expr_istrue: "istrue" "(" expr ")" -#line 710 "parser.ypp" +#line 704 "parser.ypp" { yylhs.value.as < ast::expr_istrue::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3118 "parser.cpp" +#line 3117 "parser.cpp" break; case 185: // expr_reference: "::" expr_identifier -#line 715 "parser.ypp" +#line 709 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3124 "parser.cpp" +#line 3123 "parser.cpp" break; case 186: // expr_reference: expr_path "::" expr_identifier -#line 717 "parser.ypp" +#line 711 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_path::ptr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3130 "parser.cpp" +#line 3129 "parser.cpp" break; case 187: // expr_array: expr_object "[" expr "]" -#line 722 "parser.ypp" +#line 716 "parser.ypp" { yylhs.value.as < ast::expr_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3136 "parser.cpp" +#line 3135 "parser.cpp" break; case 188: // expr_field: expr_object "." expr_identifier -#line 727 "parser.ypp" +#line 721 "parser.ypp" { yylhs.value.as < ast::expr_field::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3142 "parser.cpp" +#line 3141 "parser.cpp" break; case 189: // expr_size: expr_object ".size" -#line 732 "parser.ypp" +#line 726 "parser.ypp" { yylhs.value.as < ast::expr_size::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3148 "parser.cpp" +#line 3147 "parser.cpp" break; case 190: // expr_paren: "(" expr ")" -#line 737 "parser.ypp" +#line 731 "parser.ypp" { yylhs.value.as < ast::expr_paren::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3154 "parser.cpp" +#line 3153 "parser.cpp" break; case 191: // expr_object: expr_call -#line 741 "parser.ypp" +#line 735 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 3160 "parser.cpp" +#line 3159 "parser.cpp" break; case 192: // expr_object: expr_method -#line 742 "parser.ypp" +#line 736 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 3166 "parser.cpp" +#line 3165 "parser.cpp" break; case 193: // expr_object: expr_array -#line 743 "parser.ypp" +#line 737 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 3172 "parser.cpp" +#line 3171 "parser.cpp" break; case 194: // expr_object: expr_field -#line 744 "parser.ypp" +#line 738 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 3178 "parser.cpp" +#line 3177 "parser.cpp" break; case 195: // expr_object: expr_game -#line 745 "parser.ypp" +#line 739 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 3184 "parser.cpp" +#line 3183 "parser.cpp" break; case 196: // expr_object: expr_self -#line 746 "parser.ypp" +#line 740 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 3190 "parser.cpp" +#line 3189 "parser.cpp" break; case 197: // expr_object: expr_anim -#line 747 "parser.ypp" +#line 741 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 3196 "parser.cpp" +#line 3195 "parser.cpp" break; case 198: // expr_object: expr_level -#line 748 "parser.ypp" +#line 742 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 3202 "parser.cpp" +#line 3201 "parser.cpp" break; case 199: // expr_object: expr_identifier -#line 749 "parser.ypp" +#line 743 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 3208 "parser.cpp" +#line 3207 "parser.cpp" break; case 200: // expr_thisthread: "thisthread" -#line 754 "parser.ypp" +#line 748 "parser.ypp" { yylhs.value.as < ast::expr_thisthread::ptr > () = std::make_unique(yylhs.location); } -#line 3214 "parser.cpp" +#line 3213 "parser.cpp" break; case 201: // expr_empty_array: "[" "]" -#line 759 "parser.ypp" +#line 753 "parser.ypp" { yylhs.value.as < ast::expr_empty_array::ptr > () = std::make_unique(yylhs.location); } -#line 3220 "parser.cpp" +#line 3219 "parser.cpp" break; case 202: // expr_undefined: "undefined" -#line 764 "parser.ypp" +#line 758 "parser.ypp" { yylhs.value.as < ast::expr_undefined::ptr > () = std::make_unique(yylhs.location); } -#line 3226 "parser.cpp" +#line 3225 "parser.cpp" break; case 203: // expr_game: "game" -#line 769 "parser.ypp" +#line 763 "parser.ypp" { yylhs.value.as < ast::expr_game::ptr > () = std::make_unique(yylhs.location); } -#line 3232 "parser.cpp" +#line 3231 "parser.cpp" break; case 204: // expr_self: "self" -#line 774 "parser.ypp" +#line 768 "parser.ypp" { yylhs.value.as < ast::expr_self::ptr > () = std::make_unique(yylhs.location); } -#line 3238 "parser.cpp" +#line 3237 "parser.cpp" break; case 205: // expr_anim: "anim" -#line 779 "parser.ypp" +#line 773 "parser.ypp" { yylhs.value.as < ast::expr_anim::ptr > () = std::make_unique(yylhs.location); } -#line 3244 "parser.cpp" +#line 3243 "parser.cpp" break; case 206: // expr_level: "level" -#line 784 "parser.ypp" +#line 778 "parser.ypp" { yylhs.value.as < ast::expr_level::ptr > () = std::make_unique(yylhs.location); } -#line 3250 "parser.cpp" +#line 3249 "parser.cpp" break; case 207: // expr_animation: "%" "identifier" -#line 789 "parser.ypp" +#line 783 "parser.ypp" { yylhs.value.as < ast::expr_animation::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3256 "parser.cpp" +#line 3255 "parser.cpp" break; case 208: // expr_animtree: "#animtree" -#line 794 "parser.ypp" +#line 788 "parser.ypp" { yylhs.value.as < ast::expr_animtree::ptr > () = std::make_unique(yylhs.location); } -#line 3262 "parser.cpp" +#line 3261 "parser.cpp" break; case 209: // expr_identifier: "identifier" -#line 799 "parser.ypp" +#line 793 "parser.ypp" { yylhs.value.as < ast::expr_identifier::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3268 "parser.cpp" +#line 3267 "parser.cpp" break; case 210: // expr_path: "path" -#line 804 "parser.ypp" +#line 798 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3274 "parser.cpp" +#line 3273 "parser.cpp" break; case 211: // expr_path: expr_identifier -#line 806 "parser.ypp" +#line 800 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < ast::expr_identifier::ptr > ()->value); } -#line 3280 "parser.cpp" +#line 3279 "parser.cpp" break; case 212: // expr_istring: "localized string" -#line 811 "parser.ypp" +#line 805 "parser.ypp" { yylhs.value.as < ast::expr_istring::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3286 "parser.cpp" +#line 3285 "parser.cpp" break; case 213: // expr_string: "string literal" -#line 816 "parser.ypp" +#line 810 "parser.ypp" { yylhs.value.as < ast::expr_string::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3292 "parser.cpp" +#line 3291 "parser.cpp" break; case 214: // expr_color: "color" -#line 821 "parser.ypp" +#line 815 "parser.ypp" { yylhs.value.as < ast::expr_color::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3298 "parser.cpp" +#line 3297 "parser.cpp" break; case 215: // expr_vector: "(" expr "," expr "," expr ")" -#line 826 "parser.ypp" +#line 820 "parser.ypp" { yylhs.value.as < ast::expr_vector::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3304 "parser.cpp" +#line 3303 "parser.cpp" break; case 216: // expr_float: "-" "float" -#line 831 "parser.ypp" +#line 825 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3310 "parser.cpp" +#line 3309 "parser.cpp" break; case 217: // expr_float: "float" -#line 833 "parser.ypp" +#line 827 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3316 "parser.cpp" +#line 3315 "parser.cpp" break; case 218: // expr_integer: "-" "integer" -#line 838 "parser.ypp" +#line 832 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3322 "parser.cpp" +#line 3321 "parser.cpp" break; case 219: // expr_integer: "integer" -#line 840 "parser.ypp" +#line 834 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3328 "parser.cpp" +#line 3327 "parser.cpp" break; case 220: // expr_false: "false" -#line 845 "parser.ypp" +#line 839 "parser.ypp" { yylhs.value.as < ast::expr_false::ptr > () = std::make_unique(yylhs.location); } -#line 3334 "parser.cpp" +#line 3333 "parser.cpp" break; case 221: // expr_true: "true" -#line 850 "parser.ypp" +#line 844 "parser.ypp" { yylhs.value.as < ast::expr_true::ptr > () = std::make_unique(yylhs.location); } -#line 3340 "parser.cpp" +#line 3339 "parser.cpp" break; -#line 3344 "parser.cpp" +#line 3343 "parser.cpp" default: break; @@ -4544,29 +4543,29 @@ namespace xsk { namespace gsc { namespace iw8 { const short parser::yyrline_[] = { - 0, 255, 255, 256, 260, 262, 264, 266, 268, 270, - 275, 279, 284, 285, 286, 287, 288, 292, 297, 302, - 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, - 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, - 327, 328, 329, 330, 331, 332, 336, 337, 341, 342, - 346, 348, 353, 355, 357, 360, 364, 366, 371, 373, - 375, 380, 385, 387, 392, 397, 399, 404, 406, 411, - 416, 418, 423, 428, 433, 438, 443, 448, 450, 455, - 460, 462, 467, 472, 477, 482, 484, 489, 494, 499, - 504, 505, 506, 510, 511, 515, 517, 519, 521, 523, - 525, 527, 529, 531, 533, 535, 540, 542, 547, 549, - 554, 559, 561, 563, 565, 567, 569, 571, 573, 575, - 577, 579, 581, 583, 585, 587, 589, 591, 593, 598, - 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, - 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, - 619, 620, 621, 622, 623, 624, 625, 626, 627, 631, - 636, 641, 642, 645, 646, 650, 652, 654, 656, 658, - 660, 665, 667, 669, 671, 676, 681, 683, 686, 690, - 693, 697, 699, 704, 709, 714, 716, 721, 726, 731, - 736, 741, 742, 743, 744, 745, 746, 747, 748, 749, - 753, 758, 763, 768, 773, 778, 783, 788, 793, 798, - 803, 805, 810, 815, 820, 825, 830, 832, 837, 839, - 844, 849 + 0, 249, 249, 250, 254, 256, 258, 260, 262, 264, + 269, 273, 278, 279, 280, 281, 282, 286, 291, 296, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 324, 325, 326, 330, 331, 335, 336, + 340, 342, 347, 349, 351, 354, 358, 360, 365, 367, + 369, 374, 379, 381, 386, 391, 393, 398, 400, 405, + 410, 412, 417, 422, 427, 432, 437, 442, 444, 449, + 454, 456, 461, 466, 471, 476, 478, 483, 488, 493, + 498, 499, 500, 504, 505, 509, 511, 513, 515, 517, + 519, 521, 523, 525, 527, 529, 534, 536, 541, 543, + 548, 553, 555, 557, 559, 561, 563, 565, 567, 569, + 571, 573, 575, 577, 579, 581, 583, 585, 587, 592, + 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, + 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, + 613, 614, 615, 616, 617, 618, 619, 620, 621, 625, + 630, 635, 636, 639, 640, 644, 646, 648, 650, 652, + 654, 659, 661, 663, 665, 670, 675, 677, 680, 684, + 687, 691, 693, 698, 703, 708, 710, 715, 720, 725, + 730, 735, 736, 737, 738, 739, 740, 741, 742, 743, + 747, 752, 757, 762, 767, 772, 777, 782, 787, 792, + 797, 799, 804, 809, 814, 819, 824, 826, 831, 833, + 838, 843 }; void @@ -4599,9 +4598,9 @@ namespace xsk { namespace gsc { namespace iw8 { #line 13 "parser.ypp" } } } // xsk::gsc::iw8 -#line 4603 "parser.cpp" +#line 4602 "parser.cpp" -#line 853 "parser.ypp" +#line 847 "parser.ypp" void xsk::gsc::iw8::parser::error(const xsk::gsc::location& loc, const std::string& msg) diff --git a/src/iw8/xsk/parser.hpp b/src/iw8/xsk/parser.hpp index 22c2d862..43ba5ecf 100644 --- a/src/iw8/xsk/parser.hpp +++ b/src/iw8/xsk/parser.hpp @@ -45,13 +45,12 @@ #ifndef YY_IW8_PARSER_HPP_INCLUDED # define YY_IW8_PARSER_HPP_INCLUDED // "%code requires" blocks. -#line 33 "parser.ypp" +#line 28 "parser.ypp" #include "iw8.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::iw8::parser::symbol_type IW8lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::iw8 { class lexer; } -#line 55 "parser.hpp" +#line 54 "parser.hpp" # include # include // std::abort @@ -194,7 +193,7 @@ typedef void *yyscan_t; #line 13 "parser.ypp" namespace xsk { namespace gsc { namespace iw8 { -#line 198 "parser.hpp" +#line 197 "parser.hpp" @@ -2741,7 +2740,7 @@ switch (yykind) }; /// Build a parser object. - parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); + parser (xsk::gsc::iw8::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); virtual ~parser (); #if 201103L <= YY_CPLUSPLUS @@ -4742,8 +4741,7 @@ switch (yykind) // User arguments. - yyscan_t yyscanner; - xsk::gsc::context* ctx; + xsk::gsc::iw8::lexer& lexer; xsk::gsc::ast::program::ptr& ast; }; @@ -5444,7 +5442,7 @@ switch (yykind) #line 13 "parser.ypp" } } } // xsk::gsc::iw8 -#line 5448 "parser.hpp" +#line 5446 "parser.hpp" diff --git a/src/iw8/xsk/resolver.cpp b/src/iw8/xsk/resolver.cpp index 3603b1a4..7702e772 100644 --- a/src/iw8/xsk/resolver.cpp +++ b/src/iw8/xsk/resolver.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -206,6 +206,35 @@ auto resolver::make_token(std::string_view str) -> std::string return data; } +std::function(const std::string&)> read_callback = nullptr; +std::unordered_map> files; + +auto resolver::file_data(const std::string& name) -> std::tuple +{ + const auto& itr = files.find(name); + + if(itr != files.end()) + { + return { &itr->first ,reinterpret_cast(itr->second.data()), itr->second.size() }; + } + + auto data = read_callback(name); + + const auto& res = files.insert({ name, std::move(data)}); + + if(res.second) + { + return { &res.first->first, reinterpret_cast(res.first->second.data()), res.first->second.size() }; + } + + throw error("couldn't open gsc file '" + name + "'"); +} + +void resolver::set_reader(std::function(const std::string&)> callback) +{ + read_callback = callback; +} + const std::array, 190> opcode_list {{ { 0x00, "CAST_FIELD_OBJECT" }, diff --git a/src/iw8/xsk/resolver.hpp b/src/iw8/xsk/resolver.hpp index b6913992..139bc975 100644 --- a/src/iw8/xsk/resolver.hpp +++ b/src/iw8/xsk/resolver.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -30,6 +30,8 @@ public: static auto find_method(const std::string& name) -> bool; static auto make_token(std::string_view str) -> std::string; + static auto file_data(const std::string& name) -> std::tuple; + static void set_reader(std::function(const std::string&)> callback); }; } // namespace xsk::gsc::iw8 diff --git a/src/s1/stdafx.cpp b/src/s1/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/s1/stdafx.cpp +++ b/src/s1/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s1/stdafx.hpp b/src/s1/stdafx.hpp index 946c655d..2dd3f882 100644 --- a/src/s1/stdafx.hpp +++ b/src/s1/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s1/xsk/assembler.cpp b/src/s1/xsk/assembler.cpp index 638593eb..f7f9595b 100644 --- a/src/s1/xsk/assembler.cpp +++ b/src/s1/xsk/assembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s1/xsk/assembler.hpp b/src/s1/xsk/assembler.hpp index 390b7821..2e702292 100644 --- a/src/s1/xsk/assembler.hpp +++ b/src/s1/xsk/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s1/xsk/compiler.cpp b/src/s1/xsk/compiler.cpp index 4ed93b25..63e878a4 100644 --- a/src/s1/xsk/compiler.cpp +++ b/src/s1/xsk/compiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,7 +19,6 @@ auto compiler::output() -> std::vector void compiler::compile(const std::string& file, std::vector& data) { filename_ = file; - sources_.clear(); auto prog = parse_buffer(filename_, data); @@ -33,39 +32,19 @@ void compiler::read_callback(std::function(const std:: auto compiler::parse_buffer(const std::string& file, std::vector& data) -> ast::program::ptr { - yyscan_t scanner; - context ctx; ast::program::ptr result(nullptr); - ctx.header_top = 0; - ctx.mode = mode_; - ctx.read_callback = read_callback_; - ctx.sources = &sources_; - ctx.loc.initialize(&file); + resolver::set_reader(read_callback_); - // Add the two NULL terminators, required by flex. - data.push_back(0); - data.push_back(0); + lexer lexer(file, reinterpret_cast(data.data()), data.size()); - if (s1_lex_init(&scanner)) - { - throw comp_error(ctx.loc, "An unknown error ocurred while starting lexer context."); - } - - ctx.scanner = scanner; - - YY_BUFFER_STATE yybuffer = s1__scan_buffer(reinterpret_cast(data.data()), data.size(), scanner); - - parser parser(scanner, &ctx, result); + parser parser(lexer, result); if (parser.parse() || result == nullptr) { - throw comp_error(ctx.loc, "An unknown error ocurred while parsing gsc file."); + throw comp_error(xsk::gsc::location(&file), "An unknown error ocurred while parsing gsc file."); } - s1__delete_buffer(yybuffer, scanner); - s1_lex_destroy(scanner); - return result; } diff --git a/src/s1/xsk/compiler.hpp b/src/s1/xsk/compiler.hpp index ec5240fe..6f4916f9 100644 --- a/src/s1/xsk/compiler.hpp +++ b/src/s1/xsk/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -25,7 +25,6 @@ class compiler : public gsc::compiler std::vector animtrees_; std::unordered_map constants_; std::function(const std::string&)> read_callback_; - std::vector sources_; std::vector break_blks_; std::vector continue_blks_; bool can_break_; diff --git a/src/s1/xsk/decompiler.cpp b/src/s1/xsk/decompiler.cpp index a16ecf16..c37832d4 100644 --- a/src/s1/xsk/decompiler.cpp +++ b/src/s1/xsk/decompiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s1/xsk/decompiler.hpp b/src/s1/xsk/decompiler.hpp index 63f39ef2..af8a3287 100644 --- a/src/s1/xsk/decompiler.hpp +++ b/src/s1/xsk/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s1/xsk/disassembler.cpp b/src/s1/xsk/disassembler.cpp index 9b909f33..493020e1 100644 --- a/src/s1/xsk/disassembler.cpp +++ b/src/s1/xsk/disassembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s1/xsk/disassembler.hpp b/src/s1/xsk/disassembler.hpp index 34db4a04..38546617 100644 --- a/src/s1/xsk/disassembler.hpp +++ b/src/s1/xsk/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s1/xsk/lexer.cpp b/src/s1/xsk/lexer.cpp index 59a442e1..891b9cb1 100644 --- a/src/s1/xsk/lexer.cpp +++ b/src/s1/xsk/lexer.cpp @@ -1,3040 +1,990 @@ -#line 1 "lexer.cpp" -#include "stdafx.hpp" -#include "s1.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void s1_push_header(xsk::gsc::context* ctx, const std::string& file); -void s1_pop_header(xsk::gsc::context* ctx); - -#line 9 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define s1__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer s1__create_buffer -#endif - -#ifdef yy_delete_buffer -#define s1__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer s1__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define s1__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer s1__scan_buffer -#endif - -#ifdef yy_scan_string -#define s1__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string s1__scan_string -#endif - -#ifdef yy_scan_bytes -#define s1__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes s1__scan_bytes -#endif - -#ifdef yy_init_buffer -#define s1__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer s1__init_buffer -#endif - -#ifdef yy_flush_buffer -#define s1__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer s1__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define s1__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state s1__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define s1__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer s1__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define s1_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state s1_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define s1_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state s1_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define s1_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack s1_ensure_buffer_stack -#endif - -#ifdef yylex -#define s1_lex_ALREADY_DEFINED -#else -#define yylex s1_lex -#endif - -#ifdef yyrestart -#define s1_restart_ALREADY_DEFINED -#else -#define yyrestart s1_restart -#endif - -#ifdef yylex_init -#define s1_lex_init_ALREADY_DEFINED -#else -#define yylex_init s1_lex_init -#endif - -#ifdef yylex_init_extra -#define s1_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra s1_lex_init_extra -#endif - -#ifdef yylex_destroy -#define s1_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy s1_lex_destroy -#endif - -#ifdef yyget_debug -#define s1_get_debug_ALREADY_DEFINED -#else -#define yyget_debug s1_get_debug -#endif - -#ifdef yyset_debug -#define s1_set_debug_ALREADY_DEFINED -#else -#define yyset_debug s1_set_debug -#endif - -#ifdef yyget_extra -#define s1_get_extra_ALREADY_DEFINED -#else -#define yyget_extra s1_get_extra -#endif - -#ifdef yyset_extra -#define s1_set_extra_ALREADY_DEFINED -#else -#define yyset_extra s1_set_extra -#endif - -#ifdef yyget_in -#define s1_get_in_ALREADY_DEFINED -#else -#define yyget_in s1_get_in -#endif - -#ifdef yyset_in -#define s1_set_in_ALREADY_DEFINED -#else -#define yyset_in s1_set_in -#endif - -#ifdef yyget_out -#define s1_get_out_ALREADY_DEFINED -#else -#define yyget_out s1_get_out -#endif - -#ifdef yyset_out -#define s1_set_out_ALREADY_DEFINED -#else -#define yyset_out s1_set_out -#endif - -#ifdef yyget_leng -#define s1_get_leng_ALREADY_DEFINED -#else -#define yyget_leng s1_get_leng -#endif - -#ifdef yyget_text -#define s1_get_text_ALREADY_DEFINED -#else -#define yyget_text s1_get_text -#endif - -#ifdef yyget_lineno -#define s1_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno s1_get_lineno -#endif - -#ifdef yyset_lineno -#define s1_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno s1_set_lineno -#endif - -#ifdef yyget_column -#define s1_get_column_ALREADY_DEFINED -#else -#define yyget_column s1_get_column -#endif - -#ifdef yyset_column -#define s1_set_column_ALREADY_DEFINED -#else -#define yyset_column s1_set_column -#endif - -#ifdef yywrap -#define s1_wrap_ALREADY_DEFINED -#else -#define yywrap s1_wrap -#endif - -#ifdef yyalloc -#define s1_alloc_ALREADY_DEFINED -#else -#define yyalloc s1_alloc -#endif - -#ifdef yyrealloc -#define s1_realloc_ALREADY_DEFINED -#else -#define yyrealloc s1_realloc -#endif - -#ifdef yyfree -#define s1_free_ALREADY_DEFINED -#else -#define yyfree s1_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin , yyscanner ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define s1_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); -static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 112 -#define YY_END_OF_BUFFER 113 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[333] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 113, 111, - 1, 2, 95, 111, 111, 94, 98, 111, 55, 56, - 92, 90, 61, 91, 62, 93, 110, 110, 64, 65, - 79, 89, 80, 66, 101, 59, 60, 99, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 57, 97, 58, 96, 5, 6, - 5, 12, 13, 12, 111, 92, 93, 76, 0, 103, - 0, 15, 0, 0, 0, 0, 85, 0, 74, 0, - 87, 0, 0, 8, 83, 67, 81, 68, 82, 106, - 0, 11, 4, 3, 84, 106, 110, 107, 0, 0, - - 0, 0, 63, 71, 77, 75, 78, 72, 101, 88, - 101, 101, 101, 101, 101, 101, 29, 101, 101, 101, - 101, 101, 27, 33, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 86, 73, 7, 14, 10, - 9, 0, 103, 0, 0, 0, 0, 0, 0, 102, - 0, 0, 0, 0, 103, 0, 106, 0, 3, 106, - 106, 107, 108, 109, 100, 69, 70, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 31, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 104, 0, 0, 0, 0, 0, 102, 0, 0, - - 102, 0, 0, 53, 101, 46, 35, 101, 101, 101, - 28, 101, 101, 101, 51, 101, 101, 101, 101, 52, - 101, 101, 101, 47, 101, 22, 101, 0, 0, 0, - 0, 0, 50, 37, 101, 101, 101, 20, 48, 101, - 54, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 30, 0, 0, 0, 0, 0, 101, 101, 101, 101, - 101, 21, 101, 101, 39, 34, 101, 43, 101, 101, - 101, 105, 0, 0, 16, 0, 101, 101, 101, 36, - 32, 101, 101, 101, 101, 101, 101, 0, 17, 0, - 101, 101, 38, 101, 42, 101, 101, 101, 23, 19, - - 0, 101, 101, 101, 101, 49, 26, 101, 101, 0, - 40, 101, 41, 45, 101, 101, 0, 44, 101, 101, - 0, 101, 101, 0, 101, 24, 0, 101, 18, 101, - 25, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, - 25, 26, 27, 1, 28, 29, 28, 28, 28, 28, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 31, 30, 30, - 32, 33, 34, 35, 36, 1, 37, 38, 39, 40, - - 41, 42, 43, 44, 45, 30, 46, 47, 48, 49, - 50, 51, 30, 52, 53, 54, 55, 56, 57, 31, - 58, 59, 60, 61, 62, 63, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[64] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 5, 5, 5, - 5, 1, 1, 1, 1, 1, 1, 5, 5, 6, - 6, 1, 7, 1, 1, 6, 5, 5, 5, 5, - 5, 5, 6, 6, 8, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 8, 6, 6, 6, 6, 1, - 1, 1, 1 - } ; - -static const flex_int16_t yy_base[353] = - { 0, - 0, 0, 61, 62, 63, 64, 65, 66, 712, 713, - 713, 713, 686, 63, 58, 685, 76, 67, 713, 713, - 62, 67, 713, 73, 86, 85, 96, 102, 687, 713, - 65, 683, 68, 713, 674, 713, 713, 681, 75, 76, - 93, 99, 98, 105, 111, 108, 78, 103, 100, 113, - 118, 125, 123, 127, 713, 136, 713, 713, 713, 713, - 688, 713, 713, 687, 145, 678, 161, 713, 158, 713, - 163, 713, 0, 653, 652, 647, 713, 160, 713, 161, - 713, 165, 176, 713, 713, 713, 713, 713, 713, 183, - 654, 713, 713, 0, 713, 187, 194, 200, 195, 216, - - 234, 0, 713, 673, 713, 713, 713, 672, 663, 713, - 143, 148, 184, 147, 150, 197, 662, 189, 203, 191, - 193, 208, 661, 660, 190, 207, 214, 211, 233, 215, - 225, 224, 245, 236, 249, 713, 713, 713, 713, 713, - 713, 254, 263, 281, 0, 647, 148, 646, 278, 713, - 285, 280, 288, 283, 284, 292, 713, 631, 0, 284, - 713, 311, 290, 0, 656, 713, 713, 267, 287, 265, - 266, 286, 289, 301, 295, 302, 304, 306, 307, 308, - 309, 313, 312, 317, 318, 320, 323, 325, 327, 328, - 329, 0, 640, 640, 641, 636, 358, 360, 366, 361, - - 365, 372, 643, 650, 53, 649, 648, 344, 345, 346, - 647, 347, 354, 352, 646, 350, 367, 370, 355, 645, - 353, 369, 371, 644, 377, 378, 380, 0, 622, 620, - 625, 630, 713, 379, 381, 382, 389, 639, 638, 385, - 637, 383, 396, 384, 394, 395, 407, 409, 392, 410, - 636, 0, 616, 627, 625, 629, 412, 413, 393, 416, - 417, 631, 418, 419, 630, 629, 420, 628, 425, 423, - 430, 713, 619, 618, 713, 621, 431, 432, 434, 624, - 623, 436, 433, 445, 447, 448, 438, 614, 713, 605, - 449, 450, 620, 454, 619, 456, 457, 459, 461, 713, - - 606, 462, 468, 469, 471, 617, 616, 473, 475, 600, - 597, 474, 588, 546, 480, 477, 514, 534, 482, 487, - 487, 486, 488, 496, 495, 502, 493, 489, 713, 500, - 496, 713, 540, 548, 556, 561, 569, 575, 579, 587, - 519, 595, 603, 611, 619, 623, 518, 631, 639, 305, - 246, 179 - } ; - -static const flex_int16_t yy_def[353] = - { 0, - 332, 1, 333, 333, 334, 334, 1, 1, 332, 332, - 332, 332, 332, 335, 336, 332, 332, 337, 332, 332, - 332, 332, 332, 332, 332, 332, 338, 338, 332, 332, - 332, 332, 332, 332, 339, 332, 332, 332, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 336, 332, 332, 332, 335, 332, - 340, 332, 341, 341, 332, 332, 332, 342, 332, 343, - 332, 337, 344, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 345, 332, 332, 338, 338, 338, 338, - - 338, 346, 332, 332, 332, 332, 332, 332, 339, 332, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 332, 332, 332, 332, 332, - 332, 335, 335, 340, 347, 332, 332, 332, 342, 332, - 348, 343, 349, 337, 337, 344, 332, 332, 345, 332, - 332, 338, 338, 101, 346, 332, 332, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 350, 332, 332, 332, 332, 342, 342, 348, 343, - - 343, 349, 332, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 351, 332, 332, - 332, 332, 332, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 352, 332, 332, 332, 332, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 332, 332, 332, 332, 332, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 332, 332, 332, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 332, - - 332, 339, 339, 339, 339, 339, 339, 339, 339, 332, - 339, 339, 339, 339, 339, 339, 332, 339, 339, 339, - 332, 339, 339, 332, 339, 339, 332, 339, 332, 339, - 339, 0, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332 - } ; - -static const flex_int16_t yy_nxt[777] = - { 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, - 28, 29, 30, 31, 32, 33, 34, 35, 35, 35, - 35, 36, 10, 37, 38, 35, 39, 40, 41, 42, - 43, 44, 45, 35, 46, 35, 47, 35, 48, 35, - 49, 50, 51, 52, 53, 35, 54, 35, 35, 55, - 56, 57, 58, 60, 60, 63, 63, 70, 64, 64, - 65, 65, 61, 61, 72, 70, 66, 66, 84, 86, - 78, 67, 67, 79, 80, 102, 85, 88, 104, 105, - 92, 87, 107, 108, 74, 71, 93, 89, 234, 83, - - 81, 94, 75, 90, 90, 90, 90, 102, 102, 95, - 102, 96, 76, 97, 98, 98, 97, 96, 125, 97, - 97, 97, 97, 111, 100, 102, 101, 112, 102, 113, - 102, 102, 102, 100, 102, 102, 114, 102, 91, 116, - 102, 120, 115, 102, 118, 102, 119, 122, 117, 123, - 102, 127, 126, 128, 121, 102, 124, 102, 129, 102, - 136, 140, 70, 134, 150, 69, 141, 143, 131, 150, - 135, 133, 93, 70, 130, 102, 132, 94, 82, 102, - 102, 74, 102, 272, 155, 95, 194, 168, 169, 75, - 71, 172, 151, 153, 195, 144, 137, 83, 173, 76, - - 90, 90, 90, 90, 160, 160, 160, 160, 156, 96, - 332, 97, 97, 97, 97, 96, 102, 162, 162, 162, - 97, 102, 102, 102, 157, 102, 102, 102, 161, 102, - 170, 332, 102, 163, 163, 102, 171, 177, 174, 102, - 102, 175, 176, 102, 178, 180, 102, 102, 102, 332, - 252, 164, 164, 164, 164, 179, 102, 102, 70, 185, - 181, 164, 164, 182, 183, 102, 102, 70, 102, 186, - 164, 164, 164, 164, 164, 164, 187, 102, 188, 184, - 190, 102, 150, 69, 189, 143, 71, 149, 150, 198, - 152, 70, 70, 191, 82, 71, 201, 102, 102, 102, - - 155, 160, 160, 160, 160, 332, 207, 163, 163, 228, - 151, 206, 153, 144, 204, 83, 83, 199, 102, 102, - 202, 102, 102, 205, 156, 161, 96, 102, 162, 162, - 162, 97, 208, 102, 102, 211, 102, 210, 102, 102, - 102, 102, 209, 102, 102, 102, 214, 215, 216, 102, - 102, 212, 102, 217, 218, 102, 213, 102, 220, 102, - 102, 102, 150, 223, 150, 224, 219, 225, 149, 150, - 198, 221, 222, 150, 152, 227, 102, 102, 102, 102, - 201, 226, 102, 235, 102, 102, 102, 102, 240, 236, - 151, 245, 151, 153, 239, 238, 241, 153, 199, 102, - - 237, 102, 102, 102, 202, 243, 244, 247, 242, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 248, 249, - 251, 102, 246, 261, 102, 102, 102, 102, 102, 257, - 259, 250, 265, 263, 258, 260, 264, 266, 267, 102, - 262, 102, 102, 270, 102, 102, 268, 279, 102, 102, - 102, 102, 102, 269, 271, 102, 278, 102, 282, 286, - 281, 277, 102, 102, 102, 102, 102, 283, 102, 280, - 102, 284, 295, 285, 293, 291, 287, 102, 294, 102, - 102, 102, 102, 292, 299, 296, 102, 297, 102, 102, - 303, 102, 305, 102, 102, 298, 306, 302, 304, 307, - - 102, 102, 308, 102, 312, 102, 102, 102, 309, 102, - 314, 316, 102, 318, 102, 311, 319, 313, 102, 102, - 102, 102, 192, 145, 315, 323, 325, 102, 102, 322, - 320, 326, 102, 329, 102, 328, 327, 330, 324, 331, - 59, 59, 59, 59, 59, 59, 59, 59, 62, 62, - 62, 62, 62, 62, 62, 62, 69, 69, 69, 69, - 69, 69, 69, 69, 73, 73, 102, 321, 73, 82, - 82, 82, 82, 82, 82, 82, 82, 99, 102, 99, - 99, 99, 99, 109, 109, 109, 109, 142, 142, 142, - 142, 142, 142, 142, 142, 149, 149, 149, 149, 149, - - 149, 149, 149, 152, 152, 152, 152, 152, 152, 152, - 152, 154, 154, 154, 154, 154, 154, 154, 154, 159, - 102, 159, 159, 159, 159, 159, 159, 165, 165, 102, - 165, 197, 197, 197, 197, 197, 197, 197, 197, 200, - 200, 200, 200, 200, 200, 200, 200, 317, 102, 102, - 310, 102, 102, 301, 300, 102, 102, 290, 289, 288, - 102, 102, 102, 102, 276, 275, 274, 273, 102, 102, - 102, 102, 256, 255, 254, 253, 102, 102, 102, 102, - 102, 102, 102, 233, 232, 231, 230, 229, 102, 203, - 196, 193, 102, 102, 102, 102, 167, 166, 158, 148, - - 147, 146, 85, 139, 138, 110, 102, 106, 103, 77, - 68, 332, 9, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332 - } ; - -static const flex_int16_t yy_chk[777] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 5, 6, 14, 5, 6, - 7, 8, 3, 4, 15, 18, 7, 8, 21, 22, - 17, 7, 8, 17, 17, 205, 21, 24, 31, 31, - 26, 22, 33, 33, 15, 14, 26, 24, 205, 18, - - 17, 26, 15, 25, 25, 25, 25, 39, 40, 26, - 47, 27, 15, 27, 27, 27, 27, 28, 47, 28, - 28, 28, 28, 39, 27, 41, 27, 40, 27, 41, - 43, 42, 49, 27, 28, 48, 41, 44, 25, 42, - 46, 44, 41, 45, 43, 50, 43, 45, 42, 46, - 51, 49, 48, 50, 44, 53, 46, 52, 51, 54, - 56, 65, 69, 54, 78, 71, 67, 71, 52, 80, - 54, 53, 67, 82, 51, 111, 52, 67, 83, 114, - 112, 65, 115, 352, 83, 67, 147, 111, 112, 65, - 69, 114, 78, 80, 147, 71, 56, 82, 115, 65, - - 90, 90, 90, 90, 96, 96, 96, 96, 83, 97, - 99, 97, 97, 97, 97, 98, 113, 98, 98, 98, - 98, 118, 125, 120, 90, 121, 97, 99, 96, 116, - 113, 100, 98, 100, 100, 119, 113, 120, 116, 126, - 122, 118, 119, 128, 121, 125, 127, 130, 100, 101, - 351, 101, 101, 101, 101, 122, 132, 131, 142, 130, - 126, 101, 101, 127, 128, 129, 101, 143, 134, 131, - 101, 101, 101, 101, 101, 101, 131, 133, 132, 129, - 134, 135, 149, 144, 133, 144, 142, 151, 152, 151, - 153, 154, 155, 135, 156, 143, 153, 170, 171, 168, - - 156, 160, 160, 160, 160, 163, 171, 163, 163, 350, - 149, 170, 152, 144, 168, 154, 155, 151, 172, 169, - 153, 173, 163, 169, 156, 160, 162, 175, 162, 162, - 162, 162, 172, 174, 176, 175, 177, 174, 178, 179, - 180, 181, 173, 162, 183, 182, 178, 179, 180, 184, - 185, 176, 186, 181, 182, 187, 177, 188, 184, 189, - 190, 191, 197, 187, 198, 188, 183, 189, 199, 200, - 199, 185, 186, 201, 202, 191, 208, 209, 210, 212, - 202, 190, 216, 208, 214, 221, 213, 219, 214, 209, - 197, 221, 198, 200, 213, 212, 216, 201, 199, 217, - - 210, 222, 218, 223, 202, 218, 219, 223, 217, 225, - 226, 234, 227, 235, 236, 242, 244, 240, 225, 226, - 227, 237, 222, 240, 249, 259, 245, 246, 243, 234, - 236, 226, 244, 243, 235, 237, 243, 245, 246, 247, - 242, 248, 250, 249, 257, 258, 247, 259, 260, 261, - 263, 264, 267, 248, 250, 270, 258, 269, 263, 270, - 261, 257, 271, 277, 278, 283, 279, 264, 282, 260, - 287, 267, 283, 269, 279, 277, 271, 284, 282, 285, - 286, 291, 292, 278, 287, 284, 294, 285, 296, 297, - 292, 298, 296, 299, 302, 286, 297, 291, 294, 298, - - 303, 304, 299, 305, 303, 308, 312, 309, 299, 316, - 305, 309, 315, 312, 319, 302, 315, 304, 322, 320, - 323, 328, 347, 341, 308, 320, 322, 325, 331, 319, - 316, 323, 330, 327, 326, 325, 324, 328, 321, 330, - 333, 333, 333, 333, 333, 333, 333, 333, 334, 334, - 334, 334, 334, 334, 334, 334, 335, 335, 335, 335, - 335, 335, 335, 335, 336, 336, 318, 317, 336, 337, - 337, 337, 337, 337, 337, 337, 337, 338, 314, 338, - 338, 338, 338, 339, 339, 339, 339, 340, 340, 340, - 340, 340, 340, 340, 340, 342, 342, 342, 342, 342, - - 342, 342, 342, 343, 343, 343, 343, 343, 343, 343, - 343, 344, 344, 344, 344, 344, 344, 344, 344, 345, - 313, 345, 345, 345, 345, 345, 345, 346, 346, 311, - 346, 348, 348, 348, 348, 348, 348, 348, 348, 349, - 349, 349, 349, 349, 349, 349, 349, 310, 307, 306, - 301, 295, 293, 290, 288, 281, 280, 276, 274, 273, - 268, 266, 265, 262, 256, 255, 254, 253, 251, 241, - 239, 238, 232, 231, 230, 229, 224, 220, 215, 211, - 207, 206, 204, 203, 196, 195, 194, 193, 165, 158, - 148, 146, 124, 123, 117, 109, 108, 104, 91, 76, - - 75, 74, 66, 64, 61, 38, 35, 32, 29, 16, - 13, 9, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.lpp" -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ -#define YY_NO_INPUT 1 -#define YY_NO_UNISTD_H 1 - -#line 25 "lexer.lpp" -#define YY_USER_ACTION ctx->loc.columns(yyleng); -#line 933 "lexer.cpp" - -#line 935 "lexer.cpp" - -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#include "stdafx.hpp" +#include "s1.hpp" +#include "parser.hpp" +#include "lexer.hpp" + +xsk::gsc::s1::parser::symbol_type S1lex(xsk::gsc::s1::lexer& lexer) +{ + return lexer.lex(); +} + +namespace xsk::gsc::s1 +{ + +enum class keyword +{ +/* KW_pre_define, + KW_pre_undef, + KW_pre_ifdef, + KW_pre_ifndef, + KW_pre_if, + KW_pre_elif, + KW_pre_else, + KW_pre_endif,*/ + KW_pre_inline, + KW_pre_include, + KW_pre_using_animtree, + KW_pre_animtree, + KW_endon, + KW_notify, + KW_wait, + KW_waittill, + KW_waittillmatch, + KW_waittillframeend, + KW_waitframe, + KW_if, + KW_else, + KW_do, + KW_while, + KW_for, + KW_foreach, + KW_in, + KW_switch, + KW_case, + KW_default, + KW_break, + KW_continue, + KW_return, + KW_breakpoint, + KW_prof_begin, + KW_prof_end, + KW_thread, + KW_childthread, + KW_thisthread, + KW_call, + KW_true, + KW_false, + KW_undefined, + KW_dotsize, + KW_game, + KW_self, + KW_anim, + KW_level, + KW_INVALID, +}; + +buffer::buffer() : size(1024), length(0) +{ + data = static_cast(std::malloc(size)); +} + +buffer::~buffer() +{ + if(data) std::free(data); +} + +bool buffer::push(char c) +{ + if(length >= size) { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals ( yyscan_t yyscanner ); - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef YY_NO_UNPUT - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( yyscan_t yyscanner ); -#else -static int input ( yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_load_buffer_state( yyscanner ); - } - - { -#line 44 "lexer.lpp" - - - -#line 48 "lexer.lpp" - ctx->loc.step(); - - -#line 1204 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 332 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 51 "lexer.lpp" -{ ctx->loc.step(); } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 52 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 54 "lexer.lpp" - - YY_BREAK -case 4: -YY_RULE_SETUP -#line 56 "lexer.lpp" -{ BEGIN(COMMENT_STATE); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 57 "lexer.lpp" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 58 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(COMMENT_STATE): -#line 60 "lexer.lpp" -{ throw s1::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "lexer.lpp" -{ throw s1::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 63 "lexer.lpp" -{ throw s1::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 64 "lexer.lpp" -{ BEGIN(INITIAL); return s1::parser::make_DEVEND(ctx->loc); } - YY_BREAK -case YY_STATE_EOF(DEV_ON_STATE): -#line 65 "lexer.lpp" -{ throw s1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 67 "lexer.lpp" -{ BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return s1::parser::make_DEVBEGIN(ctx->loc); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 68 "lexer.lpp" - - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 69 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 70 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(DEV_OFF_STATE): -#line 71 "lexer.lpp" -{ throw s1::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.lpp" -{ throw s1::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 74 "lexer.lpp" -{ return s1::parser::make_INLINE(ctx->loc); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 75 "lexer.lpp" -{ return s1::parser::make_INCLUDE(ctx->loc); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 76 "lexer.lpp" -{ return s1::parser::make_USINGTREE(ctx->loc); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 77 "lexer.lpp" -{ return s1::parser::make_ANIMTREE(ctx->loc); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 78 "lexer.lpp" -{ return s1::parser::make_ENDON(ctx->loc); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 79 "lexer.lpp" -{ return s1::parser::make_NOTIFY(ctx->loc); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 80 "lexer.lpp" -{ return s1::parser::make_WAIT(ctx->loc); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 81 "lexer.lpp" -{ return s1::parser::make_WAITTILL(ctx->loc); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 82 "lexer.lpp" -{ return s1::parser::make_WAITTILLMATCH(ctx->loc); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 83 "lexer.lpp" -{ return s1::parser::make_WAITTILLFRAMEEND(ctx->loc); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 84 "lexer.lpp" -{ return s1::parser::make_WAITFRAME(ctx->loc); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 85 "lexer.lpp" -{ return s1::parser::make_IF(ctx->loc); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 86 "lexer.lpp" -{ return s1::parser::make_ELSE(ctx->loc); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 87 "lexer.lpp" -{ return s1::parser::make_DO(ctx->loc); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 88 "lexer.lpp" -{ return s1::parser::make_WHILE(ctx->loc); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 89 "lexer.lpp" -{ return s1::parser::make_FOR(ctx->loc); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 90 "lexer.lpp" -{ return s1::parser::make_FOREACH(ctx->loc); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 91 "lexer.lpp" -{ return s1::parser::make_IN(ctx->loc); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 92 "lexer.lpp" -{ return s1::parser::make_SWITCH(ctx->loc); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 93 "lexer.lpp" -{ return s1::parser::make_CASE(ctx->loc); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 94 "lexer.lpp" -{ return s1::parser::make_DEFAULT(ctx->loc); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 95 "lexer.lpp" -{ return s1::parser::make_BREAK(ctx->loc); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 96 "lexer.lpp" -{ return s1::parser::make_CONTINUE(ctx->loc); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 97 "lexer.lpp" -{ return s1::parser::make_RETURN(ctx->loc); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 98 "lexer.lpp" -{ return s1::parser::make_BREAKPOINT(ctx->loc); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 99 "lexer.lpp" -{ return s1::parser::make_PROFBEGIN(ctx->loc); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 100 "lexer.lpp" -{ return s1::parser::make_PROFEND(ctx->loc); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 101 "lexer.lpp" -{ return s1::parser::make_THREAD(ctx->loc); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 102 "lexer.lpp" -{ return s1::parser::make_CHILDTHREAD(ctx->loc); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 103 "lexer.lpp" -{ return s1::parser::make_THISTHREAD(ctx->loc); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 104 "lexer.lpp" -{ return s1::parser::make_CALL(ctx->loc); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 105 "lexer.lpp" -{ return s1::parser::make_TRUE(ctx->loc); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 106 "lexer.lpp" -{ return s1::parser::make_FALSE(ctx->loc); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 107 "lexer.lpp" -{ return s1::parser::make_UNDEFINED(ctx->loc); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 108 "lexer.lpp" -{ return s1::parser::make_SIZE(ctx->loc); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 109 "lexer.lpp" -{ return s1::parser::make_GAME(ctx->loc); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 110 "lexer.lpp" -{ return s1::parser::make_SELF(ctx->loc); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 111 "lexer.lpp" -{ return s1::parser::make_ANIM(ctx->loc); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 112 "lexer.lpp" -{ return s1::parser::make_LEVEL(ctx->loc); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 113 "lexer.lpp" -{ return s1::parser::make_LPAREN(ctx->loc); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 114 "lexer.lpp" -{ return s1::parser::make_RPAREN(ctx->loc); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 115 "lexer.lpp" -{ return s1::parser::make_LBRACE(ctx->loc); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 116 "lexer.lpp" -{ return s1::parser::make_RBRACE(ctx->loc); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 117 "lexer.lpp" -{ return s1::parser::make_LBRACKET(ctx->loc); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 118 "lexer.lpp" -{ return s1::parser::make_RBRACKET(ctx->loc); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 119 "lexer.lpp" -{ return s1::parser::make_COMMA(ctx->loc); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 120 "lexer.lpp" -{ return s1::parser::make_DOT(ctx->loc); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 121 "lexer.lpp" -{ return s1::parser::make_DOUBLECOLON(ctx->loc); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 122 "lexer.lpp" -{ return s1::parser::make_COLON(ctx->loc); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 123 "lexer.lpp" -{ return s1::parser::make_SEMICOLON(ctx->loc); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 124 "lexer.lpp" -{ return s1::parser::make_QMARK(ctx->loc); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 125 "lexer.lpp" -{ return s1::parser::make_INCREMENT(ctx->loc); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 126 "lexer.lpp" -{ return s1::parser::make_DECREMENT(ctx->loc); } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 127 "lexer.lpp" -{ return s1::parser::make_ASSIGN_LSHIFT(ctx->loc); } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 128 "lexer.lpp" -{ return s1::parser::make_ASSIGN_RSHIFT(ctx->loc); } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 129 "lexer.lpp" -{ return s1::parser::make_LSHIFT(ctx->loc); } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 130 "lexer.lpp" -{ return s1::parser::make_RSHIFT(ctx->loc); } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 131 "lexer.lpp" -{ return s1::parser::make_OR(ctx->loc); } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 132 "lexer.lpp" -{ return s1::parser::make_AND(ctx->loc); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 133 "lexer.lpp" -{ return s1::parser::make_EQUALITY(ctx->loc); } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 134 "lexer.lpp" -{ return s1::parser::make_INEQUALITY(ctx->loc); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 135 "lexer.lpp" -{ return s1::parser::make_LESS_EQUAL(ctx->loc); } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 136 "lexer.lpp" -{ return s1::parser::make_GREATER_EQUAL(ctx->loc); } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 137 "lexer.lpp" -{ return s1::parser::make_LESS(ctx->loc); } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 138 "lexer.lpp" -{ return s1::parser::make_GREATER(ctx->loc); } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 139 "lexer.lpp" -{ return s1::parser::make_ASSIGN_ADD(ctx->loc); } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 140 "lexer.lpp" -{ return s1::parser::make_ASSIGN_SUB(ctx->loc); } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 141 "lexer.lpp" -{ return s1::parser::make_ASSIGN_MUL(ctx->loc); } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 142 "lexer.lpp" -{ return s1::parser::make_ASSIGN_DIV(ctx->loc); } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 143 "lexer.lpp" -{ return s1::parser::make_ASSIGN_MOD(ctx->loc); } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 144 "lexer.lpp" -{ return s1::parser::make_ASSIGN_BW_OR(ctx->loc); } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 145 "lexer.lpp" -{ return s1::parser::make_ASSIGN_BW_AND(ctx->loc); } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 146 "lexer.lpp" -{ return s1::parser::make_ASSIGN_BW_EXOR(ctx->loc); } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 147 "lexer.lpp" -{ return s1::parser::make_ASSIGN(ctx->loc); } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 148 "lexer.lpp" -{ return s1::parser::make_ADD(ctx->loc); } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 149 "lexer.lpp" -{ return s1::parser::make_SUB(ctx->loc); } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 150 "lexer.lpp" -{ return s1::parser::make_MUL(ctx->loc); } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 151 "lexer.lpp" -{ return s1::parser::make_DIV(ctx->loc); } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 152 "lexer.lpp" -{ return s1::parser::make_MOD(ctx->loc); } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 153 "lexer.lpp" -{ return s1::parser::make_NOT(ctx->loc); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 154 "lexer.lpp" -{ return s1::parser::make_COMPLEMENT(ctx->loc); } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 155 "lexer.lpp" -{ return s1::parser::make_BITWISE_OR(ctx->loc); } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 156 "lexer.lpp" -{ return s1::parser::make_BITWISE_AND(ctx->loc); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 157 "lexer.lpp" -{ return s1::parser::make_BITWISE_EXOR(ctx->loc); } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 158 "lexer.lpp" -{ return s1::parser::make_PATH(xsk::gsc::s1::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 101: -YY_RULE_SETUP -#line 159 "lexer.lpp" -{ return s1::parser::make_IDENTIFIER(xsk::gsc::s1::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 102: -/* rule 102 can match eol */ -YY_RULE_SETUP -#line 160 "lexer.lpp" -{ return s1::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 103: -/* rule 103 can match eol */ -YY_RULE_SETUP -#line 161 "lexer.lpp" -{ return s1::parser::make_STRING(std::string(yytext), ctx->loc); } - YY_BREAK -case 104: -YY_RULE_SETUP -#line 162 "lexer.lpp" -{ return s1::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 105: -YY_RULE_SETUP -#line 163 "lexer.lpp" -{ return s1::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 164 "lexer.lpp" -{ return s1::parser::make_FLOAT(std::string(yytext), ctx->loc); } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 165 "lexer.lpp" -{ return s1::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 166 "lexer.lpp" -{ return s1::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 167 "lexer.lpp" -{ return s1::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } - YY_BREAK -case 110: -YY_RULE_SETUP -#line 168 "lexer.lpp" -{ return s1::parser::make_INTEGER(std::string(yytext), ctx->loc); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 169 "lexer.lpp" -{ if(ctx->header_top > 0) s1_pop_header(ctx); else return s1::parser::make_S1EOF(ctx->loc); } - YY_BREAK -case 111: -/* rule 111 can match eol */ -YY_RULE_SETUP -#line 170 "lexer.lpp" -{ throw s1::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - YY_BREAK -case 112: -YY_RULE_SETUP -#line 172 "lexer.lpp" -ECHO; - YY_BREAK -#line 1839 "lexer.cpp" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap( yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin , yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + auto nsize = size * 2; + auto ndata = reinterpret_cast(std::malloc(nsize)); + + if(!ndata) return false; + + std::memmove(ndata, data, size); + std::free(data); + size = nsize; + data = ndata; + } + data[length++] = c; + return true; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; } -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +void reader::init(const char* data, size_t size) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 332); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + if(data && size) + { + state = reader::ok; + buffer_pos = data; + bytes_remaining = size; + last_byte = 0; + current_byte = *data; + } + else + { + state = reader::end; + buffer_pos = 0; + bytes_remaining = 0; + last_byte = 0; + current_byte = 0; + } } -#ifndef YY_NO_UNPUT - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - +void reader::advance() { - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + ++buffer_pos; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin , yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); - yy_load_buffer_state( yyscanner ); + if(bytes_remaining-- == 1) + { + state = reader::end; + bytes_remaining = 0; + last_byte = current_byte; + current_byte = 0; + } + else + { + last_byte = current_byte; + current_byte = *buffer_pos; + } } -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +lexer::lexer(const std::string& name, const char* data, size_t size) : in_dev_state_(false), loc_(xsk::gsc::location(&name)), + mode_(build::dev), header_top_(0), locs_(std::stack()), readers_(std::stack()) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + reader_.init(data, size); } -static void yy_load_buffer_state (yyscan_t yyscanner) +void lexer::push_header(const std::string& file) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + try + { + if (header_top_++ >= 10) + throw xsk::gsc::error("maximum gsh depth exceeded '10'"); + + auto data = resolver::file_data(file + ".gsh"); + + readers_.push(reader_); + locs_.push(loc_); + loc_.initialize(std::get<0>(data)); + reader_.init(std::get<1>(data), std::get<2>(data)); + } + catch (const std::exception& e) + { + throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); + } } -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +void lexer::pop_header() { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file , yyscanner); - - return b; + header_top_--; + loc_ = locs_.top(); + locs_.pop(); + reader_ = readers_.top(); + readers_.pop(); } -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void lexer::restrict_header(const xsk::gsc::location& loc) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf , yyscanner ); - - yyfree( (void *) b , yyscanner ); + if (header_top_ > 0) + { + throw comp_error(loc, "not allowed inside a gsh file"); + } } -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - +auto lexer::lex() -> xsk::gsc::s1::parser::symbol_type { - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + buffer_.length = 0; + loc_.step(); - yy_flush_buffer( b , yyscanner); + while (true) + { + if (reader_.state == reader::end) + { + if (in_dev_state_) + throw s1::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + if(header_top_ > 0) + pop_header(); + else + return s1::parser::make_S1EOF(loc_); + } - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + reader_.advance(); + auto& last = reader_.last_byte; + auto& curr = reader_.current_byte; + + switch (last) + { + case ' ': + case '\t': + case '\r': + loc_.step(); + continue; + case '\n': + loc_.lines(); + loc_.step(); + continue; + case '/': + if(reader_.state == reader::end || (curr != '/' && curr != '*' && curr != '#' && curr != '=')) + return s1::parser::make_DIV(loc_); + + reader_.advance(); + + if (last == '=') + return s1::parser::make_ASSIGN_DIV(loc_); + + if (last == '#') + { + if (in_dev_state_) + { + throw s1::parser::syntax_error(loc_, "cannot recurse devblock ('/#')"); + } + else if (mode_ == xsk::gsc::build::dev) + { + in_dev_state_ = true; + return s1::parser::make_DEVBEGIN(loc_); + } + else + { + while (true) + { + if (reader_.state == reader::end) + { + throw s1::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '#' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + } + else if (last == '*') + { + while (true) + { + if (reader_.state == reader::end) + { + throw s1::parser::syntax_error(loc_, "unmatched multiline comment start ('/*')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '*' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + else if (last == '/') + { + while (true) + { + if (reader_.state == reader::end || curr == '\n') + break; + + reader_.advance(); + } + } + continue; + case '#': + if (curr == '/') + { + if (!in_dev_state_) + throw s1::parser::syntax_error(loc_, "unmatched devblock end ('#/')"); + + in_dev_state_ = false; + reader_.advance(); + return s1::parser::make_DEVEND(loc_); + } + + buffer_.push(last); + while (reader_.state == reader::ok) + { + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + { + if (auto len = buffer_.length; len == 4 || len == 7) + { + auto data = buffer_.data; + auto color = true; + for (auto i = 1; i < len; i++) + { + if ((data[i] < 48 || data[i] > 57) && (data[i] < 65 || data[i] > 70) && (data[i] < 97 || data[i] > 102)) + { + color = false; + break; + } + } + + if (color) return s1::parser::make_COLOR(std::string(++data, --len), loc_); + } + + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); + + if (key == keyword::KW_INVALID) + throw s1::parser::syntax_error(loc_, utils::string::va("unknown preprocessor directive ('%s')", "#")); + + if (keyword_is_token(key)) + return keyword_token(key); + + // call preprocessor(key); + } + continue; + case '*': + if (reader_.state == reader::end || (curr != '/' && curr != '=')) + return s1::parser::make_MUL(loc_); + + reader_.advance(); + + if (curr == '/') + throw s1::parser::syntax_error(loc_, "unmatched multiline comment end ('*/')"); + + return s1::parser::make_ASSIGN_MUL(loc_); + case '"': + case '\'': + return read_string(last, false); + case '.': + return read_dotsize(); + case '(': + return s1::parser::make_LPAREN(loc_); + case ')': + return s1::parser::make_RPAREN(loc_); + case '{': + return s1::parser::make_LBRACE(loc_); + case '}': + return s1::parser::make_RBRACE(loc_); + case '[': + return s1::parser::make_LBRACKET(loc_); + case ']': + return s1::parser::make_RBRACKET(loc_); + case ',': + return s1::parser::make_COMMA(loc_); + case ';': + return s1::parser::make_SEMICOLON(loc_); + case ':': + if (curr != ':') + return s1::parser::make_COLON(loc_); + reader_.advance(); + return s1::parser::make_DOUBLECOLON(loc_); + case '?': + return s1::parser::make_QMARK(loc_); + case '=': + if (curr != '=') + return s1::parser::make_ASSIGN(loc_); + reader_.advance(); + return s1::parser::make_EQUALITY(loc_); + case '+': + if (curr != '+' && curr != '=') + return s1::parser::make_ADD(loc_); + reader_.advance(); + return (last == '+') ? s1::parser::make_INCREMENT(loc_) : s1::parser::make_ASSIGN_ADD(loc_); + case '-': + if (curr != '-' && curr != '=') + return s1::parser::make_SUB(loc_); + reader_.advance(); + return (last == '-') ? s1::parser::make_DECREMENT(loc_) : s1::parser::make_ASSIGN_SUB(loc_); + case '%': + if (curr != '=') + return s1::parser::make_MOD(loc_); + reader_.advance(); + return s1::parser::make_ASSIGN_MOD(loc_); + case '|': + if (curr != '|' && curr != '=') + return s1::parser::make_BITWISE_OR(loc_); + reader_.advance(); + return (last == '|') ? s1::parser::make_OR(loc_) : s1::parser::make_ASSIGN_BW_OR(loc_); + case '&': + if (curr != '&' && curr != '=' && curr != '"' && curr != '\'') + return s1::parser::make_BITWISE_AND(loc_); + reader_.advance(); + if (last == '"' || last == '\'') + return read_string(last, true); + return (last == '&') ? s1::parser::make_AND(loc_) : s1::parser::make_ASSIGN_BW_AND(loc_); + case '^': + if (curr != '=') + return s1::parser::make_BITWISE_EXOR(loc_); + reader_.advance(); + return s1::parser::make_ASSIGN_BW_EXOR(loc_); + case '!': + if (curr != '=') + return s1::parser::make_NOT(loc_); + reader_.advance(); + return s1::parser::make_INEQUALITY(loc_); + case '~': + return s1::parser::make_COMPLEMENT(loc_); + case '<': + if (curr != '<' && curr != '=') + return s1::parser::make_LESS(loc_); + reader_.advance(); + if (last == '<') + { + reader_.advance(); + return (last == '=') ? s1::parser::make_ASSIGN_LSHIFT(loc_) : s1::parser::make_LSHIFT(loc_); + } + return s1::parser::make_LESS_EQUAL(loc_); + case '>': + if (curr != '>' && curr != '=') + return s1::parser::make_GREATER(loc_); + reader_.advance(); + if (last == '>') + { + reader_.advance(); + return (last == '=') ? s1::parser::make_ASSIGN_RSHIFT(loc_) : s1::parser::make_RSHIFT(loc_); + } + return s1::parser::make_GREATER_EQUAL(loc_); + default: + if (last >= '0' && last <= '9') + return lexer::read_number(last); + else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z') + return lexer::read_word(last); + + throw s1::parser::syntax_error(loc_, utils::string::va("bad token: \'%c\'", last)); + } + } +} + +auto lexer::read_string(char quote, bool localize) -> xsk::gsc::s1::parser::symbol_type +{ + if (localize) + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + reader_.advance(); + + if (last == '\n') + throw s1::parser::syntax_error(loc_, "unterminated string"); + + if (last == '\\') // process scapes + { + // TODO: + } + + if (last != '\\' && curr == quote) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); } - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b , yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n , yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n , yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int _line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = _line_number; -} - -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column (int _column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = _column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int _bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = _bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (reader_.state == reader::end) + { + throw s1::parser::syntax_error(loc_, utils::string::va("unmatched string start ('%s')", (quote == '"') ? "\"" : "\\'")); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + if (localize) + return s1::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + return s1::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_); +} + +auto lexer::read_number(char first) -> xsk::gsc::s1::parser::symbol_type +{ + if (first == '.') + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = true; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw s1::parser::syntax_error(loc_, "invalid number '.'"); + } + if (data[i] == 'f' && i != len - 1) + throw s1::parser::syntax_error(loc_, "invalid number 'f'"); + } + + return s1::parser::make_FLOAT(std::string(data, len), loc_); + } + else + { + auto curr = reader_.current_byte; + + if (first == '0' && curr == 'o') + { + buffer_.push(first); + buffer_.push('o'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'o')) + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'o' && last == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr > 47 && curr < 56)) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid octal literal!"); + + return s1::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data + 2), loc_); + } + else if (first == '0' && curr == 'b') + { + buffer_.push(first); + buffer_.push('b'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'b')) + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'b' && last == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (curr != '0' && curr != '1') + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid binary literal!"); + + return s1::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_); + } + else if (first == '0' && curr == 'x') + { + buffer_.push(first); + buffer_.push('x'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'x')) + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'x' && last == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!((curr > 47 && curr < 58) || (curr > 64 && curr < 71) || (curr > 96 && curr < 103))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid hexadecimal literal!"); + + return s1::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_); + } + else + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s1::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = false; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw s1::parser::syntax_error(loc_, "invalid number '.'"); + + dot = true; + } + if (data[i] == 'f' && i != len - 1) + throw s1::parser::syntax_error(loc_, "invalid number 'f'"); + } + + if (dot || data[len - 1] == 'f') + return s1::parser::make_FLOAT(std::string(data, len), loc_); + + return s1::parser::make_INTEGER(std::string(data, len), loc_); + } + } +} + +auto lexer::read_word(char first) -> xsk::gsc::s1::parser::symbol_type +{ + auto path = false; + + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto curr = reader_.current_byte; + + if (!(curr == '\\' || curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (curr == '\\') + { + if (reader_.last_byte == '\\') + throw s1::parser::syntax_error(loc_, "invalid path '\\\\'"); + + path = true; + curr = '/'; + } + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); - return yy_init_globals ( *ptr_yy_globals ); -} + if (key != keyword::KW_INVALID) + return keyword_token(key); -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; + if (path) + { + if (buffer_.data[buffer_.length - 1] == '/') + throw s1::parser::syntax_error(loc_, "invalid path end '\\'"); - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + return s1::parser::make_PATH(xsk::gsc::s1::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + return s1::parser::make_IDENTIFIER(xsk::gsc::s1::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); +} - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; +auto lexer::read_dotsize() -> xsk::gsc::s1::parser::symbol_type +{ + auto curr = reader_.current_byte; + + if (curr > 47 && curr < 58) + { + return lexer::read_number('.'); + } + else if (curr == '_' || curr > 64 && curr < 91 || curr > 96 && curr < 123) + { + reader save; + save.state = reader_.state; + save.bytes_remaining = reader_.bytes_remaining; + save.buffer_pos = reader_.buffer_pos; + save.last_byte = reader_.last_byte; + save.current_byte = reader_.current_byte; + + while (reader_.state == reader::ok) + { + curr = reader_.current_byte; + + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (std::string_view(buffer_.data, buffer_.length) == "size") + { + return s1::parser::make_SIZE(loc_); + } + + reader_.state = save.state; + reader_.bytes_remaining = save.bytes_remaining; + reader_.buffer_pos = save.buffer_pos; + reader_.last_byte = save.last_byte; + reader_.current_byte = save.current_byte; + + return s1::parser::make_DOT(loc_); + + } + else return s1::parser::make_DOT(loc_); +} + +auto lexer::keyword_token(keyword k) -> xsk::gsc::s1::parser::symbol_type +{ + switch (k) + { + case keyword::KW_pre_inline: + return s1::parser::make_INLINE(loc_); + case keyword::KW_pre_include: + return s1::parser::make_INCLUDE(loc_); + case keyword::KW_pre_using_animtree: + return s1::parser::make_USINGTREE(loc_); + case keyword::KW_pre_animtree: + return s1::parser::make_ANIMTREE(loc_); + case keyword::KW_endon: + return s1::parser::make_ENDON(loc_); + case keyword::KW_notify: + return s1::parser::make_NOTIFY(loc_); + case keyword::KW_wait: + return s1::parser::make_WAIT(loc_); + case keyword::KW_waittill: + return s1::parser::make_WAITTILL(loc_); + case keyword::KW_waittillmatch: + return s1::parser::make_WAITTILLMATCH(loc_); + case keyword::KW_waittillframeend: + return s1::parser::make_WAITTILLFRAMEEND(loc_); + case keyword::KW_waitframe: + return s1::parser::make_WAITFRAME(loc_); + case keyword::KW_if: + return s1::parser::make_IF(loc_); + case keyword::KW_else: + return s1::parser::make_ELSE(loc_); + case keyword::KW_do: + return s1::parser::make_DO(loc_); + case keyword::KW_while: + return s1::parser::make_WHILE(loc_); + case keyword::KW_for: + return s1::parser::make_FOR(loc_); + case keyword::KW_foreach: + return s1::parser::make_FOREACH(loc_); + case keyword::KW_in: + return s1::parser::make_IN(loc_); + case keyword::KW_switch: + return s1::parser::make_SWITCH(loc_); + case keyword::KW_case: + return s1::parser::make_CASE(loc_); + case keyword::KW_default: + return s1::parser::make_DEFAULT(loc_); + case keyword::KW_break: + return s1::parser::make_BREAK(loc_); + case keyword::KW_continue: + return s1::parser::make_CONTINUE(loc_); + case keyword::KW_return: + return s1::parser::make_RETURN(loc_); + case keyword::KW_breakpoint: + return s1::parser::make_BREAKPOINT(loc_); + case keyword::KW_prof_begin: + return s1::parser::make_PROFBEGIN(loc_); + case keyword::KW_prof_end: + return s1::parser::make_PROFEND(loc_); + case keyword::KW_thread: + return s1::parser::make_THREAD(loc_); + case keyword::KW_childthread: + return s1::parser::make_CHILDTHREAD(loc_); + case keyword::KW_thisthread: + return s1::parser::make_THISTHREAD(loc_); + case keyword::KW_call: + return s1::parser::make_CALL(loc_); + case keyword::KW_true: + return s1::parser::make_TRUE(loc_); + case keyword::KW_false: + return s1::parser::make_FALSE(loc_); + case keyword::KW_undefined: + return s1::parser::make_UNDEFINED(loc_); + case keyword::KW_dotsize: + return s1::parser::make_SIZE(loc_); + case keyword::KW_game: + return s1::parser::make_GAME(loc_); + case keyword::KW_self: + return s1::parser::make_SELF(loc_); + case keyword::KW_anim: + return s1::parser::make_ANIM(loc_); + case keyword::KW_level: + return s1::parser::make_LEVEL(loc_); + default: + throw error("gsc lexer: INVALID KEYWORD TOKEN!"); + } +} + +auto lexer::keyword_is_token(keyword k) -> bool +{ + switch (k) + { +/* case keyword::KW_pre_define: + case keyword::KW_pre_undef: + case keyword::KW_pre_ifdef: + case keyword::KW_pre_ifndef: + case keyword::KW_pre_if: + case keyword::KW_pre_elif: + case keyword::KW_pre_else: + case keyword::KW_pre_endif:*/ + case keyword::KW_INVALID: + return false; + default: + return true; + } +} + +auto lexer::get_keyword(std::string_view str) -> keyword +{ + auto itr = keywords.find(str); + + if(itr != keywords.end()) + { + return itr->second; } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + return keyword::KW_INVALID; } -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack , yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack , yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s , yyscan_t yyscanner) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 172 "lexer.lpp" - - -void s1_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void s1_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} +std::unordered_map lexer::keywords +{{ +/* { "#define", keyword::KW_pre_define }, + { "#undef", keyword::KW_pre_undef }, + { "#ifdef", keyword::KW_pre_ifdef }, + { "#ifndef", keyword::KW_pre_ifndef }, + { "#if", keyword::KW_pre_if }, + { "#elif", keyword::KW_pre_elif }, + { "#else", keyword::KW_pre_else }, + { "#endif", keyword::KW_pre_endif },*/ + { "#inline", keyword::KW_pre_inline }, + { "#include", keyword::KW_pre_include }, + { "#using_animtree", keyword::KW_pre_using_animtree }, + { "#animtree", keyword::KW_pre_animtree }, + { "endon", keyword::KW_endon }, + { "notify", keyword::KW_notify }, + { "wait", keyword::KW_wait }, + { "waittill", keyword::KW_waittill }, + { "waittillmatch", keyword::KW_waittillmatch }, + { "waittillframeend", keyword::KW_waittillframeend }, + { "waitframe", keyword::KW_waitframe }, + { "if", keyword::KW_if }, + { "else", keyword::KW_else }, + { "do", keyword::KW_do }, + { "while", keyword::KW_while }, + { "for", keyword::KW_for }, + { "foreach", keyword::KW_foreach }, + { "in", keyword::KW_in }, + { "switch", keyword::KW_switch }, + { "case", keyword::KW_case }, + { "default", keyword::KW_default }, + { "break", keyword::KW_break }, + { "continue", keyword::KW_continue }, + { "return", keyword::KW_return }, + { "breakpoint", keyword::KW_breakpoint }, + { "prof_begin", keyword::KW_prof_begin }, + { "prof_end", keyword::KW_prof_end }, + { "thread", keyword::KW_thread }, + { "childthread", keyword::KW_childthread }, + { "thisthread", keyword::KW_thisthread }, + { "call", keyword::KW_call }, + { "true", keyword::KW_true }, + { "false", keyword::KW_false }, + { "undefined", keyword::KW_undefined }, + { ".size", keyword::KW_dotsize }, + { "game", keyword::KW_game }, + { "self", keyword::KW_self }, + { "anim", keyword::KW_anim }, + { "level", keyword::KW_level }, +}}; +} // namespace xsk::gsc::s1 diff --git a/src/s1/xsk/lexer.hpp b/src/s1/xsk/lexer.hpp index e8365297..01d09e1e 100644 --- a/src/s1/xsk/lexer.hpp +++ b/src/s1/xsk/lexer.hpp @@ -1,711 +1,79 @@ -#ifndef s1_HEADER_H -#define s1_HEADER_H 1 -#define s1_IN_HEADER 1 - -#line 5 "lexer.hpp" -#include "stdafx.hpp" -#include "s1.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void s1_push_header(xsk::gsc::context* ctx, const std::string& file); -void s1_pop_header(xsk::gsc::context* ctx); - -#line 13 "lexer.hpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define s1__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer s1__create_buffer -#endif - -#ifdef yy_delete_buffer -#define s1__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer s1__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define s1__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer s1__scan_buffer -#endif - -#ifdef yy_scan_string -#define s1__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string s1__scan_string -#endif - -#ifdef yy_scan_bytes -#define s1__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes s1__scan_bytes -#endif - -#ifdef yy_init_buffer -#define s1__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer s1__init_buffer -#endif - -#ifdef yy_flush_buffer -#define s1__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer s1__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define s1__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state s1__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define s1__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer s1__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define s1_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state s1_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define s1_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state s1_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define s1_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack s1_ensure_buffer_stack -#endif - -#ifdef yylex -#define s1_lex_ALREADY_DEFINED -#else -#define yylex s1_lex -#endif - -#ifdef yyrestart -#define s1_restart_ALREADY_DEFINED -#else -#define yyrestart s1_restart -#endif - -#ifdef yylex_init -#define s1_lex_init_ALREADY_DEFINED -#else -#define yylex_init s1_lex_init -#endif - -#ifdef yylex_init_extra -#define s1_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra s1_lex_init_extra -#endif - -#ifdef yylex_destroy -#define s1_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy s1_lex_destroy -#endif - -#ifdef yyget_debug -#define s1_get_debug_ALREADY_DEFINED -#else -#define yyget_debug s1_get_debug -#endif - -#ifdef yyset_debug -#define s1_set_debug_ALREADY_DEFINED -#else -#define yyset_debug s1_set_debug -#endif - -#ifdef yyget_extra -#define s1_get_extra_ALREADY_DEFINED -#else -#define yyget_extra s1_get_extra -#endif - -#ifdef yyset_extra -#define s1_set_extra_ALREADY_DEFINED -#else -#define yyset_extra s1_set_extra -#endif - -#ifdef yyget_in -#define s1_get_in_ALREADY_DEFINED -#else -#define yyget_in s1_get_in -#endif - -#ifdef yyset_in -#define s1_set_in_ALREADY_DEFINED -#else -#define yyset_in s1_set_in -#endif - -#ifdef yyget_out -#define s1_get_out_ALREADY_DEFINED -#else -#define yyget_out s1_get_out -#endif - -#ifdef yyset_out -#define s1_set_out_ALREADY_DEFINED -#else -#define yyset_out s1_set_out -#endif - -#ifdef yyget_leng -#define s1_get_leng_ALREADY_DEFINED -#else -#define yyget_leng s1_get_leng -#endif - -#ifdef yyget_text -#define s1_get_text_ALREADY_DEFINED -#else -#define yyget_text s1_get_text -#endif - -#ifdef yyget_lineno -#define s1_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno s1_get_lineno -#endif - -#ifdef yyset_lineno -#define s1_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno s1_set_lineno -#endif - -#ifdef yyget_column -#define s1_get_column_ALREADY_DEFINED -#else -#define yyget_column s1_get_column -#endif - -#ifdef yyset_column -#define s1_set_column_ALREADY_DEFINED -#else -#define yyset_column s1_set_column -#endif - -#ifdef yywrap -#define s1_wrap_ALREADY_DEFINED -#else -#define yywrap s1_wrap -#endif - -#ifdef yyalloc -#define s1_alloc_ALREADY_DEFINED -#else -#define yyalloc s1_alloc -#endif - -#ifdef yyrealloc -#define s1_realloc_ALREADY_DEFINED -#else -#define yyrealloc s1_realloc -#endif - -#ifdef yyfree -#define s1_free_ALREADY_DEFINED -#else -#define yyfree s1_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define s1_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#ifndef s1__create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef s1__delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef s1__scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef s1__scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef s1__scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef s1__init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef s1__flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef s1__load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef s1__switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef s1_push_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef s1_pop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef s1_ensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef s1_lex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef s1_restart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef s1_lex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef s1_lex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef s1_lex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef s1_get_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef s1_set_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef s1_get_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef s1_set_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef s1_get_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef s1_set_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef s1_get_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef s1_set_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef s1_get_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef s1_get_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef s1_get_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef s1_set_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef s1_get_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef s1_set_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef s1_wrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef s1_get_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef s1_set_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef s1_get_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef s1_set_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef s1_alloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef s1_realloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef s1_free_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef s1_text_ALREADY_DEFINED -#undef yytext -#endif -#ifndef s1_leng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef s1_in_ALREADY_DEFINED -#undef yyin -#endif -#ifndef s1_out_ALREADY_DEFINED -#undef yyout -#endif -#ifndef s1__flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef s1_lineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef s1_tables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef s1_tables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef s1_TABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 172 "lexer.lpp" - - -#line 709 "lexer.hpp" -#undef s1_IN_HEADER -#endif /* s1_HEADER_H */ +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#pragma once + +#include "s1.hpp" + +namespace xsk::gsc::s1 +{ + +enum class keyword; + +struct buffer +{ + int size; + int length; + char* data; + + buffer(); + ~buffer(); + bool push(char c); +}; + +struct reader +{ + enum states { end, ok }; + + states state; + int bytes_remaining; + const char* buffer_pos; + char last_byte; + char current_byte; + + reader(); + + reader& operator=(const reader& r) + { + std::memcpy(this, &r, sizeof(reader)); + return *this; + } + + void init(const char* data, size_t size); + void advance(); +}; + +class lexer +{ +private: + reader reader_; + buffer buffer_; + location loc_; + build mode_; + bool in_dev_state_; + std::stack locs_; + std::stack readers_; + std::uint32_t header_top_; + +public: + lexer(const std::string& name, const char* data, size_t size); + auto lex() -> xsk::gsc::s1::parser::symbol_type; + void push_header(const std::string& file); + void pop_header(); + void restrict_header(const xsk::gsc::location& loc); + +private: + auto read_string(char quote, bool localize) -> xsk::gsc::s1::parser::symbol_type; + auto read_number(char first) -> xsk::gsc::s1::parser::symbol_type; + auto read_word(char first) -> xsk::gsc::s1::parser::symbol_type; + auto read_dotsize() -> xsk::gsc::s1::parser::symbol_type; + auto keyword_token(keyword k) -> xsk::gsc::s1::parser::symbol_type; + static auto keyword_is_token(keyword k) -> bool; + static auto get_keyword(std::string_view str) -> keyword; + + static std::unordered_map keywords; +}; + +} // namespace xsk::gsc::s1 diff --git a/src/s1/xsk/parser.cpp b/src/s1/xsk/parser.cpp index 72c644a0..05bc791e 100644 --- a/src/s1/xsk/parser.cpp +++ b/src/s1/xsk/parser.cpp @@ -35,13 +35,13 @@ // private implementation details that can be changed or removed. // "%code top" blocks. -#line 40 "parser.ypp" +#line 34 "parser.ypp" #include "stdafx.hpp" #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::s1::parser::symbol_type S1lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::s1::parser::symbol_type S1lex(xsk::gsc::s1::lexer& lexer); #line 47 "parser.cpp" @@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace s1 { #line 149 "parser.cpp" /// Build a parser object. - parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) + parser::parser (xsk::gsc::s1::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) #if S1DEBUG : yydebug_ (false), yycdebug_ (&std::cerr), @@ -156,8 +156,7 @@ namespace xsk { namespace gsc { namespace s1 { : #endif yy_lac_established_ (false), - yyscanner (yyscanner_yyarg), - ctx (ctx_yyarg), + lexer (lexer_yyarg), ast (ast_yyarg) {} @@ -1593,7 +1592,7 @@ namespace xsk { namespace gsc { namespace s1 { try #endif // YY_EXCEPTIONS { - symbol_type yylookahead (yylex (yyscanner, ctx)); + symbol_type yylookahead (yylex (lexer)); yyla.move (yylookahead); } #if YY_EXCEPTIONS @@ -1980,1303 +1979,1303 @@ namespace xsk { namespace gsc { namespace s1 { switch (yyn) { case 2: // root: program -#line 251 "parser.ypp" +#line 245 "parser.ypp" { ast = std::move(yystack_[0].value.as < ast::program::ptr > ()); } -#line 1986 "parser.cpp" +#line 1985 "parser.cpp" break; case 3: // root: %empty -#line 252 "parser.ypp" +#line 246 "parser.ypp" { ast = std::make_unique(yylhs.location); } -#line 1992 "parser.cpp" +#line 1991 "parser.cpp" break; case 4: // program: program inline -#line 257 "parser.ypp" +#line 251 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); } -#line 1998 "parser.cpp" +#line 1997 "parser.cpp" break; case 5: // program: program include -#line 259 "parser.ypp" +#line 253 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2004 "parser.cpp" +#line 2003 "parser.cpp" break; case 6: // program: program declaration -#line 261 "parser.ypp" +#line 255 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2010 "parser.cpp" +#line 2009 "parser.cpp" break; case 7: // program: inline -#line 263 "parser.ypp" +#line 257 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); } -#line 2016 "parser.cpp" +#line 2015 "parser.cpp" break; case 8: // program: include -#line 265 "parser.ypp" +#line 259 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2022 "parser.cpp" +#line 2021 "parser.cpp" break; case 9: // program: declaration -#line 267 "parser.ypp" +#line 261 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2028 "parser.cpp" +#line 2027 "parser.cpp" break; case 10: // inline: "#inline" expr_path ";" -#line 271 "parser.ypp" - { s1_push_header(ctx, yystack_[1].value.as < ast::expr_path::ptr > ()->value); } -#line 2034 "parser.cpp" +#line 265 "parser.ypp" + { lexer.push_header(yystack_[1].value.as < ast::expr_path::ptr > ()->value); } +#line 2033 "parser.cpp" break; case 11: // include: "#include" expr_path ";" -#line 276 "parser.ypp" +#line 270 "parser.ypp" { yylhs.value.as < ast::include::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_path::ptr > ())); } -#line 2040 "parser.cpp" +#line 2039 "parser.cpp" break; case 12: // declaration: "/#" -#line 280 "parser.ypp" +#line 274 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_begin = std::make_unique(yylhs.location); } -#line 2046 "parser.cpp" +#line 2045 "parser.cpp" break; case 13: // declaration: "#/" -#line 281 "parser.ypp" +#line 275 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_end = std::make_unique(yylhs.location); } -#line 2052 "parser.cpp" +#line 2051 "parser.cpp" break; case 14: // declaration: decl_usingtree -#line 282 "parser.ypp" +#line 276 "parser.ypp" { yylhs.value.as < ast::decl > ().as_usingtree = std::move(yystack_[0].value.as < ast::decl_usingtree::ptr > ()); } -#line 2058 "parser.cpp" +#line 2057 "parser.cpp" break; case 15: // declaration: decl_constant -#line 283 "parser.ypp" +#line 277 "parser.ypp" { yylhs.value.as < ast::decl > ().as_constant = std::move(yystack_[0].value.as < ast::decl_constant::ptr > ()); } -#line 2064 "parser.cpp" +#line 2063 "parser.cpp" break; case 16: // declaration: decl_thread -#line 284 "parser.ypp" +#line 278 "parser.ypp" { yylhs.value.as < ast::decl > ().as_thread = std::move(yystack_[0].value.as < ast::decl_thread::ptr > ()); } -#line 2070 "parser.cpp" +#line 2069 "parser.cpp" break; case 17: // decl_usingtree: "#using_animtree" "(" expr_string ")" ";" -#line 289 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } -#line 2076 "parser.cpp" +#line 283 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } +#line 2075 "parser.cpp" break; case 18: // decl_constant: expr_identifier "=" expr ";" -#line 294 "parser.ypp" +#line 288 "parser.ypp" { yylhs.value.as < ast::decl_constant::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2082 "parser.cpp" +#line 2081 "parser.cpp" break; case 19: // decl_thread: expr_identifier "(" expr_parameters ")" stmt_block -#line 299 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2088 "parser.cpp" +#line 293 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } +#line 2087 "parser.cpp" break; case 20: // stmt: stmt_dev -#line 303 "parser.ypp" +#line 297 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2094 "parser.cpp" +#line 2093 "parser.cpp" break; case 21: // stmt: stmt_block -#line 304 "parser.ypp" +#line 298 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2100 "parser.cpp" +#line 2099 "parser.cpp" break; case 22: // stmt: stmt_call -#line 305 "parser.ypp" +#line 299 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_call = std::move(yystack_[0].value.as < ast::stmt_call::ptr > ()); } -#line 2106 "parser.cpp" +#line 2105 "parser.cpp" break; case 23: // stmt: stmt_assign -#line 306 "parser.ypp" +#line 300 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_assign = std::move(yystack_[0].value.as < ast::stmt_assign::ptr > ()); } -#line 2112 "parser.cpp" +#line 2111 "parser.cpp" break; case 24: // stmt: stmt_endon -#line 307 "parser.ypp" +#line 301 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_endon = std::move(yystack_[0].value.as < ast::stmt_endon::ptr > ()); } -#line 2118 "parser.cpp" +#line 2117 "parser.cpp" break; case 25: // stmt: stmt_notify -#line 308 "parser.ypp" +#line 302 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_notify = std::move(yystack_[0].value.as < ast::stmt_notify::ptr > ()); } -#line 2124 "parser.cpp" +#line 2123 "parser.cpp" break; case 26: // stmt: stmt_wait -#line 309 "parser.ypp" +#line 303 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_wait = std::move(yystack_[0].value.as < ast::stmt_wait::ptr > ()); } -#line 2130 "parser.cpp" +#line 2129 "parser.cpp" break; case 27: // stmt: stmt_waittill -#line 310 "parser.ypp" +#line 304 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittill = std::move(yystack_[0].value.as < ast::stmt_waittill::ptr > ()); } -#line 2136 "parser.cpp" +#line 2135 "parser.cpp" break; case 28: // stmt: stmt_waittillmatch -#line 311 "parser.ypp" +#line 305 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillmatch = std::move(yystack_[0].value.as < ast::stmt_waittillmatch::ptr > ()); } -#line 2142 "parser.cpp" +#line 2141 "parser.cpp" break; case 29: // stmt: stmt_waittillframeend -#line 312 "parser.ypp" +#line 306 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillframeend = std::move(yystack_[0].value.as < ast::stmt_waittillframeend::ptr > ()); } -#line 2148 "parser.cpp" +#line 2147 "parser.cpp" break; case 30: // stmt: stmt_waitframe -#line 313 "parser.ypp" +#line 307 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waitframe = std::move(yystack_[0].value.as < ast::stmt_waitframe::ptr > ()); } -#line 2154 "parser.cpp" +#line 2153 "parser.cpp" break; case 31: // stmt: stmt_if -#line 314 "parser.ypp" +#line 308 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_if = std::move(yystack_[0].value.as < ast::stmt_if::ptr > ()); } -#line 2160 "parser.cpp" +#line 2159 "parser.cpp" break; case 32: // stmt: stmt_ifelse -#line 315 "parser.ypp" +#line 309 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_ifelse = std::move(yystack_[0].value.as < ast::stmt_ifelse::ptr > ()); } -#line 2166 "parser.cpp" +#line 2165 "parser.cpp" break; case 33: // stmt: stmt_while -#line 316 "parser.ypp" +#line 310 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_while = std::move(yystack_[0].value.as < ast::stmt_while::ptr > ()); } -#line 2172 "parser.cpp" +#line 2171 "parser.cpp" break; case 34: // stmt: stmt_dowhile -#line 317 "parser.ypp" +#line 311 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_dowhile = std::move(yystack_[0].value.as < ast::stmt_dowhile::ptr > ()); } -#line 2178 "parser.cpp" +#line 2177 "parser.cpp" break; case 35: // stmt: stmt_for -#line 318 "parser.ypp" +#line 312 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_for = std::move(yystack_[0].value.as < ast::stmt_for::ptr > ()); } -#line 2184 "parser.cpp" +#line 2183 "parser.cpp" break; case 36: // stmt: stmt_foreach -#line 319 "parser.ypp" +#line 313 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_foreach = std::move(yystack_[0].value.as < ast::stmt_foreach::ptr > ()); } -#line 2190 "parser.cpp" +#line 2189 "parser.cpp" break; case 37: // stmt: stmt_switch -#line 320 "parser.ypp" +#line 314 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_switch = std::move(yystack_[0].value.as < ast::stmt_switch::ptr > ()); } -#line 2196 "parser.cpp" +#line 2195 "parser.cpp" break; case 38: // stmt: stmt_case -#line 321 "parser.ypp" +#line 315 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_case = std::move(yystack_[0].value.as < ast::stmt_case::ptr > ()); } -#line 2202 "parser.cpp" +#line 2201 "parser.cpp" break; case 39: // stmt: stmt_default -#line 322 "parser.ypp" +#line 316 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_default = std::move(yystack_[0].value.as < ast::stmt_default::ptr > ()); } -#line 2208 "parser.cpp" +#line 2207 "parser.cpp" break; case 40: // stmt: stmt_break -#line 323 "parser.ypp" +#line 317 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_break = std::move(yystack_[0].value.as < ast::stmt_break::ptr > ()); } -#line 2214 "parser.cpp" +#line 2213 "parser.cpp" break; case 41: // stmt: stmt_continue -#line 324 "parser.ypp" +#line 318 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_continue = std::move(yystack_[0].value.as < ast::stmt_continue::ptr > ()); } -#line 2220 "parser.cpp" +#line 2219 "parser.cpp" break; case 42: // stmt: stmt_return -#line 325 "parser.ypp" +#line 319 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_return = std::move(yystack_[0].value.as < ast::stmt_return::ptr > ()); } -#line 2226 "parser.cpp" +#line 2225 "parser.cpp" break; case 43: // stmt: stmt_breakpoint -#line 326 "parser.ypp" +#line 320 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_breakpoint = std::move(yystack_[0].value.as < ast::stmt_breakpoint::ptr > ()); } -#line 2232 "parser.cpp" +#line 2231 "parser.cpp" break; case 44: // stmt: stmt_prof_begin -#line 327 "parser.ypp" +#line 321 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_begin = std::move(yystack_[0].value.as < ast::stmt_prof_begin::ptr > ()); } -#line 2238 "parser.cpp" +#line 2237 "parser.cpp" break; case 45: // stmt: stmt_prof_end -#line 328 "parser.ypp" +#line 322 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_end = std::move(yystack_[0].value.as < ast::stmt_prof_end::ptr > ()); } -#line 2244 "parser.cpp" +#line 2243 "parser.cpp" break; case 46: // stmt_dev: "/#" stmt_list "#/" -#line 332 "parser.ypp" +#line 326 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2250 "parser.cpp" +#line 2249 "parser.cpp" break; case 47: // stmt_dev: "/#" "#/" -#line 333 "parser.ypp" +#line 327 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2256 "parser.cpp" +#line 2255 "parser.cpp" break; case 48: // stmt_block: "{" stmt_list "}" -#line 337 "parser.ypp" +#line 331 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2262 "parser.cpp" +#line 2261 "parser.cpp" break; case 49: // stmt_block: "{" "}" -#line 338 "parser.ypp" +#line 332 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2268 "parser.cpp" +#line 2267 "parser.cpp" break; case 50: // stmt_list: stmt_list stmt -#line 343 "parser.ypp" +#line 337 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2274 "parser.cpp" +#line 2273 "parser.cpp" break; case 51: // stmt_list: stmt -#line 345 "parser.ypp" +#line 339 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2280 "parser.cpp" +#line 2279 "parser.cpp" break; case 52: // stmt_expr: expr_assign -#line 350 "parser.ypp" +#line 344 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2286 "parser.cpp" +#line 2285 "parser.cpp" break; case 53: // stmt_expr: expr_increment -#line 352 "parser.ypp" +#line 346 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2292 "parser.cpp" +#line 2291 "parser.cpp" break; case 54: // stmt_expr: expr_decrement -#line 354 "parser.ypp" +#line 348 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2298 "parser.cpp" +#line 2297 "parser.cpp" break; case 55: // stmt_expr: %empty -#line 356 "parser.ypp" +#line 350 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2304 "parser.cpp" +#line 2303 "parser.cpp" break; case 56: // stmt_call: expr_call ";" -#line 361 "parser.ypp" +#line 355 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_call::ptr > ()))); } -#line 2310 "parser.cpp" +#line 2309 "parser.cpp" break; case 57: // stmt_call: expr_method ";" -#line 363 "parser.ypp" +#line 357 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_method::ptr > ()))); } -#line 2316 "parser.cpp" +#line 2315 "parser.cpp" break; case 58: // stmt_assign: expr_assign ";" -#line 368 "parser.ypp" +#line 362 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2322 "parser.cpp" +#line 2321 "parser.cpp" break; case 59: // stmt_assign: expr_increment ";" -#line 370 "parser.ypp" +#line 364 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2328 "parser.cpp" +#line 2327 "parser.cpp" break; case 60: // stmt_assign: expr_decrement ";" -#line 372 "parser.ypp" +#line 366 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2334 "parser.cpp" +#line 2333 "parser.cpp" break; case 61: // stmt_endon: expr_object "endon" "(" expr ")" ";" -#line 377 "parser.ypp" +#line 371 "parser.ypp" { yylhs.value.as < ast::stmt_endon::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ())); } -#line 2340 "parser.cpp" +#line 2339 "parser.cpp" break; case 62: // stmt_notify: expr_object "notify" "(" expr "," expr_arguments_no_empty ")" ";" -#line 382 "parser.ypp" +#line 376 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2346 "parser.cpp" +#line 2345 "parser.cpp" break; case 63: // stmt_notify: expr_object "notify" "(" expr ")" ";" -#line 384 "parser.ypp" +#line 378 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2352 "parser.cpp" +#line 2351 "parser.cpp" break; case 64: // stmt_wait: "wait" expr ";" -#line 389 "parser.ypp" +#line 383 "parser.ypp" { yylhs.value.as < ast::stmt_wait::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2358 "parser.cpp" +#line 2357 "parser.cpp" break; case 65: // stmt_waittill: expr_object "waittill" "(" expr "," expr_arguments_no_empty ")" ";" -#line 394 "parser.ypp" +#line 388 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2364 "parser.cpp" +#line 2363 "parser.cpp" break; case 66: // stmt_waittill: expr_object "waittill" "(" expr ")" ";" -#line 396 "parser.ypp" +#line 390 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2370 "parser.cpp" +#line 2369 "parser.cpp" break; case 67: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr "," expr_arguments_no_empty ")" ";" -#line 401 "parser.ypp" +#line 395 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2376 "parser.cpp" +#line 2375 "parser.cpp" break; case 68: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr ")" ";" -#line 403 "parser.ypp" +#line 397 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2382 "parser.cpp" +#line 2381 "parser.cpp" break; case 69: // stmt_waittillframeend: "waittillframeend" ";" -#line 408 "parser.ypp" +#line 402 "parser.ypp" { yylhs.value.as < ast::stmt_waittillframeend::ptr > () = std::make_unique(yylhs.location); } -#line 2388 "parser.cpp" +#line 2387 "parser.cpp" break; case 70: // stmt_waitframe: "waitframe" ";" -#line 413 "parser.ypp" +#line 407 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2394 "parser.cpp" +#line 2393 "parser.cpp" break; case 71: // stmt_waitframe: "waitframe" "(" ")" ";" -#line 415 "parser.ypp" +#line 409 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2400 "parser.cpp" +#line 2399 "parser.cpp" break; case 72: // stmt_if: "if" "(" expr ")" stmt -#line 420 "parser.ypp" +#line 414 "parser.ypp" { yylhs.value.as < ast::stmt_if::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2406 "parser.cpp" +#line 2405 "parser.cpp" break; case 73: // stmt_ifelse: "if" "(" expr ")" stmt "else" stmt -#line 425 "parser.ypp" +#line 419 "parser.ypp" { yylhs.value.as < ast::stmt_ifelse::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::stmt > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2412 "parser.cpp" +#line 2411 "parser.cpp" break; case 74: // stmt_while: "while" "(" expr ")" stmt -#line 430 "parser.ypp" +#line 424 "parser.ypp" { yylhs.value.as < ast::stmt_while::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2418 "parser.cpp" +#line 2417 "parser.cpp" break; case 75: // stmt_dowhile: "do" stmt "while" "(" expr ")" ";" -#line 435 "parser.ypp" +#line 429 "parser.ypp" { yylhs.value.as < ast::stmt_dowhile::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[5].value.as < ast::stmt > ())); } -#line 2424 "parser.cpp" +#line 2423 "parser.cpp" break; case 76: // stmt_for: "for" "(" stmt_expr ";" expr_or_empty ";" stmt_expr ")" stmt -#line 440 "parser.ypp" +#line 434 "parser.ypp" { yylhs.value.as < ast::stmt_for::ptr > () = std::make_unique(yylhs.location, ast::stmt(std::move(yystack_[6].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[4].value.as < ast::expr > ()), ast::stmt(std::move(yystack_[2].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2430 "parser.cpp" +#line 2429 "parser.cpp" break; case 77: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt -#line 445 "parser.ypp" +#line 439 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2436 "parser.cpp" +#line 2435 "parser.cpp" break; case 78: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt -#line 447 "parser.ypp" +#line 441 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[6].value.as < ast::expr_identifier::ptr > ())), ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2442 "parser.cpp" +#line 2441 "parser.cpp" break; case 79: // stmt_switch: "switch" "(" expr ")" stmt_block -#line 452 "parser.ypp" +#line 446 "parser.ypp" { yylhs.value.as < ast::stmt_switch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2448 "parser.cpp" +#line 2447 "parser.cpp" break; case 80: // stmt_case: "case" expr_integer ":" -#line 457 "parser.ypp" +#line 451 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_integer::ptr > ())), std::make_unique(yylhs.location)); } -#line 2454 "parser.cpp" +#line 2453 "parser.cpp" break; case 81: // stmt_case: "case" expr_string ":" -#line 459 "parser.ypp" +#line 453 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_string::ptr > ())), std::make_unique(yylhs.location)); } -#line 2460 "parser.cpp" +#line 2459 "parser.cpp" break; case 82: // stmt_default: "default" ":" -#line 464 "parser.ypp" +#line 458 "parser.ypp" { yylhs.value.as < ast::stmt_default::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2466 "parser.cpp" +#line 2465 "parser.cpp" break; case 83: // stmt_break: "break" ";" -#line 469 "parser.ypp" +#line 463 "parser.ypp" { yylhs.value.as < ast::stmt_break::ptr > () = std::make_unique(yylhs.location); } -#line 2472 "parser.cpp" +#line 2471 "parser.cpp" break; case 84: // stmt_continue: "continue" ";" -#line 474 "parser.ypp" +#line 468 "parser.ypp" { yylhs.value.as < ast::stmt_continue::ptr > () = std::make_unique(yylhs.location); } -#line 2478 "parser.cpp" +#line 2477 "parser.cpp" break; case 85: // stmt_return: "return" expr ";" -#line 479 "parser.ypp" +#line 473 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2484 "parser.cpp" +#line 2483 "parser.cpp" break; case 86: // stmt_return: "return" ";" -#line 481 "parser.ypp" +#line 475 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2490 "parser.cpp" +#line 2489 "parser.cpp" break; case 87: // stmt_breakpoint: "breakpoint" ";" -#line 486 "parser.ypp" +#line 480 "parser.ypp" { yylhs.value.as < ast::stmt_breakpoint::ptr > () = std::make_unique(yylhs.location); } -#line 2496 "parser.cpp" +#line 2495 "parser.cpp" break; case 88: // stmt_prof_begin: "prof_begin" "(" expr_arguments ")" ";" -#line 491 "parser.ypp" +#line 485 "parser.ypp" { yylhs.value.as < ast::stmt_prof_begin::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2502 "parser.cpp" +#line 2501 "parser.cpp" break; case 89: // stmt_prof_end: "prof_end" "(" expr_arguments ")" ";" -#line 496 "parser.ypp" +#line 490 "parser.ypp" { yylhs.value.as < ast::stmt_prof_end::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2508 "parser.cpp" +#line 2507 "parser.cpp" break; case 90: // expr: expr_ternary -#line 500 "parser.ypp" +#line 494 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2514 "parser.cpp" +#line 2513 "parser.cpp" break; case 91: // expr: expr_binary -#line 501 "parser.ypp" +#line 495 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2520 "parser.cpp" +#line 2519 "parser.cpp" break; case 92: // expr: expr_primitive -#line 502 "parser.ypp" +#line 496 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2526 "parser.cpp" +#line 2525 "parser.cpp" break; case 93: // expr_or_empty: expr -#line 506 "parser.ypp" +#line 500 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2532 "parser.cpp" +#line 2531 "parser.cpp" break; case 94: // expr_or_empty: %empty -#line 507 "parser.ypp" +#line 501 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location); } -#line 2538 "parser.cpp" +#line 2537 "parser.cpp" break; case 95: // expr_assign: expr_object "=" expr -#line 512 "parser.ypp" +#line 506 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2544 "parser.cpp" +#line 2543 "parser.cpp" break; case 96: // expr_assign: expr_object "|=" expr -#line 514 "parser.ypp" +#line 508 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2550 "parser.cpp" +#line 2549 "parser.cpp" break; case 97: // expr_assign: expr_object "&=" expr -#line 516 "parser.ypp" +#line 510 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2556 "parser.cpp" +#line 2555 "parser.cpp" break; case 98: // expr_assign: expr_object "^=" expr -#line 518 "parser.ypp" +#line 512 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2562 "parser.cpp" +#line 2561 "parser.cpp" break; case 99: // expr_assign: expr_object "<<=" expr -#line 520 "parser.ypp" +#line 514 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()),std::move( yystack_[0].value.as < ast::expr > ())); } -#line 2568 "parser.cpp" +#line 2567 "parser.cpp" break; case 100: // expr_assign: expr_object ">>=" expr -#line 522 "parser.ypp" +#line 516 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2574 "parser.cpp" +#line 2573 "parser.cpp" break; case 101: // expr_assign: expr_object "+=" expr -#line 524 "parser.ypp" +#line 518 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2580 "parser.cpp" +#line 2579 "parser.cpp" break; case 102: // expr_assign: expr_object "-=" expr -#line 526 "parser.ypp" +#line 520 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2586 "parser.cpp" +#line 2585 "parser.cpp" break; case 103: // expr_assign: expr_object "*=" expr -#line 528 "parser.ypp" +#line 522 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2592 "parser.cpp" +#line 2591 "parser.cpp" break; case 104: // expr_assign: expr_object "/=" expr -#line 530 "parser.ypp" +#line 524 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2598 "parser.cpp" +#line 2597 "parser.cpp" break; case 105: // expr_assign: expr_object "%=" expr -#line 532 "parser.ypp" +#line 526 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2604 "parser.cpp" +#line 2603 "parser.cpp" break; case 106: // expr_increment: "++" expr_object -#line 537 "parser.ypp" +#line 531 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2610 "parser.cpp" +#line 2609 "parser.cpp" break; case 107: // expr_increment: expr_object "++" -#line 539 "parser.ypp" +#line 533 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2616 "parser.cpp" +#line 2615 "parser.cpp" break; case 108: // expr_decrement: "--" expr_object -#line 544 "parser.ypp" +#line 538 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2622 "parser.cpp" +#line 2621 "parser.cpp" break; case 109: // expr_decrement: expr_object "--" -#line 546 "parser.ypp" +#line 540 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2628 "parser.cpp" +#line 2627 "parser.cpp" break; case 110: // expr_ternary: expr "?" expr ":" expr -#line 551 "parser.ypp" +#line 545 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2634 "parser.cpp" +#line 2633 "parser.cpp" break; case 111: // expr_binary: expr "||" expr -#line 556 "parser.ypp" +#line 550 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2640 "parser.cpp" +#line 2639 "parser.cpp" break; case 112: // expr_binary: expr "&&" expr -#line 558 "parser.ypp" +#line 552 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2646 "parser.cpp" +#line 2645 "parser.cpp" break; case 113: // expr_binary: expr "==" expr -#line 560 "parser.ypp" +#line 554 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2652 "parser.cpp" +#line 2651 "parser.cpp" break; case 114: // expr_binary: expr "!=" expr -#line 562 "parser.ypp" +#line 556 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2658 "parser.cpp" +#line 2657 "parser.cpp" break; case 115: // expr_binary: expr "<=" expr -#line 564 "parser.ypp" +#line 558 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2664 "parser.cpp" +#line 2663 "parser.cpp" break; case 116: // expr_binary: expr ">=" expr -#line 566 "parser.ypp" +#line 560 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2670 "parser.cpp" +#line 2669 "parser.cpp" break; case 117: // expr_binary: expr "<" expr -#line 568 "parser.ypp" +#line 562 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2676 "parser.cpp" +#line 2675 "parser.cpp" break; case 118: // expr_binary: expr ">" expr -#line 570 "parser.ypp" +#line 564 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2682 "parser.cpp" +#line 2681 "parser.cpp" break; case 119: // expr_binary: expr "|" expr -#line 572 "parser.ypp" +#line 566 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2688 "parser.cpp" +#line 2687 "parser.cpp" break; case 120: // expr_binary: expr "&" expr -#line 574 "parser.ypp" +#line 568 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2694 "parser.cpp" +#line 2693 "parser.cpp" break; case 121: // expr_binary: expr "^" expr -#line 576 "parser.ypp" +#line 570 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2700 "parser.cpp" +#line 2699 "parser.cpp" break; case 122: // expr_binary: expr "<<" expr -#line 578 "parser.ypp" +#line 572 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2706 "parser.cpp" +#line 2705 "parser.cpp" break; case 123: // expr_binary: expr ">>" expr -#line 580 "parser.ypp" +#line 574 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2712 "parser.cpp" +#line 2711 "parser.cpp" break; case 124: // expr_binary: expr "+" expr -#line 582 "parser.ypp" +#line 576 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2718 "parser.cpp" +#line 2717 "parser.cpp" break; case 125: // expr_binary: expr "-" expr -#line 584 "parser.ypp" +#line 578 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2724 "parser.cpp" +#line 2723 "parser.cpp" break; case 126: // expr_binary: expr "*" expr -#line 586 "parser.ypp" +#line 580 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2730 "parser.cpp" +#line 2729 "parser.cpp" break; case 127: // expr_binary: expr "/" expr -#line 588 "parser.ypp" +#line 582 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2736 "parser.cpp" +#line 2735 "parser.cpp" break; case 128: // expr_binary: expr "%" expr -#line 590 "parser.ypp" +#line 584 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2742 "parser.cpp" +#line 2741 "parser.cpp" break; case 129: // expr_primitive: expr_complement -#line 594 "parser.ypp" +#line 588 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_complement::ptr > ()); } -#line 2748 "parser.cpp" +#line 2747 "parser.cpp" break; case 130: // expr_primitive: expr_not -#line 595 "parser.ypp" +#line 589 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_not::ptr > ()); } -#line 2754 "parser.cpp" +#line 2753 "parser.cpp" break; case 131: // expr_primitive: expr_call -#line 596 "parser.ypp" +#line 590 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 2760 "parser.cpp" +#line 2759 "parser.cpp" break; case 132: // expr_primitive: expr_method -#line 597 "parser.ypp" +#line 591 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 2766 "parser.cpp" +#line 2765 "parser.cpp" break; case 133: // expr_primitive: expr_add_array -#line 598 "parser.ypp" +#line 592 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_add_array::ptr > ()); } -#line 2772 "parser.cpp" +#line 2771 "parser.cpp" break; case 134: // expr_primitive: expr_reference -#line 599 "parser.ypp" +#line 593 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_reference::ptr > ()); } -#line 2778 "parser.cpp" +#line 2777 "parser.cpp" break; case 135: // expr_primitive: expr_array -#line 600 "parser.ypp" +#line 594 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 2784 "parser.cpp" +#line 2783 "parser.cpp" break; case 136: // expr_primitive: expr_field -#line 601 "parser.ypp" +#line 595 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 2790 "parser.cpp" +#line 2789 "parser.cpp" break; case 137: // expr_primitive: expr_size -#line 602 "parser.ypp" +#line 596 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_size::ptr > ()); } -#line 2796 "parser.cpp" +#line 2795 "parser.cpp" break; case 138: // expr_primitive: expr_paren -#line 603 "parser.ypp" +#line 597 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_paren::ptr > ()); } -#line 2802 "parser.cpp" +#line 2801 "parser.cpp" break; case 139: // expr_primitive: expr_thisthread -#line 604 "parser.ypp" +#line 598 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_thisthread::ptr > ()); } -#line 2808 "parser.cpp" +#line 2807 "parser.cpp" break; case 140: // expr_primitive: expr_empty_array -#line 605 "parser.ypp" +#line 599 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_empty_array::ptr > ()); } -#line 2814 "parser.cpp" +#line 2813 "parser.cpp" break; case 141: // expr_primitive: expr_undefined -#line 606 "parser.ypp" +#line 600 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_undefined::ptr > ()); } -#line 2820 "parser.cpp" +#line 2819 "parser.cpp" break; case 142: // expr_primitive: expr_game -#line 607 "parser.ypp" +#line 601 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 2826 "parser.cpp" +#line 2825 "parser.cpp" break; case 143: // expr_primitive: expr_self -#line 608 "parser.ypp" +#line 602 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 2832 "parser.cpp" +#line 2831 "parser.cpp" break; case 144: // expr_primitive: expr_anim -#line 609 "parser.ypp" +#line 603 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 2838 "parser.cpp" +#line 2837 "parser.cpp" break; case 145: // expr_primitive: expr_level -#line 610 "parser.ypp" +#line 604 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 2844 "parser.cpp" +#line 2843 "parser.cpp" break; case 146: // expr_primitive: expr_animation -#line 611 "parser.ypp" +#line 605 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animation::ptr > ()); } -#line 2850 "parser.cpp" +#line 2849 "parser.cpp" break; case 147: // expr_primitive: expr_animtree -#line 612 "parser.ypp" +#line 606 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animtree::ptr > ()); } -#line 2856 "parser.cpp" +#line 2855 "parser.cpp" break; case 148: // expr_primitive: expr_identifier -#line 613 "parser.ypp" +#line 607 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 2862 "parser.cpp" +#line 2861 "parser.cpp" break; case 149: // expr_primitive: expr_istring -#line 614 "parser.ypp" +#line 608 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istring::ptr > ()); } -#line 2868 "parser.cpp" +#line 2867 "parser.cpp" break; case 150: // expr_primitive: expr_string -#line 615 "parser.ypp" +#line 609 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_string::ptr > ()); } -#line 2874 "parser.cpp" +#line 2873 "parser.cpp" break; case 151: // expr_primitive: expr_color -#line 616 "parser.ypp" +#line 610 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_color::ptr > ()); } -#line 2880 "parser.cpp" +#line 2879 "parser.cpp" break; case 152: // expr_primitive: expr_vector -#line 617 "parser.ypp" +#line 611 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_vector::ptr > ()); } -#line 2886 "parser.cpp" +#line 2885 "parser.cpp" break; case 153: // expr_primitive: expr_float -#line 618 "parser.ypp" +#line 612 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_float::ptr > ()); } -#line 2892 "parser.cpp" +#line 2891 "parser.cpp" break; case 154: // expr_primitive: expr_integer -#line 619 "parser.ypp" +#line 613 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_integer::ptr > ()); } -#line 2898 "parser.cpp" +#line 2897 "parser.cpp" break; case 155: // expr_primitive: expr_false -#line 620 "parser.ypp" +#line 614 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_false::ptr > ()); } -#line 2904 "parser.cpp" +#line 2903 "parser.cpp" break; case 156: // expr_primitive: expr_true -#line 621 "parser.ypp" +#line 615 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_true::ptr > ()); } -#line 2910 "parser.cpp" +#line 2909 "parser.cpp" break; case 157: // expr_complement: "~" expr -#line 626 "parser.ypp" +#line 620 "parser.ypp" { yylhs.value.as < ast::expr_complement::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2916 "parser.cpp" +#line 2915 "parser.cpp" break; case 158: // expr_not: "!" expr -#line 631 "parser.ypp" +#line 625 "parser.ypp" { yylhs.value.as < ast::expr_not::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2922 "parser.cpp" +#line 2921 "parser.cpp" break; case 159: // expr_call: expr_function -#line 635 "parser.ypp" +#line 629 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2928 "parser.cpp" +#line 2927 "parser.cpp" break; case 160: // expr_call: expr_pointer -#line 636 "parser.ypp" +#line 630 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2934 "parser.cpp" +#line 2933 "parser.cpp" break; case 161: // expr_method: expr_object expr_function -#line 639 "parser.ypp" +#line 633 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2940 "parser.cpp" +#line 2939 "parser.cpp" break; case 162: // expr_method: expr_object expr_pointer -#line 640 "parser.ypp" +#line 634 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2946 "parser.cpp" +#line 2945 "parser.cpp" break; case 163: // expr_function: expr_identifier "(" expr_arguments ")" -#line 645 "parser.ypp" +#line 639 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2952 "parser.cpp" +#line 2951 "parser.cpp" break; case 164: // expr_function: expr_path "::" expr_identifier "(" expr_arguments ")" -#line 647 "parser.ypp" +#line 641 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2958 "parser.cpp" +#line 2957 "parser.cpp" break; case 165: // expr_function: "thread" expr_identifier "(" expr_arguments ")" -#line 649 "parser.ypp" +#line 643 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2964 "parser.cpp" +#line 2963 "parser.cpp" break; case 166: // expr_function: "thread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 651 "parser.ypp" +#line 645 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2970 "parser.cpp" +#line 2969 "parser.cpp" break; case 167: // expr_function: "childthread" expr_identifier "(" expr_arguments ")" -#line 653 "parser.ypp" +#line 647 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2976 "parser.cpp" +#line 2975 "parser.cpp" break; case 168: // expr_function: "childthread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 655 "parser.ypp" +#line 649 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2982 "parser.cpp" +#line 2981 "parser.cpp" break; case 169: // expr_pointer: "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 660 "parser.ypp" +#line 654 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2988 "parser.cpp" +#line 2987 "parser.cpp" break; case 170: // expr_pointer: "thread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 662 "parser.ypp" +#line 656 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2994 "parser.cpp" +#line 2993 "parser.cpp" break; case 171: // expr_pointer: "childthread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 664 "parser.ypp" +#line 658 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3000 "parser.cpp" +#line 2999 "parser.cpp" break; case 172: // expr_pointer: "call" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 666 "parser.ypp" +#line 660 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::builtin); } -#line 3006 "parser.cpp" +#line 3005 "parser.cpp" break; case 173: // expr_add_array: "[" expr_arguments_no_empty "]" -#line 671 "parser.ypp" +#line 665 "parser.ypp" { yylhs.value.as < ast::expr_add_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ())); } -#line 3012 "parser.cpp" +#line 3011 "parser.cpp" break; case 174: // expr_parameters: expr_parameters "," expr_identifier -#line 676 "parser.ypp" +#line 670 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3018 "parser.cpp" +#line 3017 "parser.cpp" break; case 175: // expr_parameters: expr_identifier -#line 678 "parser.ypp" +#line 672 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3024 "parser.cpp" +#line 3023 "parser.cpp" break; case 176: // expr_parameters: %empty -#line 680 "parser.ypp" +#line 674 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); } -#line 3030 "parser.cpp" +#line 3029 "parser.cpp" break; case 177: // expr_arguments: expr_arguments_no_empty -#line 685 "parser.ypp" +#line 679 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[0].value.as < ast::expr_arguments::ptr > ()); } -#line 3036 "parser.cpp" +#line 3035 "parser.cpp" break; case 178: // expr_arguments: %empty -#line 687 "parser.ypp" +#line 681 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); } -#line 3042 "parser.cpp" +#line 3041 "parser.cpp" break; case 179: // expr_arguments_no_empty: expr_arguments "," expr -#line 692 "parser.ypp" +#line 686 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ()); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3048 "parser.cpp" +#line 3047 "parser.cpp" break; case 180: // expr_arguments_no_empty: expr -#line 694 "parser.ypp" +#line 688 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3054 "parser.cpp" +#line 3053 "parser.cpp" break; case 181: // expr_reference: "::" expr_identifier -#line 699 "parser.ypp" +#line 693 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3060 "parser.cpp" +#line 3059 "parser.cpp" break; case 182: // expr_reference: expr_path "::" expr_identifier -#line 701 "parser.ypp" +#line 695 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_path::ptr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3066 "parser.cpp" +#line 3065 "parser.cpp" break; case 183: // expr_array: expr_object "[" expr "]" -#line 706 "parser.ypp" +#line 700 "parser.ypp" { yylhs.value.as < ast::expr_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3072 "parser.cpp" +#line 3071 "parser.cpp" break; case 184: // expr_field: expr_object "." expr_identifier -#line 711 "parser.ypp" +#line 705 "parser.ypp" { yylhs.value.as < ast::expr_field::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3078 "parser.cpp" +#line 3077 "parser.cpp" break; case 185: // expr_size: expr_object ".size" -#line 716 "parser.ypp" +#line 710 "parser.ypp" { yylhs.value.as < ast::expr_size::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3084 "parser.cpp" +#line 3083 "parser.cpp" break; case 186: // expr_paren: "(" expr ")" -#line 721 "parser.ypp" +#line 715 "parser.ypp" { yylhs.value.as < ast::expr_paren::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3090 "parser.cpp" +#line 3089 "parser.cpp" break; case 187: // expr_object: expr_call -#line 725 "parser.ypp" +#line 719 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 3096 "parser.cpp" +#line 3095 "parser.cpp" break; case 188: // expr_object: expr_method -#line 726 "parser.ypp" +#line 720 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 3102 "parser.cpp" +#line 3101 "parser.cpp" break; case 189: // expr_object: expr_array -#line 727 "parser.ypp" +#line 721 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 3108 "parser.cpp" +#line 3107 "parser.cpp" break; case 190: // expr_object: expr_field -#line 728 "parser.ypp" +#line 722 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 3114 "parser.cpp" +#line 3113 "parser.cpp" break; case 191: // expr_object: expr_game -#line 729 "parser.ypp" +#line 723 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 3120 "parser.cpp" +#line 3119 "parser.cpp" break; case 192: // expr_object: expr_self -#line 730 "parser.ypp" +#line 724 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 3126 "parser.cpp" +#line 3125 "parser.cpp" break; case 193: // expr_object: expr_anim -#line 731 "parser.ypp" +#line 725 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 3132 "parser.cpp" +#line 3131 "parser.cpp" break; case 194: // expr_object: expr_level -#line 732 "parser.ypp" +#line 726 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 3138 "parser.cpp" +#line 3137 "parser.cpp" break; case 195: // expr_object: expr_identifier -#line 733 "parser.ypp" +#line 727 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 3144 "parser.cpp" +#line 3143 "parser.cpp" break; case 196: // expr_thisthread: "thisthread" -#line 738 "parser.ypp" +#line 732 "parser.ypp" { yylhs.value.as < ast::expr_thisthread::ptr > () = std::make_unique(yylhs.location); } -#line 3150 "parser.cpp" +#line 3149 "parser.cpp" break; case 197: // expr_empty_array: "[" "]" -#line 743 "parser.ypp" +#line 737 "parser.ypp" { yylhs.value.as < ast::expr_empty_array::ptr > () = std::make_unique(yylhs.location); } -#line 3156 "parser.cpp" +#line 3155 "parser.cpp" break; case 198: // expr_undefined: "undefined" -#line 748 "parser.ypp" +#line 742 "parser.ypp" { yylhs.value.as < ast::expr_undefined::ptr > () = std::make_unique(yylhs.location); } -#line 3162 "parser.cpp" +#line 3161 "parser.cpp" break; case 199: // expr_game: "game" -#line 753 "parser.ypp" +#line 747 "parser.ypp" { yylhs.value.as < ast::expr_game::ptr > () = std::make_unique(yylhs.location); } -#line 3168 "parser.cpp" +#line 3167 "parser.cpp" break; case 200: // expr_self: "self" -#line 758 "parser.ypp" +#line 752 "parser.ypp" { yylhs.value.as < ast::expr_self::ptr > () = std::make_unique(yylhs.location); } -#line 3174 "parser.cpp" +#line 3173 "parser.cpp" break; case 201: // expr_anim: "anim" -#line 763 "parser.ypp" +#line 757 "parser.ypp" { yylhs.value.as < ast::expr_anim::ptr > () = std::make_unique(yylhs.location); } -#line 3180 "parser.cpp" +#line 3179 "parser.cpp" break; case 202: // expr_level: "level" -#line 768 "parser.ypp" +#line 762 "parser.ypp" { yylhs.value.as < ast::expr_level::ptr > () = std::make_unique(yylhs.location); } -#line 3186 "parser.cpp" +#line 3185 "parser.cpp" break; case 203: // expr_animation: "%" "identifier" -#line 773 "parser.ypp" +#line 767 "parser.ypp" { yylhs.value.as < ast::expr_animation::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3192 "parser.cpp" +#line 3191 "parser.cpp" break; case 204: // expr_animtree: "#animtree" -#line 778 "parser.ypp" +#line 772 "parser.ypp" { yylhs.value.as < ast::expr_animtree::ptr > () = std::make_unique(yylhs.location); } -#line 3198 "parser.cpp" +#line 3197 "parser.cpp" break; case 205: // expr_identifier: "identifier" -#line 783 "parser.ypp" +#line 777 "parser.ypp" { yylhs.value.as < ast::expr_identifier::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3204 "parser.cpp" +#line 3203 "parser.cpp" break; case 206: // expr_path: "path" -#line 788 "parser.ypp" +#line 782 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3210 "parser.cpp" +#line 3209 "parser.cpp" break; case 207: // expr_path: expr_identifier -#line 790 "parser.ypp" +#line 784 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < ast::expr_identifier::ptr > ()->value); } -#line 3216 "parser.cpp" +#line 3215 "parser.cpp" break; case 208: // expr_istring: "localized string" -#line 795 "parser.ypp" +#line 789 "parser.ypp" { yylhs.value.as < ast::expr_istring::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3222 "parser.cpp" +#line 3221 "parser.cpp" break; case 209: // expr_string: "string literal" -#line 800 "parser.ypp" +#line 794 "parser.ypp" { yylhs.value.as < ast::expr_string::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3228 "parser.cpp" +#line 3227 "parser.cpp" break; case 210: // expr_color: "color" -#line 805 "parser.ypp" +#line 799 "parser.ypp" { yylhs.value.as < ast::expr_color::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3234 "parser.cpp" +#line 3233 "parser.cpp" break; case 211: // expr_vector: "(" expr "," expr "," expr ")" -#line 810 "parser.ypp" +#line 804 "parser.ypp" { yylhs.value.as < ast::expr_vector::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3240 "parser.cpp" +#line 3239 "parser.cpp" break; case 212: // expr_float: "-" "float" -#line 815 "parser.ypp" +#line 809 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3246 "parser.cpp" +#line 3245 "parser.cpp" break; case 213: // expr_float: "float" -#line 817 "parser.ypp" +#line 811 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3252 "parser.cpp" +#line 3251 "parser.cpp" break; case 214: // expr_integer: "-" "integer" -#line 822 "parser.ypp" +#line 816 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3258 "parser.cpp" +#line 3257 "parser.cpp" break; case 215: // expr_integer: "integer" -#line 824 "parser.ypp" +#line 818 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3264 "parser.cpp" +#line 3263 "parser.cpp" break; case 216: // expr_false: "false" -#line 829 "parser.ypp" +#line 823 "parser.ypp" { yylhs.value.as < ast::expr_false::ptr > () = std::make_unique(yylhs.location); } -#line 3270 "parser.cpp" +#line 3269 "parser.cpp" break; case 217: // expr_true: "true" -#line 834 "parser.ypp" +#line 828 "parser.ypp" { yylhs.value.as < ast::expr_true::ptr > () = std::make_unique(yylhs.location); } -#line 3276 "parser.cpp" +#line 3275 "parser.cpp" break; -#line 3280 "parser.cpp" +#line 3279 "parser.cpp" default: break; @@ -4446,28 +4445,28 @@ namespace xsk { namespace gsc { namespace s1 { const short parser::yyrline_[] = { - 0, 251, 251, 252, 256, 258, 260, 262, 264, 266, - 271, 275, 280, 281, 282, 283, 284, 288, 293, 298, - 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, - 323, 324, 325, 326, 327, 328, 332, 333, 337, 338, - 342, 344, 349, 351, 353, 356, 360, 362, 367, 369, - 371, 376, 381, 383, 388, 393, 395, 400, 402, 407, - 412, 414, 419, 424, 429, 434, 439, 444, 446, 451, - 456, 458, 463, 468, 473, 478, 480, 485, 490, 495, - 500, 501, 502, 506, 507, 511, 513, 515, 517, 519, - 521, 523, 525, 527, 529, 531, 536, 538, 543, 545, - 550, 555, 557, 559, 561, 563, 565, 567, 569, 571, - 573, 575, 577, 579, 581, 583, 585, 587, 589, 594, - 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, - 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, - 615, 616, 617, 618, 619, 620, 621, 625, 630, 635, - 636, 639, 640, 644, 646, 648, 650, 652, 654, 659, - 661, 663, 665, 670, 675, 677, 680, 684, 687, 691, - 693, 698, 700, 705, 710, 715, 720, 725, 726, 727, - 728, 729, 730, 731, 732, 733, 737, 742, 747, 752, - 757, 762, 767, 772, 777, 782, 787, 789, 794, 799, - 804, 809, 814, 816, 821, 823, 828, 833 + 0, 245, 245, 246, 250, 252, 254, 256, 258, 260, + 265, 269, 274, 275, 276, 277, 278, 282, 287, 292, + 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 326, 327, 331, 332, + 336, 338, 343, 345, 347, 350, 354, 356, 361, 363, + 365, 370, 375, 377, 382, 387, 389, 394, 396, 401, + 406, 408, 413, 418, 423, 428, 433, 438, 440, 445, + 450, 452, 457, 462, 467, 472, 474, 479, 484, 489, + 494, 495, 496, 500, 501, 505, 507, 509, 511, 513, + 515, 517, 519, 521, 523, 525, 530, 532, 537, 539, + 544, 549, 551, 553, 555, 557, 559, 561, 563, 565, + 567, 569, 571, 573, 575, 577, 579, 581, 583, 588, + 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, + 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, + 609, 610, 611, 612, 613, 614, 615, 619, 624, 629, + 630, 633, 634, 638, 640, 642, 644, 646, 648, 653, + 655, 657, 659, 664, 669, 671, 674, 678, 681, 685, + 687, 692, 694, 699, 704, 709, 714, 719, 720, 721, + 722, 723, 724, 725, 726, 727, 731, 736, 741, 746, + 751, 756, 761, 766, 771, 776, 781, 783, 788, 793, + 798, 803, 808, 810, 815, 817, 822, 827 }; void @@ -4500,9 +4499,9 @@ namespace xsk { namespace gsc { namespace s1 { #line 13 "parser.ypp" } } } // xsk::gsc::s1 -#line 4504 "parser.cpp" +#line 4503 "parser.cpp" -#line 837 "parser.ypp" +#line 831 "parser.ypp" void xsk::gsc::s1::parser::error(const xsk::gsc::location& loc, const std::string& msg) diff --git a/src/s1/xsk/parser.hpp b/src/s1/xsk/parser.hpp index c081ed1d..1355f71b 100644 --- a/src/s1/xsk/parser.hpp +++ b/src/s1/xsk/parser.hpp @@ -45,13 +45,12 @@ #ifndef YY_S1_PARSER_HPP_INCLUDED # define YY_S1_PARSER_HPP_INCLUDED // "%code requires" blocks. -#line 33 "parser.ypp" +#line 28 "parser.ypp" #include "s1.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::s1::parser::symbol_type S1lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::s1 { class lexer; } -#line 55 "parser.hpp" +#line 54 "parser.hpp" # include # include // std::abort @@ -194,7 +193,7 @@ typedef void *yyscan_t; #line 13 "parser.ypp" namespace xsk { namespace gsc { namespace s1 { -#line 198 "parser.hpp" +#line 197 "parser.hpp" @@ -2685,7 +2684,7 @@ switch (yykind) }; /// Build a parser object. - parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); + parser (xsk::gsc::s1::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); virtual ~parser (); #if 201103L <= YY_CPLUSPLUS @@ -4656,8 +4655,7 @@ switch (yykind) // User arguments. - yyscan_t yyscanner; - xsk::gsc::context* ctx; + xsk::gsc::s1::lexer& lexer; xsk::gsc::ast::program::ptr& ast; }; @@ -5342,7 +5340,7 @@ switch (yykind) #line 13 "parser.ypp" } } } // xsk::gsc::s1 -#line 5346 "parser.hpp" +#line 5344 "parser.hpp" diff --git a/src/s1/xsk/resolver.cpp b/src/s1/xsk/resolver.cpp index 4f4d76e7..ea40dd93 100644 --- a/src/s1/xsk/resolver.cpp +++ b/src/s1/xsk/resolver.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -206,6 +206,35 @@ auto resolver::make_token(std::string_view str) -> std::string return data; } +std::function(const std::string&)> read_callback = nullptr; +std::unordered_map> files; + +auto resolver::file_data(const std::string& name) -> std::tuple +{ + const auto& itr = files.find(name); + + if(itr != files.end()) + { + return { &itr->first ,reinterpret_cast(itr->second.data()), itr->second.size() }; + } + + auto data = read_callback(name); + + const auto& res = files.insert({ name, std::move(data)}); + + if(res.second) + { + return { &res.first->first, reinterpret_cast(res.first->second.data()), res.first->second.size() }; + } + + throw error("couldn't open gsc file '" + name + "'"); +} + +void resolver::set_reader(std::function(const std::string&)> callback) +{ + read_callback = callback; +} + const std::array, 154> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/s1/xsk/resolver.hpp b/src/s1/xsk/resolver.hpp index b42970f6..15c7c94e 100644 --- a/src/s1/xsk/resolver.hpp +++ b/src/s1/xsk/resolver.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -30,6 +30,8 @@ public: static auto find_method(const std::string& name) -> bool; static auto make_token(std::string_view str) -> std::string; + static auto file_data(const std::string& name) -> std::tuple; + static void set_reader(std::function(const std::string&)> callback); }; } // namespace xsk::gsc::s1 diff --git a/src/s1/xsk/s1.cpp b/src/s1/xsk/s1.cpp index f0b33751..8508651d 100644 --- a/src/s1/xsk/s1.cpp +++ b/src/s1/xsk/s1.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s1/xsk/s1.hpp b/src/s1/xsk/s1.hpp index 2220ff4d..8c3ec3c9 100644 --- a/src/s1/xsk/s1.hpp +++ b/src/s1/xsk/s1.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/stdafx.cpp b/src/s2/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/s2/stdafx.cpp +++ b/src/s2/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/stdafx.hpp b/src/s2/stdafx.hpp index 783505ff..6a27a863 100644 --- a/src/s2/stdafx.hpp +++ b/src/s2/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/xsk/assembler.cpp b/src/s2/xsk/assembler.cpp index 3465da5d..3d889099 100644 --- a/src/s2/xsk/assembler.cpp +++ b/src/s2/xsk/assembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/xsk/assembler.hpp b/src/s2/xsk/assembler.hpp index 783bf128..c8f59c7d 100644 --- a/src/s2/xsk/assembler.hpp +++ b/src/s2/xsk/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/xsk/compiler.cpp b/src/s2/xsk/compiler.cpp index 04bc5027..48d65719 100644 --- a/src/s2/xsk/compiler.cpp +++ b/src/s2/xsk/compiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,7 +19,6 @@ auto compiler::output() -> std::vector void compiler::compile(const std::string& file, std::vector& data) { filename_ = file; - sources_.clear(); auto prog = parse_buffer(filename_, data); @@ -33,39 +32,19 @@ void compiler::read_callback(std::function(const std:: auto compiler::parse_buffer(const std::string& file, std::vector& data) -> ast::program::ptr { - yyscan_t scanner; - context ctx; ast::program::ptr result(nullptr); - ctx.header_top = 0; - ctx.mode = mode_; - ctx.read_callback = read_callback_; - ctx.sources = &sources_; - ctx.loc.initialize(&file); + resolver::set_reader(read_callback_); - // Add the two NULL terminators, required by flex. - data.push_back(0); - data.push_back(0); + lexer lexer(file, reinterpret_cast(data.data()), data.size()); - if (s2_lex_init(&scanner)) - { - throw comp_error(ctx.loc, "An unknown error ocurred while starting lexer context."); - } - - ctx.scanner = scanner; - - YY_BUFFER_STATE yybuffer = s2__scan_buffer(reinterpret_cast(data.data()), data.size(), scanner); - - parser parser(scanner, &ctx, result); + parser parser(lexer, result); if (parser.parse() || result == nullptr) { - throw comp_error(ctx.loc, "An unknown error ocurred while parsing gsc file."); + throw comp_error(xsk::gsc::location(&file), "An unknown error ocurred while parsing gsc file."); } - s2__delete_buffer(yybuffer, scanner); - s2_lex_destroy(scanner); - return result; } diff --git a/src/s2/xsk/compiler.hpp b/src/s2/xsk/compiler.hpp index 37e55697..1ea0e99e 100644 --- a/src/s2/xsk/compiler.hpp +++ b/src/s2/xsk/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -25,7 +25,6 @@ class compiler : public gsc::compiler std::vector animtrees_; std::unordered_map constants_; std::function(const std::string&)> read_callback_; - std::vector sources_; std::vector break_blks_; std::vector continue_blks_; bool can_break_; diff --git a/src/s2/xsk/decompiler.cpp b/src/s2/xsk/decompiler.cpp index 46028fcf..6f856bbe 100644 --- a/src/s2/xsk/decompiler.cpp +++ b/src/s2/xsk/decompiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/xsk/decompiler.hpp b/src/s2/xsk/decompiler.hpp index 72c5fda8..c134abf1 100644 --- a/src/s2/xsk/decompiler.hpp +++ b/src/s2/xsk/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/xsk/disassembler.cpp b/src/s2/xsk/disassembler.cpp index 86abf87f..86e4e59b 100644 --- a/src/s2/xsk/disassembler.cpp +++ b/src/s2/xsk/disassembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/xsk/disassembler.hpp b/src/s2/xsk/disassembler.hpp index ca857589..d7ac3056 100644 --- a/src/s2/xsk/disassembler.hpp +++ b/src/s2/xsk/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/xsk/lexer.cpp b/src/s2/xsk/lexer.cpp index 351561a7..5af9c1ea 100644 --- a/src/s2/xsk/lexer.cpp +++ b/src/s2/xsk/lexer.cpp @@ -1,3040 +1,990 @@ -#line 1 "lexer.cpp" -#include "stdafx.hpp" -#include "s2.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void s2_push_header(xsk::gsc::context* ctx, const std::string& file); -void s2_pop_header(xsk::gsc::context* ctx); - -#line 9 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define s2__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer s2__create_buffer -#endif - -#ifdef yy_delete_buffer -#define s2__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer s2__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define s2__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer s2__scan_buffer -#endif - -#ifdef yy_scan_string -#define s2__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string s2__scan_string -#endif - -#ifdef yy_scan_bytes -#define s2__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes s2__scan_bytes -#endif - -#ifdef yy_init_buffer -#define s2__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer s2__init_buffer -#endif - -#ifdef yy_flush_buffer -#define s2__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer s2__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define s2__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state s2__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define s2__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer s2__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define s2_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state s2_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define s2_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state s2_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define s2_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack s2_ensure_buffer_stack -#endif - -#ifdef yylex -#define s2_lex_ALREADY_DEFINED -#else -#define yylex s2_lex -#endif - -#ifdef yyrestart -#define s2_restart_ALREADY_DEFINED -#else -#define yyrestart s2_restart -#endif - -#ifdef yylex_init -#define s2_lex_init_ALREADY_DEFINED -#else -#define yylex_init s2_lex_init -#endif - -#ifdef yylex_init_extra -#define s2_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra s2_lex_init_extra -#endif - -#ifdef yylex_destroy -#define s2_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy s2_lex_destroy -#endif - -#ifdef yyget_debug -#define s2_get_debug_ALREADY_DEFINED -#else -#define yyget_debug s2_get_debug -#endif - -#ifdef yyset_debug -#define s2_set_debug_ALREADY_DEFINED -#else -#define yyset_debug s2_set_debug -#endif - -#ifdef yyget_extra -#define s2_get_extra_ALREADY_DEFINED -#else -#define yyget_extra s2_get_extra -#endif - -#ifdef yyset_extra -#define s2_set_extra_ALREADY_DEFINED -#else -#define yyset_extra s2_set_extra -#endif - -#ifdef yyget_in -#define s2_get_in_ALREADY_DEFINED -#else -#define yyget_in s2_get_in -#endif - -#ifdef yyset_in -#define s2_set_in_ALREADY_DEFINED -#else -#define yyset_in s2_set_in -#endif - -#ifdef yyget_out -#define s2_get_out_ALREADY_DEFINED -#else -#define yyget_out s2_get_out -#endif - -#ifdef yyset_out -#define s2_set_out_ALREADY_DEFINED -#else -#define yyset_out s2_set_out -#endif - -#ifdef yyget_leng -#define s2_get_leng_ALREADY_DEFINED -#else -#define yyget_leng s2_get_leng -#endif - -#ifdef yyget_text -#define s2_get_text_ALREADY_DEFINED -#else -#define yyget_text s2_get_text -#endif - -#ifdef yyget_lineno -#define s2_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno s2_get_lineno -#endif - -#ifdef yyset_lineno -#define s2_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno s2_set_lineno -#endif - -#ifdef yyget_column -#define s2_get_column_ALREADY_DEFINED -#else -#define yyget_column s2_get_column -#endif - -#ifdef yyset_column -#define s2_set_column_ALREADY_DEFINED -#else -#define yyset_column s2_set_column -#endif - -#ifdef yywrap -#define s2_wrap_ALREADY_DEFINED -#else -#define yywrap s2_wrap -#endif - -#ifdef yyalloc -#define s2_alloc_ALREADY_DEFINED -#else -#define yyalloc s2_alloc -#endif - -#ifdef yyrealloc -#define s2_realloc_ALREADY_DEFINED -#else -#define yyrealloc s2_realloc -#endif - -#ifdef yyfree -#define s2_free_ALREADY_DEFINED -#else -#define yyfree s2_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin , yyscanner ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define s2_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); -static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 112 -#define YY_END_OF_BUFFER 113 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[333] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 113, 111, - 1, 2, 95, 111, 111, 94, 98, 111, 55, 56, - 92, 90, 61, 91, 62, 93, 110, 110, 64, 65, - 79, 89, 80, 66, 101, 59, 60, 99, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 57, 97, 58, 96, 5, 6, - 5, 12, 13, 12, 111, 92, 93, 76, 0, 103, - 0, 15, 0, 0, 0, 0, 85, 0, 74, 0, - 87, 0, 0, 8, 83, 67, 81, 68, 82, 106, - 0, 11, 4, 3, 84, 106, 110, 107, 0, 0, - - 0, 0, 63, 71, 77, 75, 78, 72, 101, 88, - 101, 101, 101, 101, 101, 101, 29, 101, 101, 101, - 101, 101, 27, 33, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 86, 73, 7, 14, 10, - 9, 0, 103, 0, 0, 0, 0, 0, 0, 102, - 0, 0, 0, 0, 103, 0, 106, 0, 3, 106, - 106, 107, 108, 109, 100, 69, 70, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 31, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 104, 0, 0, 0, 0, 0, 102, 0, 0, - - 102, 0, 0, 53, 101, 46, 35, 101, 101, 101, - 28, 101, 101, 101, 51, 101, 101, 101, 101, 52, - 101, 101, 101, 47, 101, 22, 101, 0, 0, 0, - 0, 0, 50, 37, 101, 101, 101, 20, 48, 101, - 54, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 30, 0, 0, 0, 0, 0, 101, 101, 101, 101, - 101, 21, 101, 101, 39, 34, 101, 43, 101, 101, - 101, 105, 0, 0, 16, 0, 101, 101, 101, 36, - 32, 101, 101, 101, 101, 101, 101, 0, 17, 0, - 101, 101, 38, 101, 42, 101, 101, 101, 23, 19, - - 0, 101, 101, 101, 101, 49, 26, 101, 101, 0, - 40, 101, 41, 45, 101, 101, 0, 44, 101, 101, - 0, 101, 101, 0, 101, 24, 0, 101, 18, 101, - 25, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, - 25, 26, 27, 1, 28, 29, 28, 28, 28, 28, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 31, 30, 30, - 32, 33, 34, 35, 36, 1, 37, 38, 39, 40, - - 41, 42, 43, 44, 45, 30, 46, 47, 48, 49, - 50, 51, 30, 52, 53, 54, 55, 56, 57, 31, - 58, 59, 60, 61, 62, 63, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[64] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 5, 5, 5, - 5, 1, 1, 1, 1, 1, 1, 5, 5, 6, - 6, 1, 7, 1, 1, 6, 5, 5, 5, 5, - 5, 5, 6, 6, 8, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 8, 6, 6, 6, 6, 1, - 1, 1, 1 - } ; - -static const flex_int16_t yy_base[353] = - { 0, - 0, 0, 61, 62, 63, 64, 65, 66, 712, 713, - 713, 713, 686, 63, 58, 685, 76, 67, 713, 713, - 62, 67, 713, 73, 86, 85, 96, 102, 687, 713, - 65, 683, 68, 713, 674, 713, 713, 681, 75, 76, - 93, 99, 98, 105, 111, 108, 78, 103, 100, 113, - 118, 125, 123, 127, 713, 136, 713, 713, 713, 713, - 688, 713, 713, 687, 145, 678, 161, 713, 158, 713, - 163, 713, 0, 653, 652, 647, 713, 160, 713, 161, - 713, 165, 176, 713, 713, 713, 713, 713, 713, 183, - 654, 713, 713, 0, 713, 187, 194, 200, 195, 216, - - 234, 0, 713, 673, 713, 713, 713, 672, 663, 713, - 143, 148, 184, 147, 150, 197, 662, 189, 203, 191, - 193, 208, 661, 660, 190, 207, 214, 211, 233, 215, - 225, 224, 245, 236, 249, 713, 713, 713, 713, 713, - 713, 254, 263, 281, 0, 647, 148, 646, 278, 713, - 285, 280, 288, 283, 284, 292, 713, 631, 0, 284, - 713, 311, 290, 0, 656, 713, 713, 267, 287, 265, - 266, 286, 289, 301, 295, 302, 304, 306, 307, 308, - 309, 313, 312, 317, 318, 320, 323, 325, 327, 328, - 329, 0, 640, 640, 641, 636, 358, 360, 366, 361, - - 365, 372, 643, 650, 53, 649, 648, 344, 345, 346, - 647, 347, 354, 352, 646, 350, 367, 370, 355, 645, - 353, 369, 371, 644, 377, 378, 380, 0, 622, 620, - 625, 630, 713, 379, 381, 382, 389, 639, 638, 385, - 637, 383, 396, 384, 394, 395, 407, 409, 392, 410, - 636, 0, 616, 627, 625, 629, 412, 413, 393, 416, - 417, 631, 418, 419, 630, 629, 420, 628, 425, 423, - 430, 713, 619, 618, 713, 621, 431, 432, 434, 624, - 623, 436, 433, 445, 447, 448, 438, 614, 713, 605, - 449, 450, 620, 454, 619, 456, 457, 459, 461, 713, - - 606, 462, 468, 469, 471, 617, 616, 473, 475, 600, - 597, 474, 588, 546, 480, 477, 514, 534, 482, 487, - 487, 486, 488, 496, 495, 502, 493, 489, 713, 500, - 496, 713, 540, 548, 556, 561, 569, 575, 579, 587, - 519, 595, 603, 611, 619, 623, 518, 631, 639, 305, - 246, 179 - } ; - -static const flex_int16_t yy_def[353] = - { 0, - 332, 1, 333, 333, 334, 334, 1, 1, 332, 332, - 332, 332, 332, 335, 336, 332, 332, 337, 332, 332, - 332, 332, 332, 332, 332, 332, 338, 338, 332, 332, - 332, 332, 332, 332, 339, 332, 332, 332, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 336, 332, 332, 332, 335, 332, - 340, 332, 341, 341, 332, 332, 332, 342, 332, 343, - 332, 337, 344, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 345, 332, 332, 338, 338, 338, 338, - - 338, 346, 332, 332, 332, 332, 332, 332, 339, 332, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 332, 332, 332, 332, 332, - 332, 335, 335, 340, 347, 332, 332, 332, 342, 332, - 348, 343, 349, 337, 337, 344, 332, 332, 345, 332, - 332, 338, 338, 101, 346, 332, 332, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 350, 332, 332, 332, 332, 342, 342, 348, 343, - - 343, 349, 332, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 351, 332, 332, - 332, 332, 332, 339, 339, 339, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 352, 332, 332, 332, 332, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, - 339, 332, 332, 332, 332, 332, 339, 339, 339, 339, - 339, 339, 339, 339, 339, 339, 339, 332, 332, 332, - 339, 339, 339, 339, 339, 339, 339, 339, 339, 332, - - 332, 339, 339, 339, 339, 339, 339, 339, 339, 332, - 339, 339, 339, 339, 339, 339, 332, 339, 339, 339, - 332, 339, 339, 332, 339, 339, 332, 339, 332, 339, - 339, 0, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332 - } ; - -static const flex_int16_t yy_nxt[777] = - { 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, - 28, 29, 30, 31, 32, 33, 34, 35, 35, 35, - 35, 36, 10, 37, 38, 35, 39, 40, 41, 42, - 43, 44, 45, 35, 46, 35, 47, 35, 48, 35, - 49, 50, 51, 52, 53, 35, 54, 35, 35, 55, - 56, 57, 58, 60, 60, 63, 63, 70, 64, 64, - 65, 65, 61, 61, 72, 70, 66, 66, 84, 86, - 78, 67, 67, 79, 80, 102, 85, 88, 104, 105, - 92, 87, 107, 108, 74, 71, 93, 89, 234, 83, - - 81, 94, 75, 90, 90, 90, 90, 102, 102, 95, - 102, 96, 76, 97, 98, 98, 97, 96, 125, 97, - 97, 97, 97, 111, 100, 102, 101, 112, 102, 113, - 102, 102, 102, 100, 102, 102, 114, 102, 91, 116, - 102, 120, 115, 102, 118, 102, 119, 122, 117, 123, - 102, 127, 126, 128, 121, 102, 124, 102, 129, 102, - 136, 140, 70, 134, 150, 69, 141, 143, 131, 150, - 135, 133, 93, 70, 130, 102, 132, 94, 82, 102, - 102, 74, 102, 272, 155, 95, 194, 168, 169, 75, - 71, 172, 151, 153, 195, 144, 137, 83, 173, 76, - - 90, 90, 90, 90, 160, 160, 160, 160, 156, 96, - 332, 97, 97, 97, 97, 96, 102, 162, 162, 162, - 97, 102, 102, 102, 157, 102, 102, 102, 161, 102, - 170, 332, 102, 163, 163, 102, 171, 177, 174, 102, - 102, 175, 176, 102, 178, 180, 102, 102, 102, 332, - 252, 164, 164, 164, 164, 179, 102, 102, 70, 185, - 181, 164, 164, 182, 183, 102, 102, 70, 102, 186, - 164, 164, 164, 164, 164, 164, 187, 102, 188, 184, - 190, 102, 150, 69, 189, 143, 71, 149, 150, 198, - 152, 70, 70, 191, 82, 71, 201, 102, 102, 102, - - 155, 160, 160, 160, 160, 332, 207, 163, 163, 228, - 151, 206, 153, 144, 204, 83, 83, 199, 102, 102, - 202, 102, 102, 205, 156, 161, 96, 102, 162, 162, - 162, 97, 208, 102, 102, 211, 102, 210, 102, 102, - 102, 102, 209, 102, 102, 102, 214, 215, 216, 102, - 102, 212, 102, 217, 218, 102, 213, 102, 220, 102, - 102, 102, 150, 223, 150, 224, 219, 225, 149, 150, - 198, 221, 222, 150, 152, 227, 102, 102, 102, 102, - 201, 226, 102, 235, 102, 102, 102, 102, 240, 236, - 151, 245, 151, 153, 239, 238, 241, 153, 199, 102, - - 237, 102, 102, 102, 202, 243, 244, 247, 242, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 248, 249, - 251, 102, 246, 261, 102, 102, 102, 102, 102, 257, - 259, 250, 265, 263, 258, 260, 264, 266, 267, 102, - 262, 102, 102, 270, 102, 102, 268, 279, 102, 102, - 102, 102, 102, 269, 271, 102, 278, 102, 282, 286, - 281, 277, 102, 102, 102, 102, 102, 283, 102, 280, - 102, 284, 295, 285, 293, 291, 287, 102, 294, 102, - 102, 102, 102, 292, 299, 296, 102, 297, 102, 102, - 303, 102, 305, 102, 102, 298, 306, 302, 304, 307, - - 102, 102, 308, 102, 312, 102, 102, 102, 309, 102, - 314, 316, 102, 318, 102, 311, 319, 313, 102, 102, - 102, 102, 192, 145, 315, 323, 325, 102, 102, 322, - 320, 326, 102, 329, 102, 328, 327, 330, 324, 331, - 59, 59, 59, 59, 59, 59, 59, 59, 62, 62, - 62, 62, 62, 62, 62, 62, 69, 69, 69, 69, - 69, 69, 69, 69, 73, 73, 102, 321, 73, 82, - 82, 82, 82, 82, 82, 82, 82, 99, 102, 99, - 99, 99, 99, 109, 109, 109, 109, 142, 142, 142, - 142, 142, 142, 142, 142, 149, 149, 149, 149, 149, - - 149, 149, 149, 152, 152, 152, 152, 152, 152, 152, - 152, 154, 154, 154, 154, 154, 154, 154, 154, 159, - 102, 159, 159, 159, 159, 159, 159, 165, 165, 102, - 165, 197, 197, 197, 197, 197, 197, 197, 197, 200, - 200, 200, 200, 200, 200, 200, 200, 317, 102, 102, - 310, 102, 102, 301, 300, 102, 102, 290, 289, 288, - 102, 102, 102, 102, 276, 275, 274, 273, 102, 102, - 102, 102, 256, 255, 254, 253, 102, 102, 102, 102, - 102, 102, 102, 233, 232, 231, 230, 229, 102, 203, - 196, 193, 102, 102, 102, 102, 167, 166, 158, 148, - - 147, 146, 85, 139, 138, 110, 102, 106, 103, 77, - 68, 332, 9, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332 - } ; - -static const flex_int16_t yy_chk[777] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 5, 6, 14, 5, 6, - 7, 8, 3, 4, 15, 18, 7, 8, 21, 22, - 17, 7, 8, 17, 17, 205, 21, 24, 31, 31, - 26, 22, 33, 33, 15, 14, 26, 24, 205, 18, - - 17, 26, 15, 25, 25, 25, 25, 39, 40, 26, - 47, 27, 15, 27, 27, 27, 27, 28, 47, 28, - 28, 28, 28, 39, 27, 41, 27, 40, 27, 41, - 43, 42, 49, 27, 28, 48, 41, 44, 25, 42, - 46, 44, 41, 45, 43, 50, 43, 45, 42, 46, - 51, 49, 48, 50, 44, 53, 46, 52, 51, 54, - 56, 65, 69, 54, 78, 71, 67, 71, 52, 80, - 54, 53, 67, 82, 51, 111, 52, 67, 83, 114, - 112, 65, 115, 352, 83, 67, 147, 111, 112, 65, - 69, 114, 78, 80, 147, 71, 56, 82, 115, 65, - - 90, 90, 90, 90, 96, 96, 96, 96, 83, 97, - 99, 97, 97, 97, 97, 98, 113, 98, 98, 98, - 98, 118, 125, 120, 90, 121, 97, 99, 96, 116, - 113, 100, 98, 100, 100, 119, 113, 120, 116, 126, - 122, 118, 119, 128, 121, 125, 127, 130, 100, 101, - 351, 101, 101, 101, 101, 122, 132, 131, 142, 130, - 126, 101, 101, 127, 128, 129, 101, 143, 134, 131, - 101, 101, 101, 101, 101, 101, 131, 133, 132, 129, - 134, 135, 149, 144, 133, 144, 142, 151, 152, 151, - 153, 154, 155, 135, 156, 143, 153, 170, 171, 168, - - 156, 160, 160, 160, 160, 163, 171, 163, 163, 350, - 149, 170, 152, 144, 168, 154, 155, 151, 172, 169, - 153, 173, 163, 169, 156, 160, 162, 175, 162, 162, - 162, 162, 172, 174, 176, 175, 177, 174, 178, 179, - 180, 181, 173, 162, 183, 182, 178, 179, 180, 184, - 185, 176, 186, 181, 182, 187, 177, 188, 184, 189, - 190, 191, 197, 187, 198, 188, 183, 189, 199, 200, - 199, 185, 186, 201, 202, 191, 208, 209, 210, 212, - 202, 190, 216, 208, 214, 221, 213, 219, 214, 209, - 197, 221, 198, 200, 213, 212, 216, 201, 199, 217, - - 210, 222, 218, 223, 202, 218, 219, 223, 217, 225, - 226, 234, 227, 235, 236, 242, 244, 240, 225, 226, - 227, 237, 222, 240, 249, 259, 245, 246, 243, 234, - 236, 226, 244, 243, 235, 237, 243, 245, 246, 247, - 242, 248, 250, 249, 257, 258, 247, 259, 260, 261, - 263, 264, 267, 248, 250, 270, 258, 269, 263, 270, - 261, 257, 271, 277, 278, 283, 279, 264, 282, 260, - 287, 267, 283, 269, 279, 277, 271, 284, 282, 285, - 286, 291, 292, 278, 287, 284, 294, 285, 296, 297, - 292, 298, 296, 299, 302, 286, 297, 291, 294, 298, - - 303, 304, 299, 305, 303, 308, 312, 309, 299, 316, - 305, 309, 315, 312, 319, 302, 315, 304, 322, 320, - 323, 328, 347, 341, 308, 320, 322, 325, 331, 319, - 316, 323, 330, 327, 326, 325, 324, 328, 321, 330, - 333, 333, 333, 333, 333, 333, 333, 333, 334, 334, - 334, 334, 334, 334, 334, 334, 335, 335, 335, 335, - 335, 335, 335, 335, 336, 336, 318, 317, 336, 337, - 337, 337, 337, 337, 337, 337, 337, 338, 314, 338, - 338, 338, 338, 339, 339, 339, 339, 340, 340, 340, - 340, 340, 340, 340, 340, 342, 342, 342, 342, 342, - - 342, 342, 342, 343, 343, 343, 343, 343, 343, 343, - 343, 344, 344, 344, 344, 344, 344, 344, 344, 345, - 313, 345, 345, 345, 345, 345, 345, 346, 346, 311, - 346, 348, 348, 348, 348, 348, 348, 348, 348, 349, - 349, 349, 349, 349, 349, 349, 349, 310, 307, 306, - 301, 295, 293, 290, 288, 281, 280, 276, 274, 273, - 268, 266, 265, 262, 256, 255, 254, 253, 251, 241, - 239, 238, 232, 231, 230, 229, 224, 220, 215, 211, - 207, 206, 204, 203, 196, 195, 194, 193, 165, 158, - 148, 146, 124, 123, 117, 109, 108, 104, 91, 76, - - 75, 74, 66, 64, 61, 38, 35, 32, 29, 16, - 13, 9, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, - 332, 332, 332, 332, 332, 332 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.lpp" -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ -#define YY_NO_INPUT 1 -#define YY_NO_UNISTD_H 1 - -#line 25 "lexer.lpp" -#define YY_USER_ACTION ctx->loc.columns(yyleng); -#line 933 "lexer.cpp" - -#line 935 "lexer.cpp" - -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#include "stdafx.hpp" +#include "s2.hpp" +#include "parser.hpp" +#include "lexer.hpp" + +xsk::gsc::s2::parser::symbol_type S2lex(xsk::gsc::s2::lexer& lexer) +{ + return lexer.lex(); +} + +namespace xsk::gsc::s2 +{ + +enum class keyword +{ +/* KW_pre_define, + KW_pre_undef, + KW_pre_ifdef, + KW_pre_ifndef, + KW_pre_if, + KW_pre_elif, + KW_pre_else, + KW_pre_endif,*/ + KW_pre_inline, + KW_pre_include, + KW_pre_using_animtree, + KW_pre_animtree, + KW_endon, + KW_notify, + KW_wait, + KW_waittill, + KW_waittillmatch, + KW_waittillframeend, + KW_waitframe, + KW_if, + KW_else, + KW_do, + KW_while, + KW_for, + KW_foreach, + KW_in, + KW_switch, + KW_case, + KW_default, + KW_break, + KW_continue, + KW_return, + KW_breakpoint, + KW_prof_begin, + KW_prof_end, + KW_thread, + KW_childthread, + KW_thisthread, + KW_call, + KW_true, + KW_false, + KW_undefined, + KW_dotsize, + KW_game, + KW_self, + KW_anim, + KW_level, + KW_INVALID, +}; + +buffer::buffer() : size(1024), length(0) +{ + data = static_cast(std::malloc(size)); +} + +buffer::~buffer() +{ + if(data) std::free(data); +} + +bool buffer::push(char c) +{ + if(length >= size) { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals ( yyscan_t yyscanner ); - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef YY_NO_UNPUT - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( yyscan_t yyscanner ); -#else -static int input ( yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_load_buffer_state( yyscanner ); - } - - { -#line 44 "lexer.lpp" - - - -#line 48 "lexer.lpp" - ctx->loc.step(); - - -#line 1204 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 332 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 51 "lexer.lpp" -{ ctx->loc.step(); } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 52 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 54 "lexer.lpp" - - YY_BREAK -case 4: -YY_RULE_SETUP -#line 56 "lexer.lpp" -{ BEGIN(COMMENT_STATE); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 57 "lexer.lpp" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 58 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(COMMENT_STATE): -#line 60 "lexer.lpp" -{ throw s2::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "lexer.lpp" -{ throw s2::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 63 "lexer.lpp" -{ throw s2::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 64 "lexer.lpp" -{ BEGIN(INITIAL); return s2::parser::make_DEVEND(ctx->loc); } - YY_BREAK -case YY_STATE_EOF(DEV_ON_STATE): -#line 65 "lexer.lpp" -{ throw s2::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 67 "lexer.lpp" -{ BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return s2::parser::make_DEVBEGIN(ctx->loc); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 68 "lexer.lpp" - - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 69 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 70 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(DEV_OFF_STATE): -#line 71 "lexer.lpp" -{ throw s2::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.lpp" -{ throw s2::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 74 "lexer.lpp" -{ return s2::parser::make_INLINE(ctx->loc); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 75 "lexer.lpp" -{ return s2::parser::make_INCLUDE(ctx->loc); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 76 "lexer.lpp" -{ return s2::parser::make_USINGTREE(ctx->loc); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 77 "lexer.lpp" -{ return s2::parser::make_ANIMTREE(ctx->loc); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 78 "lexer.lpp" -{ return s2::parser::make_ENDON(ctx->loc); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 79 "lexer.lpp" -{ return s2::parser::make_NOTIFY(ctx->loc); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 80 "lexer.lpp" -{ return s2::parser::make_WAIT(ctx->loc); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 81 "lexer.lpp" -{ return s2::parser::make_WAITTILL(ctx->loc); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 82 "lexer.lpp" -{ return s2::parser::make_WAITTILLMATCH(ctx->loc); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 83 "lexer.lpp" -{ return s2::parser::make_WAITTILLFRAMEEND(ctx->loc); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 84 "lexer.lpp" -{ return s2::parser::make_WAITFRAME(ctx->loc); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 85 "lexer.lpp" -{ return s2::parser::make_IF(ctx->loc); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 86 "lexer.lpp" -{ return s2::parser::make_ELSE(ctx->loc); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 87 "lexer.lpp" -{ return s2::parser::make_DO(ctx->loc); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 88 "lexer.lpp" -{ return s2::parser::make_WHILE(ctx->loc); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 89 "lexer.lpp" -{ return s2::parser::make_FOR(ctx->loc); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 90 "lexer.lpp" -{ return s2::parser::make_FOREACH(ctx->loc); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 91 "lexer.lpp" -{ return s2::parser::make_IN(ctx->loc); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 92 "lexer.lpp" -{ return s2::parser::make_SWITCH(ctx->loc); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 93 "lexer.lpp" -{ return s2::parser::make_CASE(ctx->loc); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 94 "lexer.lpp" -{ return s2::parser::make_DEFAULT(ctx->loc); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 95 "lexer.lpp" -{ return s2::parser::make_BREAK(ctx->loc); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 96 "lexer.lpp" -{ return s2::parser::make_CONTINUE(ctx->loc); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 97 "lexer.lpp" -{ return s2::parser::make_RETURN(ctx->loc); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 98 "lexer.lpp" -{ return s2::parser::make_BREAKPOINT(ctx->loc); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 99 "lexer.lpp" -{ return s2::parser::make_PROFBEGIN(ctx->loc); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 100 "lexer.lpp" -{ return s2::parser::make_PROFEND(ctx->loc); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 101 "lexer.lpp" -{ return s2::parser::make_THREAD(ctx->loc); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 102 "lexer.lpp" -{ return s2::parser::make_CHILDTHREAD(ctx->loc); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 103 "lexer.lpp" -{ return s2::parser::make_THISTHREAD(ctx->loc); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 104 "lexer.lpp" -{ return s2::parser::make_CALL(ctx->loc); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 105 "lexer.lpp" -{ return s2::parser::make_TRUE(ctx->loc); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 106 "lexer.lpp" -{ return s2::parser::make_FALSE(ctx->loc); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 107 "lexer.lpp" -{ return s2::parser::make_UNDEFINED(ctx->loc); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 108 "lexer.lpp" -{ return s2::parser::make_SIZE(ctx->loc); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 109 "lexer.lpp" -{ return s2::parser::make_GAME(ctx->loc); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 110 "lexer.lpp" -{ return s2::parser::make_SELF(ctx->loc); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 111 "lexer.lpp" -{ return s2::parser::make_ANIM(ctx->loc); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 112 "lexer.lpp" -{ return s2::parser::make_LEVEL(ctx->loc); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 113 "lexer.lpp" -{ return s2::parser::make_LPAREN(ctx->loc); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 114 "lexer.lpp" -{ return s2::parser::make_RPAREN(ctx->loc); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 115 "lexer.lpp" -{ return s2::parser::make_LBRACE(ctx->loc); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 116 "lexer.lpp" -{ return s2::parser::make_RBRACE(ctx->loc); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 117 "lexer.lpp" -{ return s2::parser::make_LBRACKET(ctx->loc); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 118 "lexer.lpp" -{ return s2::parser::make_RBRACKET(ctx->loc); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 119 "lexer.lpp" -{ return s2::parser::make_COMMA(ctx->loc); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 120 "lexer.lpp" -{ return s2::parser::make_DOT(ctx->loc); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 121 "lexer.lpp" -{ return s2::parser::make_DOUBLECOLON(ctx->loc); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 122 "lexer.lpp" -{ return s2::parser::make_COLON(ctx->loc); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 123 "lexer.lpp" -{ return s2::parser::make_SEMICOLON(ctx->loc); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 124 "lexer.lpp" -{ return s2::parser::make_QMARK(ctx->loc); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 125 "lexer.lpp" -{ return s2::parser::make_INCREMENT(ctx->loc); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 126 "lexer.lpp" -{ return s2::parser::make_DECREMENT(ctx->loc); } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 127 "lexer.lpp" -{ return s2::parser::make_ASSIGN_LSHIFT(ctx->loc); } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 128 "lexer.lpp" -{ return s2::parser::make_ASSIGN_RSHIFT(ctx->loc); } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 129 "lexer.lpp" -{ return s2::parser::make_LSHIFT(ctx->loc); } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 130 "lexer.lpp" -{ return s2::parser::make_RSHIFT(ctx->loc); } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 131 "lexer.lpp" -{ return s2::parser::make_OR(ctx->loc); } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 132 "lexer.lpp" -{ return s2::parser::make_AND(ctx->loc); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 133 "lexer.lpp" -{ return s2::parser::make_EQUALITY(ctx->loc); } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 134 "lexer.lpp" -{ return s2::parser::make_INEQUALITY(ctx->loc); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 135 "lexer.lpp" -{ return s2::parser::make_LESS_EQUAL(ctx->loc); } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 136 "lexer.lpp" -{ return s2::parser::make_GREATER_EQUAL(ctx->loc); } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 137 "lexer.lpp" -{ return s2::parser::make_LESS(ctx->loc); } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 138 "lexer.lpp" -{ return s2::parser::make_GREATER(ctx->loc); } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 139 "lexer.lpp" -{ return s2::parser::make_ASSIGN_ADD(ctx->loc); } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 140 "lexer.lpp" -{ return s2::parser::make_ASSIGN_SUB(ctx->loc); } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 141 "lexer.lpp" -{ return s2::parser::make_ASSIGN_MUL(ctx->loc); } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 142 "lexer.lpp" -{ return s2::parser::make_ASSIGN_DIV(ctx->loc); } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 143 "lexer.lpp" -{ return s2::parser::make_ASSIGN_MOD(ctx->loc); } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 144 "lexer.lpp" -{ return s2::parser::make_ASSIGN_BW_OR(ctx->loc); } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 145 "lexer.lpp" -{ return s2::parser::make_ASSIGN_BW_AND(ctx->loc); } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 146 "lexer.lpp" -{ return s2::parser::make_ASSIGN_BW_EXOR(ctx->loc); } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 147 "lexer.lpp" -{ return s2::parser::make_ASSIGN(ctx->loc); } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 148 "lexer.lpp" -{ return s2::parser::make_ADD(ctx->loc); } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 149 "lexer.lpp" -{ return s2::parser::make_SUB(ctx->loc); } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 150 "lexer.lpp" -{ return s2::parser::make_MUL(ctx->loc); } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 151 "lexer.lpp" -{ return s2::parser::make_DIV(ctx->loc); } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 152 "lexer.lpp" -{ return s2::parser::make_MOD(ctx->loc); } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 153 "lexer.lpp" -{ return s2::parser::make_NOT(ctx->loc); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 154 "lexer.lpp" -{ return s2::parser::make_COMPLEMENT(ctx->loc); } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 155 "lexer.lpp" -{ return s2::parser::make_BITWISE_OR(ctx->loc); } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 156 "lexer.lpp" -{ return s2::parser::make_BITWISE_AND(ctx->loc); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 157 "lexer.lpp" -{ return s2::parser::make_BITWISE_EXOR(ctx->loc); } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 158 "lexer.lpp" -{ return s2::parser::make_PATH(xsk::gsc::s2::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 101: -YY_RULE_SETUP -#line 159 "lexer.lpp" -{ return s2::parser::make_IDENTIFIER(xsk::gsc::s2::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 102: -/* rule 102 can match eol */ -YY_RULE_SETUP -#line 160 "lexer.lpp" -{ return s2::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 103: -/* rule 103 can match eol */ -YY_RULE_SETUP -#line 161 "lexer.lpp" -{ return s2::parser::make_STRING(std::string(yytext), ctx->loc); } - YY_BREAK -case 104: -YY_RULE_SETUP -#line 162 "lexer.lpp" -{ return s2::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 105: -YY_RULE_SETUP -#line 163 "lexer.lpp" -{ return s2::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 164 "lexer.lpp" -{ return s2::parser::make_FLOAT(std::string(yytext), ctx->loc); } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 165 "lexer.lpp" -{ return s2::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 166 "lexer.lpp" -{ return s2::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 167 "lexer.lpp" -{ return s2::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } - YY_BREAK -case 110: -YY_RULE_SETUP -#line 168 "lexer.lpp" -{ return s2::parser::make_INTEGER(std::string(yytext), ctx->loc); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 169 "lexer.lpp" -{ if(ctx->header_top > 0) s2_pop_header(ctx); else return s2::parser::make_S2EOF(ctx->loc); } - YY_BREAK -case 111: -/* rule 111 can match eol */ -YY_RULE_SETUP -#line 170 "lexer.lpp" -{ throw s2::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - YY_BREAK -case 112: -YY_RULE_SETUP -#line 172 "lexer.lpp" -ECHO; - YY_BREAK -#line 1839 "lexer.cpp" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap( yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin , yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + auto nsize = size * 2; + auto ndata = reinterpret_cast(std::malloc(nsize)); + + if(!ndata) return false; + + std::memmove(ndata, data, size); + std::free(data); + size = nsize; + data = ndata; + } + data[length++] = c; + return true; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; } -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +void reader::init(const char* data, size_t size) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 333 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 332); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + if(data && size) + { + state = reader::ok; + buffer_pos = data; + bytes_remaining = size; + last_byte = 0; + current_byte = *data; + } + else + { + state = reader::end; + buffer_pos = 0; + bytes_remaining = 0; + last_byte = 0; + current_byte = 0; + } } -#ifndef YY_NO_UNPUT - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - +void reader::advance() { - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + ++buffer_pos; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin , yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); - yy_load_buffer_state( yyscanner ); + if(bytes_remaining-- == 1) + { + state = reader::end; + bytes_remaining = 0; + last_byte = current_byte; + current_byte = 0; + } + else + { + last_byte = current_byte; + current_byte = *buffer_pos; + } } -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +lexer::lexer(const std::string& name, const char* data, size_t size) : in_dev_state_(false), loc_(xsk::gsc::location(&name)), + mode_(build::dev), header_top_(0), locs_(std::stack()), readers_(std::stack()) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + reader_.init(data, size); } -static void yy_load_buffer_state (yyscan_t yyscanner) +void lexer::push_header(const std::string& file) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + try + { + if (header_top_++ >= 10) + throw xsk::gsc::error("maximum gsh depth exceeded '10'"); + + auto data = resolver::file_data(file + ".gsh"); + + readers_.push(reader_); + locs_.push(loc_); + loc_.initialize(std::get<0>(data)); + reader_.init(std::get<1>(data), std::get<2>(data)); + } + catch (const std::exception& e) + { + throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); + } } -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +void lexer::pop_header() { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file , yyscanner); - - return b; + header_top_--; + loc_ = locs_.top(); + locs_.pop(); + reader_ = readers_.top(); + readers_.pop(); } -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void lexer::restrict_header(const xsk::gsc::location& loc) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf , yyscanner ); - - yyfree( (void *) b , yyscanner ); + if (header_top_ > 0) + { + throw comp_error(loc, "not allowed inside a gsh file"); + } } -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - +auto lexer::lex() -> xsk::gsc::s2::parser::symbol_type { - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + buffer_.length = 0; + loc_.step(); - yy_flush_buffer( b , yyscanner); + while (true) + { + if (reader_.state == reader::end) + { + if (in_dev_state_) + throw s2::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + if(header_top_ > 0) + pop_header(); + else + return s2::parser::make_S2EOF(loc_); + } - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + reader_.advance(); + auto& last = reader_.last_byte; + auto& curr = reader_.current_byte; + + switch (last) + { + case ' ': + case '\t': + case '\r': + loc_.step(); + continue; + case '\n': + loc_.lines(); + loc_.step(); + continue; + case '/': + if(reader_.state == reader::end || (curr != '/' && curr != '*' && curr != '#' && curr != '=')) + return s2::parser::make_DIV(loc_); + + reader_.advance(); + + if (last == '=') + return s2::parser::make_ASSIGN_DIV(loc_); + + if (last == '#') + { + if (in_dev_state_) + { + throw s2::parser::syntax_error(loc_, "cannot recurse devblock ('/#')"); + } + else if (mode_ == xsk::gsc::build::dev) + { + in_dev_state_ = true; + return s2::parser::make_DEVBEGIN(loc_); + } + else + { + while (true) + { + if (reader_.state == reader::end) + { + throw s2::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '#' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + } + else if (last == '*') + { + while (true) + { + if (reader_.state == reader::end) + { + throw s2::parser::syntax_error(loc_, "unmatched multiline comment start ('/*')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '*' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + else if (last == '/') + { + while (true) + { + if (reader_.state == reader::end || curr == '\n') + break; + + reader_.advance(); + } + } + continue; + case '#': + if (curr == '/') + { + if (!in_dev_state_) + throw s2::parser::syntax_error(loc_, "unmatched devblock end ('#/')"); + + in_dev_state_ = false; + reader_.advance(); + return s2::parser::make_DEVEND(loc_); + } + + buffer_.push(last); + while (reader_.state == reader::ok) + { + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + { + if (auto len = buffer_.length; len == 4 || len == 7) + { + auto data = buffer_.data; + auto color = true; + for (auto i = 1; i < len; i++) + { + if ((data[i] < 48 || data[i] > 57) && (data[i] < 65 || data[i] > 70) && (data[i] < 97 || data[i] > 102)) + { + color = false; + break; + } + } + + if (color) return s2::parser::make_COLOR(std::string(++data, --len), loc_); + } + + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); + + if (key == keyword::KW_INVALID) + throw s2::parser::syntax_error(loc_, utils::string::va("unknown preprocessor directive ('%s')", "#")); + + if (keyword_is_token(key)) + return keyword_token(key); + + // call preprocessor(key); + } + continue; + case '*': + if (reader_.state == reader::end || (curr != '/' && curr != '=')) + return s2::parser::make_MUL(loc_); + + reader_.advance(); + + if (curr == '/') + throw s2::parser::syntax_error(loc_, "unmatched multiline comment end ('*/')"); + + return s2::parser::make_ASSIGN_MUL(loc_); + case '"': + case '\'': + return read_string(last, false); + case '.': + return read_dotsize(); + case '(': + return s2::parser::make_LPAREN(loc_); + case ')': + return s2::parser::make_RPAREN(loc_); + case '{': + return s2::parser::make_LBRACE(loc_); + case '}': + return s2::parser::make_RBRACE(loc_); + case '[': + return s2::parser::make_LBRACKET(loc_); + case ']': + return s2::parser::make_RBRACKET(loc_); + case ',': + return s2::parser::make_COMMA(loc_); + case ';': + return s2::parser::make_SEMICOLON(loc_); + case ':': + if (curr != ':') + return s2::parser::make_COLON(loc_); + reader_.advance(); + return s2::parser::make_DOUBLECOLON(loc_); + case '?': + return s2::parser::make_QMARK(loc_); + case '=': + if (curr != '=') + return s2::parser::make_ASSIGN(loc_); + reader_.advance(); + return s2::parser::make_EQUALITY(loc_); + case '+': + if (curr != '+' && curr != '=') + return s2::parser::make_ADD(loc_); + reader_.advance(); + return (last == '+') ? s2::parser::make_INCREMENT(loc_) : s2::parser::make_ASSIGN_ADD(loc_); + case '-': + if (curr != '-' && curr != '=') + return s2::parser::make_SUB(loc_); + reader_.advance(); + return (last == '-') ? s2::parser::make_DECREMENT(loc_) : s2::parser::make_ASSIGN_SUB(loc_); + case '%': + if (curr != '=') + return s2::parser::make_MOD(loc_); + reader_.advance(); + return s2::parser::make_ASSIGN_MOD(loc_); + case '|': + if (curr != '|' && curr != '=') + return s2::parser::make_BITWISE_OR(loc_); + reader_.advance(); + return (last == '|') ? s2::parser::make_OR(loc_) : s2::parser::make_ASSIGN_BW_OR(loc_); + case '&': + if (curr != '&' && curr != '=' && curr != '"' && curr != '\'') + return s2::parser::make_BITWISE_AND(loc_); + reader_.advance(); + if (last == '"' || last == '\'') + return read_string(last, true); + return (last == '&') ? s2::parser::make_AND(loc_) : s2::parser::make_ASSIGN_BW_AND(loc_); + case '^': + if (curr != '=') + return s2::parser::make_BITWISE_EXOR(loc_); + reader_.advance(); + return s2::parser::make_ASSIGN_BW_EXOR(loc_); + case '!': + if (curr != '=') + return s2::parser::make_NOT(loc_); + reader_.advance(); + return s2::parser::make_INEQUALITY(loc_); + case '~': + return s2::parser::make_COMPLEMENT(loc_); + case '<': + if (curr != '<' && curr != '=') + return s2::parser::make_LESS(loc_); + reader_.advance(); + if (last == '<') + { + reader_.advance(); + return (last == '=') ? s2::parser::make_ASSIGN_LSHIFT(loc_) : s2::parser::make_LSHIFT(loc_); + } + return s2::parser::make_LESS_EQUAL(loc_); + case '>': + if (curr != '>' && curr != '=') + return s2::parser::make_GREATER(loc_); + reader_.advance(); + if (last == '>') + { + reader_.advance(); + return (last == '=') ? s2::parser::make_ASSIGN_RSHIFT(loc_) : s2::parser::make_RSHIFT(loc_); + } + return s2::parser::make_GREATER_EQUAL(loc_); + default: + if (last >= '0' && last <= '9') + return lexer::read_number(last); + else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z') + return lexer::read_word(last); + + throw s2::parser::syntax_error(loc_, utils::string::va("bad token: \'%c\'", last)); + } + } +} + +auto lexer::read_string(char quote, bool localize) -> xsk::gsc::s2::parser::symbol_type +{ + if (localize) + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + reader_.advance(); + + if (last == '\n') + throw s2::parser::syntax_error(loc_, "unterminated string"); + + if (last == '\\') // process scapes + { + // TODO: + } + + if (last != '\\' && curr == quote) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); } - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b , yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n , yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n , yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int _line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = _line_number; -} - -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column (int _column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = _column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int _bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = _bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (reader_.state == reader::end) + { + throw s2::parser::syntax_error(loc_, utils::string::va("unmatched string start ('%s')", (quote == '"') ? "\"" : "\\'")); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + if (localize) + return s2::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + return s2::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_); +} + +auto lexer::read_number(char first) -> xsk::gsc::s2::parser::symbol_type +{ + if (first == '.') + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = true; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw s2::parser::syntax_error(loc_, "invalid number '.'"); + } + if (data[i] == 'f' && i != len - 1) + throw s2::parser::syntax_error(loc_, "invalid number 'f'"); + } + + return s2::parser::make_FLOAT(std::string(data, len), loc_); + } + else + { + auto curr = reader_.current_byte; + + if (first == '0' && curr == 'o') + { + buffer_.push(first); + buffer_.push('o'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'o')) + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'o' && last == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr > 47 && curr < 56)) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid octal literal!"); + + return s2::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data + 2), loc_); + } + else if (first == '0' && curr == 'b') + { + buffer_.push(first); + buffer_.push('b'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'b')) + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'b' && last == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (curr != '0' && curr != '1') + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid binary literal!"); + + return s2::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_); + } + else if (first == '0' && curr == 'x') + { + buffer_.push(first); + buffer_.push('x'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'x')) + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'x' && last == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!((curr > 47 && curr < 58) || (curr > 64 && curr < 71) || (curr > 96 && curr < 103))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid hexadecimal literal!"); + + return s2::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_); + } + else + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s2::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = false; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw s2::parser::syntax_error(loc_, "invalid number '.'"); + + dot = true; + } + if (data[i] == 'f' && i != len - 1) + throw s2::parser::syntax_error(loc_, "invalid number 'f'"); + } + + if (dot || data[len - 1] == 'f') + return s2::parser::make_FLOAT(std::string(data, len), loc_); + + return s2::parser::make_INTEGER(std::string(data, len), loc_); + } + } +} + +auto lexer::read_word(char first) -> xsk::gsc::s2::parser::symbol_type +{ + auto path = false; + + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto curr = reader_.current_byte; + + if (!(curr == '\\' || curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (curr == '\\') + { + if (reader_.last_byte == '\\') + throw s2::parser::syntax_error(loc_, "invalid path '\\\\'"); + + path = true; + curr = '/'; + } + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); - return yy_init_globals ( *ptr_yy_globals ); -} + if (key != keyword::KW_INVALID) + return keyword_token(key); -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; + if (path) + { + if (buffer_.data[buffer_.length - 1] == '/') + throw s2::parser::syntax_error(loc_, "invalid path end '\\'"); - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + return s2::parser::make_PATH(xsk::gsc::s2::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + return s2::parser::make_IDENTIFIER(xsk::gsc::s2::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); +} - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; +auto lexer::read_dotsize() -> xsk::gsc::s2::parser::symbol_type +{ + auto curr = reader_.current_byte; + + if (curr > 47 && curr < 58) + { + return lexer::read_number('.'); + } + else if (curr == '_' || curr > 64 && curr < 91 || curr > 96 && curr < 123) + { + reader save; + save.state = reader_.state; + save.bytes_remaining = reader_.bytes_remaining; + save.buffer_pos = reader_.buffer_pos; + save.last_byte = reader_.last_byte; + save.current_byte = reader_.current_byte; + + while (reader_.state == reader::ok) + { + curr = reader_.current_byte; + + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (std::string_view(buffer_.data, buffer_.length) == "size") + { + return s2::parser::make_SIZE(loc_); + } + + reader_.state = save.state; + reader_.bytes_remaining = save.bytes_remaining; + reader_.buffer_pos = save.buffer_pos; + reader_.last_byte = save.last_byte; + reader_.current_byte = save.current_byte; + + return s2::parser::make_DOT(loc_); + + } + else return s2::parser::make_DOT(loc_); +} + +auto lexer::keyword_token(keyword k) -> xsk::gsc::s2::parser::symbol_type +{ + switch (k) + { + case keyword::KW_pre_inline: + return s2::parser::make_INLINE(loc_); + case keyword::KW_pre_include: + return s2::parser::make_INCLUDE(loc_); + case keyword::KW_pre_using_animtree: + return s2::parser::make_USINGTREE(loc_); + case keyword::KW_pre_animtree: + return s2::parser::make_ANIMTREE(loc_); + case keyword::KW_endon: + return s2::parser::make_ENDON(loc_); + case keyword::KW_notify: + return s2::parser::make_NOTIFY(loc_); + case keyword::KW_wait: + return s2::parser::make_WAIT(loc_); + case keyword::KW_waittill: + return s2::parser::make_WAITTILL(loc_); + case keyword::KW_waittillmatch: + return s2::parser::make_WAITTILLMATCH(loc_); + case keyword::KW_waittillframeend: + return s2::parser::make_WAITTILLFRAMEEND(loc_); + case keyword::KW_waitframe: + return s2::parser::make_WAITFRAME(loc_); + case keyword::KW_if: + return s2::parser::make_IF(loc_); + case keyword::KW_else: + return s2::parser::make_ELSE(loc_); + case keyword::KW_do: + return s2::parser::make_DO(loc_); + case keyword::KW_while: + return s2::parser::make_WHILE(loc_); + case keyword::KW_for: + return s2::parser::make_FOR(loc_); + case keyword::KW_foreach: + return s2::parser::make_FOREACH(loc_); + case keyword::KW_in: + return s2::parser::make_IN(loc_); + case keyword::KW_switch: + return s2::parser::make_SWITCH(loc_); + case keyword::KW_case: + return s2::parser::make_CASE(loc_); + case keyword::KW_default: + return s2::parser::make_DEFAULT(loc_); + case keyword::KW_break: + return s2::parser::make_BREAK(loc_); + case keyword::KW_continue: + return s2::parser::make_CONTINUE(loc_); + case keyword::KW_return: + return s2::parser::make_RETURN(loc_); + case keyword::KW_breakpoint: + return s2::parser::make_BREAKPOINT(loc_); + case keyword::KW_prof_begin: + return s2::parser::make_PROFBEGIN(loc_); + case keyword::KW_prof_end: + return s2::parser::make_PROFEND(loc_); + case keyword::KW_thread: + return s2::parser::make_THREAD(loc_); + case keyword::KW_childthread: + return s2::parser::make_CHILDTHREAD(loc_); + case keyword::KW_thisthread: + return s2::parser::make_THISTHREAD(loc_); + case keyword::KW_call: + return s2::parser::make_CALL(loc_); + case keyword::KW_true: + return s2::parser::make_TRUE(loc_); + case keyword::KW_false: + return s2::parser::make_FALSE(loc_); + case keyword::KW_undefined: + return s2::parser::make_UNDEFINED(loc_); + case keyword::KW_dotsize: + return s2::parser::make_SIZE(loc_); + case keyword::KW_game: + return s2::parser::make_GAME(loc_); + case keyword::KW_self: + return s2::parser::make_SELF(loc_); + case keyword::KW_anim: + return s2::parser::make_ANIM(loc_); + case keyword::KW_level: + return s2::parser::make_LEVEL(loc_); + default: + throw error("gsc lexer: INVALID KEYWORD TOKEN!"); + } +} + +auto lexer::keyword_is_token(keyword k) -> bool +{ + switch (k) + { +/* case keyword::KW_pre_define: + case keyword::KW_pre_undef: + case keyword::KW_pre_ifdef: + case keyword::KW_pre_ifndef: + case keyword::KW_pre_if: + case keyword::KW_pre_elif: + case keyword::KW_pre_else: + case keyword::KW_pre_endif:*/ + case keyword::KW_INVALID: + return false; + default: + return true; + } +} + +auto lexer::get_keyword(std::string_view str) -> keyword +{ + auto itr = keywords.find(str); + + if(itr != keywords.end()) + { + return itr->second; } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + return keyword::KW_INVALID; } -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack , yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack , yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s , yyscan_t yyscanner) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 172 "lexer.lpp" - - -void s2_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void s2_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} +std::unordered_map lexer::keywords +{{ +/* { "#define", keyword::KW_pre_define }, + { "#undef", keyword::KW_pre_undef }, + { "#ifdef", keyword::KW_pre_ifdef }, + { "#ifndef", keyword::KW_pre_ifndef }, + { "#if", keyword::KW_pre_if }, + { "#elif", keyword::KW_pre_elif }, + { "#else", keyword::KW_pre_else }, + { "#endif", keyword::KW_pre_endif },*/ + { "#inline", keyword::KW_pre_inline }, + { "#include", keyword::KW_pre_include }, + { "#using_animtree", keyword::KW_pre_using_animtree }, + { "#animtree", keyword::KW_pre_animtree }, + { "endon", keyword::KW_endon }, + { "notify", keyword::KW_notify }, + { "wait", keyword::KW_wait }, + { "waittill", keyword::KW_waittill }, + { "waittillmatch", keyword::KW_waittillmatch }, + { "waittillframeend", keyword::KW_waittillframeend }, + { "waitframe", keyword::KW_waitframe }, + { "if", keyword::KW_if }, + { "else", keyword::KW_else }, + { "do", keyword::KW_do }, + { "while", keyword::KW_while }, + { "for", keyword::KW_for }, + { "foreach", keyword::KW_foreach }, + { "in", keyword::KW_in }, + { "switch", keyword::KW_switch }, + { "case", keyword::KW_case }, + { "default", keyword::KW_default }, + { "break", keyword::KW_break }, + { "continue", keyword::KW_continue }, + { "return", keyword::KW_return }, + { "breakpoint", keyword::KW_breakpoint }, + { "prof_begin", keyword::KW_prof_begin }, + { "prof_end", keyword::KW_prof_end }, + { "thread", keyword::KW_thread }, + { "childthread", keyword::KW_childthread }, + { "thisthread", keyword::KW_thisthread }, + { "call", keyword::KW_call }, + { "true", keyword::KW_true }, + { "false", keyword::KW_false }, + { "undefined", keyword::KW_undefined }, + { ".size", keyword::KW_dotsize }, + { "game", keyword::KW_game }, + { "self", keyword::KW_self }, + { "anim", keyword::KW_anim }, + { "level", keyword::KW_level }, +}}; +} // namespace xsk::gsc::s2 diff --git a/src/s2/xsk/lexer.hpp b/src/s2/xsk/lexer.hpp index 453356e5..833ad470 100644 --- a/src/s2/xsk/lexer.hpp +++ b/src/s2/xsk/lexer.hpp @@ -1,711 +1,79 @@ -#ifndef s2_HEADER_H -#define s2_HEADER_H 1 -#define s2_IN_HEADER 1 - -#line 5 "lexer.hpp" -#include "stdafx.hpp" -#include "s2.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void s2_push_header(xsk::gsc::context* ctx, const std::string& file); -void s2_pop_header(xsk::gsc::context* ctx); - -#line 13 "lexer.hpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define s2__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer s2__create_buffer -#endif - -#ifdef yy_delete_buffer -#define s2__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer s2__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define s2__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer s2__scan_buffer -#endif - -#ifdef yy_scan_string -#define s2__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string s2__scan_string -#endif - -#ifdef yy_scan_bytes -#define s2__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes s2__scan_bytes -#endif - -#ifdef yy_init_buffer -#define s2__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer s2__init_buffer -#endif - -#ifdef yy_flush_buffer -#define s2__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer s2__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define s2__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state s2__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define s2__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer s2__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define s2_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state s2_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define s2_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state s2_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define s2_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack s2_ensure_buffer_stack -#endif - -#ifdef yylex -#define s2_lex_ALREADY_DEFINED -#else -#define yylex s2_lex -#endif - -#ifdef yyrestart -#define s2_restart_ALREADY_DEFINED -#else -#define yyrestart s2_restart -#endif - -#ifdef yylex_init -#define s2_lex_init_ALREADY_DEFINED -#else -#define yylex_init s2_lex_init -#endif - -#ifdef yylex_init_extra -#define s2_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra s2_lex_init_extra -#endif - -#ifdef yylex_destroy -#define s2_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy s2_lex_destroy -#endif - -#ifdef yyget_debug -#define s2_get_debug_ALREADY_DEFINED -#else -#define yyget_debug s2_get_debug -#endif - -#ifdef yyset_debug -#define s2_set_debug_ALREADY_DEFINED -#else -#define yyset_debug s2_set_debug -#endif - -#ifdef yyget_extra -#define s2_get_extra_ALREADY_DEFINED -#else -#define yyget_extra s2_get_extra -#endif - -#ifdef yyset_extra -#define s2_set_extra_ALREADY_DEFINED -#else -#define yyset_extra s2_set_extra -#endif - -#ifdef yyget_in -#define s2_get_in_ALREADY_DEFINED -#else -#define yyget_in s2_get_in -#endif - -#ifdef yyset_in -#define s2_set_in_ALREADY_DEFINED -#else -#define yyset_in s2_set_in -#endif - -#ifdef yyget_out -#define s2_get_out_ALREADY_DEFINED -#else -#define yyget_out s2_get_out -#endif - -#ifdef yyset_out -#define s2_set_out_ALREADY_DEFINED -#else -#define yyset_out s2_set_out -#endif - -#ifdef yyget_leng -#define s2_get_leng_ALREADY_DEFINED -#else -#define yyget_leng s2_get_leng -#endif - -#ifdef yyget_text -#define s2_get_text_ALREADY_DEFINED -#else -#define yyget_text s2_get_text -#endif - -#ifdef yyget_lineno -#define s2_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno s2_get_lineno -#endif - -#ifdef yyset_lineno -#define s2_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno s2_set_lineno -#endif - -#ifdef yyget_column -#define s2_get_column_ALREADY_DEFINED -#else -#define yyget_column s2_get_column -#endif - -#ifdef yyset_column -#define s2_set_column_ALREADY_DEFINED -#else -#define yyset_column s2_set_column -#endif - -#ifdef yywrap -#define s2_wrap_ALREADY_DEFINED -#else -#define yywrap s2_wrap -#endif - -#ifdef yyalloc -#define s2_alloc_ALREADY_DEFINED -#else -#define yyalloc s2_alloc -#endif - -#ifdef yyrealloc -#define s2_realloc_ALREADY_DEFINED -#else -#define yyrealloc s2_realloc -#endif - -#ifdef yyfree -#define s2_free_ALREADY_DEFINED -#else -#define yyfree s2_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define s2_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#ifndef s2__create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef s2__delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef s2__scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef s2__scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef s2__scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef s2__init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef s2__flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef s2__load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef s2__switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef s2_push_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef s2_pop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef s2_ensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef s2_lex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef s2_restart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef s2_lex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef s2_lex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef s2_lex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef s2_get_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef s2_set_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef s2_get_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef s2_set_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef s2_get_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef s2_set_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef s2_get_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef s2_set_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef s2_get_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef s2_get_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef s2_get_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef s2_set_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef s2_get_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef s2_set_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef s2_wrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef s2_get_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef s2_set_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef s2_get_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef s2_set_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef s2_alloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef s2_realloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef s2_free_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef s2_text_ALREADY_DEFINED -#undef yytext -#endif -#ifndef s2_leng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef s2_in_ALREADY_DEFINED -#undef yyin -#endif -#ifndef s2_out_ALREADY_DEFINED -#undef yyout -#endif -#ifndef s2__flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef s2_lineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef s2_tables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef s2_tables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef s2_TABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 172 "lexer.lpp" - - -#line 709 "lexer.hpp" -#undef s2_IN_HEADER -#endif /* s2_HEADER_H */ +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#pragma once + +#include "s2.hpp" + +namespace xsk::gsc::s2 +{ + +enum class keyword; + +struct buffer +{ + int size; + int length; + char* data; + + buffer(); + ~buffer(); + bool push(char c); +}; + +struct reader +{ + enum states { end, ok }; + + states state; + int bytes_remaining; + const char* buffer_pos; + char last_byte; + char current_byte; + + reader(); + + reader& operator=(const reader& r) + { + std::memcpy(this, &r, sizeof(reader)); + return *this; + } + + void init(const char* data, size_t size); + void advance(); +}; + +class lexer +{ +private: + reader reader_; + buffer buffer_; + location loc_; + build mode_; + bool in_dev_state_; + std::stack locs_; + std::stack readers_; + std::uint32_t header_top_; + +public: + lexer(const std::string& name, const char* data, size_t size); + auto lex() -> xsk::gsc::s2::parser::symbol_type; + void push_header(const std::string& file); + void pop_header(); + void restrict_header(const xsk::gsc::location& loc); + +private: + auto read_string(char quote, bool localize) -> xsk::gsc::s2::parser::symbol_type; + auto read_number(char first) -> xsk::gsc::s2::parser::symbol_type; + auto read_word(char first) -> xsk::gsc::s2::parser::symbol_type; + auto read_dotsize() -> xsk::gsc::s2::parser::symbol_type; + auto keyword_token(keyword k) -> xsk::gsc::s2::parser::symbol_type; + static auto keyword_is_token(keyword k) -> bool; + static auto get_keyword(std::string_view str) -> keyword; + + static std::unordered_map keywords; +}; + +} // namespace xsk::gsc::s2 diff --git a/src/s2/xsk/parser.cpp b/src/s2/xsk/parser.cpp index 72057ad7..8cb7a131 100644 --- a/src/s2/xsk/parser.cpp +++ b/src/s2/xsk/parser.cpp @@ -35,13 +35,13 @@ // private implementation details that can be changed or removed. // "%code top" blocks. -#line 40 "parser.ypp" +#line 34 "parser.ypp" #include "stdafx.hpp" #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::s2::parser::symbol_type S2lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::s2::parser::symbol_type S2lex(xsk::gsc::s2::lexer& lexer); #line 47 "parser.cpp" @@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace s2 { #line 149 "parser.cpp" /// Build a parser object. - parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) + parser::parser (xsk::gsc::s2::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) #if S2DEBUG : yydebug_ (false), yycdebug_ (&std::cerr), @@ -156,8 +156,7 @@ namespace xsk { namespace gsc { namespace s2 { : #endif yy_lac_established_ (false), - yyscanner (yyscanner_yyarg), - ctx (ctx_yyarg), + lexer (lexer_yyarg), ast (ast_yyarg) {} @@ -1593,7 +1592,7 @@ namespace xsk { namespace gsc { namespace s2 { try #endif // YY_EXCEPTIONS { - symbol_type yylookahead (yylex (yyscanner, ctx)); + symbol_type yylookahead (yylex (lexer)); yyla.move (yylookahead); } #if YY_EXCEPTIONS @@ -1980,1303 +1979,1303 @@ namespace xsk { namespace gsc { namespace s2 { switch (yyn) { case 2: // root: program -#line 251 "parser.ypp" +#line 245 "parser.ypp" { ast = std::move(yystack_[0].value.as < ast::program::ptr > ()); } -#line 1986 "parser.cpp" +#line 1985 "parser.cpp" break; case 3: // root: %empty -#line 252 "parser.ypp" +#line 246 "parser.ypp" { ast = std::make_unique(yylhs.location); } -#line 1992 "parser.cpp" +#line 1991 "parser.cpp" break; case 4: // program: program inline -#line 257 "parser.ypp" +#line 251 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); } -#line 1998 "parser.cpp" +#line 1997 "parser.cpp" break; case 5: // program: program include -#line 259 "parser.ypp" +#line 253 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2004 "parser.cpp" +#line 2003 "parser.cpp" break; case 6: // program: program declaration -#line 261 "parser.ypp" +#line 255 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2010 "parser.cpp" +#line 2009 "parser.cpp" break; case 7: // program: inline -#line 263 "parser.ypp" +#line 257 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); } -#line 2016 "parser.cpp" +#line 2015 "parser.cpp" break; case 8: // program: include -#line 265 "parser.ypp" +#line 259 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2022 "parser.cpp" +#line 2021 "parser.cpp" break; case 9: // program: declaration -#line 267 "parser.ypp" +#line 261 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2028 "parser.cpp" +#line 2027 "parser.cpp" break; case 10: // inline: "#inline" expr_path ";" -#line 271 "parser.ypp" - { s2_push_header(ctx, yystack_[1].value.as < ast::expr_path::ptr > ()->value); } -#line 2034 "parser.cpp" +#line 265 "parser.ypp" + { lexer.push_header(yystack_[1].value.as < ast::expr_path::ptr > ()->value); } +#line 2033 "parser.cpp" break; case 11: // include: "#include" expr_path ";" -#line 276 "parser.ypp" +#line 270 "parser.ypp" { yylhs.value.as < ast::include::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_path::ptr > ())); } -#line 2040 "parser.cpp" +#line 2039 "parser.cpp" break; case 12: // declaration: "/#" -#line 280 "parser.ypp" +#line 274 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_begin = std::make_unique(yylhs.location); } -#line 2046 "parser.cpp" +#line 2045 "parser.cpp" break; case 13: // declaration: "#/" -#line 281 "parser.ypp" +#line 275 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_end = std::make_unique(yylhs.location); } -#line 2052 "parser.cpp" +#line 2051 "parser.cpp" break; case 14: // declaration: decl_usingtree -#line 282 "parser.ypp" +#line 276 "parser.ypp" { yylhs.value.as < ast::decl > ().as_usingtree = std::move(yystack_[0].value.as < ast::decl_usingtree::ptr > ()); } -#line 2058 "parser.cpp" +#line 2057 "parser.cpp" break; case 15: // declaration: decl_constant -#line 283 "parser.ypp" +#line 277 "parser.ypp" { yylhs.value.as < ast::decl > ().as_constant = std::move(yystack_[0].value.as < ast::decl_constant::ptr > ()); } -#line 2064 "parser.cpp" +#line 2063 "parser.cpp" break; case 16: // declaration: decl_thread -#line 284 "parser.ypp" +#line 278 "parser.ypp" { yylhs.value.as < ast::decl > ().as_thread = std::move(yystack_[0].value.as < ast::decl_thread::ptr > ()); } -#line 2070 "parser.cpp" +#line 2069 "parser.cpp" break; case 17: // decl_usingtree: "#using_animtree" "(" expr_string ")" ";" -#line 289 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } -#line 2076 "parser.cpp" +#line 283 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } +#line 2075 "parser.cpp" break; case 18: // decl_constant: expr_identifier "=" expr ";" -#line 294 "parser.ypp" +#line 288 "parser.ypp" { yylhs.value.as < ast::decl_constant::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2082 "parser.cpp" +#line 2081 "parser.cpp" break; case 19: // decl_thread: expr_identifier "(" expr_parameters ")" stmt_block -#line 299 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2088 "parser.cpp" +#line 293 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } +#line 2087 "parser.cpp" break; case 20: // stmt: stmt_dev -#line 303 "parser.ypp" +#line 297 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2094 "parser.cpp" +#line 2093 "parser.cpp" break; case 21: // stmt: stmt_block -#line 304 "parser.ypp" +#line 298 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2100 "parser.cpp" +#line 2099 "parser.cpp" break; case 22: // stmt: stmt_call -#line 305 "parser.ypp" +#line 299 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_call = std::move(yystack_[0].value.as < ast::stmt_call::ptr > ()); } -#line 2106 "parser.cpp" +#line 2105 "parser.cpp" break; case 23: // stmt: stmt_assign -#line 306 "parser.ypp" +#line 300 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_assign = std::move(yystack_[0].value.as < ast::stmt_assign::ptr > ()); } -#line 2112 "parser.cpp" +#line 2111 "parser.cpp" break; case 24: // stmt: stmt_endon -#line 307 "parser.ypp" +#line 301 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_endon = std::move(yystack_[0].value.as < ast::stmt_endon::ptr > ()); } -#line 2118 "parser.cpp" +#line 2117 "parser.cpp" break; case 25: // stmt: stmt_notify -#line 308 "parser.ypp" +#line 302 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_notify = std::move(yystack_[0].value.as < ast::stmt_notify::ptr > ()); } -#line 2124 "parser.cpp" +#line 2123 "parser.cpp" break; case 26: // stmt: stmt_wait -#line 309 "parser.ypp" +#line 303 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_wait = std::move(yystack_[0].value.as < ast::stmt_wait::ptr > ()); } -#line 2130 "parser.cpp" +#line 2129 "parser.cpp" break; case 27: // stmt: stmt_waittill -#line 310 "parser.ypp" +#line 304 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittill = std::move(yystack_[0].value.as < ast::stmt_waittill::ptr > ()); } -#line 2136 "parser.cpp" +#line 2135 "parser.cpp" break; case 28: // stmt: stmt_waittillmatch -#line 311 "parser.ypp" +#line 305 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillmatch = std::move(yystack_[0].value.as < ast::stmt_waittillmatch::ptr > ()); } -#line 2142 "parser.cpp" +#line 2141 "parser.cpp" break; case 29: // stmt: stmt_waittillframeend -#line 312 "parser.ypp" +#line 306 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillframeend = std::move(yystack_[0].value.as < ast::stmt_waittillframeend::ptr > ()); } -#line 2148 "parser.cpp" +#line 2147 "parser.cpp" break; case 30: // stmt: stmt_waitframe -#line 313 "parser.ypp" +#line 307 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waitframe = std::move(yystack_[0].value.as < ast::stmt_waitframe::ptr > ()); } -#line 2154 "parser.cpp" +#line 2153 "parser.cpp" break; case 31: // stmt: stmt_if -#line 314 "parser.ypp" +#line 308 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_if = std::move(yystack_[0].value.as < ast::stmt_if::ptr > ()); } -#line 2160 "parser.cpp" +#line 2159 "parser.cpp" break; case 32: // stmt: stmt_ifelse -#line 315 "parser.ypp" +#line 309 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_ifelse = std::move(yystack_[0].value.as < ast::stmt_ifelse::ptr > ()); } -#line 2166 "parser.cpp" +#line 2165 "parser.cpp" break; case 33: // stmt: stmt_while -#line 316 "parser.ypp" +#line 310 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_while = std::move(yystack_[0].value.as < ast::stmt_while::ptr > ()); } -#line 2172 "parser.cpp" +#line 2171 "parser.cpp" break; case 34: // stmt: stmt_dowhile -#line 317 "parser.ypp" +#line 311 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_dowhile = std::move(yystack_[0].value.as < ast::stmt_dowhile::ptr > ()); } -#line 2178 "parser.cpp" +#line 2177 "parser.cpp" break; case 35: // stmt: stmt_for -#line 318 "parser.ypp" +#line 312 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_for = std::move(yystack_[0].value.as < ast::stmt_for::ptr > ()); } -#line 2184 "parser.cpp" +#line 2183 "parser.cpp" break; case 36: // stmt: stmt_foreach -#line 319 "parser.ypp" +#line 313 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_foreach = std::move(yystack_[0].value.as < ast::stmt_foreach::ptr > ()); } -#line 2190 "parser.cpp" +#line 2189 "parser.cpp" break; case 37: // stmt: stmt_switch -#line 320 "parser.ypp" +#line 314 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_switch = std::move(yystack_[0].value.as < ast::stmt_switch::ptr > ()); } -#line 2196 "parser.cpp" +#line 2195 "parser.cpp" break; case 38: // stmt: stmt_case -#line 321 "parser.ypp" +#line 315 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_case = std::move(yystack_[0].value.as < ast::stmt_case::ptr > ()); } -#line 2202 "parser.cpp" +#line 2201 "parser.cpp" break; case 39: // stmt: stmt_default -#line 322 "parser.ypp" +#line 316 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_default = std::move(yystack_[0].value.as < ast::stmt_default::ptr > ()); } -#line 2208 "parser.cpp" +#line 2207 "parser.cpp" break; case 40: // stmt: stmt_break -#line 323 "parser.ypp" +#line 317 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_break = std::move(yystack_[0].value.as < ast::stmt_break::ptr > ()); } -#line 2214 "parser.cpp" +#line 2213 "parser.cpp" break; case 41: // stmt: stmt_continue -#line 324 "parser.ypp" +#line 318 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_continue = std::move(yystack_[0].value.as < ast::stmt_continue::ptr > ()); } -#line 2220 "parser.cpp" +#line 2219 "parser.cpp" break; case 42: // stmt: stmt_return -#line 325 "parser.ypp" +#line 319 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_return = std::move(yystack_[0].value.as < ast::stmt_return::ptr > ()); } -#line 2226 "parser.cpp" +#line 2225 "parser.cpp" break; case 43: // stmt: stmt_breakpoint -#line 326 "parser.ypp" +#line 320 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_breakpoint = std::move(yystack_[0].value.as < ast::stmt_breakpoint::ptr > ()); } -#line 2232 "parser.cpp" +#line 2231 "parser.cpp" break; case 44: // stmt: stmt_prof_begin -#line 327 "parser.ypp" +#line 321 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_begin = std::move(yystack_[0].value.as < ast::stmt_prof_begin::ptr > ()); } -#line 2238 "parser.cpp" +#line 2237 "parser.cpp" break; case 45: // stmt: stmt_prof_end -#line 328 "parser.ypp" +#line 322 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_end = std::move(yystack_[0].value.as < ast::stmt_prof_end::ptr > ()); } -#line 2244 "parser.cpp" +#line 2243 "parser.cpp" break; case 46: // stmt_dev: "/#" stmt_list "#/" -#line 332 "parser.ypp" +#line 326 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2250 "parser.cpp" +#line 2249 "parser.cpp" break; case 47: // stmt_dev: "/#" "#/" -#line 333 "parser.ypp" +#line 327 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2256 "parser.cpp" +#line 2255 "parser.cpp" break; case 48: // stmt_block: "{" stmt_list "}" -#line 337 "parser.ypp" +#line 331 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2262 "parser.cpp" +#line 2261 "parser.cpp" break; case 49: // stmt_block: "{" "}" -#line 338 "parser.ypp" +#line 332 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2268 "parser.cpp" +#line 2267 "parser.cpp" break; case 50: // stmt_list: stmt_list stmt -#line 343 "parser.ypp" +#line 337 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2274 "parser.cpp" +#line 2273 "parser.cpp" break; case 51: // stmt_list: stmt -#line 345 "parser.ypp" +#line 339 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2280 "parser.cpp" +#line 2279 "parser.cpp" break; case 52: // stmt_expr: expr_assign -#line 350 "parser.ypp" +#line 344 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2286 "parser.cpp" +#line 2285 "parser.cpp" break; case 53: // stmt_expr: expr_increment -#line 352 "parser.ypp" +#line 346 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2292 "parser.cpp" +#line 2291 "parser.cpp" break; case 54: // stmt_expr: expr_decrement -#line 354 "parser.ypp" +#line 348 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2298 "parser.cpp" +#line 2297 "parser.cpp" break; case 55: // stmt_expr: %empty -#line 356 "parser.ypp" +#line 350 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2304 "parser.cpp" +#line 2303 "parser.cpp" break; case 56: // stmt_call: expr_call ";" -#line 361 "parser.ypp" +#line 355 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_call::ptr > ()))); } -#line 2310 "parser.cpp" +#line 2309 "parser.cpp" break; case 57: // stmt_call: expr_method ";" -#line 363 "parser.ypp" +#line 357 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_method::ptr > ()))); } -#line 2316 "parser.cpp" +#line 2315 "parser.cpp" break; case 58: // stmt_assign: expr_assign ";" -#line 368 "parser.ypp" +#line 362 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2322 "parser.cpp" +#line 2321 "parser.cpp" break; case 59: // stmt_assign: expr_increment ";" -#line 370 "parser.ypp" +#line 364 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2328 "parser.cpp" +#line 2327 "parser.cpp" break; case 60: // stmt_assign: expr_decrement ";" -#line 372 "parser.ypp" +#line 366 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2334 "parser.cpp" +#line 2333 "parser.cpp" break; case 61: // stmt_endon: expr_object "endon" "(" expr ")" ";" -#line 377 "parser.ypp" +#line 371 "parser.ypp" { yylhs.value.as < ast::stmt_endon::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ())); } -#line 2340 "parser.cpp" +#line 2339 "parser.cpp" break; case 62: // stmt_notify: expr_object "notify" "(" expr "," expr_arguments_no_empty ")" ";" -#line 382 "parser.ypp" +#line 376 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2346 "parser.cpp" +#line 2345 "parser.cpp" break; case 63: // stmt_notify: expr_object "notify" "(" expr ")" ";" -#line 384 "parser.ypp" +#line 378 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2352 "parser.cpp" +#line 2351 "parser.cpp" break; case 64: // stmt_wait: "wait" expr ";" -#line 389 "parser.ypp" +#line 383 "parser.ypp" { yylhs.value.as < ast::stmt_wait::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2358 "parser.cpp" +#line 2357 "parser.cpp" break; case 65: // stmt_waittill: expr_object "waittill" "(" expr "," expr_arguments_no_empty ")" ";" -#line 394 "parser.ypp" +#line 388 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2364 "parser.cpp" +#line 2363 "parser.cpp" break; case 66: // stmt_waittill: expr_object "waittill" "(" expr ")" ";" -#line 396 "parser.ypp" +#line 390 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2370 "parser.cpp" +#line 2369 "parser.cpp" break; case 67: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr "," expr_arguments_no_empty ")" ";" -#line 401 "parser.ypp" +#line 395 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2376 "parser.cpp" +#line 2375 "parser.cpp" break; case 68: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr ")" ";" -#line 403 "parser.ypp" +#line 397 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2382 "parser.cpp" +#line 2381 "parser.cpp" break; case 69: // stmt_waittillframeend: "waittillframeend" ";" -#line 408 "parser.ypp" +#line 402 "parser.ypp" { yylhs.value.as < ast::stmt_waittillframeend::ptr > () = std::make_unique(yylhs.location); } -#line 2388 "parser.cpp" +#line 2387 "parser.cpp" break; case 70: // stmt_waitframe: "waitframe" ";" -#line 413 "parser.ypp" +#line 407 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2394 "parser.cpp" +#line 2393 "parser.cpp" break; case 71: // stmt_waitframe: "waitframe" "(" ")" ";" -#line 415 "parser.ypp" +#line 409 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2400 "parser.cpp" +#line 2399 "parser.cpp" break; case 72: // stmt_if: "if" "(" expr ")" stmt -#line 420 "parser.ypp" +#line 414 "parser.ypp" { yylhs.value.as < ast::stmt_if::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2406 "parser.cpp" +#line 2405 "parser.cpp" break; case 73: // stmt_ifelse: "if" "(" expr ")" stmt "else" stmt -#line 425 "parser.ypp" +#line 419 "parser.ypp" { yylhs.value.as < ast::stmt_ifelse::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::stmt > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2412 "parser.cpp" +#line 2411 "parser.cpp" break; case 74: // stmt_while: "while" "(" expr ")" stmt -#line 430 "parser.ypp" +#line 424 "parser.ypp" { yylhs.value.as < ast::stmt_while::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2418 "parser.cpp" +#line 2417 "parser.cpp" break; case 75: // stmt_dowhile: "do" stmt "while" "(" expr ")" ";" -#line 435 "parser.ypp" +#line 429 "parser.ypp" { yylhs.value.as < ast::stmt_dowhile::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[5].value.as < ast::stmt > ())); } -#line 2424 "parser.cpp" +#line 2423 "parser.cpp" break; case 76: // stmt_for: "for" "(" stmt_expr ";" expr_or_empty ";" stmt_expr ")" stmt -#line 440 "parser.ypp" +#line 434 "parser.ypp" { yylhs.value.as < ast::stmt_for::ptr > () = std::make_unique(yylhs.location, ast::stmt(std::move(yystack_[6].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[4].value.as < ast::expr > ()), ast::stmt(std::move(yystack_[2].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2430 "parser.cpp" +#line 2429 "parser.cpp" break; case 77: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt -#line 445 "parser.ypp" +#line 439 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2436 "parser.cpp" +#line 2435 "parser.cpp" break; case 78: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt -#line 447 "parser.ypp" +#line 441 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[6].value.as < ast::expr_identifier::ptr > ())), ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2442 "parser.cpp" +#line 2441 "parser.cpp" break; case 79: // stmt_switch: "switch" "(" expr ")" stmt_block -#line 452 "parser.ypp" +#line 446 "parser.ypp" { yylhs.value.as < ast::stmt_switch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2448 "parser.cpp" +#line 2447 "parser.cpp" break; case 80: // stmt_case: "case" expr_integer ":" -#line 457 "parser.ypp" +#line 451 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_integer::ptr > ())), std::make_unique(yylhs.location)); } -#line 2454 "parser.cpp" +#line 2453 "parser.cpp" break; case 81: // stmt_case: "case" expr_string ":" -#line 459 "parser.ypp" +#line 453 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_string::ptr > ())), std::make_unique(yylhs.location)); } -#line 2460 "parser.cpp" +#line 2459 "parser.cpp" break; case 82: // stmt_default: "default" ":" -#line 464 "parser.ypp" +#line 458 "parser.ypp" { yylhs.value.as < ast::stmt_default::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2466 "parser.cpp" +#line 2465 "parser.cpp" break; case 83: // stmt_break: "break" ";" -#line 469 "parser.ypp" +#line 463 "parser.ypp" { yylhs.value.as < ast::stmt_break::ptr > () = std::make_unique(yylhs.location); } -#line 2472 "parser.cpp" +#line 2471 "parser.cpp" break; case 84: // stmt_continue: "continue" ";" -#line 474 "parser.ypp" +#line 468 "parser.ypp" { yylhs.value.as < ast::stmt_continue::ptr > () = std::make_unique(yylhs.location); } -#line 2478 "parser.cpp" +#line 2477 "parser.cpp" break; case 85: // stmt_return: "return" expr ";" -#line 479 "parser.ypp" +#line 473 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2484 "parser.cpp" +#line 2483 "parser.cpp" break; case 86: // stmt_return: "return" ";" -#line 481 "parser.ypp" +#line 475 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2490 "parser.cpp" +#line 2489 "parser.cpp" break; case 87: // stmt_breakpoint: "breakpoint" ";" -#line 486 "parser.ypp" +#line 480 "parser.ypp" { yylhs.value.as < ast::stmt_breakpoint::ptr > () = std::make_unique(yylhs.location); } -#line 2496 "parser.cpp" +#line 2495 "parser.cpp" break; case 88: // stmt_prof_begin: "prof_begin" "(" expr_arguments ")" ";" -#line 491 "parser.ypp" +#line 485 "parser.ypp" { yylhs.value.as < ast::stmt_prof_begin::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2502 "parser.cpp" +#line 2501 "parser.cpp" break; case 89: // stmt_prof_end: "prof_end" "(" expr_arguments ")" ";" -#line 496 "parser.ypp" +#line 490 "parser.ypp" { yylhs.value.as < ast::stmt_prof_end::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2508 "parser.cpp" +#line 2507 "parser.cpp" break; case 90: // expr: expr_ternary -#line 500 "parser.ypp" +#line 494 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2514 "parser.cpp" +#line 2513 "parser.cpp" break; case 91: // expr: expr_binary -#line 501 "parser.ypp" +#line 495 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2520 "parser.cpp" +#line 2519 "parser.cpp" break; case 92: // expr: expr_primitive -#line 502 "parser.ypp" +#line 496 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2526 "parser.cpp" +#line 2525 "parser.cpp" break; case 93: // expr_or_empty: expr -#line 506 "parser.ypp" +#line 500 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2532 "parser.cpp" +#line 2531 "parser.cpp" break; case 94: // expr_or_empty: %empty -#line 507 "parser.ypp" +#line 501 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location); } -#line 2538 "parser.cpp" +#line 2537 "parser.cpp" break; case 95: // expr_assign: expr_object "=" expr -#line 512 "parser.ypp" +#line 506 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2544 "parser.cpp" +#line 2543 "parser.cpp" break; case 96: // expr_assign: expr_object "|=" expr -#line 514 "parser.ypp" +#line 508 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2550 "parser.cpp" +#line 2549 "parser.cpp" break; case 97: // expr_assign: expr_object "&=" expr -#line 516 "parser.ypp" +#line 510 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2556 "parser.cpp" +#line 2555 "parser.cpp" break; case 98: // expr_assign: expr_object "^=" expr -#line 518 "parser.ypp" +#line 512 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2562 "parser.cpp" +#line 2561 "parser.cpp" break; case 99: // expr_assign: expr_object "<<=" expr -#line 520 "parser.ypp" +#line 514 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()),std::move( yystack_[0].value.as < ast::expr > ())); } -#line 2568 "parser.cpp" +#line 2567 "parser.cpp" break; case 100: // expr_assign: expr_object ">>=" expr -#line 522 "parser.ypp" +#line 516 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2574 "parser.cpp" +#line 2573 "parser.cpp" break; case 101: // expr_assign: expr_object "+=" expr -#line 524 "parser.ypp" +#line 518 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2580 "parser.cpp" +#line 2579 "parser.cpp" break; case 102: // expr_assign: expr_object "-=" expr -#line 526 "parser.ypp" +#line 520 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2586 "parser.cpp" +#line 2585 "parser.cpp" break; case 103: // expr_assign: expr_object "*=" expr -#line 528 "parser.ypp" +#line 522 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2592 "parser.cpp" +#line 2591 "parser.cpp" break; case 104: // expr_assign: expr_object "/=" expr -#line 530 "parser.ypp" +#line 524 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2598 "parser.cpp" +#line 2597 "parser.cpp" break; case 105: // expr_assign: expr_object "%=" expr -#line 532 "parser.ypp" +#line 526 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2604 "parser.cpp" +#line 2603 "parser.cpp" break; case 106: // expr_increment: "++" expr_object -#line 537 "parser.ypp" +#line 531 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2610 "parser.cpp" +#line 2609 "parser.cpp" break; case 107: // expr_increment: expr_object "++" -#line 539 "parser.ypp" +#line 533 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2616 "parser.cpp" +#line 2615 "parser.cpp" break; case 108: // expr_decrement: "--" expr_object -#line 544 "parser.ypp" +#line 538 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2622 "parser.cpp" +#line 2621 "parser.cpp" break; case 109: // expr_decrement: expr_object "--" -#line 546 "parser.ypp" +#line 540 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2628 "parser.cpp" +#line 2627 "parser.cpp" break; case 110: // expr_ternary: expr "?" expr ":" expr -#line 551 "parser.ypp" +#line 545 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2634 "parser.cpp" +#line 2633 "parser.cpp" break; case 111: // expr_binary: expr "||" expr -#line 556 "parser.ypp" +#line 550 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2640 "parser.cpp" +#line 2639 "parser.cpp" break; case 112: // expr_binary: expr "&&" expr -#line 558 "parser.ypp" +#line 552 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2646 "parser.cpp" +#line 2645 "parser.cpp" break; case 113: // expr_binary: expr "==" expr -#line 560 "parser.ypp" +#line 554 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2652 "parser.cpp" +#line 2651 "parser.cpp" break; case 114: // expr_binary: expr "!=" expr -#line 562 "parser.ypp" +#line 556 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2658 "parser.cpp" +#line 2657 "parser.cpp" break; case 115: // expr_binary: expr "<=" expr -#line 564 "parser.ypp" +#line 558 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2664 "parser.cpp" +#line 2663 "parser.cpp" break; case 116: // expr_binary: expr ">=" expr -#line 566 "parser.ypp" +#line 560 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2670 "parser.cpp" +#line 2669 "parser.cpp" break; case 117: // expr_binary: expr "<" expr -#line 568 "parser.ypp" +#line 562 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2676 "parser.cpp" +#line 2675 "parser.cpp" break; case 118: // expr_binary: expr ">" expr -#line 570 "parser.ypp" +#line 564 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2682 "parser.cpp" +#line 2681 "parser.cpp" break; case 119: // expr_binary: expr "|" expr -#line 572 "parser.ypp" +#line 566 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2688 "parser.cpp" +#line 2687 "parser.cpp" break; case 120: // expr_binary: expr "&" expr -#line 574 "parser.ypp" +#line 568 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2694 "parser.cpp" +#line 2693 "parser.cpp" break; case 121: // expr_binary: expr "^" expr -#line 576 "parser.ypp" +#line 570 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2700 "parser.cpp" +#line 2699 "parser.cpp" break; case 122: // expr_binary: expr "<<" expr -#line 578 "parser.ypp" +#line 572 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2706 "parser.cpp" +#line 2705 "parser.cpp" break; case 123: // expr_binary: expr ">>" expr -#line 580 "parser.ypp" +#line 574 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2712 "parser.cpp" +#line 2711 "parser.cpp" break; case 124: // expr_binary: expr "+" expr -#line 582 "parser.ypp" +#line 576 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2718 "parser.cpp" +#line 2717 "parser.cpp" break; case 125: // expr_binary: expr "-" expr -#line 584 "parser.ypp" +#line 578 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2724 "parser.cpp" +#line 2723 "parser.cpp" break; case 126: // expr_binary: expr "*" expr -#line 586 "parser.ypp" +#line 580 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2730 "parser.cpp" +#line 2729 "parser.cpp" break; case 127: // expr_binary: expr "/" expr -#line 588 "parser.ypp" +#line 582 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2736 "parser.cpp" +#line 2735 "parser.cpp" break; case 128: // expr_binary: expr "%" expr -#line 590 "parser.ypp" +#line 584 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2742 "parser.cpp" +#line 2741 "parser.cpp" break; case 129: // expr_primitive: expr_complement -#line 594 "parser.ypp" +#line 588 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_complement::ptr > ()); } -#line 2748 "parser.cpp" +#line 2747 "parser.cpp" break; case 130: // expr_primitive: expr_not -#line 595 "parser.ypp" +#line 589 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_not::ptr > ()); } -#line 2754 "parser.cpp" +#line 2753 "parser.cpp" break; case 131: // expr_primitive: expr_call -#line 596 "parser.ypp" +#line 590 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 2760 "parser.cpp" +#line 2759 "parser.cpp" break; case 132: // expr_primitive: expr_method -#line 597 "parser.ypp" +#line 591 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 2766 "parser.cpp" +#line 2765 "parser.cpp" break; case 133: // expr_primitive: expr_add_array -#line 598 "parser.ypp" +#line 592 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_add_array::ptr > ()); } -#line 2772 "parser.cpp" +#line 2771 "parser.cpp" break; case 134: // expr_primitive: expr_reference -#line 599 "parser.ypp" +#line 593 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_reference::ptr > ()); } -#line 2778 "parser.cpp" +#line 2777 "parser.cpp" break; case 135: // expr_primitive: expr_array -#line 600 "parser.ypp" +#line 594 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 2784 "parser.cpp" +#line 2783 "parser.cpp" break; case 136: // expr_primitive: expr_field -#line 601 "parser.ypp" +#line 595 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 2790 "parser.cpp" +#line 2789 "parser.cpp" break; case 137: // expr_primitive: expr_size -#line 602 "parser.ypp" +#line 596 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_size::ptr > ()); } -#line 2796 "parser.cpp" +#line 2795 "parser.cpp" break; case 138: // expr_primitive: expr_paren -#line 603 "parser.ypp" +#line 597 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_paren::ptr > ()); } -#line 2802 "parser.cpp" +#line 2801 "parser.cpp" break; case 139: // expr_primitive: expr_thisthread -#line 604 "parser.ypp" +#line 598 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_thisthread::ptr > ()); } -#line 2808 "parser.cpp" +#line 2807 "parser.cpp" break; case 140: // expr_primitive: expr_empty_array -#line 605 "parser.ypp" +#line 599 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_empty_array::ptr > ()); } -#line 2814 "parser.cpp" +#line 2813 "parser.cpp" break; case 141: // expr_primitive: expr_undefined -#line 606 "parser.ypp" +#line 600 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_undefined::ptr > ()); } -#line 2820 "parser.cpp" +#line 2819 "parser.cpp" break; case 142: // expr_primitive: expr_game -#line 607 "parser.ypp" +#line 601 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 2826 "parser.cpp" +#line 2825 "parser.cpp" break; case 143: // expr_primitive: expr_self -#line 608 "parser.ypp" +#line 602 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 2832 "parser.cpp" +#line 2831 "parser.cpp" break; case 144: // expr_primitive: expr_anim -#line 609 "parser.ypp" +#line 603 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 2838 "parser.cpp" +#line 2837 "parser.cpp" break; case 145: // expr_primitive: expr_level -#line 610 "parser.ypp" +#line 604 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 2844 "parser.cpp" +#line 2843 "parser.cpp" break; case 146: // expr_primitive: expr_animation -#line 611 "parser.ypp" +#line 605 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animation::ptr > ()); } -#line 2850 "parser.cpp" +#line 2849 "parser.cpp" break; case 147: // expr_primitive: expr_animtree -#line 612 "parser.ypp" +#line 606 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animtree::ptr > ()); } -#line 2856 "parser.cpp" +#line 2855 "parser.cpp" break; case 148: // expr_primitive: expr_identifier -#line 613 "parser.ypp" +#line 607 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 2862 "parser.cpp" +#line 2861 "parser.cpp" break; case 149: // expr_primitive: expr_istring -#line 614 "parser.ypp" +#line 608 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istring::ptr > ()); } -#line 2868 "parser.cpp" +#line 2867 "parser.cpp" break; case 150: // expr_primitive: expr_string -#line 615 "parser.ypp" +#line 609 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_string::ptr > ()); } -#line 2874 "parser.cpp" +#line 2873 "parser.cpp" break; case 151: // expr_primitive: expr_color -#line 616 "parser.ypp" +#line 610 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_color::ptr > ()); } -#line 2880 "parser.cpp" +#line 2879 "parser.cpp" break; case 152: // expr_primitive: expr_vector -#line 617 "parser.ypp" +#line 611 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_vector::ptr > ()); } -#line 2886 "parser.cpp" +#line 2885 "parser.cpp" break; case 153: // expr_primitive: expr_float -#line 618 "parser.ypp" +#line 612 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_float::ptr > ()); } -#line 2892 "parser.cpp" +#line 2891 "parser.cpp" break; case 154: // expr_primitive: expr_integer -#line 619 "parser.ypp" +#line 613 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_integer::ptr > ()); } -#line 2898 "parser.cpp" +#line 2897 "parser.cpp" break; case 155: // expr_primitive: expr_false -#line 620 "parser.ypp" +#line 614 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_false::ptr > ()); } -#line 2904 "parser.cpp" +#line 2903 "parser.cpp" break; case 156: // expr_primitive: expr_true -#line 621 "parser.ypp" +#line 615 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_true::ptr > ()); } -#line 2910 "parser.cpp" +#line 2909 "parser.cpp" break; case 157: // expr_complement: "~" expr -#line 626 "parser.ypp" +#line 620 "parser.ypp" { yylhs.value.as < ast::expr_complement::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2916 "parser.cpp" +#line 2915 "parser.cpp" break; case 158: // expr_not: "!" expr -#line 631 "parser.ypp" +#line 625 "parser.ypp" { yylhs.value.as < ast::expr_not::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2922 "parser.cpp" +#line 2921 "parser.cpp" break; case 159: // expr_call: expr_function -#line 635 "parser.ypp" +#line 629 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2928 "parser.cpp" +#line 2927 "parser.cpp" break; case 160: // expr_call: expr_pointer -#line 636 "parser.ypp" +#line 630 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2934 "parser.cpp" +#line 2933 "parser.cpp" break; case 161: // expr_method: expr_object expr_function -#line 639 "parser.ypp" +#line 633 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2940 "parser.cpp" +#line 2939 "parser.cpp" break; case 162: // expr_method: expr_object expr_pointer -#line 640 "parser.ypp" +#line 634 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2946 "parser.cpp" +#line 2945 "parser.cpp" break; case 163: // expr_function: expr_identifier "(" expr_arguments ")" -#line 645 "parser.ypp" +#line 639 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2952 "parser.cpp" +#line 2951 "parser.cpp" break; case 164: // expr_function: expr_path "::" expr_identifier "(" expr_arguments ")" -#line 647 "parser.ypp" +#line 641 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2958 "parser.cpp" +#line 2957 "parser.cpp" break; case 165: // expr_function: "thread" expr_identifier "(" expr_arguments ")" -#line 649 "parser.ypp" +#line 643 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2964 "parser.cpp" +#line 2963 "parser.cpp" break; case 166: // expr_function: "thread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 651 "parser.ypp" +#line 645 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2970 "parser.cpp" +#line 2969 "parser.cpp" break; case 167: // expr_function: "childthread" expr_identifier "(" expr_arguments ")" -#line 653 "parser.ypp" +#line 647 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2976 "parser.cpp" +#line 2975 "parser.cpp" break; case 168: // expr_function: "childthread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 655 "parser.ypp" +#line 649 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 2982 "parser.cpp" +#line 2981 "parser.cpp" break; case 169: // expr_pointer: "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 660 "parser.ypp" +#line 654 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 2988 "parser.cpp" +#line 2987 "parser.cpp" break; case 170: // expr_pointer: "thread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 662 "parser.ypp" +#line 656 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 2994 "parser.cpp" +#line 2993 "parser.cpp" break; case 171: // expr_pointer: "childthread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 664 "parser.ypp" +#line 658 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3000 "parser.cpp" +#line 2999 "parser.cpp" break; case 172: // expr_pointer: "call" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 666 "parser.ypp" +#line 660 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::builtin); } -#line 3006 "parser.cpp" +#line 3005 "parser.cpp" break; case 173: // expr_add_array: "[" expr_arguments_no_empty "]" -#line 671 "parser.ypp" +#line 665 "parser.ypp" { yylhs.value.as < ast::expr_add_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ())); } -#line 3012 "parser.cpp" +#line 3011 "parser.cpp" break; case 174: // expr_parameters: expr_parameters "," expr_identifier -#line 676 "parser.ypp" +#line 670 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3018 "parser.cpp" +#line 3017 "parser.cpp" break; case 175: // expr_parameters: expr_identifier -#line 678 "parser.ypp" +#line 672 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3024 "parser.cpp" +#line 3023 "parser.cpp" break; case 176: // expr_parameters: %empty -#line 680 "parser.ypp" +#line 674 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); } -#line 3030 "parser.cpp" +#line 3029 "parser.cpp" break; case 177: // expr_arguments: expr_arguments_no_empty -#line 685 "parser.ypp" +#line 679 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[0].value.as < ast::expr_arguments::ptr > ()); } -#line 3036 "parser.cpp" +#line 3035 "parser.cpp" break; case 178: // expr_arguments: %empty -#line 687 "parser.ypp" +#line 681 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); } -#line 3042 "parser.cpp" +#line 3041 "parser.cpp" break; case 179: // expr_arguments_no_empty: expr_arguments "," expr -#line 692 "parser.ypp" +#line 686 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ()); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3048 "parser.cpp" +#line 3047 "parser.cpp" break; case 180: // expr_arguments_no_empty: expr -#line 694 "parser.ypp" +#line 688 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3054 "parser.cpp" +#line 3053 "parser.cpp" break; case 181: // expr_reference: "::" expr_identifier -#line 699 "parser.ypp" +#line 693 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3060 "parser.cpp" +#line 3059 "parser.cpp" break; case 182: // expr_reference: expr_path "::" expr_identifier -#line 701 "parser.ypp" +#line 695 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_path::ptr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3066 "parser.cpp" +#line 3065 "parser.cpp" break; case 183: // expr_array: expr_object "[" expr "]" -#line 706 "parser.ypp" +#line 700 "parser.ypp" { yylhs.value.as < ast::expr_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3072 "parser.cpp" +#line 3071 "parser.cpp" break; case 184: // expr_field: expr_object "." expr_identifier -#line 711 "parser.ypp" +#line 705 "parser.ypp" { yylhs.value.as < ast::expr_field::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3078 "parser.cpp" +#line 3077 "parser.cpp" break; case 185: // expr_size: expr_object ".size" -#line 716 "parser.ypp" +#line 710 "parser.ypp" { yylhs.value.as < ast::expr_size::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3084 "parser.cpp" +#line 3083 "parser.cpp" break; case 186: // expr_paren: "(" expr ")" -#line 721 "parser.ypp" +#line 715 "parser.ypp" { yylhs.value.as < ast::expr_paren::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3090 "parser.cpp" +#line 3089 "parser.cpp" break; case 187: // expr_object: expr_call -#line 725 "parser.ypp" +#line 719 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 3096 "parser.cpp" +#line 3095 "parser.cpp" break; case 188: // expr_object: expr_method -#line 726 "parser.ypp" +#line 720 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 3102 "parser.cpp" +#line 3101 "parser.cpp" break; case 189: // expr_object: expr_array -#line 727 "parser.ypp" +#line 721 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 3108 "parser.cpp" +#line 3107 "parser.cpp" break; case 190: // expr_object: expr_field -#line 728 "parser.ypp" +#line 722 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 3114 "parser.cpp" +#line 3113 "parser.cpp" break; case 191: // expr_object: expr_game -#line 729 "parser.ypp" +#line 723 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 3120 "parser.cpp" +#line 3119 "parser.cpp" break; case 192: // expr_object: expr_self -#line 730 "parser.ypp" +#line 724 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 3126 "parser.cpp" +#line 3125 "parser.cpp" break; case 193: // expr_object: expr_anim -#line 731 "parser.ypp" +#line 725 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 3132 "parser.cpp" +#line 3131 "parser.cpp" break; case 194: // expr_object: expr_level -#line 732 "parser.ypp" +#line 726 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 3138 "parser.cpp" +#line 3137 "parser.cpp" break; case 195: // expr_object: expr_identifier -#line 733 "parser.ypp" +#line 727 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 3144 "parser.cpp" +#line 3143 "parser.cpp" break; case 196: // expr_thisthread: "thisthread" -#line 738 "parser.ypp" +#line 732 "parser.ypp" { yylhs.value.as < ast::expr_thisthread::ptr > () = std::make_unique(yylhs.location); } -#line 3150 "parser.cpp" +#line 3149 "parser.cpp" break; case 197: // expr_empty_array: "[" "]" -#line 743 "parser.ypp" +#line 737 "parser.ypp" { yylhs.value.as < ast::expr_empty_array::ptr > () = std::make_unique(yylhs.location); } -#line 3156 "parser.cpp" +#line 3155 "parser.cpp" break; case 198: // expr_undefined: "undefined" -#line 748 "parser.ypp" +#line 742 "parser.ypp" { yylhs.value.as < ast::expr_undefined::ptr > () = std::make_unique(yylhs.location); } -#line 3162 "parser.cpp" +#line 3161 "parser.cpp" break; case 199: // expr_game: "game" -#line 753 "parser.ypp" +#line 747 "parser.ypp" { yylhs.value.as < ast::expr_game::ptr > () = std::make_unique(yylhs.location); } -#line 3168 "parser.cpp" +#line 3167 "parser.cpp" break; case 200: // expr_self: "self" -#line 758 "parser.ypp" +#line 752 "parser.ypp" { yylhs.value.as < ast::expr_self::ptr > () = std::make_unique(yylhs.location); } -#line 3174 "parser.cpp" +#line 3173 "parser.cpp" break; case 201: // expr_anim: "anim" -#line 763 "parser.ypp" +#line 757 "parser.ypp" { yylhs.value.as < ast::expr_anim::ptr > () = std::make_unique(yylhs.location); } -#line 3180 "parser.cpp" +#line 3179 "parser.cpp" break; case 202: // expr_level: "level" -#line 768 "parser.ypp" +#line 762 "parser.ypp" { yylhs.value.as < ast::expr_level::ptr > () = std::make_unique(yylhs.location); } -#line 3186 "parser.cpp" +#line 3185 "parser.cpp" break; case 203: // expr_animation: "%" "identifier" -#line 773 "parser.ypp" +#line 767 "parser.ypp" { yylhs.value.as < ast::expr_animation::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3192 "parser.cpp" +#line 3191 "parser.cpp" break; case 204: // expr_animtree: "#animtree" -#line 778 "parser.ypp" +#line 772 "parser.ypp" { yylhs.value.as < ast::expr_animtree::ptr > () = std::make_unique(yylhs.location); } -#line 3198 "parser.cpp" +#line 3197 "parser.cpp" break; case 205: // expr_identifier: "identifier" -#line 783 "parser.ypp" +#line 777 "parser.ypp" { yylhs.value.as < ast::expr_identifier::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3204 "parser.cpp" +#line 3203 "parser.cpp" break; case 206: // expr_path: "path" -#line 788 "parser.ypp" +#line 782 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3210 "parser.cpp" +#line 3209 "parser.cpp" break; case 207: // expr_path: expr_identifier -#line 790 "parser.ypp" +#line 784 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < ast::expr_identifier::ptr > ()->value); } -#line 3216 "parser.cpp" +#line 3215 "parser.cpp" break; case 208: // expr_istring: "localized string" -#line 795 "parser.ypp" +#line 789 "parser.ypp" { yylhs.value.as < ast::expr_istring::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3222 "parser.cpp" +#line 3221 "parser.cpp" break; case 209: // expr_string: "string literal" -#line 800 "parser.ypp" +#line 794 "parser.ypp" { yylhs.value.as < ast::expr_string::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3228 "parser.cpp" +#line 3227 "parser.cpp" break; case 210: // expr_color: "color" -#line 805 "parser.ypp" +#line 799 "parser.ypp" { yylhs.value.as < ast::expr_color::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3234 "parser.cpp" +#line 3233 "parser.cpp" break; case 211: // expr_vector: "(" expr "," expr "," expr ")" -#line 810 "parser.ypp" +#line 804 "parser.ypp" { yylhs.value.as < ast::expr_vector::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3240 "parser.cpp" +#line 3239 "parser.cpp" break; case 212: // expr_float: "-" "float" -#line 815 "parser.ypp" +#line 809 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3246 "parser.cpp" +#line 3245 "parser.cpp" break; case 213: // expr_float: "float" -#line 817 "parser.ypp" +#line 811 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3252 "parser.cpp" +#line 3251 "parser.cpp" break; case 214: // expr_integer: "-" "integer" -#line 822 "parser.ypp" +#line 816 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3258 "parser.cpp" +#line 3257 "parser.cpp" break; case 215: // expr_integer: "integer" -#line 824 "parser.ypp" +#line 818 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3264 "parser.cpp" +#line 3263 "parser.cpp" break; case 216: // expr_false: "false" -#line 829 "parser.ypp" +#line 823 "parser.ypp" { yylhs.value.as < ast::expr_false::ptr > () = std::make_unique(yylhs.location); } -#line 3270 "parser.cpp" +#line 3269 "parser.cpp" break; case 217: // expr_true: "true" -#line 834 "parser.ypp" +#line 828 "parser.ypp" { yylhs.value.as < ast::expr_true::ptr > () = std::make_unique(yylhs.location); } -#line 3276 "parser.cpp" +#line 3275 "parser.cpp" break; -#line 3280 "parser.cpp" +#line 3279 "parser.cpp" default: break; @@ -4446,28 +4445,28 @@ namespace xsk { namespace gsc { namespace s2 { const short parser::yyrline_[] = { - 0, 251, 251, 252, 256, 258, 260, 262, 264, 266, - 271, 275, 280, 281, 282, 283, 284, 288, 293, 298, - 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, - 323, 324, 325, 326, 327, 328, 332, 333, 337, 338, - 342, 344, 349, 351, 353, 356, 360, 362, 367, 369, - 371, 376, 381, 383, 388, 393, 395, 400, 402, 407, - 412, 414, 419, 424, 429, 434, 439, 444, 446, 451, - 456, 458, 463, 468, 473, 478, 480, 485, 490, 495, - 500, 501, 502, 506, 507, 511, 513, 515, 517, 519, - 521, 523, 525, 527, 529, 531, 536, 538, 543, 545, - 550, 555, 557, 559, 561, 563, 565, 567, 569, 571, - 573, 575, 577, 579, 581, 583, 585, 587, 589, 594, - 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, - 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, - 615, 616, 617, 618, 619, 620, 621, 625, 630, 635, - 636, 639, 640, 644, 646, 648, 650, 652, 654, 659, - 661, 663, 665, 670, 675, 677, 680, 684, 687, 691, - 693, 698, 700, 705, 710, 715, 720, 725, 726, 727, - 728, 729, 730, 731, 732, 733, 737, 742, 747, 752, - 757, 762, 767, 772, 777, 782, 787, 789, 794, 799, - 804, 809, 814, 816, 821, 823, 828, 833 + 0, 245, 245, 246, 250, 252, 254, 256, 258, 260, + 265, 269, 274, 275, 276, 277, 278, 282, 287, 292, + 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 326, 327, 331, 332, + 336, 338, 343, 345, 347, 350, 354, 356, 361, 363, + 365, 370, 375, 377, 382, 387, 389, 394, 396, 401, + 406, 408, 413, 418, 423, 428, 433, 438, 440, 445, + 450, 452, 457, 462, 467, 472, 474, 479, 484, 489, + 494, 495, 496, 500, 501, 505, 507, 509, 511, 513, + 515, 517, 519, 521, 523, 525, 530, 532, 537, 539, + 544, 549, 551, 553, 555, 557, 559, 561, 563, 565, + 567, 569, 571, 573, 575, 577, 579, 581, 583, 588, + 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, + 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, + 609, 610, 611, 612, 613, 614, 615, 619, 624, 629, + 630, 633, 634, 638, 640, 642, 644, 646, 648, 653, + 655, 657, 659, 664, 669, 671, 674, 678, 681, 685, + 687, 692, 694, 699, 704, 709, 714, 719, 720, 721, + 722, 723, 724, 725, 726, 727, 731, 736, 741, 746, + 751, 756, 761, 766, 771, 776, 781, 783, 788, 793, + 798, 803, 808, 810, 815, 817, 822, 827 }; void @@ -4500,9 +4499,9 @@ namespace xsk { namespace gsc { namespace s2 { #line 13 "parser.ypp" } } } // xsk::gsc::s2 -#line 4504 "parser.cpp" +#line 4503 "parser.cpp" -#line 837 "parser.ypp" +#line 831 "parser.ypp" void xsk::gsc::s2::parser::error(const xsk::gsc::location& loc, const std::string& msg) diff --git a/src/s2/xsk/parser.hpp b/src/s2/xsk/parser.hpp index f1558432..7348e42d 100644 --- a/src/s2/xsk/parser.hpp +++ b/src/s2/xsk/parser.hpp @@ -45,13 +45,12 @@ #ifndef YY_S2_PARSER_HPP_INCLUDED # define YY_S2_PARSER_HPP_INCLUDED // "%code requires" blocks. -#line 33 "parser.ypp" +#line 28 "parser.ypp" #include "s2.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::s2::parser::symbol_type S2lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::s2 { class lexer; } -#line 55 "parser.hpp" +#line 54 "parser.hpp" # include # include // std::abort @@ -194,7 +193,7 @@ typedef void *yyscan_t; #line 13 "parser.ypp" namespace xsk { namespace gsc { namespace s2 { -#line 198 "parser.hpp" +#line 197 "parser.hpp" @@ -2685,7 +2684,7 @@ switch (yykind) }; /// Build a parser object. - parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); + parser (xsk::gsc::s2::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); virtual ~parser (); #if 201103L <= YY_CPLUSPLUS @@ -4656,8 +4655,7 @@ switch (yykind) // User arguments. - yyscan_t yyscanner; - xsk::gsc::context* ctx; + xsk::gsc::s2::lexer& lexer; xsk::gsc::ast::program::ptr& ast; }; @@ -5342,7 +5340,7 @@ switch (yykind) #line 13 "parser.ypp" } } } // xsk::gsc::s2 -#line 5346 "parser.hpp" +#line 5344 "parser.hpp" diff --git a/src/s2/xsk/resolver.cpp b/src/s2/xsk/resolver.cpp index 8f7ff2f7..de176e36 100644 --- a/src/s2/xsk/resolver.cpp +++ b/src/s2/xsk/resolver.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -206,6 +206,35 @@ auto resolver::make_token(std::string_view str) -> std::string return data; } +std::function(const std::string&)> read_callback = nullptr; +std::unordered_map> files; + +auto resolver::file_data(const std::string& name) -> std::tuple +{ + const auto& itr = files.find(name); + + if(itr != files.end()) + { + return { &itr->first ,reinterpret_cast(itr->second.data()), itr->second.size() }; + } + + auto data = read_callback(name); + + const auto& res = files.insert({ name, std::move(data)}); + + if(res.second) + { + return { &res.first->first, reinterpret_cast(res.first->second.data()), res.first->second.size() }; + } + + throw error("couldn't open gsc file '" + name + "'"); +} + +void resolver::set_reader(std::function(const std::string&)> callback) +{ + read_callback = callback; +} + const std::array, 155> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/s2/xsk/resolver.hpp b/src/s2/xsk/resolver.hpp index 02b06389..d304c1ca 100644 --- a/src/s2/xsk/resolver.hpp +++ b/src/s2/xsk/resolver.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -30,6 +30,8 @@ public: static auto find_method(const std::string& name) -> bool; static auto make_token(std::string_view str) -> std::string; + static auto file_data(const std::string& name) -> std::tuple; + static void set_reader(std::function(const std::string&)> callback); }; } // namespace xsk::gsc::s2 diff --git a/src/s2/xsk/s2.cpp b/src/s2/xsk/s2.cpp index bf204ca8..fb3e6714 100644 --- a/src/s2/xsk/s2.cpp +++ b/src/s2/xsk/s2.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s2/xsk/s2.hpp b/src/s2/xsk/s2.hpp index b7ffc1f5..2e9fda07 100644 --- a/src/s2/xsk/s2.hpp +++ b/src/s2/xsk/s2.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/stdafx.cpp b/src/s4/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/s4/stdafx.cpp +++ b/src/s4/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/stdafx.hpp b/src/s4/stdafx.hpp index 051c0cb9..dd33234d 100644 --- a/src/s4/stdafx.hpp +++ b/src/s4/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/xsk/assembler.cpp b/src/s4/xsk/assembler.cpp index c261fb8a..4412a785 100644 --- a/src/s4/xsk/assembler.cpp +++ b/src/s4/xsk/assembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/xsk/assembler.hpp b/src/s4/xsk/assembler.hpp index c773f68c..37efd520 100644 --- a/src/s4/xsk/assembler.hpp +++ b/src/s4/xsk/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/xsk/compiler.cpp b/src/s4/xsk/compiler.cpp index 2b772f2d..7026f1db 100644 --- a/src/s4/xsk/compiler.cpp +++ b/src/s4/xsk/compiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -19,7 +19,6 @@ auto compiler::output() -> std::vector void compiler::compile(const std::string& file, std::vector& data) { filename_ = file; - sources_.clear(); auto prog = parse_buffer(filename_, data); @@ -33,39 +32,19 @@ void compiler::read_callback(std::function(const std:: auto compiler::parse_buffer(const std::string& file, std::vector& data) -> ast::program::ptr { - yyscan_t scanner; - context ctx; ast::program::ptr result(nullptr); - ctx.header_top = 0; - ctx.mode = mode_; - ctx.read_callback = read_callback_; - ctx.sources = &sources_; - ctx.loc.initialize(&file); + resolver::set_reader(read_callback_); - // Add the two NULL terminators, required by flex. - data.push_back(0); - data.push_back(0); + lexer lexer(file, reinterpret_cast(data.data()), data.size()); - if (s4_lex_init(&scanner)) - { - throw comp_error(ctx.loc, "An unknown error ocurred while starting lexer context."); - } - - ctx.scanner = scanner; - - YY_BUFFER_STATE yybuffer = s4__scan_buffer(reinterpret_cast(data.data()), data.size(), scanner); - - parser parser(scanner, &ctx, result); + parser parser(lexer, result); if (parser.parse() || result == nullptr) { - throw comp_error(ctx.loc, "An unknown error ocurred while parsing gsc file."); + throw comp_error(xsk::gsc::location(&file), "An unknown error ocurred while parsing gsc file."); } - s4__delete_buffer(yybuffer, scanner); - s4_lex_destroy(scanner); - return result; } diff --git a/src/s4/xsk/compiler.hpp b/src/s4/xsk/compiler.hpp index 9d519b68..ef87c570 100644 --- a/src/s4/xsk/compiler.hpp +++ b/src/s4/xsk/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -25,7 +25,6 @@ class compiler : public gsc::compiler std::vector animtrees_; std::unordered_map constants_; std::function(const std::string&)> read_callback_; - std::vector sources_; std::vector break_blks_; std::vector continue_blks_; bool can_break_; diff --git a/src/s4/xsk/decompiler.cpp b/src/s4/xsk/decompiler.cpp index 144be4b6..e43ad2a5 100644 --- a/src/s4/xsk/decompiler.cpp +++ b/src/s4/xsk/decompiler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/xsk/decompiler.hpp b/src/s4/xsk/decompiler.hpp index bc5dfb80..aa4b3743 100644 --- a/src/s4/xsk/decompiler.hpp +++ b/src/s4/xsk/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/xsk/disassembler.cpp b/src/s4/xsk/disassembler.cpp index 008c75c7..5b8e1ef5 100644 --- a/src/s4/xsk/disassembler.cpp +++ b/src/s4/xsk/disassembler.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/xsk/disassembler.hpp b/src/s4/xsk/disassembler.hpp index b3101e55..736ccdf4 100644 --- a/src/s4/xsk/disassembler.hpp +++ b/src/s4/xsk/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/xsk/lexer.cpp b/src/s4/xsk/lexer.cpp index 5fffcbd6..e05f8a13 100644 --- a/src/s4/xsk/lexer.cpp +++ b/src/s4/xsk/lexer.cpp @@ -1,3068 +1,1010 @@ -#line 1 "lexer.cpp" -#include "stdafx.hpp" -#include "s4.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void s4_push_header(xsk::gsc::context* ctx, const std::string& file); -void s4_pop_header(xsk::gsc::context* ctx); - -#line 9 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define s4__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer s4__create_buffer -#endif - -#ifdef yy_delete_buffer -#define s4__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer s4__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define s4__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer s4__scan_buffer -#endif - -#ifdef yy_scan_string -#define s4__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string s4__scan_string -#endif - -#ifdef yy_scan_bytes -#define s4__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes s4__scan_bytes -#endif - -#ifdef yy_init_buffer -#define s4__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer s4__init_buffer -#endif - -#ifdef yy_flush_buffer -#define s4__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer s4__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define s4__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state s4__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define s4__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer s4__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define s4_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state s4_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define s4_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state s4_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define s4_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack s4_ensure_buffer_stack -#endif - -#ifdef yylex -#define s4_lex_ALREADY_DEFINED -#else -#define yylex s4_lex -#endif - -#ifdef yyrestart -#define s4_restart_ALREADY_DEFINED -#else -#define yyrestart s4_restart -#endif - -#ifdef yylex_init -#define s4_lex_init_ALREADY_DEFINED -#else -#define yylex_init s4_lex_init -#endif - -#ifdef yylex_init_extra -#define s4_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra s4_lex_init_extra -#endif - -#ifdef yylex_destroy -#define s4_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy s4_lex_destroy -#endif - -#ifdef yyget_debug -#define s4_get_debug_ALREADY_DEFINED -#else -#define yyget_debug s4_get_debug -#endif - -#ifdef yyset_debug -#define s4_set_debug_ALREADY_DEFINED -#else -#define yyset_debug s4_set_debug -#endif - -#ifdef yyget_extra -#define s4_get_extra_ALREADY_DEFINED -#else -#define yyget_extra s4_get_extra -#endif - -#ifdef yyset_extra -#define s4_set_extra_ALREADY_DEFINED -#else -#define yyset_extra s4_set_extra -#endif - -#ifdef yyget_in -#define s4_get_in_ALREADY_DEFINED -#else -#define yyget_in s4_get_in -#endif - -#ifdef yyset_in -#define s4_set_in_ALREADY_DEFINED -#else -#define yyset_in s4_set_in -#endif - -#ifdef yyget_out -#define s4_get_out_ALREADY_DEFINED -#else -#define yyget_out s4_get_out -#endif - -#ifdef yyset_out -#define s4_set_out_ALREADY_DEFINED -#else -#define yyset_out s4_set_out -#endif - -#ifdef yyget_leng -#define s4_get_leng_ALREADY_DEFINED -#else -#define yyget_leng s4_get_leng -#endif - -#ifdef yyget_text -#define s4_get_text_ALREADY_DEFINED -#else -#define yyget_text s4_get_text -#endif - -#ifdef yyget_lineno -#define s4_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno s4_get_lineno -#endif - -#ifdef yyset_lineno -#define s4_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno s4_set_lineno -#endif - -#ifdef yyget_column -#define s4_get_column_ALREADY_DEFINED -#else -#define yyget_column s4_get_column -#endif - -#ifdef yyset_column -#define s4_set_column_ALREADY_DEFINED -#else -#define yyset_column s4_set_column -#endif - -#ifdef yywrap -#define s4_wrap_ALREADY_DEFINED -#else -#define yywrap s4_wrap -#endif - -#ifdef yyalloc -#define s4_alloc_ALREADY_DEFINED -#else -#define yyalloc s4_alloc -#endif - -#ifdef yyrealloc -#define s4_realloc_ALREADY_DEFINED -#else -#define yyrealloc s4_realloc -#endif - -#ifdef yyfree -#define s4_free_ALREADY_DEFINED -#else -#define yyfree s4_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin , yyscanner ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -static void yyensure_buffer_stack ( yyscan_t yyscanner ); -static void yy_load_buffer_state ( yyscan_t yyscanner ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define s4_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); -static int yy_get_next_buffer ( yyscan_t yyscanner ); -static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 114 -#define YY_END_OF_BUFFER 115 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[346] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 115, 113, - 1, 2, 97, 113, 113, 96, 100, 113, 57, 58, - 94, 92, 63, 93, 64, 95, 112, 112, 66, 67, - 81, 91, 82, 68, 103, 103, 61, 62, 101, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 59, 99, 60, 98, 5, - 6, 5, 12, 13, 12, 113, 94, 95, 78, 0, - 105, 0, 15, 0, 0, 0, 0, 87, 0, 76, - 0, 89, 0, 0, 8, 85, 69, 83, 70, 84, - 108, 0, 11, 4, 3, 86, 108, 112, 109, 0, - - 0, 0, 0, 65, 73, 79, 77, 80, 74, 103, - 103, 90, 103, 103, 103, 103, 103, 103, 29, 103, - 103, 103, 103, 103, 27, 33, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 88, 75, 7, - 14, 10, 9, 0, 105, 0, 0, 0, 0, 0, - 0, 104, 0, 0, 0, 0, 105, 0, 108, 0, - 3, 108, 108, 109, 110, 111, 102, 71, 72, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 31, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 106, 0, 0, 0, 0, - - 0, 104, 0, 0, 104, 0, 0, 103, 103, 53, - 103, 46, 35, 103, 103, 103, 28, 103, 103, 103, - 51, 103, 103, 103, 103, 52, 103, 103, 103, 47, - 103, 22, 103, 0, 0, 0, 0, 0, 50, 103, - 103, 37, 103, 103, 103, 20, 48, 103, 54, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 30, 0, - 0, 0, 0, 0, 103, 56, 103, 103, 103, 103, - 103, 21, 103, 103, 39, 34, 103, 43, 103, 103, - 103, 107, 0, 0, 16, 0, 103, 103, 103, 103, - 36, 32, 103, 103, 103, 103, 103, 103, 0, 17, - - 0, 103, 103, 103, 38, 103, 42, 103, 103, 103, - 23, 19, 0, 55, 103, 103, 103, 103, 49, 26, - 103, 103, 0, 40, 103, 41, 45, 103, 103, 0, - 44, 103, 103, 0, 103, 103, 0, 103, 24, 0, - 103, 18, 103, 25, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, - 25, 26, 27, 1, 28, 29, 28, 30, 31, 32, - 33, 33, 34, 33, 33, 33, 33, 35, 33, 33, - 33, 36, 37, 38, 39, 33, 33, 40, 33, 33, - 41, 42, 43, 44, 45, 1, 46, 47, 48, 49, - - 50, 51, 52, 53, 54, 33, 55, 56, 57, 58, - 59, 60, 33, 61, 62, 63, 64, 65, 66, 40, - 67, 68, 69, 70, 71, 72, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[73] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 5, 5, 5, - 5, 1, 1, 1, 1, 1, 1, 5, 5, 5, - 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, - 1, 7, 1, 1, 6, 5, 5, 5, 5, 5, - 5, 6, 6, 8, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 8, 6, 6, 6, 6, 1, 1, - 1, 1 - } ; - -static const flex_int16_t yy_base[366] = - { 0, - 0, 0, 70, 71, 72, 73, 74, 75, 763, 764, - 764, 764, 737, 72, 67, 736, 80, 81, 764, 764, - 76, 81, 764, 82, 90, 110, 99, 124, 738, 764, - 71, 734, 73, 764, 716, 87, 764, 764, 732, 90, - 92, 105, 112, 114, 91, 58, 118, 88, 115, 117, - 123, 125, 126, 119, 139, 764, 138, 764, 764, 764, - 764, 739, 764, 764, 738, 165, 729, 177, 764, 179, - 764, 183, 764, 0, 695, 694, 689, 764, 185, 764, - 94, 764, 184, 192, 764, 764, 764, 764, 764, 764, - 179, 696, 764, 764, 0, 764, 185, 196, 221, 180, - - 191, 248, 0, 764, 724, 764, 764, 764, 723, 705, - 223, 764, 178, 181, 193, 202, 201, 203, 704, 186, - 208, 70, 209, 205, 703, 702, 60, 210, 216, 218, - 229, 246, 247, 182, 242, 250, 251, 764, 764, 764, - 764, 764, 764, 269, 277, 304, 0, 689, 254, 688, - 278, 764, 309, 294, 312, 297, 307, 314, 764, 673, - 0, 306, 764, 313, 319, 0, 698, 764, 764, 310, - 286, 288, 298, 306, 300, 311, 301, 317, 316, 323, - 326, 327, 328, 329, 330, 332, 331, 334, 333, 338, - 339, 344, 348, 345, 349, 0, 682, 682, 683, 678, - - 387, 388, 394, 392, 393, 400, 685, 372, 368, 692, - 364, 691, 690, 369, 370, 373, 689, 375, 371, 374, - 688, 383, 380, 396, 384, 687, 398, 385, 401, 686, - 402, 407, 409, 0, 664, 662, 667, 672, 764, 418, - 419, 413, 412, 420, 415, 681, 680, 426, 679, 414, - 435, 421, 423, 438, 441, 442, 425, 445, 678, 0, - 658, 669, 667, 671, 453, 673, 447, 450, 451, 455, - 452, 672, 458, 456, 671, 670, 459, 669, 465, 467, - 460, 764, 660, 659, 764, 662, 479, 470, 475, 477, - 665, 664, 480, 484, 488, 489, 483, 486, 655, 764, - - 646, 504, 493, 495, 661, 501, 643, 502, 505, 499, - 508, 764, 622, 592, 510, 514, 516, 515, 581, 580, - 519, 520, 537, 551, 521, 550, 549, 525, 526, 527, - 544, 527, 530, 521, 533, 534, 454, 535, 424, 414, - 537, 764, 539, 386, 764, 595, 603, 611, 616, 624, - 630, 634, 642, 313, 650, 658, 666, 674, 678, 308, - 686, 694, 282, 213, 208 - } ; - -static const flex_int16_t yy_def[366] = - { 0, - 345, 1, 346, 346, 347, 347, 1, 1, 345, 345, - 345, 345, 345, 348, 349, 345, 345, 350, 345, 345, - 345, 345, 345, 345, 345, 345, 351, 351, 345, 345, - 345, 345, 345, 345, 352, 352, 345, 345, 345, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 349, 345, 345, 345, 348, - 345, 353, 345, 354, 354, 345, 345, 345, 355, 345, - 356, 345, 350, 357, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 358, 345, 345, 351, 351, 351, - - 351, 351, 359, 345, 345, 345, 345, 345, 345, 352, - 352, 345, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 345, 345, 345, - 345, 345, 345, 348, 348, 353, 360, 345, 345, 345, - 355, 345, 361, 356, 362, 350, 350, 357, 345, 345, - 358, 345, 345, 351, 351, 102, 359, 345, 345, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 363, 345, 345, 345, 345, - - 355, 355, 361, 356, 356, 362, 345, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 364, 345, 345, 345, 345, 345, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 365, - 345, 345, 345, 345, 352, 352, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 345, 345, 345, 345, 345, 352, 352, 352, 352, - 352, 352, 352, 352, 352, 352, 352, 352, 345, 345, - - 345, 352, 352, 352, 352, 352, 352, 352, 352, 352, - 352, 345, 345, 352, 352, 352, 352, 352, 352, 352, - 352, 352, 345, 352, 352, 352, 352, 352, 352, 345, - 352, 352, 352, 345, 352, 352, 345, 352, 352, 345, - 352, 345, 352, 352, 0, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345 - } ; - -static const flex_int16_t yy_nxt[837] = - { 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, - 28, 29, 30, 31, 32, 33, 34, 35, 35, 35, - 35, 35, 35, 36, 35, 35, 35, 35, 35, 35, - 37, 10, 38, 39, 35, 40, 41, 42, 43, 44, - 45, 46, 35, 47, 35, 48, 35, 49, 35, 50, - 51, 52, 53, 54, 35, 55, 35, 35, 56, 57, - 58, 59, 61, 61, 64, 64, 71, 65, 65, 66, - 66, 62, 62, 73, 79, 67, 67, 80, 81, 71, - 68, 68, 85, 87, 105, 106, 89, 108, 109, 103, - - 86, 103, 152, 124, 82, 88, 90, 91, 91, 91, - 91, 103, 75, 72, 97, 93, 98, 99, 99, 98, - 76, 94, 84, 111, 184, 181, 95, 101, 103, 103, - 77, 103, 103, 103, 96, 155, 122, 127, 102, 97, - 103, 98, 98, 98, 98, 101, 103, 113, 111, 123, - 115, 92, 114, 103, 111, 103, 103, 116, 103, 103, - 103, 118, 138, 117, 103, 103, 103, 103, 125, 120, - 119, 121, 130, 128, 131, 126, 135, 129, 133, 111, - 103, 142, 143, 71, 136, 70, 134, 145, 94, 152, - 132, 137, 71, 95, 83, 345, 91, 91, 91, 91, - - 157, 96, 162, 162, 162, 162, 345, 139, 165, 165, - 75, 97, 282, 98, 98, 98, 98, 260, 76, 103, - 72, 103, 103, 103, 146, 84, 153, 103, 77, 159, - 173, 172, 103, 158, 103, 163, 97, 103, 164, 164, - 164, 98, 103, 103, 103, 192, 103, 179, 174, 103, - 103, 103, 170, 178, 175, 176, 180, 103, 177, 103, - 171, 183, 103, 345, 103, 166, 166, 166, 166, 182, - 103, 170, 185, 71, 186, 166, 166, 166, 166, 166, - 187, 71, 152, 103, 188, 171, 234, 103, 103, 103, - 193, 103, 103, 166, 166, 166, 166, 166, 166, 189, - - 190, 198, 152, 194, 195, 71, 70, 191, 145, 199, - 72, 151, 196, 202, 154, 71, 83, 147, 72, 153, - 205, 209, 157, 162, 162, 162, 162, 103, 97, 103, - 164, 164, 164, 98, 345, 155, 165, 165, 84, 103, - 208, 103, 103, 211, 210, 146, 209, 103, 84, 213, - 203, 103, 103, 206, 103, 158, 163, 103, 103, 208, - 103, 212, 216, 215, 103, 217, 214, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 220, 221, 222, 103, - 103, 218, 224, 223, 226, 103, 103, 219, 229, 103, - 103, 152, 152, 230, 225, 227, 151, 231, 202, 228, - - 152, 152, 154, 240, 233, 103, 241, 232, 205, 103, - 103, 103, 103, 103, 103, 103, 103, 243, 242, 248, - 247, 103, 240, 244, 103, 103, 103, 103, 153, 153, - 250, 241, 246, 155, 155, 203, 245, 103, 249, 103, - 251, 206, 103, 103, 252, 253, 255, 254, 103, 266, - 103, 265, 256, 103, 103, 103, 103, 257, 259, 103, - 103, 103, 103, 342, 103, 103, 103, 103, 266, 258, - 270, 265, 267, 271, 268, 276, 103, 269, 275, 103, - 272, 273, 103, 103, 274, 280, 103, 287, 103, 278, - 277, 103, 103, 103, 103, 279, 103, 103, 281, 103, - - 103, 103, 289, 340, 292, 288, 103, 293, 103, 302, - 287, 103, 297, 294, 290, 298, 103, 291, 103, 295, - 103, 103, 296, 303, 103, 103, 305, 103, 302, 103, - 103, 306, 307, 314, 103, 304, 103, 308, 309, 310, - 103, 311, 103, 103, 316, 103, 103, 318, 320, 103, - 315, 103, 314, 319, 317, 103, 103, 103, 321, 325, - 103, 103, 103, 327, 322, 329, 103, 103, 103, 331, - 332, 103, 324, 326, 103, 103, 103, 336, 103, 328, - 103, 337, 338, 335, 341, 103, 339, 344, 333, 334, - 103, 103, 103, 330, 343, 60, 60, 60, 60, 60, - - 60, 60, 60, 63, 63, 63, 63, 63, 63, 63, - 63, 70, 70, 70, 70, 70, 70, 70, 70, 74, - 74, 103, 103, 74, 83, 83, 83, 83, 83, 83, - 83, 83, 100, 103, 100, 100, 100, 100, 110, 110, - 110, 110, 144, 144, 144, 144, 144, 144, 144, 144, - 151, 151, 151, 151, 151, 151, 151, 151, 154, 154, - 154, 154, 154, 154, 154, 154, 156, 156, 156, 156, - 156, 156, 156, 156, 161, 323, 161, 161, 161, 161, - 161, 161, 167, 167, 103, 167, 201, 201, 201, 201, - 201, 201, 201, 201, 204, 204, 204, 204, 204, 204, - - 204, 204, 103, 313, 312, 103, 103, 301, 300, 299, - 103, 103, 103, 103, 103, 286, 285, 284, 283, 103, - 103, 103, 103, 264, 263, 262, 261, 103, 103, 103, - 103, 103, 103, 103, 239, 238, 237, 236, 235, 103, - 207, 200, 197, 103, 103, 103, 103, 169, 168, 160, - 150, 149, 148, 86, 141, 140, 112, 103, 107, 104, - 78, 69, 345, 9, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345 - } ; - -static const flex_int16_t yy_chk[837] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 4, 5, 6, 14, 5, 6, 7, - 8, 3, 4, 15, 17, 7, 8, 17, 17, 18, - 7, 8, 21, 22, 31, 31, 24, 33, 33, 46, - - 21, 127, 81, 46, 17, 22, 24, 25, 25, 25, - 25, 122, 15, 14, 27, 26, 27, 27, 27, 27, - 15, 26, 18, 36, 127, 122, 26, 27, 36, 48, - 15, 40, 45, 41, 26, 81, 45, 48, 27, 28, - 27, 28, 28, 28, 28, 27, 42, 40, 36, 45, - 42, 25, 41, 43, 47, 44, 49, 42, 50, 47, - 54, 43, 57, 42, 51, 28, 52, 53, 47, 44, - 43, 44, 51, 49, 52, 47, 54, 50, 53, 47, - 55, 66, 68, 70, 55, 72, 53, 72, 68, 79, - 52, 55, 83, 68, 84, 100, 91, 91, 91, 91, - - 84, 68, 97, 97, 97, 97, 101, 57, 101, 101, - 66, 98, 365, 98, 98, 98, 98, 364, 66, 113, - 70, 100, 114, 134, 72, 83, 79, 120, 66, 91, - 114, 113, 101, 84, 115, 97, 99, 98, 99, 99, - 99, 99, 117, 116, 118, 134, 124, 120, 115, 121, - 123, 128, 111, 118, 115, 116, 121, 129, 117, 130, - 111, 124, 99, 102, 111, 102, 102, 102, 102, 123, - 131, 111, 128, 144, 129, 102, 102, 102, 102, 102, - 130, 145, 151, 135, 131, 111, 363, 132, 133, 102, - 135, 136, 137, 102, 102, 102, 102, 102, 102, 132, - - 133, 149, 154, 136, 137, 156, 146, 133, 146, 149, - 144, 153, 360, 153, 155, 157, 158, 354, 145, 151, - 155, 171, 158, 162, 162, 162, 162, 171, 164, 172, - 164, 164, 164, 164, 165, 154, 165, 165, 156, 173, - 170, 175, 177, 173, 172, 146, 171, 174, 157, 175, - 153, 170, 176, 155, 164, 158, 162, 179, 178, 170, - 165, 174, 178, 177, 180, 179, 176, 181, 182, 183, - 184, 185, 187, 186, 189, 188, 182, 183, 184, 190, - 191, 180, 186, 185, 188, 192, 194, 181, 191, 193, - 195, 201, 202, 192, 187, 189, 203, 193, 203, 190, - - 204, 205, 206, 208, 195, 211, 209, 194, 206, 209, - 214, 215, 219, 208, 216, 220, 218, 214, 211, 220, - 219, 223, 208, 215, 222, 225, 228, 344, 201, 202, - 223, 209, 218, 204, 205, 203, 216, 224, 222, 227, - 224, 206, 229, 231, 225, 227, 229, 228, 232, 241, - 233, 240, 231, 243, 242, 250, 245, 232, 233, 240, - 241, 244, 252, 340, 253, 339, 257, 248, 241, 232, - 245, 240, 242, 248, 243, 253, 251, 244, 252, 254, - 250, 251, 255, 256, 251, 257, 258, 265, 267, 255, - 254, 268, 269, 271, 265, 256, 270, 274, 258, 273, - - 277, 281, 268, 337, 271, 267, 279, 273, 280, 287, - 265, 288, 280, 274, 269, 281, 289, 270, 290, 277, - 287, 293, 279, 288, 297, 294, 290, 298, 287, 295, - 296, 293, 294, 302, 303, 289, 304, 295, 296, 297, - 310, 298, 306, 308, 304, 302, 309, 308, 310, 311, - 303, 315, 302, 309, 306, 316, 318, 317, 311, 316, - 321, 322, 325, 318, 311, 322, 328, 329, 332, 325, - 328, 333, 315, 317, 335, 336, 338, 333, 341, 321, - 343, 334, 335, 332, 338, 331, 336, 343, 329, 330, - 327, 326, 324, 323, 341, 346, 346, 346, 346, 346, - - 346, 346, 346, 347, 347, 347, 347, 347, 347, 347, - 347, 348, 348, 348, 348, 348, 348, 348, 348, 349, - 349, 320, 319, 349, 350, 350, 350, 350, 350, 350, - 350, 350, 351, 314, 351, 351, 351, 351, 352, 352, - 352, 352, 353, 353, 353, 353, 353, 353, 353, 353, - 355, 355, 355, 355, 355, 355, 355, 355, 356, 356, - 356, 356, 356, 356, 356, 356, 357, 357, 357, 357, - 357, 357, 357, 357, 358, 313, 358, 358, 358, 358, - 358, 358, 359, 359, 307, 359, 361, 361, 361, 361, - 361, 361, 361, 361, 362, 362, 362, 362, 362, 362, - - 362, 362, 305, 301, 299, 292, 291, 286, 284, 283, - 278, 276, 275, 272, 266, 264, 263, 262, 261, 259, - 249, 247, 246, 238, 237, 236, 235, 230, 226, 221, - 217, 213, 212, 210, 207, 200, 199, 198, 197, 167, - 160, 150, 148, 126, 125, 119, 110, 109, 105, 92, - 77, 76, 75, 67, 65, 62, 39, 35, 32, 29, - 16, 13, 9, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, - 345, 345, 345, 345, 345, 345 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.lpp" -/* Copyright 2021 xensik. All rights reserved. -// -// Use of this source code is governed by a GNU GPLv3 license -// that can be found in the LICENSE file. -*/ -#define YY_NO_INPUT 1 -#define YY_NO_UNISTD_H 1 - -#line 25 "lexer.lpp" -#define YY_USER_ACTION ctx->loc.columns(yyleng); -#line 951 "lexer.cpp" - -#line 953 "lexer.cpp" - -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#include "stdafx.hpp" +#include "s4.hpp" +#include "parser.hpp" +#include "lexer.hpp" + +xsk::gsc::s4::parser::symbol_type S4lex(xsk::gsc::s4::lexer& lexer) +{ + return lexer.lex(); +} + +namespace xsk::gsc::s4 +{ + +enum class keyword +{ +/* KW_pre_define, + KW_pre_undef, + KW_pre_ifdef, + KW_pre_ifndef, + KW_pre_if, + KW_pre_elif, + KW_pre_else, + KW_pre_endif,*/ + KW_pre_inline, + KW_pre_include, + KW_pre_using_animtree, + KW_pre_animtree, + KW_endon, + KW_notify, + KW_wait, + KW_waittill, + KW_waittillmatch, + KW_waittillframeend, + KW_waitframe, + KW_if, + KW_else, + KW_do, + KW_while, + KW_for, + KW_foreach, + KW_in, + KW_switch, + KW_case, + KW_default, + KW_break, + KW_continue, + KW_return, + KW_breakpoint, + KW_prof_begin, + KW_prof_end, + KW_thread, + KW_childthread, + KW_thisthread, + KW_call, + KW_true, + KW_false, + KW_undefined, + KW_dotsize, + KW_game, + KW_self, + KW_anim, + KW_level, + KW_isdefined, + KW_istrue, + KW_INVALID, +}; + +buffer::buffer() : size(1024), length(0) +{ + data = static_cast(std::malloc(size)); +} + +buffer::~buffer() +{ + if(data) std::free(data); +} + +bool buffer::push(char c) +{ + if(length >= size) { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals ( yyscan_t yyscanner ); - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef YY_NO_UNPUT - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( yyscan_t yyscanner ); -#else -static int input ( yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_load_buffer_state( yyscanner ); - } - - { -#line 44 "lexer.lpp" - - - -#line 48 "lexer.lpp" - ctx->loc.step(); - - -#line 1222 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 346 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_current_state != 345 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 51 "lexer.lpp" -{ ctx->loc.step(); } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 52 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 54 "lexer.lpp" - - YY_BREAK -case 4: -YY_RULE_SETUP -#line 56 "lexer.lpp" -{ BEGIN(COMMENT_STATE); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 57 "lexer.lpp" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 58 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(COMMENT_STATE): -#line 60 "lexer.lpp" -{ throw s4::parser::syntax_error(ctx->loc, "unmatched multiline comment start ('/*')"); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 61 "lexer.lpp" -{ throw s4::parser::syntax_error(ctx->loc, "unmatched multiline comment end ('*/')"); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 63 "lexer.lpp" -{ throw s4::parser::syntax_error(ctx->loc, "cannot recurse devblock ('/#')"); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 64 "lexer.lpp" -{ BEGIN(INITIAL); return s4::parser::make_DEVEND(ctx->loc); } - YY_BREAK -case YY_STATE_EOF(DEV_ON_STATE): -#line 65 "lexer.lpp" -{ throw s4::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 67 "lexer.lpp" -{ BEGIN(ctx->mode == xsk::gsc::build::dev ? DEV_ON_STATE : DEV_OFF_STATE); if(ctx->mode == xsk::gsc::build::dev) return s4::parser::make_DEVBEGIN(ctx->loc); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 68 "lexer.lpp" - - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 69 "lexer.lpp" -{ ctx->loc.lines(yyleng); ctx->loc.step(); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 70 "lexer.lpp" -{ BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(DEV_OFF_STATE): -#line 71 "lexer.lpp" -{ throw s4::parser::syntax_error(ctx->loc, "unmatched devblock start ('/#')"); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 72 "lexer.lpp" -{ throw s4::parser::syntax_error(ctx->loc, "unmatched devblock end ('#/')"); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 74 "lexer.lpp" -{ return s4::parser::make_INLINE(ctx->loc); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 75 "lexer.lpp" -{ return s4::parser::make_INCLUDE(ctx->loc); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 76 "lexer.lpp" -{ return s4::parser::make_USINGTREE(ctx->loc); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 77 "lexer.lpp" -{ return s4::parser::make_ANIMTREE(ctx->loc); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 78 "lexer.lpp" -{ return s4::parser::make_ENDON(ctx->loc); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 79 "lexer.lpp" -{ return s4::parser::make_NOTIFY(ctx->loc); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 80 "lexer.lpp" -{ return s4::parser::make_WAIT(ctx->loc); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 81 "lexer.lpp" -{ return s4::parser::make_WAITTILL(ctx->loc); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 82 "lexer.lpp" -{ return s4::parser::make_WAITTILLMATCH(ctx->loc); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 83 "lexer.lpp" -{ return s4::parser::make_WAITTILLFRAMEEND(ctx->loc); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 84 "lexer.lpp" -{ return s4::parser::make_WAITFRAME(ctx->loc); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 85 "lexer.lpp" -{ return s4::parser::make_IF(ctx->loc); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 86 "lexer.lpp" -{ return s4::parser::make_ELSE(ctx->loc); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 87 "lexer.lpp" -{ return s4::parser::make_DO(ctx->loc); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 88 "lexer.lpp" -{ return s4::parser::make_WHILE(ctx->loc); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 89 "lexer.lpp" -{ return s4::parser::make_FOR(ctx->loc); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 90 "lexer.lpp" -{ return s4::parser::make_FOREACH(ctx->loc); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 91 "lexer.lpp" -{ return s4::parser::make_IN(ctx->loc); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 92 "lexer.lpp" -{ return s4::parser::make_SWITCH(ctx->loc); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 93 "lexer.lpp" -{ return s4::parser::make_CASE(ctx->loc); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 94 "lexer.lpp" -{ return s4::parser::make_DEFAULT(ctx->loc); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 95 "lexer.lpp" -{ return s4::parser::make_BREAK(ctx->loc); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 96 "lexer.lpp" -{ return s4::parser::make_CONTINUE(ctx->loc); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 97 "lexer.lpp" -{ return s4::parser::make_RETURN(ctx->loc); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 98 "lexer.lpp" -{ return s4::parser::make_BREAKPOINT(ctx->loc); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 99 "lexer.lpp" -{ return s4::parser::make_PROFBEGIN(ctx->loc); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 100 "lexer.lpp" -{ return s4::parser::make_PROFEND(ctx->loc); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 101 "lexer.lpp" -{ return s4::parser::make_THREAD(ctx->loc); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 102 "lexer.lpp" -{ return s4::parser::make_CHILDTHREAD(ctx->loc); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 103 "lexer.lpp" -{ return s4::parser::make_THISTHREAD(ctx->loc); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 104 "lexer.lpp" -{ return s4::parser::make_CALL(ctx->loc); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 105 "lexer.lpp" -{ return s4::parser::make_TRUE(ctx->loc); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 106 "lexer.lpp" -{ return s4::parser::make_FALSE(ctx->loc); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 107 "lexer.lpp" -{ return s4::parser::make_UNDEFINED(ctx->loc); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 108 "lexer.lpp" -{ return s4::parser::make_SIZE(ctx->loc); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 109 "lexer.lpp" -{ return s4::parser::make_GAME(ctx->loc); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 110 "lexer.lpp" -{ return s4::parser::make_SELF(ctx->loc); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 111 "lexer.lpp" -{ return s4::parser::make_ANIM(ctx->loc); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 112 "lexer.lpp" -{ return s4::parser::make_LEVEL(ctx->loc); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 113 "lexer.lpp" -{ return s4::parser::make_ISDEFINED(ctx->loc); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 114 "lexer.lpp" -{ return s4::parser::make_ISTRUE(ctx->loc); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 115 "lexer.lpp" -{ return s4::parser::make_LPAREN(ctx->loc); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 116 "lexer.lpp" -{ return s4::parser::make_RPAREN(ctx->loc); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 117 "lexer.lpp" -{ return s4::parser::make_LBRACE(ctx->loc); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 118 "lexer.lpp" -{ return s4::parser::make_RBRACE(ctx->loc); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 119 "lexer.lpp" -{ return s4::parser::make_LBRACKET(ctx->loc); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 120 "lexer.lpp" -{ return s4::parser::make_RBRACKET(ctx->loc); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 121 "lexer.lpp" -{ return s4::parser::make_COMMA(ctx->loc); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 122 "lexer.lpp" -{ return s4::parser::make_DOT(ctx->loc); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 123 "lexer.lpp" -{ return s4::parser::make_DOUBLECOLON(ctx->loc); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 124 "lexer.lpp" -{ return s4::parser::make_COLON(ctx->loc); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 125 "lexer.lpp" -{ return s4::parser::make_SEMICOLON(ctx->loc); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 126 "lexer.lpp" -{ return s4::parser::make_QMARK(ctx->loc); } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 127 "lexer.lpp" -{ return s4::parser::make_INCREMENT(ctx->loc); } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 128 "lexer.lpp" -{ return s4::parser::make_DECREMENT(ctx->loc); } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 129 "lexer.lpp" -{ return s4::parser::make_ASSIGN_LSHIFT(ctx->loc); } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 130 "lexer.lpp" -{ return s4::parser::make_ASSIGN_RSHIFT(ctx->loc); } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 131 "lexer.lpp" -{ return s4::parser::make_LSHIFT(ctx->loc); } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 132 "lexer.lpp" -{ return s4::parser::make_RSHIFT(ctx->loc); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 133 "lexer.lpp" -{ return s4::parser::make_OR(ctx->loc); } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 134 "lexer.lpp" -{ return s4::parser::make_AND(ctx->loc); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 135 "lexer.lpp" -{ return s4::parser::make_EQUALITY(ctx->loc); } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 136 "lexer.lpp" -{ return s4::parser::make_INEQUALITY(ctx->loc); } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 137 "lexer.lpp" -{ return s4::parser::make_LESS_EQUAL(ctx->loc); } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 138 "lexer.lpp" -{ return s4::parser::make_GREATER_EQUAL(ctx->loc); } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 139 "lexer.lpp" -{ return s4::parser::make_LESS(ctx->loc); } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 140 "lexer.lpp" -{ return s4::parser::make_GREATER(ctx->loc); } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 141 "lexer.lpp" -{ return s4::parser::make_ASSIGN_ADD(ctx->loc); } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 142 "lexer.lpp" -{ return s4::parser::make_ASSIGN_SUB(ctx->loc); } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 143 "lexer.lpp" -{ return s4::parser::make_ASSIGN_MUL(ctx->loc); } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 144 "lexer.lpp" -{ return s4::parser::make_ASSIGN_DIV(ctx->loc); } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 145 "lexer.lpp" -{ return s4::parser::make_ASSIGN_MOD(ctx->loc); } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 146 "lexer.lpp" -{ return s4::parser::make_ASSIGN_BW_OR(ctx->loc); } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 147 "lexer.lpp" -{ return s4::parser::make_ASSIGN_BW_AND(ctx->loc); } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 148 "lexer.lpp" -{ return s4::parser::make_ASSIGN_BW_EXOR(ctx->loc); } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 149 "lexer.lpp" -{ return s4::parser::make_ASSIGN(ctx->loc); } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 150 "lexer.lpp" -{ return s4::parser::make_ADD(ctx->loc); } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 151 "lexer.lpp" -{ return s4::parser::make_SUB(ctx->loc); } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 152 "lexer.lpp" -{ return s4::parser::make_MUL(ctx->loc); } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 153 "lexer.lpp" -{ return s4::parser::make_DIV(ctx->loc); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 154 "lexer.lpp" -{ return s4::parser::make_MOD(ctx->loc); } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 155 "lexer.lpp" -{ return s4::parser::make_NOT(ctx->loc); } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 156 "lexer.lpp" -{ return s4::parser::make_COMPLEMENT(ctx->loc); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 157 "lexer.lpp" -{ return s4::parser::make_BITWISE_OR(ctx->loc); } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 158 "lexer.lpp" -{ return s4::parser::make_BITWISE_AND(ctx->loc); } - YY_BREAK -case 101: -YY_RULE_SETUP -#line 159 "lexer.lpp" -{ return s4::parser::make_BITWISE_EXOR(ctx->loc); } - YY_BREAK -case 102: -YY_RULE_SETUP -#line 160 "lexer.lpp" -{ return s4::parser::make_PATH(xsk::gsc::s4::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 103: -YY_RULE_SETUP -#line 161 "lexer.lpp" -{ return s4::parser::make_IDENTIFIER(xsk::gsc::s4::resolver::make_token(std::string_view(yytext, yyleng)), ctx->loc); } - YY_BREAK -case 104: -/* rule 104 can match eol */ -YY_RULE_SETUP -#line 162 "lexer.lpp" -{ return s4::parser::make_ISTRING(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 105: -/* rule 105 can match eol */ -YY_RULE_SETUP -#line 163 "lexer.lpp" -{ return s4::parser::make_STRING(std::string(yytext), ctx->loc); } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 164 "lexer.lpp" -{ return s4::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 165 "lexer.lpp" -{ return s4::parser::make_COLOR(std::string(++yytext, --yyleng), ctx->loc); } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 166 "lexer.lpp" -{ return s4::parser::make_FLOAT(std::string(yytext), ctx->loc); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 167 "lexer.lpp" -{ return s4::parser::make_INTEGER(xsk::utils::string::oct_to_dec(yytext), ctx->loc); } - YY_BREAK -case 110: -YY_RULE_SETUP -#line 168 "lexer.lpp" -{ return s4::parser::make_INTEGER(xsk::utils::string::bin_to_dec(yytext), ctx->loc); } - YY_BREAK -case 111: -YY_RULE_SETUP -#line 169 "lexer.lpp" -{ return s4::parser::make_INTEGER(xsk::utils::string::hex_to_dec(yytext), ctx->loc); } - YY_BREAK -case 112: -YY_RULE_SETUP -#line 170 "lexer.lpp" -{ return s4::parser::make_INTEGER(std::string(yytext), ctx->loc); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 171 "lexer.lpp" -{ if(ctx->header_top > 0) s4_pop_header(ctx); else return s4::parser::make_S4EOF(ctx->loc); } - YY_BREAK -case 113: -/* rule 113 can match eol */ -YY_RULE_SETUP -#line 172 "lexer.lpp" -{ throw s4::parser::syntax_error(ctx->loc, "bad token: \'" + std::string(yytext) + "\'"); } - YY_BREAK -case 114: -YY_RULE_SETUP -#line 174 "lexer.lpp" -ECHO; - YY_BREAK -#line 1867 "lexer.cpp" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap( yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin , yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + auto nsize = size * 2; + auto ndata = reinterpret_cast(std::malloc(nsize)); + + if(!ndata) return false; + + std::memmove(ndata, data, size); + std::free(data); + size = nsize; + data = ndata; + } + data[length++] = c; + return true; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 346 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; } -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +void reader::init(const char* data, size_t size) { - int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 346 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 345); - - (void)yyg; - return yy_is_jam ? 0 : yy_current_state; + if(data && size) + { + state = reader::ok; + buffer_pos = data; + bytes_remaining = size; + last_byte = 0; + current_byte = *data; + } + else + { + state = reader::end; + buffer_pos = 0; + bytes_remaining = 0; + last_byte = 0; + current_byte = 0; + } } -#ifndef YY_NO_UNPUT - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - +void reader::advance() { - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + ++buffer_pos; - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin , yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( yyscanner ) ) - return 0; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); - yy_load_buffer_state( yyscanner ); + if(bytes_remaining-- == 1) + { + state = reader::end; + bytes_remaining = 0; + last_byte = current_byte; + current_byte = 0; + } + else + { + last_byte = current_byte; + current_byte = *buffer_pos; + } } -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +lexer::lexer(const std::string& name, const char* data, size_t size) : in_dev_state_(false), loc_(xsk::gsc::location(&name)), + mode_(build::dev), header_top_(0), locs_(std::stack()), readers_(std::stack()) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + reader_.init(data, size); } -static void yy_load_buffer_state (yyscan_t yyscanner) +void lexer::push_header(const std::string& file) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + try + { + if (header_top_++ >= 10) + throw xsk::gsc::error("maximum gsh depth exceeded '10'"); + + auto data = resolver::file_data(file + ".gsh"); + + readers_.push(reader_); + locs_.push(loc_); + loc_.initialize(std::get<0>(data)); + reader_.init(std::get<1>(data), std::get<2>(data)); + } + catch (const std::exception& e) + { + throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); + } } -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +void lexer::pop_header() { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file , yyscanner); - - return b; + header_top_--; + loc_ = locs_.top(); + locs_.pop(); + reader_ = readers_.top(); + readers_.pop(); } -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void lexer::restrict_header(const xsk::gsc::location& loc) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf , yyscanner ); - - yyfree( (void *) b , yyscanner ); + if (header_top_ > 0) + { + throw comp_error(loc, "not allowed inside a gsh file"); + } } -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - +auto lexer::lex() -> xsk::gsc::s4::parser::symbol_type { - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + buffer_.length = 0; + loc_.step(); - yy_flush_buffer( b , yyscanner); + while (true) + { + if (reader_.state == reader::end) + { + if (in_dev_state_) + throw s4::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + if(header_top_ > 0) + pop_header(); + else + return s4::parser::make_S4EOF(loc_); + } - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; + reader_.advance(); + auto& last = reader_.last_byte; + auto& curr = reader_.current_byte; + + switch (last) + { + case ' ': + case '\t': + case '\r': + loc_.step(); + continue; + case '\n': + loc_.lines(); + loc_.step(); + continue; + case '/': + if(reader_.state == reader::end || (curr != '/' && curr != '*' && curr != '#' && curr != '=')) + return s4::parser::make_DIV(loc_); + + reader_.advance(); + + if (last == '=') + return s4::parser::make_ASSIGN_DIV(loc_); + + if (last == '#') + { + if (in_dev_state_) + { + throw s4::parser::syntax_error(loc_, "cannot recurse devblock ('/#')"); + } + else if (mode_ == xsk::gsc::build::dev) + { + in_dev_state_ = true; + return s4::parser::make_DEVBEGIN(loc_); + } + else + { + while (true) + { + if (reader_.state == reader::end) + { + throw s4::parser::syntax_error(loc_, "unmatched devblock start ('/#')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '#' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + } + else if (last == '*') + { + while (true) + { + if (reader_.state == reader::end) + { + throw s4::parser::syntax_error(loc_, "unmatched multiline comment start ('/*')"); + } + else if (curr == '\n') + { + loc_.lines(); + loc_.step(); + } + else if (reader_.state == reader::ok && last == '*' && curr == '/') + { + reader_.advance(); + break; + } + + reader_.advance(); + } + } + else if (last == '/') + { + while (true) + { + if (reader_.state == reader::end || curr == '\n') + break; + + reader_.advance(); + } + } + continue; + case '#': + if (curr == '/') + { + if (!in_dev_state_) + throw s4::parser::syntax_error(loc_, "unmatched devblock end ('#/')"); + + in_dev_state_ = false; + reader_.advance(); + return s4::parser::make_DEVEND(loc_); + } + + buffer_.push(last); + while (reader_.state == reader::ok) + { + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + { + if (auto len = buffer_.length; len == 4 || len == 7) + { + auto data = buffer_.data; + auto color = true; + for (auto i = 1; i < len; i++) + { + if ((data[i] < 48 || data[i] > 57) && (data[i] < 65 || data[i] > 70) && (data[i] < 97 || data[i] > 102)) + { + color = false; + break; + } + } + + if (color) return s4::parser::make_COLOR(std::string(++data, --len), loc_); + } + + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); + + if (key == keyword::KW_INVALID) + throw s4::parser::syntax_error(loc_, utils::string::va("unknown preprocessor directive ('%s')", "#")); + + if (keyword_is_token(key)) + return keyword_token(key); + + // call preprocessor(key); + } + continue; + case '*': + if (reader_.state == reader::end || (curr != '/' && curr != '=')) + return s4::parser::make_MUL(loc_); + + reader_.advance(); + + if (curr == '/') + throw s4::parser::syntax_error(loc_, "unmatched multiline comment end ('*/')"); + + return s4::parser::make_ASSIGN_MUL(loc_); + case '"': + case '\'': + return read_string(last, false); + case '.': + return read_dotsize(); + case '(': + return s4::parser::make_LPAREN(loc_); + case ')': + return s4::parser::make_RPAREN(loc_); + case '{': + return s4::parser::make_LBRACE(loc_); + case '}': + return s4::parser::make_RBRACE(loc_); + case '[': + return s4::parser::make_LBRACKET(loc_); + case ']': + return s4::parser::make_RBRACKET(loc_); + case ',': + return s4::parser::make_COMMA(loc_); + case ';': + return s4::parser::make_SEMICOLON(loc_); + case ':': + if (curr != ':') + return s4::parser::make_COLON(loc_); + reader_.advance(); + return s4::parser::make_DOUBLECOLON(loc_); + case '?': + return s4::parser::make_QMARK(loc_); + case '=': + if (curr != '=') + return s4::parser::make_ASSIGN(loc_); + reader_.advance(); + return s4::parser::make_EQUALITY(loc_); + case '+': + if (curr != '+' && curr != '=') + return s4::parser::make_ADD(loc_); + reader_.advance(); + return (last == '+') ? s4::parser::make_INCREMENT(loc_) : s4::parser::make_ASSIGN_ADD(loc_); + case '-': + if (curr != '-' && curr != '=') + return s4::parser::make_SUB(loc_); + reader_.advance(); + return (last == '-') ? s4::parser::make_DECREMENT(loc_) : s4::parser::make_ASSIGN_SUB(loc_); + case '%': + if (curr != '=') + return s4::parser::make_MOD(loc_); + reader_.advance(); + return s4::parser::make_ASSIGN_MOD(loc_); + case '|': + if (curr != '|' && curr != '=') + return s4::parser::make_BITWISE_OR(loc_); + reader_.advance(); + return (last == '|') ? s4::parser::make_OR(loc_) : s4::parser::make_ASSIGN_BW_OR(loc_); + case '&': + if (curr != '&' && curr != '=' && curr != '"' && curr != '\'') + return s4::parser::make_BITWISE_AND(loc_); + reader_.advance(); + if (last == '"' || last == '\'') + return read_string(last, true); + return (last == '&') ? s4::parser::make_AND(loc_) : s4::parser::make_ASSIGN_BW_AND(loc_); + case '^': + if (curr != '=') + return s4::parser::make_BITWISE_EXOR(loc_); + reader_.advance(); + return s4::parser::make_ASSIGN_BW_EXOR(loc_); + case '!': + if (curr != '=') + return s4::parser::make_NOT(loc_); + reader_.advance(); + return s4::parser::make_INEQUALITY(loc_); + case '~': + return s4::parser::make_COMPLEMENT(loc_); + case '<': + if (curr != '<' && curr != '=') + return s4::parser::make_LESS(loc_); + reader_.advance(); + if (last == '<') + { + reader_.advance(); + return (last == '=') ? s4::parser::make_ASSIGN_LSHIFT(loc_) : s4::parser::make_LSHIFT(loc_); + } + return s4::parser::make_LESS_EQUAL(loc_); + case '>': + if (curr != '>' && curr != '=') + return s4::parser::make_GREATER(loc_); + reader_.advance(); + if (last == '>') + { + reader_.advance(); + return (last == '=') ? s4::parser::make_ASSIGN_RSHIFT(loc_) : s4::parser::make_RSHIFT(loc_); + } + return s4::parser::make_GREATER_EQUAL(loc_); + default: + if (last >= '0' && last <= '9') + return lexer::read_number(last); + else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z') + return lexer::read_word(last); + + throw s4::parser::syntax_error(loc_, utils::string::va("bad token: \'%c\'", last)); + } + } +} + +auto lexer::read_string(char quote, bool localize) -> xsk::gsc::s4::parser::symbol_type +{ + if (localize) + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + reader_.advance(); + + if (last == '\n') + throw s4::parser::syntax_error(loc_, "unterminated string"); + + if (last == '\\') // process scapes + { + // TODO: + } + + if (last != '\\' && curr == quote) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); } - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - yy_size_t num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b , yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n , yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n , yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param _line_number line number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int _line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); - - yylineno = _line_number; -} - -/** Set the current column. - * @param _column_no column number - * @param yyscanner The scanner object. - */ -void yyset_column (int _column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - YY_FATAL_ERROR( "yyset_column called with no buffer" ); - - yycolumn = _column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = _out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int _bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = _bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ -int yylex_init(yyscan_t* ptr_yy_globals) -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (reader_.state == reader::end) + { + throw s4::parser::syntax_error(loc_, utils::string::va("unmatched string start ('%s')", (quote == '"') ? "\"" : "\\'")); } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + if (localize) + return s4::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + return s4::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_); +} + +auto lexer::read_number(char first) -> xsk::gsc::s4::parser::symbol_type +{ + if (first == '.') + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = true; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw s4::parser::syntax_error(loc_, "invalid number '.'"); + } + if (data[i] == 'f' && i != len - 1) + throw s4::parser::syntax_error(loc_, "invalid number 'f'"); + } + + return s4::parser::make_FLOAT(std::string(data, len), loc_); + } + else + { + auto curr = reader_.current_byte; + + if (first == '0' && curr == 'o') + { + buffer_.push(first); + buffer_.push('o'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'o')) + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'o' && last == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr > 47 && curr < 56)) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid octal literal!"); + + return s4::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data + 2), loc_); + } + else if (first == '0' && curr == 'b') + { + buffer_.push(first); + buffer_.push('b'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'b')) + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'b' && last == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (curr != '0' && curr != '1') + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid binary literal!"); + + return s4::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_); + } + else if (first == '0' && curr == 'x') + { + buffer_.push(first); + buffer_.push('x'); + reader_.advance(); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'x')) + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == 'x' && last == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!((curr > 47 && curr < 58) || (curr > 64 && curr < 71) || (curr > 96 && curr < 103))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (buffer_.length < 3) + throw error("gsc lexer: invalid hexadecimal literal!"); + + return s4::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_); + } + else + { + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto last = reader_.last_byte; + auto curr = reader_.current_byte; + + if (curr == '\'' && (last == '\'' || last == 'f' || last == '.')) + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if ((curr == '.' || curr == 'f') && last == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + if (curr == '\'') + { + reader_.advance(); + continue; + } + + if (!(curr == 'f' || curr == '.' || (curr > 47 && curr < 58))) + break; + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (reader_.last_byte == '\'') + throw s4::parser::syntax_error(loc_, "invalid number '\''"); + + auto data = buffer_.data; + auto len = buffer_.length; + auto dot = false; + + for (auto i = 1; i < len; i++) + { + if (data[i] == '.') + { + if (dot) + throw s4::parser::syntax_error(loc_, "invalid number '.'"); + + dot = true; + } + if (data[i] == 'f' && i != len - 1) + throw s4::parser::syntax_error(loc_, "invalid number 'f'"); + } + + if (dot || data[len - 1] == 'f') + return s4::parser::make_FLOAT(std::string(data, len), loc_); + + return s4::parser::make_INTEGER(std::string(data, len), loc_); + } + } +} + +auto lexer::read_word(char first) -> xsk::gsc::s4::parser::symbol_type +{ + auto path = false; + + buffer_.push(first); + + while (reader_.state == reader::ok) + { + auto curr = reader_.current_byte; + + if (!(curr == '\\' || curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123) || (curr > 47 && curr < 58))) + break; + + if (curr == '\\') + { + if (reader_.last_byte == '\\') + throw s4::parser::syntax_error(loc_, "invalid path '\\\\'"); + + path = true; + curr = '/'; + } + + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - return yy_init_globals ( *ptr_yy_globals ); -} + if(buffer_.data[0] != '_') + { + for(auto i = 0; i < buffer_.length; i++) + { + auto c = buffer_.data[i]; -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ -int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) -{ - struct yyguts_t dummy_yyguts; - - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; + if (c > 64 && c < 91) + buffer_.data[i] = c + 32; + } } - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + auto key = get_keyword(std::string_view(buffer_.data, buffer_.length)); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; + if (key != keyword::KW_INVALID) + return keyword_token(key); + + if (path) + { + if (buffer_.data[buffer_.length - 1] == '/') + throw s4::parser::syntax_error(loc_, "invalid path end '\\'"); + + return s4::parser::make_PATH(xsk::gsc::s4::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + return s4::parser::make_IDENTIFIER(xsk::gsc::s4::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_); } -static int yy_init_globals (yyscan_t yyscanner) +auto lexer::read_dotsize() -> xsk::gsc::s4::parser::symbol_type { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ + auto curr = reader_.current_byte; - yyg->yy_buffer_stack = NULL; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = NULL; - yyg->yy_init = 0; - yyg->yy_start = 0; + if (curr > 47 && curr < 58) + { + return lexer::read_number('.'); + } + else if (curr == '_' || curr > 64 && curr < 91 || curr > 96 && curr < 123) + { + reader save; + save.state = reader_.state; + save.bytes_remaining = reader_.bytes_remaining; + save.buffer_pos = reader_.buffer_pos; + save.last_byte = reader_.last_byte; + save.current_byte = reader_.current_byte; - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; + while (reader_.state == reader::ok) + { + curr = reader_.current_byte; -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif + if (!(curr == '_' || (curr > 64 && curr < 91) || (curr > 96 && curr < 123))) + break; - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; + if (!buffer_.push(curr)) + throw error("gsc lexer: out of memory!"); + + reader_.advance(); + } + + if (std::string_view(buffer_.data, buffer_.length) == "size") + { + return s4::parser::make_SIZE(loc_); + } + + reader_.state = save.state; + reader_.bytes_remaining = save.bytes_remaining; + reader_.buffer_pos = save.buffer_pos; + reader_.last_byte = save.last_byte; + reader_.current_byte = save.current_byte; + + return s4::parser::make_DOT(loc_); + + } + else return s4::parser::make_DOT(loc_); } -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) +auto lexer::keyword_token(keyword k) -> xsk::gsc::s4::parser::symbol_type { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack , yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree( yyg->yy_start_stack , yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; + switch (k) + { + case keyword::KW_pre_inline: + return s4::parser::make_INLINE(loc_); + case keyword::KW_pre_include: + return s4::parser::make_INCLUDE(loc_); + case keyword::KW_pre_using_animtree: + return s4::parser::make_USINGTREE(loc_); + case keyword::KW_pre_animtree: + return s4::parser::make_ANIMTREE(loc_); + case keyword::KW_endon: + return s4::parser::make_ENDON(loc_); + case keyword::KW_notify: + return s4::parser::make_NOTIFY(loc_); + case keyword::KW_wait: + return s4::parser::make_WAIT(loc_); + case keyword::KW_waittill: + return s4::parser::make_WAITTILL(loc_); + case keyword::KW_waittillmatch: + return s4::parser::make_WAITTILLMATCH(loc_); + case keyword::KW_waittillframeend: + return s4::parser::make_WAITTILLFRAMEEND(loc_); + case keyword::KW_waitframe: + return s4::parser::make_WAITFRAME(loc_); + case keyword::KW_if: + return s4::parser::make_IF(loc_); + case keyword::KW_else: + return s4::parser::make_ELSE(loc_); + case keyword::KW_do: + return s4::parser::make_DO(loc_); + case keyword::KW_while: + return s4::parser::make_WHILE(loc_); + case keyword::KW_for: + return s4::parser::make_FOR(loc_); + case keyword::KW_foreach: + return s4::parser::make_FOREACH(loc_); + case keyword::KW_in: + return s4::parser::make_IN(loc_); + case keyword::KW_switch: + return s4::parser::make_SWITCH(loc_); + case keyword::KW_case: + return s4::parser::make_CASE(loc_); + case keyword::KW_default: + return s4::parser::make_DEFAULT(loc_); + case keyword::KW_break: + return s4::parser::make_BREAK(loc_); + case keyword::KW_continue: + return s4::parser::make_CONTINUE(loc_); + case keyword::KW_return: + return s4::parser::make_RETURN(loc_); + case keyword::KW_breakpoint: + return s4::parser::make_BREAKPOINT(loc_); + case keyword::KW_prof_begin: + return s4::parser::make_PROFBEGIN(loc_); + case keyword::KW_prof_end: + return s4::parser::make_PROFEND(loc_); + case keyword::KW_thread: + return s4::parser::make_THREAD(loc_); + case keyword::KW_childthread: + return s4::parser::make_CHILDTHREAD(loc_); + case keyword::KW_thisthread: + return s4::parser::make_THISTHREAD(loc_); + case keyword::KW_call: + return s4::parser::make_CALL(loc_); + case keyword::KW_true: + return s4::parser::make_TRUE(loc_); + case keyword::KW_false: + return s4::parser::make_FALSE(loc_); + case keyword::KW_undefined: + return s4::parser::make_UNDEFINED(loc_); + case keyword::KW_dotsize: + return s4::parser::make_SIZE(loc_); + case keyword::KW_game: + return s4::parser::make_GAME(loc_); + case keyword::KW_self: + return s4::parser::make_SELF(loc_); + case keyword::KW_anim: + return s4::parser::make_ANIM(loc_); + case keyword::KW_level: + return s4::parser::make_LEVEL(loc_); + case keyword::KW_isdefined: + return s4::parser::make_ISDEFINED(loc_); + case keyword::KW_istrue: + return s4::parser::make_ISTRUE(loc_); + default: + throw error("gsc lexer: INVALID KEYWORD TOKEN!"); + } } -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +auto lexer::keyword_is_token(keyword k) -> bool { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; + switch (k) + { +/* case keyword::KW_pre_define: + case keyword::KW_pre_undef: + case keyword::KW_pre_ifdef: + case keyword::KW_pre_ifndef: + case keyword::KW_pre_if: + case keyword::KW_pre_elif: + case keyword::KW_pre_else: + case keyword::KW_pre_endif:*/ + case keyword::KW_INVALID: + return false; + default: + return true; + } } -#endif -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +auto lexer::get_keyword(std::string_view str) -> keyword { - int n; - for ( n = 0; s[n]; ++n ) - ; + auto itr = keywords.find(str); - return n; -} -#endif + if(itr != keywords.end()) + { + return itr->second; + } -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - return malloc(size); + return keyword::KW_INVALID; } -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - (void)yyg; - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 174 "lexer.lpp" - - -void s4_push_header(xsk::gsc::context* ctx, const std::string& file) -{ - try - { - if (ctx->header_top >= 4) - { - throw xsk::gsc::error("maximum gsh depth exceeded '4'"); - } - - ctx->header_top++; - - char* buf_data = 0; - size_t buf_size = 0; - - for (auto& src : *ctx->sources) - { - if (src.name == file) - { - buf_data = reinterpret_cast(src.buf.data()); - buf_size = src.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&src.name); - } - } - - if (buf_data == 0) - { - ctx->sources->push_back(xsk::gsc::source()); - auto& source = ctx->sources->back(); - source.name = file; - source.buf = ctx->read_callback(file + ".gsh"); - source.buf.push_back(0); - source.buf.push_back(0); - - buf_data = reinterpret_cast(source.buf.data()); - buf_size = source.buf.size(); - - ctx->locs.push(ctx->loc); - ctx->loc.initialize(&source.name); - } - - auto state = new yy_buffer_state(); - state->yy_buf_size = buf_size - 2; - state->yy_buf_pos = state->yy_ch_buf = buf_data; - state->yy_is_our_buffer = 0; - state->yy_input_file = NULL; - state->yy_n_chars = state->yy_buf_size; - state->yy_is_interactive = 0; - state->yy_at_bol = 1; - state->yy_fill_buffer = 0; - state->yy_buffer_status = 0; - - yypush_buffer_state(state, ctx->scanner); - } - catch (const std::exception& e) - { - throw xsk::gsc::error("parsing header file '" + file + "': " + e.what()); - } -} - -void s4_pop_header(xsk::gsc::context* ctx) -{ - ctx->header_top--; - ctx->loc = ctx->locs.top(); - ctx->locs.pop(); - yypop_buffer_state(ctx->scanner); -} +std::unordered_map lexer::keywords +{{ +/* { "#define", keyword::KW_pre_define }, + { "#undef", keyword::KW_pre_undef }, + { "#ifdef", keyword::KW_pre_ifdef }, + { "#ifndef", keyword::KW_pre_ifndef }, + { "#if", keyword::KW_pre_if }, + { "#elif", keyword::KW_pre_elif }, + { "#else", keyword::KW_pre_else }, + { "#endif", keyword::KW_pre_endif },*/ + { "#inline", keyword::KW_pre_inline }, + { "#include", keyword::KW_pre_include }, + { "#using_animtree", keyword::KW_pre_using_animtree }, + { "#animtree", keyword::KW_pre_animtree }, + { "endon", keyword::KW_endon }, + { "notify", keyword::KW_notify }, + { "wait", keyword::KW_wait }, + { "waittill", keyword::KW_waittill }, + { "waittillmatch", keyword::KW_waittillmatch }, + { "waittillframeend", keyword::KW_waittillframeend }, + { "waitframe", keyword::KW_waitframe }, + { "if", keyword::KW_if }, + { "else", keyword::KW_else }, + { "do", keyword::KW_do }, + { "while", keyword::KW_while }, + { "for", keyword::KW_for }, + { "foreach", keyword::KW_foreach }, + { "in", keyword::KW_in }, + { "switch", keyword::KW_switch }, + { "case", keyword::KW_case }, + { "default", keyword::KW_default }, + { "break", keyword::KW_break }, + { "continue", keyword::KW_continue }, + { "return", keyword::KW_return }, + { "breakpoint", keyword::KW_breakpoint }, + { "prof_begin", keyword::KW_prof_begin }, + { "prof_end", keyword::KW_prof_end }, + { "thread", keyword::KW_thread }, + { "childthread", keyword::KW_childthread }, + { "thisthread", keyword::KW_thisthread }, + { "call", keyword::KW_call }, + { "true", keyword::KW_true }, + { "false", keyword::KW_false }, + { "undefined", keyword::KW_undefined }, + { ".size", keyword::KW_dotsize }, + { "game", keyword::KW_game }, + { "self", keyword::KW_self }, + { "anim", keyword::KW_anim }, + { "level", keyword::KW_level }, + { "isdefined", keyword::KW_isdefined }, + { "istrue", keyword::KW_istrue }, +}}; +} // namespace xsk::gsc::s4 diff --git a/src/s4/xsk/lexer.hpp b/src/s4/xsk/lexer.hpp index e998761c..6b983c76 100644 --- a/src/s4/xsk/lexer.hpp +++ b/src/s4/xsk/lexer.hpp @@ -1,711 +1,79 @@ -#ifndef s4_HEADER_H -#define s4_HEADER_H 1 -#define s4_IN_HEADER 1 - -#line 5 "lexer.hpp" -#include "stdafx.hpp" -#include "s4.hpp" -#include "parser.hpp" -using namespace xsk::gsc; -void s4_push_header(xsk::gsc::context* ctx, const std::string& file); -void s4_pop_header(xsk::gsc::context* ctx); - -#line 13 "lexer.hpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -#ifdef yy_create_buffer -#define s4__create_buffer_ALREADY_DEFINED -#else -#define yy_create_buffer s4__create_buffer -#endif - -#ifdef yy_delete_buffer -#define s4__delete_buffer_ALREADY_DEFINED -#else -#define yy_delete_buffer s4__delete_buffer -#endif - -#ifdef yy_scan_buffer -#define s4__scan_buffer_ALREADY_DEFINED -#else -#define yy_scan_buffer s4__scan_buffer -#endif - -#ifdef yy_scan_string -#define s4__scan_string_ALREADY_DEFINED -#else -#define yy_scan_string s4__scan_string -#endif - -#ifdef yy_scan_bytes -#define s4__scan_bytes_ALREADY_DEFINED -#else -#define yy_scan_bytes s4__scan_bytes -#endif - -#ifdef yy_init_buffer -#define s4__init_buffer_ALREADY_DEFINED -#else -#define yy_init_buffer s4__init_buffer -#endif - -#ifdef yy_flush_buffer -#define s4__flush_buffer_ALREADY_DEFINED -#else -#define yy_flush_buffer s4__flush_buffer -#endif - -#ifdef yy_load_buffer_state -#define s4__load_buffer_state_ALREADY_DEFINED -#else -#define yy_load_buffer_state s4__load_buffer_state -#endif - -#ifdef yy_switch_to_buffer -#define s4__switch_to_buffer_ALREADY_DEFINED -#else -#define yy_switch_to_buffer s4__switch_to_buffer -#endif - -#ifdef yypush_buffer_state -#define s4_push_buffer_state_ALREADY_DEFINED -#else -#define yypush_buffer_state s4_push_buffer_state -#endif - -#ifdef yypop_buffer_state -#define s4_pop_buffer_state_ALREADY_DEFINED -#else -#define yypop_buffer_state s4_pop_buffer_state -#endif - -#ifdef yyensure_buffer_stack -#define s4_ensure_buffer_stack_ALREADY_DEFINED -#else -#define yyensure_buffer_stack s4_ensure_buffer_stack -#endif - -#ifdef yylex -#define s4_lex_ALREADY_DEFINED -#else -#define yylex s4_lex -#endif - -#ifdef yyrestart -#define s4_restart_ALREADY_DEFINED -#else -#define yyrestart s4_restart -#endif - -#ifdef yylex_init -#define s4_lex_init_ALREADY_DEFINED -#else -#define yylex_init s4_lex_init -#endif - -#ifdef yylex_init_extra -#define s4_lex_init_extra_ALREADY_DEFINED -#else -#define yylex_init_extra s4_lex_init_extra -#endif - -#ifdef yylex_destroy -#define s4_lex_destroy_ALREADY_DEFINED -#else -#define yylex_destroy s4_lex_destroy -#endif - -#ifdef yyget_debug -#define s4_get_debug_ALREADY_DEFINED -#else -#define yyget_debug s4_get_debug -#endif - -#ifdef yyset_debug -#define s4_set_debug_ALREADY_DEFINED -#else -#define yyset_debug s4_set_debug -#endif - -#ifdef yyget_extra -#define s4_get_extra_ALREADY_DEFINED -#else -#define yyget_extra s4_get_extra -#endif - -#ifdef yyset_extra -#define s4_set_extra_ALREADY_DEFINED -#else -#define yyset_extra s4_set_extra -#endif - -#ifdef yyget_in -#define s4_get_in_ALREADY_DEFINED -#else -#define yyget_in s4_get_in -#endif - -#ifdef yyset_in -#define s4_set_in_ALREADY_DEFINED -#else -#define yyset_in s4_set_in -#endif - -#ifdef yyget_out -#define s4_get_out_ALREADY_DEFINED -#else -#define yyget_out s4_get_out -#endif - -#ifdef yyset_out -#define s4_set_out_ALREADY_DEFINED -#else -#define yyset_out s4_set_out -#endif - -#ifdef yyget_leng -#define s4_get_leng_ALREADY_DEFINED -#else -#define yyget_leng s4_get_leng -#endif - -#ifdef yyget_text -#define s4_get_text_ALREADY_DEFINED -#else -#define yyget_text s4_get_text -#endif - -#ifdef yyget_lineno -#define s4_get_lineno_ALREADY_DEFINED -#else -#define yyget_lineno s4_get_lineno -#endif - -#ifdef yyset_lineno -#define s4_set_lineno_ALREADY_DEFINED -#else -#define yyset_lineno s4_set_lineno -#endif - -#ifdef yyget_column -#define s4_get_column_ALREADY_DEFINED -#else -#define yyget_column s4_get_column -#endif - -#ifdef yyset_column -#define s4_set_column_ALREADY_DEFINED -#else -#define yyset_column s4_set_column -#endif - -#ifdef yywrap -#define s4_wrap_ALREADY_DEFINED -#else -#define yywrap s4_wrap -#endif - -#ifdef yyalloc -#define s4_alloc_ALREADY_DEFINED -#else -#define yyalloc s4_alloc -#endif - -#ifdef yyrealloc -#define s4_realloc_ALREADY_DEFINED -#else -#define yyrealloc s4_realloc -#endif - -#ifdef yyfree -#define s4_free_ALREADY_DEFINED -#else -#define yyfree s4_free -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -void yyrestart ( FILE *input_file , yyscan_t yyscanner ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); -void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); -void yypop_buffer_state ( yyscan_t yyscanner ); - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); - -void *yyalloc ( yy_size_t , yyscan_t yyscanner ); -void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); -void yyfree ( void * , yyscan_t yyscanner ); - -/* Begin user sect3 */ - -#define s4_wrap(yyscanner) (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP - -#define yytext_ptr yytext_r - -#ifdef YY_HEADER_EXPORT_START_CONDITIONS -#define INITIAL 0 -#define COMMENT_STATE 1 -#define DEV_OFF_STATE 2 -#define DEV_ON_STATE 3 - -#endif - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( yyscan_t yyscanner ); - -int yyget_debug ( yyscan_t yyscanner ); - -void yyset_debug ( int debug_flag , yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); - -FILE *yyget_in ( yyscan_t yyscanner ); - -void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); - -FILE *yyget_out ( yyscan_t yyscanner ); - -void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - - int yyget_leng ( yyscan_t yyscanner ); - -char *yyget_text ( yyscan_t yyscanner ); - -int yyget_lineno ( yyscan_t yyscanner ); - -void yyset_lineno ( int _line_number , yyscan_t yyscanner ); - -int yyget_column ( yyscan_t yyscanner ); - -void yyset_column ( int _column_no , yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( yyscan_t yyscanner ); -#else -extern int yywrap ( yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * , yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif - -#ifndef s4__create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef s4__delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef s4__scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef s4__scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef s4__scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef s4__init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef s4__flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef s4__load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef s4__switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef s4_push_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef s4_pop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef s4_ensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef s4_lex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef s4_restart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef s4_lex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef s4_lex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef s4_lex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef s4_get_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef s4_set_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef s4_get_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef s4_set_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef s4_get_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef s4_set_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef s4_get_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef s4_set_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef s4_get_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef s4_get_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef s4_get_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef s4_set_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef s4_get_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef s4_set_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef s4_wrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef s4_get_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef s4_set_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef s4_get_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef s4_set_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef s4_alloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef s4_realloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef s4_free_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef s4_text_ALREADY_DEFINED -#undef yytext -#endif -#ifndef s4_leng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef s4_in_ALREADY_DEFINED -#undef yyin -#endif -#ifndef s4_out_ALREADY_DEFINED -#undef yyout -#endif -#ifndef s4__flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef s4_lineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef s4_tables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef s4_tables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef s4_TABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 174 "lexer.lpp" - - -#line 709 "lexer.hpp" -#undef s4_IN_HEADER -#endif /* s4_HEADER_H */ +// Copyright 2022 xensik. All rights reserved. +// +// Use of this source code is governed by a GNU GPLv3 license +// that can be found in the LICENSE file. + +#pragma once + +#include "s4.hpp" + +namespace xsk::gsc::s4 +{ + +enum class keyword; + +struct buffer +{ + int size; + int length; + char* data; + + buffer(); + ~buffer(); + bool push(char c); +}; + +struct reader +{ + enum states { end, ok }; + + states state; + int bytes_remaining; + const char* buffer_pos; + char last_byte; + char current_byte; + + reader(); + + reader& operator=(const reader& r) + { + std::memcpy(this, &r, sizeof(reader)); + return *this; + } + + void init(const char* data, size_t size); + void advance(); +}; + +class lexer +{ +private: + reader reader_; + buffer buffer_; + location loc_; + build mode_; + bool in_dev_state_; + std::stack locs_; + std::stack readers_; + std::uint32_t header_top_; + +public: + lexer(const std::string& name, const char* data, size_t size); + auto lex() -> xsk::gsc::s4::parser::symbol_type; + void push_header(const std::string& file); + void pop_header(); + void restrict_header(const xsk::gsc::location& loc); + +private: + auto read_string(char quote, bool localize) -> xsk::gsc::s4::parser::symbol_type; + auto read_number(char first) -> xsk::gsc::s4::parser::symbol_type; + auto read_word(char first) -> xsk::gsc::s4::parser::symbol_type; + auto read_dotsize() -> xsk::gsc::s4::parser::symbol_type; + auto keyword_token(keyword k) -> xsk::gsc::s4::parser::symbol_type; + static auto keyword_is_token(keyword k) -> bool; + static auto get_keyword(std::string_view str) -> keyword; + + static std::unordered_map keywords; +}; + +} // namespace xsk::gsc::s4 diff --git a/src/s4/xsk/parser.cpp b/src/s4/xsk/parser.cpp index 1fd269b2..2654f27b 100644 --- a/src/s4/xsk/parser.cpp +++ b/src/s4/xsk/parser.cpp @@ -35,13 +35,13 @@ // private implementation details that can be changed or removed. // "%code top" blocks. -#line 40 "parser.ypp" +#line 34 "parser.ypp" #include "stdafx.hpp" #include "parser.hpp" #include "lexer.hpp" using namespace xsk::gsc; -xsk::gsc::s4::parser::symbol_type S4lex(yyscan_t yyscanner, xsk::gsc::context* ctx); +xsk::gsc::s4::parser::symbol_type S4lex(xsk::gsc::s4::lexer& lexer); #line 47 "parser.cpp" @@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace s4 { #line 149 "parser.cpp" /// Build a parser object. - parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) + parser::parser (xsk::gsc::s4::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg) #if S4DEBUG : yydebug_ (false), yycdebug_ (&std::cerr), @@ -156,8 +156,7 @@ namespace xsk { namespace gsc { namespace s4 { : #endif yy_lac_established_ (false), - yyscanner (yyscanner_yyarg), - ctx (ctx_yyarg), + lexer (lexer_yyarg), ast (ast_yyarg) {} @@ -1625,7 +1624,7 @@ namespace xsk { namespace gsc { namespace s4 { try #endif // YY_EXCEPTIONS { - symbol_type yylookahead (yylex (yyscanner, ctx)); + symbol_type yylookahead (yylex (lexer)); yyla.move (yylookahead); } #if YY_EXCEPTIONS @@ -2020,1327 +2019,1327 @@ namespace xsk { namespace gsc { namespace s4 { switch (yyn) { case 2: // root: program -#line 255 "parser.ypp" +#line 249 "parser.ypp" { ast = std::move(yystack_[0].value.as < ast::program::ptr > ()); } -#line 2026 "parser.cpp" +#line 2025 "parser.cpp" break; case 3: // root: %empty -#line 256 "parser.ypp" +#line 250 "parser.ypp" { ast = std::make_unique(yylhs.location); } -#line 2032 "parser.cpp" +#line 2031 "parser.cpp" break; case 4: // program: program inline -#line 261 "parser.ypp" +#line 255 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); } -#line 2038 "parser.cpp" +#line 2037 "parser.cpp" break; case 5: // program: program include -#line 263 "parser.ypp" +#line 257 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2044 "parser.cpp" +#line 2043 "parser.cpp" break; case 6: // program: program declaration -#line 265 "parser.ypp" +#line 259 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::move(yystack_[1].value.as < ast::program::ptr > ()); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2050 "parser.cpp" +#line 2049 "parser.cpp" break; case 7: // program: inline -#line 267 "parser.ypp" +#line 261 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); } -#line 2056 "parser.cpp" +#line 2055 "parser.cpp" break; case 8: // program: include -#line 269 "parser.ypp" +#line 263 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->includes.push_back(std::move(yystack_[0].value.as < ast::include::ptr > ())); } -#line 2062 "parser.cpp" +#line 2061 "parser.cpp" break; case 9: // program: declaration -#line 271 "parser.ypp" +#line 265 "parser.ypp" { yylhs.value.as < ast::program::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::program::ptr > ()->declarations.push_back(std::move(yystack_[0].value.as < ast::decl > ())); } -#line 2068 "parser.cpp" +#line 2067 "parser.cpp" break; case 10: // inline: "#inline" expr_path ";" -#line 275 "parser.ypp" - { s4_push_header(ctx, yystack_[1].value.as < ast::expr_path::ptr > ()->value); } -#line 2074 "parser.cpp" +#line 269 "parser.ypp" + { lexer.push_header(yystack_[1].value.as < ast::expr_path::ptr > ()->value); } +#line 2073 "parser.cpp" break; case 11: // include: "#include" expr_path ";" -#line 280 "parser.ypp" +#line 274 "parser.ypp" { yylhs.value.as < ast::include::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_path::ptr > ())); } -#line 2080 "parser.cpp" +#line 2079 "parser.cpp" break; case 12: // declaration: "/#" -#line 284 "parser.ypp" +#line 278 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_begin = std::make_unique(yylhs.location); } -#line 2086 "parser.cpp" +#line 2085 "parser.cpp" break; case 13: // declaration: "#/" -#line 285 "parser.ypp" +#line 279 "parser.ypp" { yylhs.value.as < ast::decl > ().as_dev_end = std::make_unique(yylhs.location); } -#line 2092 "parser.cpp" +#line 2091 "parser.cpp" break; case 14: // declaration: decl_usingtree -#line 286 "parser.ypp" +#line 280 "parser.ypp" { yylhs.value.as < ast::decl > ().as_usingtree = std::move(yystack_[0].value.as < ast::decl_usingtree::ptr > ()); } -#line 2098 "parser.cpp" +#line 2097 "parser.cpp" break; case 15: // declaration: decl_constant -#line 287 "parser.ypp" +#line 281 "parser.ypp" { yylhs.value.as < ast::decl > ().as_constant = std::move(yystack_[0].value.as < ast::decl_constant::ptr > ()); } -#line 2104 "parser.cpp" +#line 2103 "parser.cpp" break; case 16: // declaration: decl_thread -#line 288 "parser.ypp" +#line 282 "parser.ypp" { yylhs.value.as < ast::decl > ().as_thread = std::move(yystack_[0].value.as < ast::decl_thread::ptr > ()); } -#line 2110 "parser.cpp" +#line 2109 "parser.cpp" break; case 17: // decl_usingtree: "#using_animtree" "(" expr_string ")" ";" -#line 293 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } -#line 2116 "parser.cpp" +#line 287 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_usingtree::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_string::ptr > ())); } +#line 2115 "parser.cpp" break; case 18: // decl_constant: expr_identifier "=" expr ";" -#line 298 "parser.ypp" +#line 292 "parser.ypp" { yylhs.value.as < ast::decl_constant::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2122 "parser.cpp" +#line 2121 "parser.cpp" break; case 19: // decl_thread: expr_identifier "(" expr_parameters ")" stmt_block -#line 303 "parser.ypp" - { ctx->restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2128 "parser.cpp" +#line 297 "parser.ypp" + { lexer.restrict_header(yylhs.location); yylhs.value.as < ast::decl_thread::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } +#line 2127 "parser.cpp" break; case 20: // stmt: stmt_dev -#line 307 "parser.ypp" +#line 301 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2134 "parser.cpp" +#line 2133 "parser.cpp" break; case 21: // stmt: stmt_block -#line 308 "parser.ypp" +#line 302 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_list = std::move(yystack_[0].value.as < ast::stmt_list::ptr > ()); } -#line 2140 "parser.cpp" +#line 2139 "parser.cpp" break; case 22: // stmt: stmt_call -#line 309 "parser.ypp" +#line 303 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_call = std::move(yystack_[0].value.as < ast::stmt_call::ptr > ()); } -#line 2146 "parser.cpp" +#line 2145 "parser.cpp" break; case 23: // stmt: stmt_assign -#line 310 "parser.ypp" +#line 304 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_assign = std::move(yystack_[0].value.as < ast::stmt_assign::ptr > ()); } -#line 2152 "parser.cpp" +#line 2151 "parser.cpp" break; case 24: // stmt: stmt_endon -#line 311 "parser.ypp" +#line 305 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_endon = std::move(yystack_[0].value.as < ast::stmt_endon::ptr > ()); } -#line 2158 "parser.cpp" +#line 2157 "parser.cpp" break; case 25: // stmt: stmt_notify -#line 312 "parser.ypp" +#line 306 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_notify = std::move(yystack_[0].value.as < ast::stmt_notify::ptr > ()); } -#line 2164 "parser.cpp" +#line 2163 "parser.cpp" break; case 26: // stmt: stmt_wait -#line 313 "parser.ypp" +#line 307 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_wait = std::move(yystack_[0].value.as < ast::stmt_wait::ptr > ()); } -#line 2170 "parser.cpp" +#line 2169 "parser.cpp" break; case 27: // stmt: stmt_waittill -#line 314 "parser.ypp" +#line 308 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittill = std::move(yystack_[0].value.as < ast::stmt_waittill::ptr > ()); } -#line 2176 "parser.cpp" +#line 2175 "parser.cpp" break; case 28: // stmt: stmt_waittillmatch -#line 315 "parser.ypp" +#line 309 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillmatch = std::move(yystack_[0].value.as < ast::stmt_waittillmatch::ptr > ()); } -#line 2182 "parser.cpp" +#line 2181 "parser.cpp" break; case 29: // stmt: stmt_waittillframeend -#line 316 "parser.ypp" +#line 310 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waittillframeend = std::move(yystack_[0].value.as < ast::stmt_waittillframeend::ptr > ()); } -#line 2188 "parser.cpp" +#line 2187 "parser.cpp" break; case 30: // stmt: stmt_waitframe -#line 317 "parser.ypp" +#line 311 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_waitframe = std::move(yystack_[0].value.as < ast::stmt_waitframe::ptr > ()); } -#line 2194 "parser.cpp" +#line 2193 "parser.cpp" break; case 31: // stmt: stmt_if -#line 318 "parser.ypp" +#line 312 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_if = std::move(yystack_[0].value.as < ast::stmt_if::ptr > ()); } -#line 2200 "parser.cpp" +#line 2199 "parser.cpp" break; case 32: // stmt: stmt_ifelse -#line 319 "parser.ypp" +#line 313 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_ifelse = std::move(yystack_[0].value.as < ast::stmt_ifelse::ptr > ()); } -#line 2206 "parser.cpp" +#line 2205 "parser.cpp" break; case 33: // stmt: stmt_while -#line 320 "parser.ypp" +#line 314 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_while = std::move(yystack_[0].value.as < ast::stmt_while::ptr > ()); } -#line 2212 "parser.cpp" +#line 2211 "parser.cpp" break; case 34: // stmt: stmt_dowhile -#line 321 "parser.ypp" +#line 315 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_dowhile = std::move(yystack_[0].value.as < ast::stmt_dowhile::ptr > ()); } -#line 2218 "parser.cpp" +#line 2217 "parser.cpp" break; case 35: // stmt: stmt_for -#line 322 "parser.ypp" +#line 316 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_for = std::move(yystack_[0].value.as < ast::stmt_for::ptr > ()); } -#line 2224 "parser.cpp" +#line 2223 "parser.cpp" break; case 36: // stmt: stmt_foreach -#line 323 "parser.ypp" +#line 317 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_foreach = std::move(yystack_[0].value.as < ast::stmt_foreach::ptr > ()); } -#line 2230 "parser.cpp" +#line 2229 "parser.cpp" break; case 37: // stmt: stmt_switch -#line 324 "parser.ypp" +#line 318 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_switch = std::move(yystack_[0].value.as < ast::stmt_switch::ptr > ()); } -#line 2236 "parser.cpp" +#line 2235 "parser.cpp" break; case 38: // stmt: stmt_case -#line 325 "parser.ypp" +#line 319 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_case = std::move(yystack_[0].value.as < ast::stmt_case::ptr > ()); } -#line 2242 "parser.cpp" +#line 2241 "parser.cpp" break; case 39: // stmt: stmt_default -#line 326 "parser.ypp" +#line 320 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_default = std::move(yystack_[0].value.as < ast::stmt_default::ptr > ()); } -#line 2248 "parser.cpp" +#line 2247 "parser.cpp" break; case 40: // stmt: stmt_break -#line 327 "parser.ypp" +#line 321 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_break = std::move(yystack_[0].value.as < ast::stmt_break::ptr > ()); } -#line 2254 "parser.cpp" +#line 2253 "parser.cpp" break; case 41: // stmt: stmt_continue -#line 328 "parser.ypp" +#line 322 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_continue = std::move(yystack_[0].value.as < ast::stmt_continue::ptr > ()); } -#line 2260 "parser.cpp" +#line 2259 "parser.cpp" break; case 42: // stmt: stmt_return -#line 329 "parser.ypp" +#line 323 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_return = std::move(yystack_[0].value.as < ast::stmt_return::ptr > ()); } -#line 2266 "parser.cpp" +#line 2265 "parser.cpp" break; case 43: // stmt: stmt_breakpoint -#line 330 "parser.ypp" +#line 324 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_breakpoint = std::move(yystack_[0].value.as < ast::stmt_breakpoint::ptr > ()); } -#line 2272 "parser.cpp" +#line 2271 "parser.cpp" break; case 44: // stmt: stmt_prof_begin -#line 331 "parser.ypp" +#line 325 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_begin = std::move(yystack_[0].value.as < ast::stmt_prof_begin::ptr > ()); } -#line 2278 "parser.cpp" +#line 2277 "parser.cpp" break; case 45: // stmt: stmt_prof_end -#line 332 "parser.ypp" +#line 326 "parser.ypp" { yylhs.value.as < ast::stmt > ().as_prof_end = std::move(yystack_[0].value.as < ast::stmt_prof_end::ptr > ()); } -#line 2284 "parser.cpp" +#line 2283 "parser.cpp" break; case 46: // stmt_dev: "/#" stmt_list "#/" -#line 336 "parser.ypp" +#line 330 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2290 "parser.cpp" +#line 2289 "parser.cpp" break; case 47: // stmt_dev: "/#" "#/" -#line 337 "parser.ypp" +#line 331 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2296 "parser.cpp" +#line 2295 "parser.cpp" break; case 48: // stmt_block: "{" stmt_list "}" -#line 341 "parser.ypp" +#line 335 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); } -#line 2302 "parser.cpp" +#line 2301 "parser.cpp" break; case 49: // stmt_block: "{" "}" -#line 342 "parser.ypp" +#line 336 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); } -#line 2308 "parser.cpp" +#line 2307 "parser.cpp" break; case 50: // stmt_list: stmt_list stmt -#line 347 "parser.ypp" +#line 341 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::move(yystack_[1].value.as < ast::stmt_list::ptr > ()); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2314 "parser.cpp" +#line 2313 "parser.cpp" break; case 51: // stmt_list: stmt -#line 349 "parser.ypp" +#line 343 "parser.ypp" { yylhs.value.as < ast::stmt_list::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::stmt_list::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2320 "parser.cpp" +#line 2319 "parser.cpp" break; case 52: // stmt_expr: expr_assign -#line 354 "parser.ypp" +#line 348 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2326 "parser.cpp" +#line 2325 "parser.cpp" break; case 53: // stmt_expr: expr_increment -#line 356 "parser.ypp" +#line 350 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2332 "parser.cpp" +#line 2331 "parser.cpp" break; case 54: // stmt_expr: expr_decrement -#line 358 "parser.ypp" +#line 352 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2338 "parser.cpp" +#line 2337 "parser.cpp" break; case 55: // stmt_expr: %empty -#line 360 "parser.ypp" +#line 354 "parser.ypp" { yylhs.value.as < ast::stmt_expr::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2344 "parser.cpp" +#line 2343 "parser.cpp" break; case 56: // stmt_call: expr_call ";" -#line 365 "parser.ypp" +#line 359 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_call::ptr > ()))); } -#line 2350 "parser.cpp" +#line 2349 "parser.cpp" break; case 57: // stmt_call: expr_method ";" -#line 367 "parser.ypp" +#line 361 "parser.ypp" { yylhs.value.as < ast::stmt_call::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_method::ptr > ()))); } -#line 2356 "parser.cpp" +#line 2355 "parser.cpp" break; case 58: // stmt_assign: expr_assign ";" -#line 372 "parser.ypp" +#line 366 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2362 "parser.cpp" +#line 2361 "parser.cpp" break; case 59: // stmt_assign: expr_increment ";" -#line 374 "parser.ypp" +#line 368 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2368 "parser.cpp" +#line 2367 "parser.cpp" break; case 60: // stmt_assign: expr_decrement ";" -#line 376 "parser.ypp" +#line 370 "parser.ypp" { yylhs.value.as < ast::stmt_assign::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2374 "parser.cpp" +#line 2373 "parser.cpp" break; case 61: // stmt_endon: expr_object "endon" "(" expr ")" ";" -#line 381 "parser.ypp" +#line 375 "parser.ypp" { yylhs.value.as < ast::stmt_endon::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ())); } -#line 2380 "parser.cpp" +#line 2379 "parser.cpp" break; case 62: // stmt_notify: expr_object "notify" "(" expr "," expr_arguments_no_empty ")" ";" -#line 386 "parser.ypp" +#line 380 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2386 "parser.cpp" +#line 2385 "parser.cpp" break; case 63: // stmt_notify: expr_object "notify" "(" expr ")" ";" -#line 388 "parser.ypp" +#line 382 "parser.ypp" { yylhs.value.as < ast::stmt_notify::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2392 "parser.cpp" +#line 2391 "parser.cpp" break; case 64: // stmt_wait: "wait" expr ";" -#line 393 "parser.ypp" +#line 387 "parser.ypp" { yylhs.value.as < ast::stmt_wait::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2398 "parser.cpp" +#line 2397 "parser.cpp" break; case 65: // stmt_waittill: expr_object "waittill" "(" expr "," expr_arguments_no_empty ")" ";" -#line 398 "parser.ypp" +#line 392 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2404 "parser.cpp" +#line 2403 "parser.cpp" break; case 66: // stmt_waittill: expr_object "waittill" "(" expr ")" ";" -#line 400 "parser.ypp" +#line 394 "parser.ypp" { yylhs.value.as < ast::stmt_waittill::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2410 "parser.cpp" +#line 2409 "parser.cpp" break; case 67: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr "," expr_arguments_no_empty ")" ";" -#line 405 "parser.ypp" +#line 399 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[7].value.as < ast::expr > ()), std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2416 "parser.cpp" +#line 2415 "parser.cpp" break; case 68: // stmt_waittillmatch: expr_object "waittillmatch" "(" expr ")" ";" -#line 407 "parser.ypp" +#line 401 "parser.ypp" { yylhs.value.as < ast::stmt_waittillmatch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::make_unique(yylhs.location)); } -#line 2422 "parser.cpp" +#line 2421 "parser.cpp" break; case 69: // stmt_waittillframeend: "waittillframeend" ";" -#line 412 "parser.ypp" +#line 406 "parser.ypp" { yylhs.value.as < ast::stmt_waittillframeend::ptr > () = std::make_unique(yylhs.location); } -#line 2428 "parser.cpp" +#line 2427 "parser.cpp" break; case 70: // stmt_waitframe: "waitframe" ";" -#line 417 "parser.ypp" +#line 411 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2434 "parser.cpp" +#line 2433 "parser.cpp" break; case 71: // stmt_waitframe: "waitframe" "(" ")" ";" -#line 419 "parser.ypp" +#line 413 "parser.ypp" { yylhs.value.as < ast::stmt_waitframe::ptr > () = std::make_unique(yylhs.location); } -#line 2440 "parser.cpp" +#line 2439 "parser.cpp" break; case 72: // stmt_if: "if" "(" expr ")" stmt -#line 424 "parser.ypp" +#line 418 "parser.ypp" { yylhs.value.as < ast::stmt_if::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2446 "parser.cpp" +#line 2445 "parser.cpp" break; case 73: // stmt_ifelse: "if" "(" expr ")" stmt "else" stmt -#line 429 "parser.ypp" +#line 423 "parser.ypp" { yylhs.value.as < ast::stmt_ifelse::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::stmt > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2452 "parser.cpp" +#line 2451 "parser.cpp" break; case 74: // stmt_while: "while" "(" expr ")" stmt -#line 434 "parser.ypp" +#line 428 "parser.ypp" { yylhs.value.as < ast::stmt_while::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2458 "parser.cpp" +#line 2457 "parser.cpp" break; case 75: // stmt_dowhile: "do" stmt "while" "(" expr ")" ";" -#line 439 "parser.ypp" +#line 433 "parser.ypp" { yylhs.value.as < ast::stmt_dowhile::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[5].value.as < ast::stmt > ())); } -#line 2464 "parser.cpp" +#line 2463 "parser.cpp" break; case 76: // stmt_for: "for" "(" stmt_expr ";" expr_or_empty ";" stmt_expr ")" stmt -#line 444 "parser.ypp" +#line 438 "parser.ypp" { yylhs.value.as < ast::stmt_for::ptr > () = std::make_unique(yylhs.location, ast::stmt(std::move(yystack_[6].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[4].value.as < ast::expr > ()), ast::stmt(std::move(yystack_[2].value.as < ast::stmt_expr::ptr > ())), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2470 "parser.cpp" +#line 2469 "parser.cpp" break; case 77: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt -#line 449 "parser.ypp" +#line 443 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2476 "parser.cpp" +#line 2475 "parser.cpp" break; case 78: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt -#line 451 "parser.ypp" +#line 445 "parser.ypp" { yylhs.value.as < ast::stmt_foreach::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[6].value.as < ast::expr_identifier::ptr > ())), ast::expr(std::move(yystack_[4].value.as < ast::expr_identifier::ptr > ())), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt > ())); } -#line 2482 "parser.cpp" +#line 2481 "parser.cpp" break; case 79: // stmt_switch: "switch" "(" expr ")" stmt_block -#line 456 "parser.ypp" +#line 450 "parser.ypp" { yylhs.value.as < ast::stmt_switch::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::stmt_list::ptr > ())); } -#line 2488 "parser.cpp" +#line 2487 "parser.cpp" break; case 80: // stmt_case: "case" expr_integer ":" -#line 461 "parser.ypp" +#line 455 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_integer::ptr > ())), std::make_unique(yylhs.location)); } -#line 2494 "parser.cpp" +#line 2493 "parser.cpp" break; case 81: // stmt_case: "case" expr_string ":" -#line 463 "parser.ypp" +#line 457 "parser.ypp" { yylhs.value.as < ast::stmt_case::ptr > () = std::make_unique(yylhs.location, ast::expr(std::move(yystack_[1].value.as < ast::expr_string::ptr > ())), std::make_unique(yylhs.location)); } -#line 2500 "parser.cpp" +#line 2499 "parser.cpp" break; case 82: // stmt_default: "default" ":" -#line 468 "parser.ypp" +#line 462 "parser.ypp" { yylhs.value.as < ast::stmt_default::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2506 "parser.cpp" +#line 2505 "parser.cpp" break; case 83: // stmt_break: "break" ";" -#line 473 "parser.ypp" +#line 467 "parser.ypp" { yylhs.value.as < ast::stmt_break::ptr > () = std::make_unique(yylhs.location); } -#line 2512 "parser.cpp" +#line 2511 "parser.cpp" break; case 84: // stmt_continue: "continue" ";" -#line 478 "parser.ypp" +#line 472 "parser.ypp" { yylhs.value.as < ast::stmt_continue::ptr > () = std::make_unique(yylhs.location); } -#line 2518 "parser.cpp" +#line 2517 "parser.cpp" break; case 85: // stmt_return: "return" expr ";" -#line 483 "parser.ypp" +#line 477 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 2524 "parser.cpp" +#line 2523 "parser.cpp" break; case 86: // stmt_return: "return" ";" -#line 485 "parser.ypp" +#line 479 "parser.ypp" { yylhs.value.as < ast::stmt_return::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location)); } -#line 2530 "parser.cpp" +#line 2529 "parser.cpp" break; case 87: // stmt_breakpoint: "breakpoint" ";" -#line 490 "parser.ypp" +#line 484 "parser.ypp" { yylhs.value.as < ast::stmt_breakpoint::ptr > () = std::make_unique(yylhs.location); } -#line 2536 "parser.cpp" +#line 2535 "parser.cpp" break; case 88: // stmt_prof_begin: "prof_begin" "(" expr_arguments ")" ";" -#line 495 "parser.ypp" +#line 489 "parser.ypp" { yylhs.value.as < ast::stmt_prof_begin::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2542 "parser.cpp" +#line 2541 "parser.cpp" break; case 89: // stmt_prof_end: "prof_end" "(" expr_arguments ")" ";" -#line 500 "parser.ypp" +#line 494 "parser.ypp" { yylhs.value.as < ast::stmt_prof_end::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ())); } -#line 2548 "parser.cpp" +#line 2547 "parser.cpp" break; case 90: // expr: expr_ternary -#line 504 "parser.ypp" +#line 498 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2554 "parser.cpp" +#line 2553 "parser.cpp" break; case 91: // expr: expr_binary -#line 505 "parser.ypp" +#line 499 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2560 "parser.cpp" +#line 2559 "parser.cpp" break; case 92: // expr: expr_primitive -#line 506 "parser.ypp" +#line 500 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2566 "parser.cpp" +#line 2565 "parser.cpp" break; case 93: // expr_or_empty: expr -#line 510 "parser.ypp" +#line 504 "parser.ypp" { yylhs.value.as < ast::expr > () = std::move(yystack_[0].value.as < ast::expr > ()); } -#line 2572 "parser.cpp" +#line 2571 "parser.cpp" break; case 94: // expr_or_empty: %empty -#line 511 "parser.ypp" +#line 505 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location); } -#line 2578 "parser.cpp" +#line 2577 "parser.cpp" break; case 95: // expr_assign: expr_object "=" expr -#line 516 "parser.ypp" +#line 510 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2584 "parser.cpp" +#line 2583 "parser.cpp" break; case 96: // expr_assign: expr_object "|=" expr -#line 518 "parser.ypp" +#line 512 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2590 "parser.cpp" +#line 2589 "parser.cpp" break; case 97: // expr_assign: expr_object "&=" expr -#line 520 "parser.ypp" +#line 514 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2596 "parser.cpp" +#line 2595 "parser.cpp" break; case 98: // expr_assign: expr_object "^=" expr -#line 522 "parser.ypp" +#line 516 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2602 "parser.cpp" +#line 2601 "parser.cpp" break; case 99: // expr_assign: expr_object "<<=" expr -#line 524 "parser.ypp" +#line 518 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()),std::move( yystack_[0].value.as < ast::expr > ())); } -#line 2608 "parser.cpp" +#line 2607 "parser.cpp" break; case 100: // expr_assign: expr_object ">>=" expr -#line 526 "parser.ypp" +#line 520 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2614 "parser.cpp" +#line 2613 "parser.cpp" break; case 101: // expr_assign: expr_object "+=" expr -#line 528 "parser.ypp" +#line 522 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2620 "parser.cpp" +#line 2619 "parser.cpp" break; case 102: // expr_assign: expr_object "-=" expr -#line 530 "parser.ypp" +#line 524 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2626 "parser.cpp" +#line 2625 "parser.cpp" break; case 103: // expr_assign: expr_object "*=" expr -#line 532 "parser.ypp" +#line 526 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2632 "parser.cpp" +#line 2631 "parser.cpp" break; case 104: // expr_assign: expr_object "/=" expr -#line 534 "parser.ypp" +#line 528 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2638 "parser.cpp" +#line 2637 "parser.cpp" break; case 105: // expr_assign: expr_object "%=" expr -#line 536 "parser.ypp" +#line 530 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2644 "parser.cpp" +#line 2643 "parser.cpp" break; case 106: // expr_increment: "++" expr_object -#line 541 "parser.ypp" +#line 535 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2650 "parser.cpp" +#line 2649 "parser.cpp" break; case 107: // expr_increment: expr_object "++" -#line 543 "parser.ypp" +#line 537 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2656 "parser.cpp" +#line 2655 "parser.cpp" break; case 108: // expr_decrement: "--" expr_object -#line 548 "parser.ypp" +#line 542 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ()), true); } -#line 2662 "parser.cpp" +#line 2661 "parser.cpp" break; case 109: // expr_decrement: expr_object "--" -#line 550 "parser.ypp" +#line 544 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), false); } -#line 2668 "parser.cpp" +#line 2667 "parser.cpp" break; case 110: // expr_ternary: expr "?" expr ":" expr -#line 555 "parser.ypp" +#line 549 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[4].value.as < ast::expr > ()), std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2674 "parser.cpp" +#line 2673 "parser.cpp" break; case 111: // expr_binary: expr "||" expr -#line 560 "parser.ypp" +#line 554 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2680 "parser.cpp" +#line 2679 "parser.cpp" break; case 112: // expr_binary: expr "&&" expr -#line 562 "parser.ypp" +#line 556 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2686 "parser.cpp" +#line 2685 "parser.cpp" break; case 113: // expr_binary: expr "==" expr -#line 564 "parser.ypp" +#line 558 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2692 "parser.cpp" +#line 2691 "parser.cpp" break; case 114: // expr_binary: expr "!=" expr -#line 566 "parser.ypp" +#line 560 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2698 "parser.cpp" +#line 2697 "parser.cpp" break; case 115: // expr_binary: expr "<=" expr -#line 568 "parser.ypp" +#line 562 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2704 "parser.cpp" +#line 2703 "parser.cpp" break; case 116: // expr_binary: expr ">=" expr -#line 570 "parser.ypp" +#line 564 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2710 "parser.cpp" +#line 2709 "parser.cpp" break; case 117: // expr_binary: expr "<" expr -#line 572 "parser.ypp" +#line 566 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2716 "parser.cpp" +#line 2715 "parser.cpp" break; case 118: // expr_binary: expr ">" expr -#line 574 "parser.ypp" +#line 568 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2722 "parser.cpp" +#line 2721 "parser.cpp" break; case 119: // expr_binary: expr "|" expr -#line 576 "parser.ypp" +#line 570 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2728 "parser.cpp" +#line 2727 "parser.cpp" break; case 120: // expr_binary: expr "&" expr -#line 578 "parser.ypp" +#line 572 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2734 "parser.cpp" +#line 2733 "parser.cpp" break; case 121: // expr_binary: expr "^" expr -#line 580 "parser.ypp" +#line 574 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2740 "parser.cpp" +#line 2739 "parser.cpp" break; case 122: // expr_binary: expr "<<" expr -#line 582 "parser.ypp" +#line 576 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2746 "parser.cpp" +#line 2745 "parser.cpp" break; case 123: // expr_binary: expr ">>" expr -#line 584 "parser.ypp" +#line 578 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2752 "parser.cpp" +#line 2751 "parser.cpp" break; case 124: // expr_binary: expr "+" expr -#line 586 "parser.ypp" +#line 580 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2758 "parser.cpp" +#line 2757 "parser.cpp" break; case 125: // expr_binary: expr "-" expr -#line 588 "parser.ypp" +#line 582 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2764 "parser.cpp" +#line 2763 "parser.cpp" break; case 126: // expr_binary: expr "*" expr -#line 590 "parser.ypp" +#line 584 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2770 "parser.cpp" +#line 2769 "parser.cpp" break; case 127: // expr_binary: expr "/" expr -#line 592 "parser.ypp" +#line 586 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2776 "parser.cpp" +#line 2775 "parser.cpp" break; case 128: // expr_binary: expr "%" expr -#line 594 "parser.ypp" +#line 588 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2782 "parser.cpp" +#line 2781 "parser.cpp" break; case 129: // expr_primitive: expr_complement -#line 598 "parser.ypp" +#line 592 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_complement::ptr > ()); } -#line 2788 "parser.cpp" +#line 2787 "parser.cpp" break; case 130: // expr_primitive: expr_not -#line 599 "parser.ypp" +#line 593 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_not::ptr > ()); } -#line 2794 "parser.cpp" +#line 2793 "parser.cpp" break; case 131: // expr_primitive: expr_call -#line 600 "parser.ypp" +#line 594 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 2800 "parser.cpp" +#line 2799 "parser.cpp" break; case 132: // expr_primitive: expr_method -#line 601 "parser.ypp" +#line 595 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 2806 "parser.cpp" +#line 2805 "parser.cpp" break; case 133: // expr_primitive: expr_add_array -#line 602 "parser.ypp" +#line 596 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_add_array::ptr > ()); } -#line 2812 "parser.cpp" +#line 2811 "parser.cpp" break; case 134: // expr_primitive: expr_isdefined -#line 603 "parser.ypp" +#line 597 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_isdefined::ptr > ()); } -#line 2818 "parser.cpp" +#line 2817 "parser.cpp" break; case 135: // expr_primitive: expr_istrue -#line 604 "parser.ypp" +#line 598 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istrue::ptr > ()); } -#line 2824 "parser.cpp" +#line 2823 "parser.cpp" break; case 136: // expr_primitive: expr_reference -#line 605 "parser.ypp" +#line 599 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_reference::ptr > ()); } -#line 2830 "parser.cpp" +#line 2829 "parser.cpp" break; case 137: // expr_primitive: expr_array -#line 606 "parser.ypp" +#line 600 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 2836 "parser.cpp" +#line 2835 "parser.cpp" break; case 138: // expr_primitive: expr_field -#line 607 "parser.ypp" +#line 601 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 2842 "parser.cpp" +#line 2841 "parser.cpp" break; case 139: // expr_primitive: expr_size -#line 608 "parser.ypp" +#line 602 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_size::ptr > ()); } -#line 2848 "parser.cpp" +#line 2847 "parser.cpp" break; case 140: // expr_primitive: expr_paren -#line 609 "parser.ypp" +#line 603 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_paren::ptr > ()); } -#line 2854 "parser.cpp" +#line 2853 "parser.cpp" break; case 141: // expr_primitive: expr_thisthread -#line 610 "parser.ypp" +#line 604 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_thisthread::ptr > ()); } -#line 2860 "parser.cpp" +#line 2859 "parser.cpp" break; case 142: // expr_primitive: expr_empty_array -#line 611 "parser.ypp" +#line 605 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_empty_array::ptr > ()); } -#line 2866 "parser.cpp" +#line 2865 "parser.cpp" break; case 143: // expr_primitive: expr_undefined -#line 612 "parser.ypp" +#line 606 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_undefined::ptr > ()); } -#line 2872 "parser.cpp" +#line 2871 "parser.cpp" break; case 144: // expr_primitive: expr_game -#line 613 "parser.ypp" +#line 607 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 2878 "parser.cpp" +#line 2877 "parser.cpp" break; case 145: // expr_primitive: expr_self -#line 614 "parser.ypp" +#line 608 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 2884 "parser.cpp" +#line 2883 "parser.cpp" break; case 146: // expr_primitive: expr_anim -#line 615 "parser.ypp" +#line 609 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 2890 "parser.cpp" +#line 2889 "parser.cpp" break; case 147: // expr_primitive: expr_level -#line 616 "parser.ypp" +#line 610 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 2896 "parser.cpp" +#line 2895 "parser.cpp" break; case 148: // expr_primitive: expr_animation -#line 617 "parser.ypp" +#line 611 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animation::ptr > ()); } -#line 2902 "parser.cpp" +#line 2901 "parser.cpp" break; case 149: // expr_primitive: expr_animtree -#line 618 "parser.ypp" +#line 612 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_animtree::ptr > ()); } -#line 2908 "parser.cpp" +#line 2907 "parser.cpp" break; case 150: // expr_primitive: expr_identifier -#line 619 "parser.ypp" +#line 613 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 2914 "parser.cpp" +#line 2913 "parser.cpp" break; case 151: // expr_primitive: expr_istring -#line 620 "parser.ypp" +#line 614 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_istring::ptr > ()); } -#line 2920 "parser.cpp" +#line 2919 "parser.cpp" break; case 152: // expr_primitive: expr_string -#line 621 "parser.ypp" +#line 615 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_string::ptr > ()); } -#line 2926 "parser.cpp" +#line 2925 "parser.cpp" break; case 153: // expr_primitive: expr_color -#line 622 "parser.ypp" +#line 616 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_color::ptr > ()); } -#line 2932 "parser.cpp" +#line 2931 "parser.cpp" break; case 154: // expr_primitive: expr_vector -#line 623 "parser.ypp" +#line 617 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_vector::ptr > ()); } -#line 2938 "parser.cpp" +#line 2937 "parser.cpp" break; case 155: // expr_primitive: expr_float -#line 624 "parser.ypp" +#line 618 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_float::ptr > ()); } -#line 2944 "parser.cpp" +#line 2943 "parser.cpp" break; case 156: // expr_primitive: expr_integer -#line 625 "parser.ypp" +#line 619 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_integer::ptr > ()); } -#line 2950 "parser.cpp" +#line 2949 "parser.cpp" break; case 157: // expr_primitive: expr_false -#line 626 "parser.ypp" +#line 620 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_false::ptr > ()); } -#line 2956 "parser.cpp" +#line 2955 "parser.cpp" break; case 158: // expr_primitive: expr_true -#line 627 "parser.ypp" +#line 621 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_true::ptr > ()); } -#line 2962 "parser.cpp" +#line 2961 "parser.cpp" break; case 159: // expr_complement: "~" expr -#line 632 "parser.ypp" +#line 626 "parser.ypp" { yylhs.value.as < ast::expr_complement::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2968 "parser.cpp" +#line 2967 "parser.cpp" break; case 160: // expr_not: "!" expr -#line 637 "parser.ypp" +#line 631 "parser.ypp" { yylhs.value.as < ast::expr_not::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::expr > ())); } -#line 2974 "parser.cpp" +#line 2973 "parser.cpp" break; case 161: // expr_call: expr_function -#line 641 "parser.ypp" +#line 635 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2980 "parser.cpp" +#line 2979 "parser.cpp" break; case 162: // expr_call: expr_pointer -#line 642 "parser.ypp" +#line 636 "parser.ypp" { yylhs.value.as < ast::expr_call::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[0].value.as < ast::call > ())); } -#line 2986 "parser.cpp" +#line 2985 "parser.cpp" break; case 163: // expr_method: expr_object expr_function -#line 645 "parser.ypp" +#line 639 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2992 "parser.cpp" +#line 2991 "parser.cpp" break; case 164: // expr_method: expr_object expr_pointer -#line 646 "parser.ypp" +#line 640 "parser.ypp" { yylhs.value.as < ast::expr_method::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::call > ())); } -#line 2998 "parser.cpp" +#line 2997 "parser.cpp" break; case 165: // expr_function: expr_identifier "(" expr_arguments ")" -#line 651 "parser.ypp" +#line 645 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 3004 "parser.cpp" +#line 3003 "parser.cpp" break; case 166: // expr_function: expr_path "::" expr_identifier "(" expr_arguments ")" -#line 653 "parser.ypp" +#line 647 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 3010 "parser.cpp" +#line 3009 "parser.cpp" break; case 167: // expr_function: "thread" expr_identifier "(" expr_arguments ")" -#line 655 "parser.ypp" +#line 649 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 3016 "parser.cpp" +#line 3015 "parser.cpp" break; case 168: // expr_function: "thread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 657 "parser.ypp" +#line 651 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 3022 "parser.cpp" +#line 3021 "parser.cpp" break; case 169: // expr_function: "childthread" expr_identifier "(" expr_arguments ")" -#line 659 "parser.ypp" +#line 653 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3028 "parser.cpp" +#line 3027 "parser.cpp" break; case 170: // expr_function: "childthread" expr_path "::" expr_identifier "(" expr_arguments ")" -#line 661 "parser.ypp" +#line 655 "parser.ypp" { yylhs.value.as < ast::call > ().as_function = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr_path::ptr > ()), std::move(yystack_[3].value.as < ast::expr_identifier::ptr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3034 "parser.cpp" +#line 3033 "parser.cpp" break; case 171: // expr_pointer: "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 666 "parser.ypp" +#line 660 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::normal); } -#line 3040 "parser.cpp" +#line 3039 "parser.cpp" break; case 172: // expr_pointer: "thread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 668 "parser.ypp" +#line 662 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::thread); } -#line 3046 "parser.cpp" +#line 3045 "parser.cpp" break; case 173: // expr_pointer: "childthread" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 670 "parser.ypp" +#line 664 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::childthread); } -#line 3052 "parser.cpp" +#line 3051 "parser.cpp" break; case 174: // expr_pointer: "call" "[" "[" expr "]" "]" "(" expr_arguments ")" -#line 672 "parser.ypp" +#line 666 "parser.ypp" { yylhs.value.as < ast::call > ().as_pointer = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ()), ast::call::mode::builtin); } -#line 3058 "parser.cpp" +#line 3057 "parser.cpp" break; case 175: // expr_add_array: "[" expr_arguments_no_empty "]" -#line 677 "parser.ypp" +#line 671 "parser.ypp" { yylhs.value.as < ast::expr_add_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr_arguments::ptr > ())); } -#line 3064 "parser.cpp" +#line 3063 "parser.cpp" break; case 176: // expr_parameters: expr_parameters "," expr_identifier -#line 682 "parser.ypp" +#line 676 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::move(yystack_[2].value.as < ast::expr_parameters::ptr > ()); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3070 "parser.cpp" +#line 3069 "parser.cpp" break; case 177: // expr_parameters: expr_identifier -#line 684 "parser.ypp" +#line 678 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_parameters::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3076 "parser.cpp" +#line 3075 "parser.cpp" break; case 178: // expr_parameters: %empty -#line 686 "parser.ypp" +#line 680 "parser.ypp" { yylhs.value.as < ast::expr_parameters::ptr > () = std::make_unique(yylhs.location); } -#line 3082 "parser.cpp" +#line 3081 "parser.cpp" break; case 179: // expr_arguments: expr_arguments_no_empty -#line 691 "parser.ypp" +#line 685 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[0].value.as < ast::expr_arguments::ptr > ()); } -#line 3088 "parser.cpp" +#line 3087 "parser.cpp" break; case 180: // expr_arguments: %empty -#line 693 "parser.ypp" +#line 687 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); } -#line 3094 "parser.cpp" +#line 3093 "parser.cpp" break; case 181: // expr_arguments_no_empty: expr_arguments "," expr -#line 698 "parser.ypp" +#line 692 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::move(yystack_[2].value.as < ast::expr_arguments::ptr > ()); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3100 "parser.cpp" +#line 3099 "parser.cpp" break; case 182: // expr_arguments_no_empty: expr -#line 700 "parser.ypp" +#line 694 "parser.ypp" { yylhs.value.as < ast::expr_arguments::ptr > () = std::make_unique(yylhs.location); yylhs.value.as < ast::expr_arguments::ptr > ()->list.push_back(std::move(yystack_[0].value.as < ast::expr > ())); } -#line 3106 "parser.cpp" +#line 3105 "parser.cpp" break; case 183: // expr_isdefined: "isdefined" "(" expr ")" -#line 705 "parser.ypp" +#line 699 "parser.ypp" { yylhs.value.as < ast::expr_isdefined::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3112 "parser.cpp" +#line 3111 "parser.cpp" break; case 184: // expr_istrue: "istrue" "(" expr ")" -#line 710 "parser.ypp" +#line 704 "parser.ypp" { yylhs.value.as < ast::expr_istrue::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3118 "parser.cpp" +#line 3117 "parser.cpp" break; case 185: // expr_reference: "::" expr_identifier -#line 715 "parser.ypp" +#line 709 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::make_unique(yylhs.location), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3124 "parser.cpp" +#line 3123 "parser.cpp" break; case 186: // expr_reference: expr_path "::" expr_identifier -#line 717 "parser.ypp" +#line 711 "parser.ypp" { yylhs.value.as < ast::expr_reference::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr_path::ptr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3130 "parser.cpp" +#line 3129 "parser.cpp" break; case 187: // expr_array: expr_object "[" expr "]" -#line 722 "parser.ypp" +#line 716 "parser.ypp" { yylhs.value.as < ast::expr_array::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3136 "parser.cpp" +#line 3135 "parser.cpp" break; case 188: // expr_field: expr_object "." expr_identifier -#line 727 "parser.ypp" +#line 721 "parser.ypp" { yylhs.value.as < ast::expr_field::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[2].value.as < ast::expr > ()), std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ())); } -#line 3142 "parser.cpp" +#line 3141 "parser.cpp" break; case 189: // expr_size: expr_object ".size" -#line 732 "parser.ypp" +#line 726 "parser.ypp" { yylhs.value.as < ast::expr_size::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3148 "parser.cpp" +#line 3147 "parser.cpp" break; case 190: // expr_paren: "(" expr ")" -#line 737 "parser.ypp" +#line 731 "parser.ypp" { yylhs.value.as < ast::expr_paren::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3154 "parser.cpp" +#line 3153 "parser.cpp" break; case 191: // expr_object: expr_call -#line 741 "parser.ypp" +#line 735 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_call::ptr > ()); } -#line 3160 "parser.cpp" +#line 3159 "parser.cpp" break; case 192: // expr_object: expr_method -#line 742 "parser.ypp" +#line 736 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_method::ptr > ()); } -#line 3166 "parser.cpp" +#line 3165 "parser.cpp" break; case 193: // expr_object: expr_array -#line 743 "parser.ypp" +#line 737 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_array::ptr > ()); } -#line 3172 "parser.cpp" +#line 3171 "parser.cpp" break; case 194: // expr_object: expr_field -#line 744 "parser.ypp" +#line 738 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_field::ptr > ()); } -#line 3178 "parser.cpp" +#line 3177 "parser.cpp" break; case 195: // expr_object: expr_game -#line 745 "parser.ypp" +#line 739 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_game::ptr > ()); } -#line 3184 "parser.cpp" +#line 3183 "parser.cpp" break; case 196: // expr_object: expr_self -#line 746 "parser.ypp" +#line 740 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_self::ptr > ()); } -#line 3190 "parser.cpp" +#line 3189 "parser.cpp" break; case 197: // expr_object: expr_anim -#line 747 "parser.ypp" +#line 741 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_anim::ptr > ()); } -#line 3196 "parser.cpp" +#line 3195 "parser.cpp" break; case 198: // expr_object: expr_level -#line 748 "parser.ypp" +#line 742 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_level::ptr > ()); } -#line 3202 "parser.cpp" +#line 3201 "parser.cpp" break; case 199: // expr_object: expr_identifier -#line 749 "parser.ypp" +#line 743 "parser.ypp" { yylhs.value.as < ast::expr > ().as_node = std::move(yystack_[0].value.as < ast::expr_identifier::ptr > ()); } -#line 3208 "parser.cpp" +#line 3207 "parser.cpp" break; case 200: // expr_thisthread: "thisthread" -#line 754 "parser.ypp" +#line 748 "parser.ypp" { yylhs.value.as < ast::expr_thisthread::ptr > () = std::make_unique(yylhs.location); } -#line 3214 "parser.cpp" +#line 3213 "parser.cpp" break; case 201: // expr_empty_array: "[" "]" -#line 759 "parser.ypp" +#line 753 "parser.ypp" { yylhs.value.as < ast::expr_empty_array::ptr > () = std::make_unique(yylhs.location); } -#line 3220 "parser.cpp" +#line 3219 "parser.cpp" break; case 202: // expr_undefined: "undefined" -#line 764 "parser.ypp" +#line 758 "parser.ypp" { yylhs.value.as < ast::expr_undefined::ptr > () = std::make_unique(yylhs.location); } -#line 3226 "parser.cpp" +#line 3225 "parser.cpp" break; case 203: // expr_game: "game" -#line 769 "parser.ypp" +#line 763 "parser.ypp" { yylhs.value.as < ast::expr_game::ptr > () = std::make_unique(yylhs.location); } -#line 3232 "parser.cpp" +#line 3231 "parser.cpp" break; case 204: // expr_self: "self" -#line 774 "parser.ypp" +#line 768 "parser.ypp" { yylhs.value.as < ast::expr_self::ptr > () = std::make_unique(yylhs.location); } -#line 3238 "parser.cpp" +#line 3237 "parser.cpp" break; case 205: // expr_anim: "anim" -#line 779 "parser.ypp" +#line 773 "parser.ypp" { yylhs.value.as < ast::expr_anim::ptr > () = std::make_unique(yylhs.location); } -#line 3244 "parser.cpp" +#line 3243 "parser.cpp" break; case 206: // expr_level: "level" -#line 784 "parser.ypp" +#line 778 "parser.ypp" { yylhs.value.as < ast::expr_level::ptr > () = std::make_unique(yylhs.location); } -#line 3250 "parser.cpp" +#line 3249 "parser.cpp" break; case 207: // expr_animation: "%" "identifier" -#line 789 "parser.ypp" +#line 783 "parser.ypp" { yylhs.value.as < ast::expr_animation::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3256 "parser.cpp" +#line 3255 "parser.cpp" break; case 208: // expr_animtree: "#animtree" -#line 794 "parser.ypp" +#line 788 "parser.ypp" { yylhs.value.as < ast::expr_animtree::ptr > () = std::make_unique(yylhs.location); } -#line 3262 "parser.cpp" +#line 3261 "parser.cpp" break; case 209: // expr_identifier: "identifier" -#line 799 "parser.ypp" +#line 793 "parser.ypp" { yylhs.value.as < ast::expr_identifier::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3268 "parser.cpp" +#line 3267 "parser.cpp" break; case 210: // expr_path: "path" -#line 804 "parser.ypp" +#line 798 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3274 "parser.cpp" +#line 3273 "parser.cpp" break; case 211: // expr_path: expr_identifier -#line 806 "parser.ypp" +#line 800 "parser.ypp" { yylhs.value.as < ast::expr_path::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < ast::expr_identifier::ptr > ()->value); } -#line 3280 "parser.cpp" +#line 3279 "parser.cpp" break; case 212: // expr_istring: "localized string" -#line 811 "parser.ypp" +#line 805 "parser.ypp" { yylhs.value.as < ast::expr_istring::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3286 "parser.cpp" +#line 3285 "parser.cpp" break; case 213: // expr_string: "string literal" -#line 816 "parser.ypp" +#line 810 "parser.ypp" { yylhs.value.as < ast::expr_string::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3292 "parser.cpp" +#line 3291 "parser.cpp" break; case 214: // expr_color: "color" -#line 821 "parser.ypp" +#line 815 "parser.ypp" { yylhs.value.as < ast::expr_color::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3298 "parser.cpp" +#line 3297 "parser.cpp" break; case 215: // expr_vector: "(" expr "," expr "," expr ")" -#line 826 "parser.ypp" +#line 820 "parser.ypp" { yylhs.value.as < ast::expr_vector::ptr > () = std::make_unique(yylhs.location, std::move(yystack_[5].value.as < ast::expr > ()), std::move(yystack_[3].value.as < ast::expr > ()), std::move(yystack_[1].value.as < ast::expr > ())); } -#line 3304 "parser.cpp" +#line 3303 "parser.cpp" break; case 216: // expr_float: "-" "float" -#line 831 "parser.ypp" +#line 825 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3310 "parser.cpp" +#line 3309 "parser.cpp" break; case 217: // expr_float: "float" -#line 833 "parser.ypp" +#line 827 "parser.ypp" { yylhs.value.as < ast::expr_float::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3316 "parser.cpp" +#line 3315 "parser.cpp" break; case 218: // expr_integer: "-" "integer" -#line 838 "parser.ypp" +#line 832 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, "-" + yystack_[0].value.as < std::string > ()); } -#line 3322 "parser.cpp" +#line 3321 "parser.cpp" break; case 219: // expr_integer: "integer" -#line 840 "parser.ypp" +#line 834 "parser.ypp" { yylhs.value.as < ast::expr_integer::ptr > () = std::make_unique(yylhs.location, yystack_[0].value.as < std::string > ()); } -#line 3328 "parser.cpp" +#line 3327 "parser.cpp" break; case 220: // expr_false: "false" -#line 845 "parser.ypp" +#line 839 "parser.ypp" { yylhs.value.as < ast::expr_false::ptr > () = std::make_unique(yylhs.location); } -#line 3334 "parser.cpp" +#line 3333 "parser.cpp" break; case 221: // expr_true: "true" -#line 850 "parser.ypp" +#line 844 "parser.ypp" { yylhs.value.as < ast::expr_true::ptr > () = std::make_unique(yylhs.location); } -#line 3340 "parser.cpp" +#line 3339 "parser.cpp" break; -#line 3344 "parser.cpp" +#line 3343 "parser.cpp" default: break; @@ -4544,29 +4543,29 @@ namespace xsk { namespace gsc { namespace s4 { const short parser::yyrline_[] = { - 0, 255, 255, 256, 260, 262, 264, 266, 268, 270, - 275, 279, 284, 285, 286, 287, 288, 292, 297, 302, - 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, - 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, - 327, 328, 329, 330, 331, 332, 336, 337, 341, 342, - 346, 348, 353, 355, 357, 360, 364, 366, 371, 373, - 375, 380, 385, 387, 392, 397, 399, 404, 406, 411, - 416, 418, 423, 428, 433, 438, 443, 448, 450, 455, - 460, 462, 467, 472, 477, 482, 484, 489, 494, 499, - 504, 505, 506, 510, 511, 515, 517, 519, 521, 523, - 525, 527, 529, 531, 533, 535, 540, 542, 547, 549, - 554, 559, 561, 563, 565, 567, 569, 571, 573, 575, - 577, 579, 581, 583, 585, 587, 589, 591, 593, 598, - 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, - 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, - 619, 620, 621, 622, 623, 624, 625, 626, 627, 631, - 636, 641, 642, 645, 646, 650, 652, 654, 656, 658, - 660, 665, 667, 669, 671, 676, 681, 683, 686, 690, - 693, 697, 699, 704, 709, 714, 716, 721, 726, 731, - 736, 741, 742, 743, 744, 745, 746, 747, 748, 749, - 753, 758, 763, 768, 773, 778, 783, 788, 793, 798, - 803, 805, 810, 815, 820, 825, 830, 832, 837, 839, - 844, 849 + 0, 249, 249, 250, 254, 256, 258, 260, 262, 264, + 269, 273, 278, 279, 280, 281, 282, 286, 291, 296, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 324, 325, 326, 330, 331, 335, 336, + 340, 342, 347, 349, 351, 354, 358, 360, 365, 367, + 369, 374, 379, 381, 386, 391, 393, 398, 400, 405, + 410, 412, 417, 422, 427, 432, 437, 442, 444, 449, + 454, 456, 461, 466, 471, 476, 478, 483, 488, 493, + 498, 499, 500, 504, 505, 509, 511, 513, 515, 517, + 519, 521, 523, 525, 527, 529, 534, 536, 541, 543, + 548, 553, 555, 557, 559, 561, 563, 565, 567, 569, + 571, 573, 575, 577, 579, 581, 583, 585, 587, 592, + 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, + 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, + 613, 614, 615, 616, 617, 618, 619, 620, 621, 625, + 630, 635, 636, 639, 640, 644, 646, 648, 650, 652, + 654, 659, 661, 663, 665, 670, 675, 677, 680, 684, + 687, 691, 693, 698, 703, 708, 710, 715, 720, 725, + 730, 735, 736, 737, 738, 739, 740, 741, 742, 743, + 747, 752, 757, 762, 767, 772, 777, 782, 787, 792, + 797, 799, 804, 809, 814, 819, 824, 826, 831, 833, + 838, 843 }; void @@ -4599,9 +4598,9 @@ namespace xsk { namespace gsc { namespace s4 { #line 13 "parser.ypp" } } } // xsk::gsc::s4 -#line 4603 "parser.cpp" +#line 4602 "parser.cpp" -#line 853 "parser.ypp" +#line 847 "parser.ypp" void xsk::gsc::s4::parser::error(const xsk::gsc::location& loc, const std::string& msg) diff --git a/src/s4/xsk/parser.hpp b/src/s4/xsk/parser.hpp index 893b164c..e9edf48d 100644 --- a/src/s4/xsk/parser.hpp +++ b/src/s4/xsk/parser.hpp @@ -45,13 +45,12 @@ #ifndef YY_S4_PARSER_HPP_INCLUDED # define YY_S4_PARSER_HPP_INCLUDED // "%code requires" blocks. -#line 33 "parser.ypp" +#line 28 "parser.ypp" #include "s4.hpp" -typedef void *yyscan_t; -#define YY_DECL xsk::gsc::s4::parser::symbol_type S4lex(yyscan_t yyscanner, xsk::gsc::context* ctx) +namespace xsk::gsc::s4 { class lexer; } -#line 55 "parser.hpp" +#line 54 "parser.hpp" # include # include // std::abort @@ -194,7 +193,7 @@ typedef void *yyscan_t; #line 13 "parser.ypp" namespace xsk { namespace gsc { namespace s4 { -#line 198 "parser.hpp" +#line 197 "parser.hpp" @@ -2741,7 +2740,7 @@ switch (yykind) }; /// Build a parser object. - parser (yyscan_t yyscanner_yyarg, xsk::gsc::context* ctx_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); + parser (xsk::gsc::s4::lexer& lexer_yyarg, xsk::gsc::ast::program::ptr& ast_yyarg); virtual ~parser (); #if 201103L <= YY_CPLUSPLUS @@ -4742,8 +4741,7 @@ switch (yykind) // User arguments. - yyscan_t yyscanner; - xsk::gsc::context* ctx; + xsk::gsc::s4::lexer& lexer; xsk::gsc::ast::program::ptr& ast; }; @@ -5444,7 +5442,7 @@ switch (yykind) #line 13 "parser.ypp" } } } // xsk::gsc::s4 -#line 5448 "parser.hpp" +#line 5446 "parser.hpp" diff --git a/src/s4/xsk/resolver.cpp b/src/s4/xsk/resolver.cpp index 5d61c9b9..dd3ef066 100644 --- a/src/s4/xsk/resolver.cpp +++ b/src/s4/xsk/resolver.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -206,6 +206,35 @@ auto resolver::make_token(std::string_view str) -> std::string return data; } +std::function(const std::string&)> read_callback = nullptr; +std::unordered_map> files; + +auto resolver::file_data(const std::string& name) -> std::tuple +{ + const auto& itr = files.find(name); + + if(itr != files.end()) + { + return { &itr->first ,reinterpret_cast(itr->second.data()), itr->second.size() }; + } + + auto data = read_callback(name); + + const auto& res = files.insert({ name, std::move(data)}); + + if(res.second) + { + return { &res.first->first, reinterpret_cast(res.first->second.data()), res.first->second.size() }; + } + + throw error("couldn't open gsc file '" + name + "'"); +} + +void resolver::set_reader(std::function(const std::string&)> callback) +{ + read_callback = callback; +} + const std::array, 190> opcode_list {{ { 0x00, "CAST_FIELD_OBJECT" }, diff --git a/src/s4/xsk/resolver.hpp b/src/s4/xsk/resolver.hpp index 15c92a00..15961791 100644 --- a/src/s4/xsk/resolver.hpp +++ b/src/s4/xsk/resolver.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -30,6 +30,8 @@ public: static auto find_method(const std::string& name) -> bool; static auto make_token(std::string_view str) -> std::string; + static auto file_data(const std::string& name) -> std::tuple; + static void set_reader(std::function(const std::string&)> callback); }; } // namespace xsk::gsc::s4 diff --git a/src/s4/xsk/s4.cpp b/src/s4/xsk/s4.cpp index adfb5ff8..ef7af0fc 100644 --- a/src/s4/xsk/s4.cpp +++ b/src/s4/xsk/s4.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/s4/xsk/s4.hpp b/src/s4/xsk/s4.hpp index 690c64b5..216d25df 100644 --- a/src/s4/xsk/s4.hpp +++ b/src/s4/xsk/s4.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/tool/stdafx.cpp b/src/tool/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/tool/stdafx.cpp +++ b/src/tool/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/tool/stdafx.hpp b/src/tool/stdafx.hpp index a26e6c31..5c38da30 100644 --- a/src/tool/stdafx.hpp +++ b/src/tool/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/tool/xsk/main.cpp b/src/tool/xsk/main.cpp index 853fca16..be6d1292 100644 --- a/src/tool/xsk/main.cpp +++ b/src/tool/xsk/main.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/stdafx.cpp b/src/utils/stdafx.cpp index 0f0f08c2..1f373bf1 100644 --- a/src/utils/stdafx.cpp +++ b/src/utils/stdafx.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/stdafx.hpp b/src/utils/stdafx.hpp index f21c8d05..a6ca1534 100644 --- a/src/utils/stdafx.hpp +++ b/src/utils/stdafx.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/asset.cpp b/src/utils/xsk/gsc/asset.cpp index 08364e1c..e719e750 100644 --- a/src/utils/xsk/gsc/asset.cpp +++ b/src/utils/xsk/gsc/asset.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/asset.hpp b/src/utils/xsk/gsc/asset.hpp index 20275feb..f21bd259 100644 --- a/src/utils/xsk/gsc/asset.hpp +++ b/src/utils/xsk/gsc/asset.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/block.cpp b/src/utils/xsk/gsc/block.cpp index 77c492fd..63a447e6 100644 --- a/src/utils/xsk/gsc/block.cpp +++ b/src/utils/xsk/gsc/block.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/block.hpp b/src/utils/xsk/gsc/block.hpp index f6b37d0b..7ff984f8 100644 --- a/src/utils/xsk/gsc/block.hpp +++ b/src/utils/xsk/gsc/block.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/interfaces/assembler.hpp b/src/utils/xsk/gsc/interfaces/assembler.hpp index 4e38cc79..ce50ee2c 100644 --- a/src/utils/xsk/gsc/interfaces/assembler.hpp +++ b/src/utils/xsk/gsc/interfaces/assembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/interfaces/compiler.hpp b/src/utils/xsk/gsc/interfaces/compiler.hpp index c8e60c20..77ea9b26 100644 --- a/src/utils/xsk/gsc/interfaces/compiler.hpp +++ b/src/utils/xsk/gsc/interfaces/compiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/interfaces/decompiler.hpp b/src/utils/xsk/gsc/interfaces/decompiler.hpp index 938d127e..523f4a96 100644 --- a/src/utils/xsk/gsc/interfaces/decompiler.hpp +++ b/src/utils/xsk/gsc/interfaces/decompiler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/interfaces/disassembler.hpp b/src/utils/xsk/gsc/interfaces/disassembler.hpp index 68eb7300..7c030aaf 100644 --- a/src/utils/xsk/gsc/interfaces/disassembler.hpp +++ b/src/utils/xsk/gsc/interfaces/disassembler.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/interfaces/exception.hpp b/src/utils/xsk/gsc/interfaces/exception.hpp index 812a4410..b84a61db 100644 --- a/src/utils/xsk/gsc/interfaces/exception.hpp +++ b/src/utils/xsk/gsc/interfaces/exception.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/location.hpp b/src/utils/xsk/gsc/location.hpp index 42cf5a9a..3f6f7e23 100644 --- a/src/utils/xsk/gsc/location.hpp +++ b/src/utils/xsk/gsc/location.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/nodetree.cpp b/src/utils/xsk/gsc/nodetree.cpp index ebcd14c4..0bf7c74f 100644 --- a/src/utils/xsk/gsc/nodetree.cpp +++ b/src/utils/xsk/gsc/nodetree.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/nodetree.hpp b/src/utils/xsk/gsc/nodetree.hpp index 92c7e0c0..ed4383e3 100644 --- a/src/utils/xsk/gsc/nodetree.hpp +++ b/src/utils/xsk/gsc/nodetree.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/gsc/types.cpp b/src/utils/xsk/gsc/types.cpp index 17acbc53..102d3e20 100644 --- a/src/utils/xsk/gsc/types.cpp +++ b/src/utils/xsk/gsc/types.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -8,12 +8,4 @@ namespace xsk::gsc { -void context::restrict_header(const xsk::gsc::location& loc) -{ - if (header_top > 0) - { - throw comp_error(loc, "not allowed inside a gsh file"); - } -} - } // namespace xsk::gsc diff --git a/src/utils/xsk/gsc/types.hpp b/src/utils/xsk/gsc/types.hpp index c950b262..892ea873 100644 --- a/src/utils/xsk/gsc/types.hpp +++ b/src/utils/xsk/gsc/types.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. @@ -22,27 +22,6 @@ enum class abort_t abort_return = 3, }; -struct source -{ - std::string name; - std::vector buf; -}; - -struct context -{ - using ptr = std::unique_ptr; - - void* scanner; - std::uint32_t header_top; - xsk::gsc::build mode; - xsk::gsc::location loc; - std::stack locs; - std::vector* sources; - std::function(const std::string&)> read_callback; - - void restrict_header(const xsk::gsc::location& loc); -}; - struct include_t { std::string name; diff --git a/src/utils/xsk/utils.hpp b/src/utils/xsk/utils.hpp index c668912f..d6e6324c 100644 --- a/src/utils/xsk/utils.hpp +++ b/src/utils/xsk/utils.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/utils/byte_buffer.cpp b/src/utils/xsk/utils/byte_buffer.cpp index 8b31e68d..b46cbe28 100644 --- a/src/utils/xsk/utils/byte_buffer.cpp +++ b/src/utils/xsk/utils/byte_buffer.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/utils/byte_buffer.hpp b/src/utils/xsk/utils/byte_buffer.hpp index 5b8d5f3a..c43ff3ac 100644 --- a/src/utils/xsk/utils/byte_buffer.hpp +++ b/src/utils/xsk/utils/byte_buffer.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/utils/compression.cpp b/src/utils/xsk/utils/compression.cpp index 34582246..3763e0af 100644 --- a/src/utils/xsk/utils/compression.cpp +++ b/src/utils/xsk/utils/compression.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/utils/compression.hpp b/src/utils/xsk/utils/compression.hpp index 12d409a5..f2dfbc26 100644 --- a/src/utils/xsk/utils/compression.hpp +++ b/src/utils/xsk/utils/compression.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/utils/file.cpp b/src/utils/xsk/utils/file.cpp index f0a8949b..fd78978f 100644 --- a/src/utils/xsk/utils/file.cpp +++ b/src/utils/xsk/utils/file.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/utils/file.hpp b/src/utils/xsk/utils/file.hpp index 5730d986..ace37c04 100644 --- a/src/utils/xsk/utils/file.hpp +++ b/src/utils/xsk/utils/file.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/utils/string.cpp b/src/utils/xsk/utils/string.cpp index fff8f3f5..e64a40f2 100644 --- a/src/utils/xsk/utils/string.cpp +++ b/src/utils/xsk/utils/string.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file. diff --git a/src/utils/xsk/utils/string.hpp b/src/utils/xsk/utils/string.hpp index a771f2ad..160e6198 100644 --- a/src/utils/xsk/utils/string.hpp +++ b/src/utils/xsk/utils/string.hpp @@ -1,4 +1,4 @@ -// Copyright 2021 xensik. All rights reserved. +// Copyright 2022 xensik. All rights reserved. // // Use of this source code is governed by a GNU GPLv3 license // that can be found in the LICENSE file.