finish lexer optimization

This commit is contained in:
xensik 2022-01-30 14:45:07 +01:00
parent 8b62635131
commit 30aab69283
45 changed files with 10357 additions and 10545 deletions

View File

@ -41,6 +41,14 @@ using namespace xsk::gsc;
xsk::gsc::h1::parser::symbol_type H1lex(xsk::gsc::h1::lexer& lexer);
}
%token HSDEFINE "#define"
%token HSUNDEF "#undef"
%token HSIFDEF "#ifdef"
%token HSIFNDEF "#ifndef"
%token HSIF "#if"
%token HSELIF "#elif"
%token HSELSE "#else"
%token HSENDIF "#endif"
%token DEVBEGIN "/#"
%token DEVEND "#/"
%token INLINE "#inline"
@ -283,7 +291,7 @@ declaration
decl_usingtree
: USINGTREE LPAREN expr_string RPAREN SEMICOLON
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
;
decl_constant
@ -293,7 +301,7 @@ decl_constant
decl_thread
: expr_identifier LPAREN expr_parameters RPAREN stmt_block
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
;
stmt

View File

@ -39,6 +39,14 @@ using namespace xsk::gsc;
xsk::gsc::h2::parser::symbol_type H2lex(xsk::gsc::h2::lexer& lexer);
}
%token HSDEFINE "#define"
%token HSUNDEF "#undef"
%token HSIFDEF "#ifdef"
%token HSIFNDEF "#ifndef"
%token HSIF "#if"
%token HSELIF "#elif"
%token HSELSE "#else"
%token HSENDIF "#endif"
%token DEVBEGIN "/#"
%token DEVEND "#/"
%token INLINE "#inline"
@ -281,7 +289,7 @@ declaration
decl_usingtree
: USINGTREE LPAREN expr_string RPAREN SEMICOLON
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
;
decl_constant
@ -291,7 +299,7 @@ decl_constant
decl_thread
: expr_identifier LPAREN expr_parameters RPAREN stmt_block
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
;
stmt

View File

@ -39,6 +39,14 @@ using namespace xsk::gsc;
xsk::gsc::iw5::parser::symbol_type IW5lex(xsk::gsc::iw5::lexer& lexer);
}
%token HSDEFINE "#define"
%token HSUNDEF "#undef"
%token HSIFDEF "#ifdef"
%token HSIFNDEF "#ifndef"
%token HSIF "#if"
%token HSELIF "#elif"
%token HSELSE "#else"
%token HSENDIF "#endif"
%token DEVBEGIN "/#"
%token DEVEND "#/"
%token INLINE "#inline"
@ -279,7 +287,7 @@ declaration
decl_usingtree
: USINGTREE LPAREN expr_string RPAREN SEMICOLON
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
;
decl_constant
@ -289,7 +297,7 @@ decl_constant
decl_thread
: expr_identifier LPAREN expr_parameters RPAREN stmt_block
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
;
stmt

View File

@ -39,6 +39,14 @@ using namespace xsk::gsc;
xsk::gsc::iw6::parser::symbol_type IW6lex(xsk::gsc::iw6::lexer& lexer);
}
%token HSDEFINE "#define"
%token HSUNDEF "#undef"
%token HSIFDEF "#ifdef"
%token HSIFNDEF "#ifndef"
%token HSIF "#if"
%token HSELIF "#elif"
%token HSELSE "#else"
%token HSENDIF "#endif"
%token DEVBEGIN "/#"
%token DEVEND "#/"
%token INLINE "#inline"
@ -279,7 +287,7 @@ declaration
decl_usingtree
: USINGTREE LPAREN expr_string RPAREN SEMICOLON
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
;
decl_constant
@ -289,7 +297,7 @@ decl_constant
decl_thread
: expr_identifier LPAREN expr_parameters RPAREN stmt_block
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
;
stmt

View File

@ -39,6 +39,14 @@ using namespace xsk::gsc;
xsk::gsc::iw7::parser::symbol_type IW7lex(xsk::gsc::iw7::lexer& lexer);
}
%token HSDEFINE "#define"
%token HSUNDEF "#undef"
%token HSIFDEF "#ifdef"
%token HSIFNDEF "#ifndef"
%token HSIF "#if"
%token HSELIF "#elif"
%token HSELSE "#else"
%token HSENDIF "#endif"
%token DEVBEGIN "/#"
%token DEVEND "#/"
%token INLINE "#inline"
@ -279,7 +287,7 @@ declaration
decl_usingtree
: USINGTREE LPAREN expr_string RPAREN SEMICOLON
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
;
decl_constant
@ -289,7 +297,7 @@ decl_constant
decl_thread
: expr_identifier LPAREN expr_parameters RPAREN stmt_block
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
;
stmt

View File

@ -39,6 +39,14 @@ using namespace xsk::gsc;
xsk::gsc::iw8::parser::symbol_type IW8lex(xsk::gsc::iw8::lexer& lexer);
}
%token HSDEFINE "#define"
%token HSUNDEF "#undef"
%token HSIFDEF "#ifdef"
%token HSIFNDEF "#ifndef"
%token HSIF "#if"
%token HSELIF "#elif"
%token HSELSE "#else"
%token HSENDIF "#endif"
%token DEVBEGIN "/#"
%token DEVEND "#/"
%token INLINE "#inline"
@ -285,7 +293,7 @@ declaration
decl_usingtree
: USINGTREE LPAREN expr_string RPAREN SEMICOLON
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
;
decl_constant
@ -295,7 +303,7 @@ decl_constant
decl_thread
: expr_identifier LPAREN expr_parameters RPAREN stmt_block
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
;
stmt

View File

@ -39,6 +39,14 @@ using namespace xsk::gsc;
xsk::gsc::s1::parser::symbol_type S1lex(xsk::gsc::s1::lexer& lexer);
}
%token HSDEFINE "#define"
%token HSUNDEF "#undef"
%token HSIFDEF "#ifdef"
%token HSIFNDEF "#ifndef"
%token HSIF "#if"
%token HSELIF "#elif"
%token HSELSE "#else"
%token HSENDIF "#endif"
%token DEVBEGIN "/#"
%token DEVEND "#/"
%token INLINE "#inline"
@ -281,7 +289,7 @@ declaration
decl_usingtree
: USINGTREE LPAREN expr_string RPAREN SEMICOLON
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
;
decl_constant
@ -291,7 +299,7 @@ decl_constant
decl_thread
: expr_identifier LPAREN expr_parameters RPAREN stmt_block
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
;
stmt

View File

@ -39,6 +39,14 @@ using namespace xsk::gsc;
xsk::gsc::s2::parser::symbol_type S2lex(xsk::gsc::s2::lexer& lexer);
}
%token HSDEFINE "#define"
%token HSUNDEF "#undef"
%token HSIFDEF "#ifdef"
%token HSIFNDEF "#ifndef"
%token HSIF "#if"
%token HSELIF "#elif"
%token HSELSE "#else"
%token HSENDIF "#endif"
%token DEVBEGIN "/#"
%token DEVEND "#/"
%token INLINE "#inline"
@ -281,7 +289,7 @@ declaration
decl_usingtree
: USINGTREE LPAREN expr_string RPAREN SEMICOLON
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
;
decl_constant
@ -291,7 +299,7 @@ decl_constant
decl_thread
: expr_identifier LPAREN expr_parameters RPAREN stmt_block
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
;
stmt

View File

@ -39,6 +39,14 @@ using namespace xsk::gsc;
xsk::gsc::s4::parser::symbol_type S4lex(xsk::gsc::s4::lexer& lexer);
}
%token HSDEFINE "#define"
%token HSUNDEF "#undef"
%token HSIFDEF "#ifdef"
%token HSIFNDEF "#ifndef"
%token HSIF "#if"
%token HSELIF "#elif"
%token HSELSE "#else"
%token HSENDIF "#endif"
%token DEVBEGIN "/#"
%token DEVEND "#/"
%token INLINE "#inline"
@ -285,7 +293,7 @@ declaration
decl_usingtree
: USINGTREE LPAREN expr_string RPAREN SEMICOLON
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_usingtree>(@$, std::move($3)); }
;
decl_constant
@ -295,7 +303,7 @@ decl_constant
decl_thread
: expr_identifier LPAREN expr_parameters RPAREN stmt_block
{ lexer.restrict_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
{ lexer.ban_header(@$); $$ = std::make_unique<ast::decl_thread>(@$, std::move($1), std::move($3), std::move($5)); }
;
stmt

View File

@ -16,57 +16,6 @@ xsk::gsc::h1::parser::symbol_type H1lex(xsk::gsc::h1::lexer& lexer)
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_game,
KW_self,
KW_anim,
KW_level,
KW_INVALID,
};
buffer::buffer() : length(0)
{
data = static_cast<char*>(std::malloc(max_buf_size));
@ -129,7 +78,7 @@ void reader::advance()
}
}
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(xsk::gsc::location(&name)),
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(location(&name)),
mode_(build::dev), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
{
reader_.init(data, size);
@ -140,7 +89,7 @@ void lexer::push_header(const std::string& file)
try
{
if (header_top_++ >= 10)
throw xsk::gsc::error("maximum gsh depth exceeded '10'");
throw comp_error(loc_, "maximum gsh depth exceeded '10'");
auto data = resolver::file_data(file + ".gsh");
@ -151,7 +100,7 @@ void lexer::push_header(const std::string& file)
}
catch (const std::exception& e)
{
throw xsk::gsc::error("parsing header file '" + file + "': " + e.what());
throw error("parsing header file '" + file + "': " + e.what());
}
}
@ -164,7 +113,7 @@ void lexer::pop_header()
readers_.pop();
}
void lexer::restrict_header(const xsk::gsc::location& loc)
void lexer::ban_header(const location& loc)
{
if (header_top_ > 0)
{
@ -172,7 +121,7 @@ void lexer::restrict_header(const xsk::gsc::location& loc)
}
}
auto lexer::lex() -> xsk::gsc::h1::parser::symbol_type
auto lexer::lex() -> parser::symbol_type
{
buffer_.length = 0;
state_ = state::start;
@ -193,7 +142,7 @@ auto lexer::lex() -> xsk::gsc::h1::parser::symbol_type
if (header_top_ > 0)
pop_header();
else
return h1::parser::make_H1EOF(loc_);
return parser::make_H1EOF(loc_);
}
reader_.advance();
@ -211,22 +160,22 @@ auto lexer::lex() -> xsk::gsc::h1::parser::symbol_type
continue;
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
return h1::parser::make_DIV(loc_);
return parser::make_DIV(loc_);
reader_.advance();
if (last == '=')
return h1::parser::make_ASSIGN_DIV(loc_);
return parser::make_ASSIGN_DIV(loc_);
if (last == '#')
{
if (indev_)
throw comp_error(loc_, "cannot recurse devblock ('/#')");
if (mode_ == xsk::gsc::build::dev)
if (mode_ == build::dev)
{
indev_ = true;
return h1::parser::make_DEVBEGIN(loc_);
return parser::make_DEVBEGIN(loc_);
}
else
{
@ -290,7 +239,7 @@ auto lexer::lex() -> xsk::gsc::h1::parser::symbol_type
indev_ = false;
reader_.advance();
return h1::parser::make_DEVEND(loc_);
return parser::make_DEVEND(loc_);
}
buffer_.push(last);
@ -303,12 +252,12 @@ auto lexer::lex() -> xsk::gsc::h1::parser::symbol_type
goto lex_name;
case '*':
if (curr != '/' && curr != '=')
return h1::parser::make_MUL(loc_);
return parser::make_MUL(loc_);
reader_.advance();
if (last == '=')
return h1::parser::make_ASSIGN_MUL(loc_);
return parser::make_ASSIGN_MUL(loc_);
throw comp_error(loc_, "unmatched multiline comment end ('*/')");
case '"':
@ -323,127 +272,127 @@ auto lexer::lex() -> xsk::gsc::h1::parser::symbol_type
state_ = state::field;
goto lex_name_or_number;
case '(':
return h1::parser::make_LPAREN(loc_);
return parser::make_LPAREN(loc_);
case ')':
return h1::parser::make_RPAREN(loc_);
return parser::make_RPAREN(loc_);
case '{':
return h1::parser::make_LBRACE(loc_);
return parser::make_LBRACE(loc_);
case '}':
return h1::parser::make_RBRACE(loc_);
return parser::make_RBRACE(loc_);
case '[':
return h1::parser::make_LBRACKET(loc_);
return parser::make_LBRACKET(loc_);
case ']':
return h1::parser::make_RBRACKET(loc_);
return parser::make_RBRACKET(loc_);
case ',':
return h1::parser::make_COMMA(loc_);
return parser::make_COMMA(loc_);
case ';':
return h1::parser::make_SEMICOLON(loc_);
return parser::make_SEMICOLON(loc_);
case ':':
if (curr != ':')
return h1::parser::make_COLON(loc_);
return parser::make_COLON(loc_);
reader_.advance();
return h1::parser::make_DOUBLECOLON(loc_);
return parser::make_DOUBLECOLON(loc_);
case '?':
return h1::parser::make_QMARK(loc_);
return parser::make_QMARK(loc_);
case '=':
if (curr != '=')
return h1::parser::make_ASSIGN(loc_);
return parser::make_ASSIGN(loc_);
reader_.advance();
return h1::parser::make_EQUALITY(loc_);
return parser::make_EQUALITY(loc_);
case '+':
if (curr != '+' && curr != '=')
return h1::parser::make_ADD(loc_);
return parser::make_ADD(loc_);
reader_.advance();
if (last == '+')
return h1::parser::make_INCREMENT(loc_);
return parser::make_INCREMENT(loc_);
return h1::parser::make_ASSIGN_ADD(loc_);
return parser::make_ASSIGN_ADD(loc_);
case '-':
if (curr != '-' && curr != '=')
return h1::parser::make_SUB(loc_);
return parser::make_SUB(loc_);
reader_.advance();
if (last == '-')
return h1::parser::make_DECREMENT(loc_);
return parser::make_DECREMENT(loc_);
return h1::parser::make_ASSIGN_SUB(loc_);
return parser::make_ASSIGN_SUB(loc_);
case '%':
if (curr != '=')
return h1::parser::make_MOD(loc_);
return parser::make_MOD(loc_);
reader_.advance();
return h1::parser::make_ASSIGN_MOD(loc_);
return parser::make_ASSIGN_MOD(loc_);
case '|':
if (curr != '|' && curr != '=')
return h1::parser::make_BITWISE_OR(loc_);
return parser::make_BITWISE_OR(loc_);
reader_.advance();
if (last == '|')
return h1::parser::make_OR(loc_);
return parser::make_OR(loc_);
return h1::parser::make_ASSIGN_BW_OR(loc_);
return parser::make_ASSIGN_BW_OR(loc_);
case '&':
if (curr != '&' && curr != '=' && curr != '"' && curr != '\'')
return h1::parser::make_BITWISE_AND(loc_);
return parser::make_BITWISE_AND(loc_);
reader_.advance();
if (last == '&')
return h1::parser::make_AND(loc_);
return parser::make_AND(loc_);
if (last == '=')
return h1::parser::make_ASSIGN_BW_AND(loc_);
return parser::make_ASSIGN_BW_AND(loc_);
state_ = state::localize;
goto lex_string;
case '^':
if (curr != '=')
return h1::parser::make_BITWISE_EXOR(loc_);
return parser::make_BITWISE_EXOR(loc_);
reader_.advance();
return h1::parser::make_ASSIGN_BW_EXOR(loc_);
return parser::make_ASSIGN_BW_EXOR(loc_);
case '!':
if (curr != '=')
return h1::parser::make_NOT(loc_);
return parser::make_NOT(loc_);
reader_.advance();
return h1::parser::make_INEQUALITY(loc_);
return parser::make_INEQUALITY(loc_);
case '~':
return h1::parser::make_COMPLEMENT(loc_);
return parser::make_COMPLEMENT(loc_);
case '<':
if (curr != '<' && curr != '=')
return h1::parser::make_LESS(loc_);
return parser::make_LESS(loc_);
reader_.advance();
if (last == '=')
return h1::parser::make_LESS_EQUAL(loc_);
return parser::make_LESS_EQUAL(loc_);
if (curr != '=')
return h1::parser::make_LSHIFT(loc_);
return parser::make_LSHIFT(loc_);
reader_.advance();
return h1::parser::make_ASSIGN_LSHIFT(loc_);
return parser::make_ASSIGN_LSHIFT(loc_);
case '>':
if (curr != '>' && curr != '=')
return h1::parser::make_GREATER(loc_);
return parser::make_GREATER(loc_);
reader_.advance();
if (last == '=')
return h1::parser::make_GREATER_EQUAL(loc_);
return parser::make_GREATER_EQUAL(loc_);
if (curr != '=')
return h1::parser::make_RSHIFT(loc_);
return parser::make_RSHIFT(loc_);
reader_.advance();
return h1::parser::make_ASSIGN_RSHIFT(loc_);
return parser::make_ASSIGN_RSHIFT(loc_);
default:
lex_name_or_number:
if (last >= '0' && last <= '9')
@ -496,9 +445,9 @@ lex_string:
}
if (state_ == state::localize)
return h1::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return h1::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
lex_name:
buffer_.push(last);
@ -533,44 +482,55 @@ lex_name:
if (std::string_view(buffer_.data, buffer_.length) == "size")
{
return h1::parser::make_SIZE(loc_);
return parser::make_SIZE(loc_);
}
return h1::parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
}
else if (state_ == state::preprocessor)
{
if (path)
throw comp_error(loc_, "invalid preprocessor directive");
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
auto token = parser::token::H1UNDEF;
if (key != keyword::KW_INVALID)
return keyword_token(key);
if (buffer_.length < 16)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
// TODO: call preprocessor(key);
if(itr != keyword_map.end())
{
if (itr->second > parser::token::HSENDIF)
return parser::symbol_type(itr->second, loc_);
token = itr->second;
}
}
// TODO: call preprocessor(token);
throw comp_error(loc_, "unknown preprocessor directive");
state_ = state::start;
continue;
}
else
{
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
if (buffer_.length < 17)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
if (key != keyword::KW_INVALID)
return keyword_token(key);
if(itr != keyword_map.end())
return parser::symbol_type(itr->second, loc_);
}
if (path)
{
if (buffer_.data[buffer_.length - 1] == '/')
throw comp_error(loc_, "invalid path end '\\'");
//return h1::parser::make_PATH(xsk::gsc::h1::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return h1::parser::make_PATH(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_PATH(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
//return h1::parser::make_IDENTIFIER(xsk::gsc::h1::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return h1::parser::make_IDENTIFIER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_IDENTIFIER(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
lex_number:
@ -621,9 +581,9 @@ lex_number:
throw comp_error(loc_, "invalid number literal");
if (state_ == state::field || dot || flt)
return h1::parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return h1::parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
}
else if (curr == 'o')
{
@ -655,7 +615,7 @@ lex_number:
if (last == '\'' || buffer_.length <= 0)
throw comp_error(loc_, "invalid octal literal");
return h1::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
}
else if (curr == 'b')
{
@ -689,7 +649,7 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid binary literal");
return h1::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
}
else if (curr == 'x')
{
@ -723,176 +683,60 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid hexadecimal literal");
return h1::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
}
// cant get here!
}
}
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_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;
}
return keyword::KW_INVALID;
}
std::unordered_map<std::string_view, keyword> lexer::keywords
const std::unordered_map<std::string_view, parser::token::token_kind_type> lexer::keyword_map
{{
/* { "#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 },
{ "game", keyword::KW_game },
{ "self", keyword::KW_self },
{ "anim", keyword::KW_anim },
{ "level", keyword::KW_level },
{ "#define", parser::token::HSDEFINE },
{ "#undef", parser::token::HSUNDEF },
{ "#ifdef", parser::token::HSIFDEF },
{ "#ifndef", parser::token::HSIFNDEF },
{ "#if", parser::token::HSIF },
{ "#elif", parser::token::HSELIF },
{ "#else", parser::token::HSELSE },
{ "#endif", parser::token::HSENDIF },
{ "#inline", parser::token::INLINE },
{ "#include", parser::token::INCLUDE },
{ "#using_animtree", parser::token::USINGTREE },
{ "#animtree", parser::token::ANIMTREE },
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
{ "waitframe", parser::token::WAITFRAME },
{ "if", parser::token::IF },
{ "else", parser::token::ELSE },
{ "do", parser::token::DO },
{ "while", parser::token::WHILE },
{ "for", parser::token::FOR },
{ "foreach", parser::token::FOREACH },
{ "in", parser::token::IN },
{ "switch", parser::token::SWITCH },
{ "case", parser::token::CASE },
{ "default", parser::token::DEFAULT },
{ "break", parser::token::BREAK },
{ "continue", parser::token::CONTINUE },
{ "return", parser::token::RETURN },
{ "breakpoint", parser::token::BREAKPOINT },
{ "prof_begin", parser::token::PROFBEGIN },
{ "prof_end", parser::token::PROFEND },
{ "thread", parser::token::THREAD },
{ "childthread", parser::token::CHILDTHREAD },
{ "thisthread", parser::token::THISTHREAD },
{ "call", parser::token::CALL },
{ "true", parser::token::TRUE },
{ "false", parser::token::FALSE },
{ "undefined", parser::token::UNDEFINED },
{ "game", parser::token::GAME },
{ "self", parser::token::SELF },
{ "anim", parser::token::ANIM },
{ "level", parser::token::LEVEL },
}};
} // namespace xsk::gsc::h1

View File

@ -10,8 +10,6 @@
namespace xsk::gsc::h1
{
enum class keyword;
constexpr size_t max_buf_size = 0x2000;
struct buffer
@ -53,26 +51,22 @@ class lexer
reader reader_;
buffer buffer_;
location loc_;
build mode_;
std::stack<location> locs_;
std::stack<reader> readers_;
std::uint32_t header_top_;
state state_;
build mode_;
bool indev_;
public:
lexer(const std::string& name, const char* data, size_t size);
auto lex() -> xsk::gsc::h1::parser::symbol_type;
auto lex() -> parser::symbol_type;
void push_header(const std::string& file);
void pop_header();
void restrict_header(const xsk::gsc::location& loc);
void ban_header(const location& loc);
private:
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<std::string_view, keyword> keywords;
static const std::unordered_map<std::string_view, parser::token::token_kind_type> keyword_map;
};
} // namespace xsk::gsc::h1

File diff suppressed because it is too large Load Diff

View File

@ -679,109 +679,117 @@ namespace xsk { namespace gsc { namespace h1 {
H1EOF = 0, // "end of file"
H1error = 1, // error
H1UNDEF = 2, // "invalid token"
DEVBEGIN = 3, // "/#"
DEVEND = 4, // "#/"
INLINE = 5, // "#inline"
INCLUDE = 6, // "#include"
USINGTREE = 7, // "#using_animtree"
ANIMTREE = 8, // "#animtree"
ENDON = 9, // "endon"
NOTIFY = 10, // "notify"
WAIT = 11, // "wait"
WAITTILL = 12, // "waittill"
WAITTILLMATCH = 13, // "waittillmatch"
WAITTILLFRAMEEND = 14, // "waittillframeend"
WAITFRAME = 15, // "waitframe"
IF = 16, // "if"
ELSE = 17, // "else"
DO = 18, // "do"
WHILE = 19, // "while"
FOR = 20, // "for"
FOREACH = 21, // "foreach"
IN = 22, // "in"
SWITCH = 23, // "switch"
CASE = 24, // "case"
DEFAULT = 25, // "default"
BREAK = 26, // "break"
CONTINUE = 27, // "continue"
RETURN = 28, // "return"
BREAKPOINT = 29, // "breakpoint"
PROFBEGIN = 30, // "prof_begin"
PROFEND = 31, // "prof_end"
THREAD = 32, // "thread"
CHILDTHREAD = 33, // "childthread"
THISTHREAD = 34, // "thisthread"
CALL = 35, // "call"
TRUE = 36, // "true"
FALSE = 37, // "false"
UNDEFINED = 38, // "undefined"
SIZE = 39, // ".size"
GAME = 40, // "game"
SELF = 41, // "self"
ANIM = 42, // "anim"
LEVEL = 43, // "level"
LPAREN = 44, // "("
RPAREN = 45, // ")"
LBRACE = 46, // "{"
RBRACE = 47, // "}"
LBRACKET = 48, // "["
RBRACKET = 49, // "]"
COMMA = 50, // ","
DOT = 51, // "."
DOUBLECOLON = 52, // "::"
COLON = 53, // ":"
SEMICOLON = 54, // ";"
QMARK = 55, // "?"
INCREMENT = 56, // "++"
DECREMENT = 57, // "--"
LSHIFT = 58, // "<<"
RSHIFT = 59, // ">>"
OR = 60, // "||"
AND = 61, // "&&"
EQUALITY = 62, // "=="
INEQUALITY = 63, // "!="
LESS_EQUAL = 64, // "<="
GREATER_EQUAL = 65, // ">="
LESS = 66, // "<"
GREATER = 67, // ">"
NOT = 68, // "!"
COMPLEMENT = 69, // "~"
ASSIGN = 70, // "="
ASSIGN_ADD = 71, // "+="
ASSIGN_SUB = 72, // "-="
ASSIGN_MUL = 73, // "*="
ASSIGN_DIV = 74, // "/="
ASSIGN_MOD = 75, // "%="
ASSIGN_BW_OR = 76, // "|="
ASSIGN_BW_AND = 77, // "&="
ASSIGN_BW_EXOR = 78, // "^="
ASSIGN_RSHIFT = 79, // ">>="
ASSIGN_LSHIFT = 80, // "<<="
BITWISE_OR = 81, // "|"
BITWISE_AND = 82, // "&"
BITWISE_EXOR = 83, // "^"
ADD = 84, // "+"
SUB = 85, // "-"
MUL = 86, // "*"
DIV = 87, // "/"
MOD = 88, // "%"
FIELD = 89, // "field"
PATH = 90, // "path"
IDENTIFIER = 91, // "identifier"
STRING = 92, // "string literal"
ISTRING = 93, // "localized string"
COLOR = 94, // "color"
FLOAT = 95, // "float"
INTEGER = 96, // "integer"
ADD_ARRAY = 97, // ADD_ARRAY
THEN = 98, // THEN
TERN = 99, // TERN
NEG = 100, // NEG
ANIMREF = 101, // ANIMREF
PREINC = 102, // PREINC
PREDEC = 103, // PREDEC
POSTINC = 104, // POSTINC
POSTDEC = 105 // POSTDEC
HSDEFINE = 3, // "#define"
HSUNDEF = 4, // "#undef"
HSIFDEF = 5, // "#ifdef"
HSIFNDEF = 6, // "#ifndef"
HSIF = 7, // "#if"
HSELIF = 8, // "#elif"
HSELSE = 9, // "#else"
HSENDIF = 10, // "#endif"
DEVBEGIN = 11, // "/#"
DEVEND = 12, // "#/"
INLINE = 13, // "#inline"
INCLUDE = 14, // "#include"
USINGTREE = 15, // "#using_animtree"
ANIMTREE = 16, // "#animtree"
ENDON = 17, // "endon"
NOTIFY = 18, // "notify"
WAIT = 19, // "wait"
WAITTILL = 20, // "waittill"
WAITTILLMATCH = 21, // "waittillmatch"
WAITTILLFRAMEEND = 22, // "waittillframeend"
WAITFRAME = 23, // "waitframe"
IF = 24, // "if"
ELSE = 25, // "else"
DO = 26, // "do"
WHILE = 27, // "while"
FOR = 28, // "for"
FOREACH = 29, // "foreach"
IN = 30, // "in"
SWITCH = 31, // "switch"
CASE = 32, // "case"
DEFAULT = 33, // "default"
BREAK = 34, // "break"
CONTINUE = 35, // "continue"
RETURN = 36, // "return"
BREAKPOINT = 37, // "breakpoint"
PROFBEGIN = 38, // "prof_begin"
PROFEND = 39, // "prof_end"
THREAD = 40, // "thread"
CHILDTHREAD = 41, // "childthread"
THISTHREAD = 42, // "thisthread"
CALL = 43, // "call"
TRUE = 44, // "true"
FALSE = 45, // "false"
UNDEFINED = 46, // "undefined"
SIZE = 47, // ".size"
GAME = 48, // "game"
SELF = 49, // "self"
ANIM = 50, // "anim"
LEVEL = 51, // "level"
LPAREN = 52, // "("
RPAREN = 53, // ")"
LBRACE = 54, // "{"
RBRACE = 55, // "}"
LBRACKET = 56, // "["
RBRACKET = 57, // "]"
COMMA = 58, // ","
DOT = 59, // "."
DOUBLECOLON = 60, // "::"
COLON = 61, // ":"
SEMICOLON = 62, // ";"
QMARK = 63, // "?"
INCREMENT = 64, // "++"
DECREMENT = 65, // "--"
LSHIFT = 66, // "<<"
RSHIFT = 67, // ">>"
OR = 68, // "||"
AND = 69, // "&&"
EQUALITY = 70, // "=="
INEQUALITY = 71, // "!="
LESS_EQUAL = 72, // "<="
GREATER_EQUAL = 73, // ">="
LESS = 74, // "<"
GREATER = 75, // ">"
NOT = 76, // "!"
COMPLEMENT = 77, // "~"
ASSIGN = 78, // "="
ASSIGN_ADD = 79, // "+="
ASSIGN_SUB = 80, // "-="
ASSIGN_MUL = 81, // "*="
ASSIGN_DIV = 82, // "/="
ASSIGN_MOD = 83, // "%="
ASSIGN_BW_OR = 84, // "|="
ASSIGN_BW_AND = 85, // "&="
ASSIGN_BW_EXOR = 86, // "^="
ASSIGN_RSHIFT = 87, // ">>="
ASSIGN_LSHIFT = 88, // "<<="
BITWISE_OR = 89, // "|"
BITWISE_AND = 90, // "&"
BITWISE_EXOR = 91, // "^"
ADD = 92, // "+"
SUB = 93, // "-"
MUL = 94, // "*"
DIV = 95, // "/"
MOD = 96, // "%"
FIELD = 97, // "field"
PATH = 98, // "path"
IDENTIFIER = 99, // "identifier"
STRING = 100, // "string literal"
ISTRING = 101, // "localized string"
COLOR = 102, // "color"
FLOAT = 103, // "float"
INTEGER = 104, // "integer"
ADD_ARRAY = 105, // ADD_ARRAY
THEN = 106, // THEN
TERN = 107, // TERN
NEG = 108, // NEG
ANIMREF = 109, // ANIMREF
PREINC = 110, // PREINC
PREDEC = 111, // PREDEC
POSTINC = 112, // POSTINC
POSTDEC = 113 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -798,195 +806,203 @@ namespace xsk { namespace gsc { namespace h1 {
{
enum symbol_kind_type
{
YYNTOKENS = 106, ///< Number of tokens.
YYNTOKENS = 114, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_DEVBEGIN = 3, // "/#"
S_DEVEND = 4, // "#/"
S_INLINE = 5, // "#inline"
S_INCLUDE = 6, // "#include"
S_USINGTREE = 7, // "#using_animtree"
S_ANIMTREE = 8, // "#animtree"
S_ENDON = 9, // "endon"
S_NOTIFY = 10, // "notify"
S_WAIT = 11, // "wait"
S_WAITTILL = 12, // "waittill"
S_WAITTILLMATCH = 13, // "waittillmatch"
S_WAITTILLFRAMEEND = 14, // "waittillframeend"
S_WAITFRAME = 15, // "waitframe"
S_IF = 16, // "if"
S_ELSE = 17, // "else"
S_DO = 18, // "do"
S_WHILE = 19, // "while"
S_FOR = 20, // "for"
S_FOREACH = 21, // "foreach"
S_IN = 22, // "in"
S_SWITCH = 23, // "switch"
S_CASE = 24, // "case"
S_DEFAULT = 25, // "default"
S_BREAK = 26, // "break"
S_CONTINUE = 27, // "continue"
S_RETURN = 28, // "return"
S_BREAKPOINT = 29, // "breakpoint"
S_PROFBEGIN = 30, // "prof_begin"
S_PROFEND = 31, // "prof_end"
S_THREAD = 32, // "thread"
S_CHILDTHREAD = 33, // "childthread"
S_THISTHREAD = 34, // "thisthread"
S_CALL = 35, // "call"
S_TRUE = 36, // "true"
S_FALSE = 37, // "false"
S_UNDEFINED = 38, // "undefined"
S_SIZE = 39, // ".size"
S_GAME = 40, // "game"
S_SELF = 41, // "self"
S_ANIM = 42, // "anim"
S_LEVEL = 43, // "level"
S_LPAREN = 44, // "("
S_RPAREN = 45, // ")"
S_LBRACE = 46, // "{"
S_RBRACE = 47, // "}"
S_LBRACKET = 48, // "["
S_RBRACKET = 49, // "]"
S_COMMA = 50, // ","
S_DOT = 51, // "."
S_DOUBLECOLON = 52, // "::"
S_COLON = 53, // ":"
S_SEMICOLON = 54, // ";"
S_QMARK = 55, // "?"
S_INCREMENT = 56, // "++"
S_DECREMENT = 57, // "--"
S_LSHIFT = 58, // "<<"
S_RSHIFT = 59, // ">>"
S_OR = 60, // "||"
S_AND = 61, // "&&"
S_EQUALITY = 62, // "=="
S_INEQUALITY = 63, // "!="
S_LESS_EQUAL = 64, // "<="
S_GREATER_EQUAL = 65, // ">="
S_LESS = 66, // "<"
S_GREATER = 67, // ">"
S_NOT = 68, // "!"
S_COMPLEMENT = 69, // "~"
S_ASSIGN = 70, // "="
S_ASSIGN_ADD = 71, // "+="
S_ASSIGN_SUB = 72, // "-="
S_ASSIGN_MUL = 73, // "*="
S_ASSIGN_DIV = 74, // "/="
S_ASSIGN_MOD = 75, // "%="
S_ASSIGN_BW_OR = 76, // "|="
S_ASSIGN_BW_AND = 77, // "&="
S_ASSIGN_BW_EXOR = 78, // "^="
S_ASSIGN_RSHIFT = 79, // ">>="
S_ASSIGN_LSHIFT = 80, // "<<="
S_BITWISE_OR = 81, // "|"
S_BITWISE_AND = 82, // "&"
S_BITWISE_EXOR = 83, // "^"
S_ADD = 84, // "+"
S_SUB = 85, // "-"
S_MUL = 86, // "*"
S_DIV = 87, // "/"
S_MOD = 88, // "%"
S_FIELD = 89, // "field"
S_PATH = 90, // "path"
S_IDENTIFIER = 91, // "identifier"
S_STRING = 92, // "string literal"
S_ISTRING = 93, // "localized string"
S_COLOR = 94, // "color"
S_FLOAT = 95, // "float"
S_INTEGER = 96, // "integer"
S_ADD_ARRAY = 97, // ADD_ARRAY
S_THEN = 98, // THEN
S_TERN = 99, // TERN
S_NEG = 100, // NEG
S_ANIMREF = 101, // ANIMREF
S_PREINC = 102, // PREINC
S_PREDEC = 103, // PREDEC
S_POSTINC = 104, // POSTINC
S_POSTDEC = 105, // POSTDEC
S_YYACCEPT = 106, // $accept
S_root = 107, // root
S_program = 108, // program
S_inline = 109, // inline
S_include = 110, // include
S_declaration = 111, // declaration
S_decl_usingtree = 112, // decl_usingtree
S_decl_constant = 113, // decl_constant
S_decl_thread = 114, // decl_thread
S_stmt = 115, // stmt
S_stmt_dev = 116, // stmt_dev
S_stmt_block = 117, // stmt_block
S_stmt_list = 118, // stmt_list
S_stmt_expr = 119, // stmt_expr
S_stmt_call = 120, // stmt_call
S_stmt_assign = 121, // stmt_assign
S_stmt_endon = 122, // stmt_endon
S_stmt_notify = 123, // stmt_notify
S_stmt_wait = 124, // stmt_wait
S_stmt_waittill = 125, // stmt_waittill
S_stmt_waittillmatch = 126, // stmt_waittillmatch
S_stmt_waittillframeend = 127, // stmt_waittillframeend
S_stmt_waitframe = 128, // stmt_waitframe
S_stmt_if = 129, // stmt_if
S_stmt_ifelse = 130, // stmt_ifelse
S_stmt_while = 131, // stmt_while
S_stmt_dowhile = 132, // stmt_dowhile
S_stmt_for = 133, // stmt_for
S_stmt_foreach = 134, // stmt_foreach
S_stmt_switch = 135, // stmt_switch
S_stmt_case = 136, // stmt_case
S_stmt_default = 137, // stmt_default
S_stmt_break = 138, // stmt_break
S_stmt_continue = 139, // stmt_continue
S_stmt_return = 140, // stmt_return
S_stmt_breakpoint = 141, // stmt_breakpoint
S_stmt_prof_begin = 142, // stmt_prof_begin
S_stmt_prof_end = 143, // stmt_prof_end
S_expr = 144, // expr
S_expr_or_empty = 145, // expr_or_empty
S_expr_assign = 146, // expr_assign
S_expr_increment = 147, // expr_increment
S_expr_decrement = 148, // expr_decrement
S_expr_ternary = 149, // expr_ternary
S_expr_binary = 150, // expr_binary
S_expr_primitive = 151, // expr_primitive
S_expr_complement = 152, // expr_complement
S_expr_not = 153, // expr_not
S_expr_call = 154, // expr_call
S_expr_method = 155, // expr_method
S_expr_function = 156, // expr_function
S_expr_pointer = 157, // expr_pointer
S_expr_add_array = 158, // expr_add_array
S_expr_parameters = 159, // expr_parameters
S_expr_arguments = 160, // expr_arguments
S_expr_arguments_no_empty = 161, // expr_arguments_no_empty
S_expr_reference = 162, // expr_reference
S_expr_array = 163, // expr_array
S_expr_field = 164, // expr_field
S_expr_size = 165, // expr_size
S_expr_paren = 166, // expr_paren
S_expr_object = 167, // expr_object
S_expr_thisthread = 168, // expr_thisthread
S_expr_empty_array = 169, // expr_empty_array
S_expr_undefined = 170, // expr_undefined
S_expr_game = 171, // expr_game
S_expr_self = 172, // expr_self
S_expr_anim = 173, // expr_anim
S_expr_level = 174, // expr_level
S_expr_animation = 175, // expr_animation
S_expr_animtree = 176, // expr_animtree
S_expr_identifier = 177, // expr_identifier
S_expr_path = 178, // expr_path
S_expr_istring = 179, // expr_istring
S_expr_string = 180, // expr_string
S_expr_color = 181, // expr_color
S_expr_vector = 182, // expr_vector
S_expr_float = 183, // expr_float
S_expr_integer = 184, // expr_integer
S_expr_false = 185, // expr_false
S_expr_true = 186 // expr_true
S_HSDEFINE = 3, // "#define"
S_HSUNDEF = 4, // "#undef"
S_HSIFDEF = 5, // "#ifdef"
S_HSIFNDEF = 6, // "#ifndef"
S_HSIF = 7, // "#if"
S_HSELIF = 8, // "#elif"
S_HSELSE = 9, // "#else"
S_HSENDIF = 10, // "#endif"
S_DEVBEGIN = 11, // "/#"
S_DEVEND = 12, // "#/"
S_INLINE = 13, // "#inline"
S_INCLUDE = 14, // "#include"
S_USINGTREE = 15, // "#using_animtree"
S_ANIMTREE = 16, // "#animtree"
S_ENDON = 17, // "endon"
S_NOTIFY = 18, // "notify"
S_WAIT = 19, // "wait"
S_WAITTILL = 20, // "waittill"
S_WAITTILLMATCH = 21, // "waittillmatch"
S_WAITTILLFRAMEEND = 22, // "waittillframeend"
S_WAITFRAME = 23, // "waitframe"
S_IF = 24, // "if"
S_ELSE = 25, // "else"
S_DO = 26, // "do"
S_WHILE = 27, // "while"
S_FOR = 28, // "for"
S_FOREACH = 29, // "foreach"
S_IN = 30, // "in"
S_SWITCH = 31, // "switch"
S_CASE = 32, // "case"
S_DEFAULT = 33, // "default"
S_BREAK = 34, // "break"
S_CONTINUE = 35, // "continue"
S_RETURN = 36, // "return"
S_BREAKPOINT = 37, // "breakpoint"
S_PROFBEGIN = 38, // "prof_begin"
S_PROFEND = 39, // "prof_end"
S_THREAD = 40, // "thread"
S_CHILDTHREAD = 41, // "childthread"
S_THISTHREAD = 42, // "thisthread"
S_CALL = 43, // "call"
S_TRUE = 44, // "true"
S_FALSE = 45, // "false"
S_UNDEFINED = 46, // "undefined"
S_SIZE = 47, // ".size"
S_GAME = 48, // "game"
S_SELF = 49, // "self"
S_ANIM = 50, // "anim"
S_LEVEL = 51, // "level"
S_LPAREN = 52, // "("
S_RPAREN = 53, // ")"
S_LBRACE = 54, // "{"
S_RBRACE = 55, // "}"
S_LBRACKET = 56, // "["
S_RBRACKET = 57, // "]"
S_COMMA = 58, // ","
S_DOT = 59, // "."
S_DOUBLECOLON = 60, // "::"
S_COLON = 61, // ":"
S_SEMICOLON = 62, // ";"
S_QMARK = 63, // "?"
S_INCREMENT = 64, // "++"
S_DECREMENT = 65, // "--"
S_LSHIFT = 66, // "<<"
S_RSHIFT = 67, // ">>"
S_OR = 68, // "||"
S_AND = 69, // "&&"
S_EQUALITY = 70, // "=="
S_INEQUALITY = 71, // "!="
S_LESS_EQUAL = 72, // "<="
S_GREATER_EQUAL = 73, // ">="
S_LESS = 74, // "<"
S_GREATER = 75, // ">"
S_NOT = 76, // "!"
S_COMPLEMENT = 77, // "~"
S_ASSIGN = 78, // "="
S_ASSIGN_ADD = 79, // "+="
S_ASSIGN_SUB = 80, // "-="
S_ASSIGN_MUL = 81, // "*="
S_ASSIGN_DIV = 82, // "/="
S_ASSIGN_MOD = 83, // "%="
S_ASSIGN_BW_OR = 84, // "|="
S_ASSIGN_BW_AND = 85, // "&="
S_ASSIGN_BW_EXOR = 86, // "^="
S_ASSIGN_RSHIFT = 87, // ">>="
S_ASSIGN_LSHIFT = 88, // "<<="
S_BITWISE_OR = 89, // "|"
S_BITWISE_AND = 90, // "&"
S_BITWISE_EXOR = 91, // "^"
S_ADD = 92, // "+"
S_SUB = 93, // "-"
S_MUL = 94, // "*"
S_DIV = 95, // "/"
S_MOD = 96, // "%"
S_FIELD = 97, // "field"
S_PATH = 98, // "path"
S_IDENTIFIER = 99, // "identifier"
S_STRING = 100, // "string literal"
S_ISTRING = 101, // "localized string"
S_COLOR = 102, // "color"
S_FLOAT = 103, // "float"
S_INTEGER = 104, // "integer"
S_ADD_ARRAY = 105, // ADD_ARRAY
S_THEN = 106, // THEN
S_TERN = 107, // TERN
S_NEG = 108, // NEG
S_ANIMREF = 109, // ANIMREF
S_PREINC = 110, // PREINC
S_PREDEC = 111, // PREDEC
S_POSTINC = 112, // POSTINC
S_POSTDEC = 113, // POSTDEC
S_YYACCEPT = 114, // $accept
S_root = 115, // root
S_program = 116, // program
S_inline = 117, // inline
S_include = 118, // include
S_declaration = 119, // declaration
S_decl_usingtree = 120, // decl_usingtree
S_decl_constant = 121, // decl_constant
S_decl_thread = 122, // decl_thread
S_stmt = 123, // stmt
S_stmt_dev = 124, // stmt_dev
S_stmt_block = 125, // stmt_block
S_stmt_list = 126, // stmt_list
S_stmt_expr = 127, // stmt_expr
S_stmt_call = 128, // stmt_call
S_stmt_assign = 129, // stmt_assign
S_stmt_endon = 130, // stmt_endon
S_stmt_notify = 131, // stmt_notify
S_stmt_wait = 132, // stmt_wait
S_stmt_waittill = 133, // stmt_waittill
S_stmt_waittillmatch = 134, // stmt_waittillmatch
S_stmt_waittillframeend = 135, // stmt_waittillframeend
S_stmt_waitframe = 136, // stmt_waitframe
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
};
};
@ -2781,6 +2797,126 @@ switch (yykind)
return symbol_type (token::H1UNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSDEFINE (location_type l)
{
return symbol_type (token::HSDEFINE, std::move (l));
}
#else
static
symbol_type
make_HSDEFINE (const location_type& l)
{
return symbol_type (token::HSDEFINE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSUNDEF (location_type l)
{
return symbol_type (token::HSUNDEF, std::move (l));
}
#else
static
symbol_type
make_HSUNDEF (const location_type& l)
{
return symbol_type (token::HSUNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFDEF (location_type l)
{
return symbol_type (token::HSIFDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFDEF (const location_type& l)
{
return symbol_type (token::HSIFDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFNDEF (location_type l)
{
return symbol_type (token::HSIFNDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFNDEF (const location_type& l)
{
return symbol_type (token::HSIFNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIF (location_type l)
{
return symbol_type (token::HSIF, std::move (l));
}
#else
static
symbol_type
make_HSIF (const location_type& l)
{
return symbol_type (token::HSIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELIF (location_type l)
{
return symbol_type (token::HSELIF, std::move (l));
}
#else
static
symbol_type
make_HSELIF (const location_type& l)
{
return symbol_type (token::HSELIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELSE (location_type l)
{
return symbol_type (token::HSELSE, std::move (l));
}
#else
static
symbol_type
make_HSELSE (const location_type& l)
{
return symbol_type (token::HSELSE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSENDIF (location_type l)
{
return symbol_type (token::HSENDIF, std::move (l));
}
#else
static
symbol_type
make_HSENDIF (const location_type& l)
{
return symbol_type (token::HSENDIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -5364,7 +5500,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::h1
#line 5368 "parser.hpp"
#line 5504 "parser.hpp"

View File

@ -16,58 +16,6 @@ xsk::gsc::h2::parser::symbol_type H2lex(xsk::gsc::h2::lexer& lexer)
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() : length(0)
{
data = static_cast<char*>(std::malloc(max_buf_size));
@ -130,7 +78,7 @@ void reader::advance()
}
}
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(xsk::gsc::location(&name)),
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(location(&name)),
mode_(build::dev), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
{
reader_.init(data, size);
@ -141,7 +89,7 @@ void lexer::push_header(const std::string& file)
try
{
if (header_top_++ >= 10)
throw xsk::gsc::error("maximum gsh depth exceeded '10'");
throw comp_error(loc_, "maximum gsh depth exceeded '10'");
auto data = resolver::file_data(file + ".gsh");
@ -152,7 +100,7 @@ void lexer::push_header(const std::string& file)
}
catch (const std::exception& e)
{
throw xsk::gsc::error("parsing header file '" + file + "': " + e.what());
throw error("parsing header file '" + file + "': " + e.what());
}
}
@ -165,7 +113,7 @@ void lexer::pop_header()
readers_.pop();
}
void lexer::restrict_header(const xsk::gsc::location& loc)
void lexer::ban_header(const location& loc)
{
if (header_top_ > 0)
{
@ -173,7 +121,7 @@ void lexer::restrict_header(const xsk::gsc::location& loc)
}
}
auto lexer::lex() -> xsk::gsc::h2::parser::symbol_type
auto lexer::lex() -> parser::symbol_type
{
buffer_.length = 0;
state_ = state::start;
@ -194,7 +142,7 @@ auto lexer::lex() -> xsk::gsc::h2::parser::symbol_type
if (header_top_ > 0)
pop_header();
else
return h2::parser::make_H2EOF(loc_);
return parser::make_H2EOF(loc_);
}
reader_.advance();
@ -212,22 +160,22 @@ auto lexer::lex() -> xsk::gsc::h2::parser::symbol_type
continue;
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
return h2::parser::make_DIV(loc_);
return parser::make_DIV(loc_);
reader_.advance();
if (last == '=')
return h2::parser::make_ASSIGN_DIV(loc_);
return parser::make_ASSIGN_DIV(loc_);
if (last == '#')
{
if (indev_)
throw comp_error(loc_, "cannot recurse devblock ('/#')");
if (mode_ == xsk::gsc::build::dev)
if (mode_ == build::dev)
{
indev_ = true;
return h2::parser::make_DEVBEGIN(loc_);
return parser::make_DEVBEGIN(loc_);
}
else
{
@ -291,7 +239,7 @@ auto lexer::lex() -> xsk::gsc::h2::parser::symbol_type
indev_ = false;
reader_.advance();
return h2::parser::make_DEVEND(loc_);
return parser::make_DEVEND(loc_);
}
buffer_.push(last);
@ -304,12 +252,12 @@ auto lexer::lex() -> xsk::gsc::h2::parser::symbol_type
goto lex_name;
case '*':
if (curr != '/' && curr != '=')
return h2::parser::make_MUL(loc_);
return parser::make_MUL(loc_);
reader_.advance();
if (last == '=')
return h2::parser::make_ASSIGN_MUL(loc_);
return parser::make_ASSIGN_MUL(loc_);
throw comp_error(loc_, "unmatched multiline comment end ('*/')");
case '"':
@ -324,127 +272,127 @@ auto lexer::lex() -> xsk::gsc::h2::parser::symbol_type
state_ = state::field;
goto lex_name_or_number;
case '(':
return h2::parser::make_LPAREN(loc_);
return parser::make_LPAREN(loc_);
case ')':
return h2::parser::make_RPAREN(loc_);
return parser::make_RPAREN(loc_);
case '{':
return h2::parser::make_LBRACE(loc_);
return parser::make_LBRACE(loc_);
case '}':
return h2::parser::make_RBRACE(loc_);
return parser::make_RBRACE(loc_);
case '[':
return h2::parser::make_LBRACKET(loc_);
return parser::make_LBRACKET(loc_);
case ']':
return h2::parser::make_RBRACKET(loc_);
return parser::make_RBRACKET(loc_);
case ',':
return h2::parser::make_COMMA(loc_);
return parser::make_COMMA(loc_);
case ';':
return h2::parser::make_SEMICOLON(loc_);
return parser::make_SEMICOLON(loc_);
case ':':
if (curr != ':')
return h2::parser::make_COLON(loc_);
return parser::make_COLON(loc_);
reader_.advance();
return h2::parser::make_DOUBLECOLON(loc_);
return parser::make_DOUBLECOLON(loc_);
case '?':
return h2::parser::make_QMARK(loc_);
return parser::make_QMARK(loc_);
case '=':
if (curr != '=')
return h2::parser::make_ASSIGN(loc_);
return parser::make_ASSIGN(loc_);
reader_.advance();
return h2::parser::make_EQUALITY(loc_);
return parser::make_EQUALITY(loc_);
case '+':
if (curr != '+' && curr != '=')
return h2::parser::make_ADD(loc_);
return parser::make_ADD(loc_);
reader_.advance();
if (last == '+')
return h2::parser::make_INCREMENT(loc_);
return parser::make_INCREMENT(loc_);
return h2::parser::make_ASSIGN_ADD(loc_);
return parser::make_ASSIGN_ADD(loc_);
case '-':
if (curr != '-' && curr != '=')
return h2::parser::make_SUB(loc_);
return parser::make_SUB(loc_);
reader_.advance();
if (last == '-')
return h2::parser::make_DECREMENT(loc_);
return parser::make_DECREMENT(loc_);
return h2::parser::make_ASSIGN_SUB(loc_);
return parser::make_ASSIGN_SUB(loc_);
case '%':
if (curr != '=')
return h2::parser::make_MOD(loc_);
return parser::make_MOD(loc_);
reader_.advance();
return h2::parser::make_ASSIGN_MOD(loc_);
return parser::make_ASSIGN_MOD(loc_);
case '|':
if (curr != '|' && curr != '=')
return h2::parser::make_BITWISE_OR(loc_);
return parser::make_BITWISE_OR(loc_);
reader_.advance();
if (last == '|')
return h2::parser::make_OR(loc_);
return parser::make_OR(loc_);
return h2::parser::make_ASSIGN_BW_OR(loc_);
return parser::make_ASSIGN_BW_OR(loc_);
case '&':
if (curr != '&' && curr != '=' && curr != '"' && curr != '\'')
return h2::parser::make_BITWISE_AND(loc_);
return parser::make_BITWISE_AND(loc_);
reader_.advance();
if (last == '&')
return h2::parser::make_AND(loc_);
return parser::make_AND(loc_);
if (last == '=')
return h2::parser::make_ASSIGN_BW_AND(loc_);
return parser::make_ASSIGN_BW_AND(loc_);
state_ = state::localize;
goto lex_string;
case '^':
if (curr != '=')
return h2::parser::make_BITWISE_EXOR(loc_);
return parser::make_BITWISE_EXOR(loc_);
reader_.advance();
return h2::parser::make_ASSIGN_BW_EXOR(loc_);
return parser::make_ASSIGN_BW_EXOR(loc_);
case '!':
if (curr != '=')
return h2::parser::make_NOT(loc_);
return parser::make_NOT(loc_);
reader_.advance();
return h2::parser::make_INEQUALITY(loc_);
return parser::make_INEQUALITY(loc_);
case '~':
return h2::parser::make_COMPLEMENT(loc_);
return parser::make_COMPLEMENT(loc_);
case '<':
if (curr != '<' && curr != '=')
return h2::parser::make_LESS(loc_);
return parser::make_LESS(loc_);
reader_.advance();
if (last == '=')
return h2::parser::make_LESS_EQUAL(loc_);
return parser::make_LESS_EQUAL(loc_);
if (curr != '=')
return h2::parser::make_LSHIFT(loc_);
return parser::make_LSHIFT(loc_);
reader_.advance();
return h2::parser::make_ASSIGN_LSHIFT(loc_);
return parser::make_ASSIGN_LSHIFT(loc_);
case '>':
if (curr != '>' && curr != '=')
return h2::parser::make_GREATER(loc_);
return parser::make_GREATER(loc_);
reader_.advance();
if (last == '=')
return h2::parser::make_GREATER_EQUAL(loc_);
return parser::make_GREATER_EQUAL(loc_);
if (curr != '=')
return h2::parser::make_RSHIFT(loc_);
return parser::make_RSHIFT(loc_);
reader_.advance();
return h2::parser::make_ASSIGN_RSHIFT(loc_);
return parser::make_ASSIGN_RSHIFT(loc_);
default:
lex_name_or_number:
if (last >= '0' && last <= '9')
@ -497,9 +445,9 @@ lex_string:
}
if (state_ == state::localize)
return h2::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return h2::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
lex_name:
buffer_.push(last);
@ -534,44 +482,55 @@ lex_name:
if (std::string_view(buffer_.data, buffer_.length) == "size")
{
return h2::parser::make_SIZE(loc_);
return parser::make_SIZE(loc_);
}
return h2::parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
}
else if (state_ == state::preprocessor)
{
if (path)
throw comp_error(loc_, "invalid preprocessor directive");
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
auto token = parser::token::H2UNDEF;
if (key != keyword::KW_INVALID)
return keyword_token(key);
if (buffer_.length < 16)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
// TODO: call preprocessor(key);
if(itr != keyword_map.end())
{
if (itr->second > parser::token::HSENDIF)
return parser::symbol_type(itr->second, loc_);
token = itr->second;
}
}
// TODO: call preprocessor(token);
throw comp_error(loc_, "unknown preprocessor directive");
state_ = state::start;
continue;
}
else
{
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
if (buffer_.length < 17)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
if (key != keyword::KW_INVALID)
return keyword_token(key);
if(itr != keyword_map.end())
return parser::symbol_type(itr->second, loc_);
}
if (path)
{
if (buffer_.data[buffer_.length - 1] == '/')
throw comp_error(loc_, "invalid path end '\\'");
//return h2::parser::make_PATH(xsk::gsc::h2::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return h2::parser::make_PATH(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_PATH(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
//return h2::parser::make_IDENTIFIER(xsk::gsc::h2::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return h2::parser::make_IDENTIFIER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_IDENTIFIER(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
lex_number:
@ -622,9 +581,9 @@ lex_number:
throw comp_error(loc_, "invalid number literal");
if (state_ == state::field || dot || flt)
return h2::parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return h2::parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
}
else if (curr == 'o')
{
@ -656,7 +615,7 @@ lex_number:
if (last == '\'' || buffer_.length <= 0)
throw comp_error(loc_, "invalid octal literal");
return h2::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
}
else if (curr == 'b')
{
@ -690,7 +649,7 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid binary literal");
return h2::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
}
else if (curr == 'x')
{
@ -724,179 +683,60 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid hexadecimal literal");
return h2::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
}
// cant get here!
}
}
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;
}
return keyword::KW_INVALID;
}
std::unordered_map<std::string_view, keyword> lexer::keywords
const std::unordered_map<std::string_view, parser::token::token_kind_type> lexer::keyword_map
{{
/* { "#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 },
{ "#define", parser::token::HSDEFINE },
{ "#undef", parser::token::HSUNDEF },
{ "#ifdef", parser::token::HSIFDEF },
{ "#ifndef", parser::token::HSIFNDEF },
{ "#if", parser::token::HSIF },
{ "#elif", parser::token::HSELIF },
{ "#else", parser::token::HSELSE },
{ "#endif", parser::token::HSENDIF },
{ "#inline", parser::token::INLINE },
{ "#include", parser::token::INCLUDE },
{ "#using_animtree", parser::token::USINGTREE },
{ "#animtree", parser::token::ANIMTREE },
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
{ "waitframe", parser::token::WAITFRAME },
{ "if", parser::token::IF },
{ "else", parser::token::ELSE },
{ "do", parser::token::DO },
{ "while", parser::token::WHILE },
{ "for", parser::token::FOR },
{ "foreach", parser::token::FOREACH },
{ "in", parser::token::IN },
{ "switch", parser::token::SWITCH },
{ "case", parser::token::CASE },
{ "default", parser::token::DEFAULT },
{ "break", parser::token::BREAK },
{ "continue", parser::token::CONTINUE },
{ "return", parser::token::RETURN },
{ "breakpoint", parser::token::BREAKPOINT },
{ "prof_begin", parser::token::PROFBEGIN },
{ "prof_end", parser::token::PROFEND },
{ "thread", parser::token::THREAD },
{ "childthread", parser::token::CHILDTHREAD },
{ "thisthread", parser::token::THISTHREAD },
{ "call", parser::token::CALL },
{ "true", parser::token::TRUE },
{ "false", parser::token::FALSE },
{ "undefined", parser::token::UNDEFINED },
{ "game", parser::token::GAME },
{ "self", parser::token::SELF },
{ "anim", parser::token::ANIM },
{ "level", parser::token::LEVEL },
}};
} // namespace xsk::gsc::h2

View File

@ -8,8 +8,6 @@
namespace xsk::gsc::h2
{
enum class keyword;
constexpr size_t max_buf_size = 0x2000;
struct buffer
@ -51,26 +49,22 @@ class lexer
reader reader_;
buffer buffer_;
location loc_;
build mode_;
std::stack<location> locs_;
std::stack<reader> readers_;
std::uint32_t header_top_;
state state_;
build mode_;
bool indev_;
public:
lexer(const std::string& name, const char* data, size_t size);
auto lex() -> xsk::gsc::h2::parser::symbol_type;
auto lex() -> parser::symbol_type;
void push_header(const std::string& file);
void pop_header();
void restrict_header(const xsk::gsc::location& loc);
void ban_header(const location& loc);
private:
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<std::string_view, keyword> keywords;
static const std::unordered_map<std::string_view, parser::token::token_kind_type> keyword_map;
};
} // namespace xsk::gsc::h2

File diff suppressed because it is too large Load Diff

View File

@ -677,109 +677,117 @@ namespace xsk { namespace gsc { namespace h2 {
H2EOF = 0, // "end of file"
H2error = 1, // error
H2UNDEF = 2, // "invalid token"
DEVBEGIN = 3, // "/#"
DEVEND = 4, // "#/"
INLINE = 5, // "#inline"
INCLUDE = 6, // "#include"
USINGTREE = 7, // "#using_animtree"
ANIMTREE = 8, // "#animtree"
ENDON = 9, // "endon"
NOTIFY = 10, // "notify"
WAIT = 11, // "wait"
WAITTILL = 12, // "waittill"
WAITTILLMATCH = 13, // "waittillmatch"
WAITTILLFRAMEEND = 14, // "waittillframeend"
WAITFRAME = 15, // "waitframe"
IF = 16, // "if"
ELSE = 17, // "else"
DO = 18, // "do"
WHILE = 19, // "while"
FOR = 20, // "for"
FOREACH = 21, // "foreach"
IN = 22, // "in"
SWITCH = 23, // "switch"
CASE = 24, // "case"
DEFAULT = 25, // "default"
BREAK = 26, // "break"
CONTINUE = 27, // "continue"
RETURN = 28, // "return"
BREAKPOINT = 29, // "breakpoint"
PROFBEGIN = 30, // "prof_begin"
PROFEND = 31, // "prof_end"
THREAD = 32, // "thread"
CHILDTHREAD = 33, // "childthread"
THISTHREAD = 34, // "thisthread"
CALL = 35, // "call"
TRUE = 36, // "true"
FALSE = 37, // "false"
UNDEFINED = 38, // "undefined"
SIZE = 39, // ".size"
GAME = 40, // "game"
SELF = 41, // "self"
ANIM = 42, // "anim"
LEVEL = 43, // "level"
LPAREN = 44, // "("
RPAREN = 45, // ")"
LBRACE = 46, // "{"
RBRACE = 47, // "}"
LBRACKET = 48, // "["
RBRACKET = 49, // "]"
COMMA = 50, // ","
DOT = 51, // "."
DOUBLECOLON = 52, // "::"
COLON = 53, // ":"
SEMICOLON = 54, // ";"
QMARK = 55, // "?"
INCREMENT = 56, // "++"
DECREMENT = 57, // "--"
LSHIFT = 58, // "<<"
RSHIFT = 59, // ">>"
OR = 60, // "||"
AND = 61, // "&&"
EQUALITY = 62, // "=="
INEQUALITY = 63, // "!="
LESS_EQUAL = 64, // "<="
GREATER_EQUAL = 65, // ">="
LESS = 66, // "<"
GREATER = 67, // ">"
NOT = 68, // "!"
COMPLEMENT = 69, // "~"
ASSIGN = 70, // "="
ASSIGN_ADD = 71, // "+="
ASSIGN_SUB = 72, // "-="
ASSIGN_MUL = 73, // "*="
ASSIGN_DIV = 74, // "/="
ASSIGN_MOD = 75, // "%="
ASSIGN_BW_OR = 76, // "|="
ASSIGN_BW_AND = 77, // "&="
ASSIGN_BW_EXOR = 78, // "^="
ASSIGN_RSHIFT = 79, // ">>="
ASSIGN_LSHIFT = 80, // "<<="
BITWISE_OR = 81, // "|"
BITWISE_AND = 82, // "&"
BITWISE_EXOR = 83, // "^"
ADD = 84, // "+"
SUB = 85, // "-"
MUL = 86, // "*"
DIV = 87, // "/"
MOD = 88, // "%"
FIELD = 89, // "field"
PATH = 90, // "path"
IDENTIFIER = 91, // "identifier"
STRING = 92, // "string literal"
ISTRING = 93, // "localized string"
COLOR = 94, // "color"
FLOAT = 95, // "float"
INTEGER = 96, // "integer"
ADD_ARRAY = 97, // ADD_ARRAY
THEN = 98, // THEN
TERN = 99, // TERN
NEG = 100, // NEG
ANIMREF = 101, // ANIMREF
PREINC = 102, // PREINC
PREDEC = 103, // PREDEC
POSTINC = 104, // POSTINC
POSTDEC = 105 // POSTDEC
HSDEFINE = 3, // "#define"
HSUNDEF = 4, // "#undef"
HSIFDEF = 5, // "#ifdef"
HSIFNDEF = 6, // "#ifndef"
HSIF = 7, // "#if"
HSELIF = 8, // "#elif"
HSELSE = 9, // "#else"
HSENDIF = 10, // "#endif"
DEVBEGIN = 11, // "/#"
DEVEND = 12, // "#/"
INLINE = 13, // "#inline"
INCLUDE = 14, // "#include"
USINGTREE = 15, // "#using_animtree"
ANIMTREE = 16, // "#animtree"
ENDON = 17, // "endon"
NOTIFY = 18, // "notify"
WAIT = 19, // "wait"
WAITTILL = 20, // "waittill"
WAITTILLMATCH = 21, // "waittillmatch"
WAITTILLFRAMEEND = 22, // "waittillframeend"
WAITFRAME = 23, // "waitframe"
IF = 24, // "if"
ELSE = 25, // "else"
DO = 26, // "do"
WHILE = 27, // "while"
FOR = 28, // "for"
FOREACH = 29, // "foreach"
IN = 30, // "in"
SWITCH = 31, // "switch"
CASE = 32, // "case"
DEFAULT = 33, // "default"
BREAK = 34, // "break"
CONTINUE = 35, // "continue"
RETURN = 36, // "return"
BREAKPOINT = 37, // "breakpoint"
PROFBEGIN = 38, // "prof_begin"
PROFEND = 39, // "prof_end"
THREAD = 40, // "thread"
CHILDTHREAD = 41, // "childthread"
THISTHREAD = 42, // "thisthread"
CALL = 43, // "call"
TRUE = 44, // "true"
FALSE = 45, // "false"
UNDEFINED = 46, // "undefined"
SIZE = 47, // ".size"
GAME = 48, // "game"
SELF = 49, // "self"
ANIM = 50, // "anim"
LEVEL = 51, // "level"
LPAREN = 52, // "("
RPAREN = 53, // ")"
LBRACE = 54, // "{"
RBRACE = 55, // "}"
LBRACKET = 56, // "["
RBRACKET = 57, // "]"
COMMA = 58, // ","
DOT = 59, // "."
DOUBLECOLON = 60, // "::"
COLON = 61, // ":"
SEMICOLON = 62, // ";"
QMARK = 63, // "?"
INCREMENT = 64, // "++"
DECREMENT = 65, // "--"
LSHIFT = 66, // "<<"
RSHIFT = 67, // ">>"
OR = 68, // "||"
AND = 69, // "&&"
EQUALITY = 70, // "=="
INEQUALITY = 71, // "!="
LESS_EQUAL = 72, // "<="
GREATER_EQUAL = 73, // ">="
LESS = 74, // "<"
GREATER = 75, // ">"
NOT = 76, // "!"
COMPLEMENT = 77, // "~"
ASSIGN = 78, // "="
ASSIGN_ADD = 79, // "+="
ASSIGN_SUB = 80, // "-="
ASSIGN_MUL = 81, // "*="
ASSIGN_DIV = 82, // "/="
ASSIGN_MOD = 83, // "%="
ASSIGN_BW_OR = 84, // "|="
ASSIGN_BW_AND = 85, // "&="
ASSIGN_BW_EXOR = 86, // "^="
ASSIGN_RSHIFT = 87, // ">>="
ASSIGN_LSHIFT = 88, // "<<="
BITWISE_OR = 89, // "|"
BITWISE_AND = 90, // "&"
BITWISE_EXOR = 91, // "^"
ADD = 92, // "+"
SUB = 93, // "-"
MUL = 94, // "*"
DIV = 95, // "/"
MOD = 96, // "%"
FIELD = 97, // "field"
PATH = 98, // "path"
IDENTIFIER = 99, // "identifier"
STRING = 100, // "string literal"
ISTRING = 101, // "localized string"
COLOR = 102, // "color"
FLOAT = 103, // "float"
INTEGER = 104, // "integer"
ADD_ARRAY = 105, // ADD_ARRAY
THEN = 106, // THEN
TERN = 107, // TERN
NEG = 108, // NEG
ANIMREF = 109, // ANIMREF
PREINC = 110, // PREINC
PREDEC = 111, // PREDEC
POSTINC = 112, // POSTINC
POSTDEC = 113 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -796,195 +804,203 @@ namespace xsk { namespace gsc { namespace h2 {
{
enum symbol_kind_type
{
YYNTOKENS = 106, ///< Number of tokens.
YYNTOKENS = 114, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_DEVBEGIN = 3, // "/#"
S_DEVEND = 4, // "#/"
S_INLINE = 5, // "#inline"
S_INCLUDE = 6, // "#include"
S_USINGTREE = 7, // "#using_animtree"
S_ANIMTREE = 8, // "#animtree"
S_ENDON = 9, // "endon"
S_NOTIFY = 10, // "notify"
S_WAIT = 11, // "wait"
S_WAITTILL = 12, // "waittill"
S_WAITTILLMATCH = 13, // "waittillmatch"
S_WAITTILLFRAMEEND = 14, // "waittillframeend"
S_WAITFRAME = 15, // "waitframe"
S_IF = 16, // "if"
S_ELSE = 17, // "else"
S_DO = 18, // "do"
S_WHILE = 19, // "while"
S_FOR = 20, // "for"
S_FOREACH = 21, // "foreach"
S_IN = 22, // "in"
S_SWITCH = 23, // "switch"
S_CASE = 24, // "case"
S_DEFAULT = 25, // "default"
S_BREAK = 26, // "break"
S_CONTINUE = 27, // "continue"
S_RETURN = 28, // "return"
S_BREAKPOINT = 29, // "breakpoint"
S_PROFBEGIN = 30, // "prof_begin"
S_PROFEND = 31, // "prof_end"
S_THREAD = 32, // "thread"
S_CHILDTHREAD = 33, // "childthread"
S_THISTHREAD = 34, // "thisthread"
S_CALL = 35, // "call"
S_TRUE = 36, // "true"
S_FALSE = 37, // "false"
S_UNDEFINED = 38, // "undefined"
S_SIZE = 39, // ".size"
S_GAME = 40, // "game"
S_SELF = 41, // "self"
S_ANIM = 42, // "anim"
S_LEVEL = 43, // "level"
S_LPAREN = 44, // "("
S_RPAREN = 45, // ")"
S_LBRACE = 46, // "{"
S_RBRACE = 47, // "}"
S_LBRACKET = 48, // "["
S_RBRACKET = 49, // "]"
S_COMMA = 50, // ","
S_DOT = 51, // "."
S_DOUBLECOLON = 52, // "::"
S_COLON = 53, // ":"
S_SEMICOLON = 54, // ";"
S_QMARK = 55, // "?"
S_INCREMENT = 56, // "++"
S_DECREMENT = 57, // "--"
S_LSHIFT = 58, // "<<"
S_RSHIFT = 59, // ">>"
S_OR = 60, // "||"
S_AND = 61, // "&&"
S_EQUALITY = 62, // "=="
S_INEQUALITY = 63, // "!="
S_LESS_EQUAL = 64, // "<="
S_GREATER_EQUAL = 65, // ">="
S_LESS = 66, // "<"
S_GREATER = 67, // ">"
S_NOT = 68, // "!"
S_COMPLEMENT = 69, // "~"
S_ASSIGN = 70, // "="
S_ASSIGN_ADD = 71, // "+="
S_ASSIGN_SUB = 72, // "-="
S_ASSIGN_MUL = 73, // "*="
S_ASSIGN_DIV = 74, // "/="
S_ASSIGN_MOD = 75, // "%="
S_ASSIGN_BW_OR = 76, // "|="
S_ASSIGN_BW_AND = 77, // "&="
S_ASSIGN_BW_EXOR = 78, // "^="
S_ASSIGN_RSHIFT = 79, // ">>="
S_ASSIGN_LSHIFT = 80, // "<<="
S_BITWISE_OR = 81, // "|"
S_BITWISE_AND = 82, // "&"
S_BITWISE_EXOR = 83, // "^"
S_ADD = 84, // "+"
S_SUB = 85, // "-"
S_MUL = 86, // "*"
S_DIV = 87, // "/"
S_MOD = 88, // "%"
S_FIELD = 89, // "field"
S_PATH = 90, // "path"
S_IDENTIFIER = 91, // "identifier"
S_STRING = 92, // "string literal"
S_ISTRING = 93, // "localized string"
S_COLOR = 94, // "color"
S_FLOAT = 95, // "float"
S_INTEGER = 96, // "integer"
S_ADD_ARRAY = 97, // ADD_ARRAY
S_THEN = 98, // THEN
S_TERN = 99, // TERN
S_NEG = 100, // NEG
S_ANIMREF = 101, // ANIMREF
S_PREINC = 102, // PREINC
S_PREDEC = 103, // PREDEC
S_POSTINC = 104, // POSTINC
S_POSTDEC = 105, // POSTDEC
S_YYACCEPT = 106, // $accept
S_root = 107, // root
S_program = 108, // program
S_inline = 109, // inline
S_include = 110, // include
S_declaration = 111, // declaration
S_decl_usingtree = 112, // decl_usingtree
S_decl_constant = 113, // decl_constant
S_decl_thread = 114, // decl_thread
S_stmt = 115, // stmt
S_stmt_dev = 116, // stmt_dev
S_stmt_block = 117, // stmt_block
S_stmt_list = 118, // stmt_list
S_stmt_expr = 119, // stmt_expr
S_stmt_call = 120, // stmt_call
S_stmt_assign = 121, // stmt_assign
S_stmt_endon = 122, // stmt_endon
S_stmt_notify = 123, // stmt_notify
S_stmt_wait = 124, // stmt_wait
S_stmt_waittill = 125, // stmt_waittill
S_stmt_waittillmatch = 126, // stmt_waittillmatch
S_stmt_waittillframeend = 127, // stmt_waittillframeend
S_stmt_waitframe = 128, // stmt_waitframe
S_stmt_if = 129, // stmt_if
S_stmt_ifelse = 130, // stmt_ifelse
S_stmt_while = 131, // stmt_while
S_stmt_dowhile = 132, // stmt_dowhile
S_stmt_for = 133, // stmt_for
S_stmt_foreach = 134, // stmt_foreach
S_stmt_switch = 135, // stmt_switch
S_stmt_case = 136, // stmt_case
S_stmt_default = 137, // stmt_default
S_stmt_break = 138, // stmt_break
S_stmt_continue = 139, // stmt_continue
S_stmt_return = 140, // stmt_return
S_stmt_breakpoint = 141, // stmt_breakpoint
S_stmt_prof_begin = 142, // stmt_prof_begin
S_stmt_prof_end = 143, // stmt_prof_end
S_expr = 144, // expr
S_expr_or_empty = 145, // expr_or_empty
S_expr_assign = 146, // expr_assign
S_expr_increment = 147, // expr_increment
S_expr_decrement = 148, // expr_decrement
S_expr_ternary = 149, // expr_ternary
S_expr_binary = 150, // expr_binary
S_expr_primitive = 151, // expr_primitive
S_expr_complement = 152, // expr_complement
S_expr_not = 153, // expr_not
S_expr_call = 154, // expr_call
S_expr_method = 155, // expr_method
S_expr_function = 156, // expr_function
S_expr_pointer = 157, // expr_pointer
S_expr_add_array = 158, // expr_add_array
S_expr_parameters = 159, // expr_parameters
S_expr_arguments = 160, // expr_arguments
S_expr_arguments_no_empty = 161, // expr_arguments_no_empty
S_expr_reference = 162, // expr_reference
S_expr_array = 163, // expr_array
S_expr_field = 164, // expr_field
S_expr_size = 165, // expr_size
S_expr_paren = 166, // expr_paren
S_expr_object = 167, // expr_object
S_expr_thisthread = 168, // expr_thisthread
S_expr_empty_array = 169, // expr_empty_array
S_expr_undefined = 170, // expr_undefined
S_expr_game = 171, // expr_game
S_expr_self = 172, // expr_self
S_expr_anim = 173, // expr_anim
S_expr_level = 174, // expr_level
S_expr_animation = 175, // expr_animation
S_expr_animtree = 176, // expr_animtree
S_expr_identifier = 177, // expr_identifier
S_expr_path = 178, // expr_path
S_expr_istring = 179, // expr_istring
S_expr_string = 180, // expr_string
S_expr_color = 181, // expr_color
S_expr_vector = 182, // expr_vector
S_expr_float = 183, // expr_float
S_expr_integer = 184, // expr_integer
S_expr_false = 185, // expr_false
S_expr_true = 186 // expr_true
S_HSDEFINE = 3, // "#define"
S_HSUNDEF = 4, // "#undef"
S_HSIFDEF = 5, // "#ifdef"
S_HSIFNDEF = 6, // "#ifndef"
S_HSIF = 7, // "#if"
S_HSELIF = 8, // "#elif"
S_HSELSE = 9, // "#else"
S_HSENDIF = 10, // "#endif"
S_DEVBEGIN = 11, // "/#"
S_DEVEND = 12, // "#/"
S_INLINE = 13, // "#inline"
S_INCLUDE = 14, // "#include"
S_USINGTREE = 15, // "#using_animtree"
S_ANIMTREE = 16, // "#animtree"
S_ENDON = 17, // "endon"
S_NOTIFY = 18, // "notify"
S_WAIT = 19, // "wait"
S_WAITTILL = 20, // "waittill"
S_WAITTILLMATCH = 21, // "waittillmatch"
S_WAITTILLFRAMEEND = 22, // "waittillframeend"
S_WAITFRAME = 23, // "waitframe"
S_IF = 24, // "if"
S_ELSE = 25, // "else"
S_DO = 26, // "do"
S_WHILE = 27, // "while"
S_FOR = 28, // "for"
S_FOREACH = 29, // "foreach"
S_IN = 30, // "in"
S_SWITCH = 31, // "switch"
S_CASE = 32, // "case"
S_DEFAULT = 33, // "default"
S_BREAK = 34, // "break"
S_CONTINUE = 35, // "continue"
S_RETURN = 36, // "return"
S_BREAKPOINT = 37, // "breakpoint"
S_PROFBEGIN = 38, // "prof_begin"
S_PROFEND = 39, // "prof_end"
S_THREAD = 40, // "thread"
S_CHILDTHREAD = 41, // "childthread"
S_THISTHREAD = 42, // "thisthread"
S_CALL = 43, // "call"
S_TRUE = 44, // "true"
S_FALSE = 45, // "false"
S_UNDEFINED = 46, // "undefined"
S_SIZE = 47, // ".size"
S_GAME = 48, // "game"
S_SELF = 49, // "self"
S_ANIM = 50, // "anim"
S_LEVEL = 51, // "level"
S_LPAREN = 52, // "("
S_RPAREN = 53, // ")"
S_LBRACE = 54, // "{"
S_RBRACE = 55, // "}"
S_LBRACKET = 56, // "["
S_RBRACKET = 57, // "]"
S_COMMA = 58, // ","
S_DOT = 59, // "."
S_DOUBLECOLON = 60, // "::"
S_COLON = 61, // ":"
S_SEMICOLON = 62, // ";"
S_QMARK = 63, // "?"
S_INCREMENT = 64, // "++"
S_DECREMENT = 65, // "--"
S_LSHIFT = 66, // "<<"
S_RSHIFT = 67, // ">>"
S_OR = 68, // "||"
S_AND = 69, // "&&"
S_EQUALITY = 70, // "=="
S_INEQUALITY = 71, // "!="
S_LESS_EQUAL = 72, // "<="
S_GREATER_EQUAL = 73, // ">="
S_LESS = 74, // "<"
S_GREATER = 75, // ">"
S_NOT = 76, // "!"
S_COMPLEMENT = 77, // "~"
S_ASSIGN = 78, // "="
S_ASSIGN_ADD = 79, // "+="
S_ASSIGN_SUB = 80, // "-="
S_ASSIGN_MUL = 81, // "*="
S_ASSIGN_DIV = 82, // "/="
S_ASSIGN_MOD = 83, // "%="
S_ASSIGN_BW_OR = 84, // "|="
S_ASSIGN_BW_AND = 85, // "&="
S_ASSIGN_BW_EXOR = 86, // "^="
S_ASSIGN_RSHIFT = 87, // ">>="
S_ASSIGN_LSHIFT = 88, // "<<="
S_BITWISE_OR = 89, // "|"
S_BITWISE_AND = 90, // "&"
S_BITWISE_EXOR = 91, // "^"
S_ADD = 92, // "+"
S_SUB = 93, // "-"
S_MUL = 94, // "*"
S_DIV = 95, // "/"
S_MOD = 96, // "%"
S_FIELD = 97, // "field"
S_PATH = 98, // "path"
S_IDENTIFIER = 99, // "identifier"
S_STRING = 100, // "string literal"
S_ISTRING = 101, // "localized string"
S_COLOR = 102, // "color"
S_FLOAT = 103, // "float"
S_INTEGER = 104, // "integer"
S_ADD_ARRAY = 105, // ADD_ARRAY
S_THEN = 106, // THEN
S_TERN = 107, // TERN
S_NEG = 108, // NEG
S_ANIMREF = 109, // ANIMREF
S_PREINC = 110, // PREINC
S_PREDEC = 111, // PREDEC
S_POSTINC = 112, // POSTINC
S_POSTDEC = 113, // POSTDEC
S_YYACCEPT = 114, // $accept
S_root = 115, // root
S_program = 116, // program
S_inline = 117, // inline
S_include = 118, // include
S_declaration = 119, // declaration
S_decl_usingtree = 120, // decl_usingtree
S_decl_constant = 121, // decl_constant
S_decl_thread = 122, // decl_thread
S_stmt = 123, // stmt
S_stmt_dev = 124, // stmt_dev
S_stmt_block = 125, // stmt_block
S_stmt_list = 126, // stmt_list
S_stmt_expr = 127, // stmt_expr
S_stmt_call = 128, // stmt_call
S_stmt_assign = 129, // stmt_assign
S_stmt_endon = 130, // stmt_endon
S_stmt_notify = 131, // stmt_notify
S_stmt_wait = 132, // stmt_wait
S_stmt_waittill = 133, // stmt_waittill
S_stmt_waittillmatch = 134, // stmt_waittillmatch
S_stmt_waittillframeend = 135, // stmt_waittillframeend
S_stmt_waitframe = 136, // stmt_waitframe
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
};
};
@ -2779,6 +2795,126 @@ switch (yykind)
return symbol_type (token::H2UNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSDEFINE (location_type l)
{
return symbol_type (token::HSDEFINE, std::move (l));
}
#else
static
symbol_type
make_HSDEFINE (const location_type& l)
{
return symbol_type (token::HSDEFINE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSUNDEF (location_type l)
{
return symbol_type (token::HSUNDEF, std::move (l));
}
#else
static
symbol_type
make_HSUNDEF (const location_type& l)
{
return symbol_type (token::HSUNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFDEF (location_type l)
{
return symbol_type (token::HSIFDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFDEF (const location_type& l)
{
return symbol_type (token::HSIFDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFNDEF (location_type l)
{
return symbol_type (token::HSIFNDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFNDEF (const location_type& l)
{
return symbol_type (token::HSIFNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIF (location_type l)
{
return symbol_type (token::HSIF, std::move (l));
}
#else
static
symbol_type
make_HSIF (const location_type& l)
{
return symbol_type (token::HSIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELIF (location_type l)
{
return symbol_type (token::HSELIF, std::move (l));
}
#else
static
symbol_type
make_HSELIF (const location_type& l)
{
return symbol_type (token::HSELIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELSE (location_type l)
{
return symbol_type (token::HSELSE, std::move (l));
}
#else
static
symbol_type
make_HSELSE (const location_type& l)
{
return symbol_type (token::HSELSE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSENDIF (location_type l)
{
return symbol_type (token::HSENDIF, std::move (l));
}
#else
static
symbol_type
make_HSENDIF (const location_type& l)
{
return symbol_type (token::HSENDIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -5362,7 +5498,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::h2
#line 5366 "parser.hpp"
#line 5502 "parser.hpp"

View File

@ -16,57 +16,6 @@ xsk::gsc::iw5::parser::symbol_type IW5lex(xsk::gsc::iw5::lexer& lexer)
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() : length(0)
{
data = static_cast<char*>(std::malloc(max_buf_size));
@ -129,7 +78,7 @@ void reader::advance()
}
}
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(xsk::gsc::location(&name)),
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(location(&name)),
mode_(build::dev), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
{
reader_.init(data, size);
@ -140,7 +89,7 @@ void lexer::push_header(const std::string& file)
try
{
if (header_top_++ >= 10)
throw xsk::gsc::error("maximum gsh depth exceeded '10'");
throw comp_error(loc_, "maximum gsh depth exceeded '10'");
auto data = resolver::file_data(file + ".gsh");
@ -151,7 +100,7 @@ void lexer::push_header(const std::string& file)
}
catch (const std::exception& e)
{
throw xsk::gsc::error("parsing header file '" + file + "': " + e.what());
throw error("parsing header file '" + file + "': " + e.what());
}
}
@ -164,7 +113,7 @@ void lexer::pop_header()
readers_.pop();
}
void lexer::restrict_header(const xsk::gsc::location& loc)
void lexer::ban_header(const location& loc)
{
if (header_top_ > 0)
{
@ -172,7 +121,7 @@ void lexer::restrict_header(const xsk::gsc::location& loc)
}
}
auto lexer::lex() -> xsk::gsc::iw5::parser::symbol_type
auto lexer::lex() -> parser::symbol_type
{
buffer_.length = 0;
state_ = state::start;
@ -193,7 +142,7 @@ auto lexer::lex() -> xsk::gsc::iw5::parser::symbol_type
if (header_top_ > 0)
pop_header();
else
return iw5::parser::make_IW5EOF(loc_);
return parser::make_IW5EOF(loc_);
}
reader_.advance();
@ -211,22 +160,22 @@ auto lexer::lex() -> xsk::gsc::iw5::parser::symbol_type
continue;
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
return iw5::parser::make_DIV(loc_);
return parser::make_DIV(loc_);
reader_.advance();
if (last == '=')
return iw5::parser::make_ASSIGN_DIV(loc_);
return parser::make_ASSIGN_DIV(loc_);
if (last == '#')
{
if (indev_)
throw comp_error(loc_, "cannot recurse devblock ('/#')");
if (mode_ == xsk::gsc::build::dev)
if (mode_ == build::dev)
{
indev_ = true;
return iw5::parser::make_DEVBEGIN(loc_);
return parser::make_DEVBEGIN(loc_);
}
else
{
@ -290,7 +239,7 @@ auto lexer::lex() -> xsk::gsc::iw5::parser::symbol_type
indev_ = false;
reader_.advance();
return iw5::parser::make_DEVEND(loc_);
return parser::make_DEVEND(loc_);
}
buffer_.push(last);
@ -303,12 +252,12 @@ auto lexer::lex() -> xsk::gsc::iw5::parser::symbol_type
goto lex_name;
case '*':
if (curr != '/' && curr != '=')
return iw5::parser::make_MUL(loc_);
return parser::make_MUL(loc_);
reader_.advance();
if (last == '=')
return iw5::parser::make_ASSIGN_MUL(loc_);
return parser::make_ASSIGN_MUL(loc_);
throw comp_error(loc_, "unmatched multiline comment end ('*/')");
case '"':
@ -323,127 +272,127 @@ auto lexer::lex() -> xsk::gsc::iw5::parser::symbol_type
state_ = state::field;
goto lex_name_or_number;
case '(':
return iw5::parser::make_LPAREN(loc_);
return parser::make_LPAREN(loc_);
case ')':
return iw5::parser::make_RPAREN(loc_);
return parser::make_RPAREN(loc_);
case '{':
return iw5::parser::make_LBRACE(loc_);
return parser::make_LBRACE(loc_);
case '}':
return iw5::parser::make_RBRACE(loc_);
return parser::make_RBRACE(loc_);
case '[':
return iw5::parser::make_LBRACKET(loc_);
return parser::make_LBRACKET(loc_);
case ']':
return iw5::parser::make_RBRACKET(loc_);
return parser::make_RBRACKET(loc_);
case ',':
return iw5::parser::make_COMMA(loc_);
return parser::make_COMMA(loc_);
case ';':
return iw5::parser::make_SEMICOLON(loc_);
return parser::make_SEMICOLON(loc_);
case ':':
if (curr != ':')
return iw5::parser::make_COLON(loc_);
return parser::make_COLON(loc_);
reader_.advance();
return iw5::parser::make_DOUBLECOLON(loc_);
return parser::make_DOUBLECOLON(loc_);
case '?':
return iw5::parser::make_QMARK(loc_);
return parser::make_QMARK(loc_);
case '=':
if (curr != '=')
return iw5::parser::make_ASSIGN(loc_);
return parser::make_ASSIGN(loc_);
reader_.advance();
return iw5::parser::make_EQUALITY(loc_);
return parser::make_EQUALITY(loc_);
case '+':
if (curr != '+' && curr != '=')
return iw5::parser::make_ADD(loc_);
return parser::make_ADD(loc_);
reader_.advance();
if (last == '+')
return iw5::parser::make_INCREMENT(loc_);
return parser::make_INCREMENT(loc_);
return iw5::parser::make_ASSIGN_ADD(loc_);
return parser::make_ASSIGN_ADD(loc_);
case '-':
if (curr != '-' && curr != '=')
return iw5::parser::make_SUB(loc_);
return parser::make_SUB(loc_);
reader_.advance();
if (last == '-')
return iw5::parser::make_DECREMENT(loc_);
return parser::make_DECREMENT(loc_);
return iw5::parser::make_ASSIGN_SUB(loc_);
return parser::make_ASSIGN_SUB(loc_);
case '%':
if (curr != '=')
return iw5::parser::make_MOD(loc_);
return parser::make_MOD(loc_);
reader_.advance();
return iw5::parser::make_ASSIGN_MOD(loc_);
return parser::make_ASSIGN_MOD(loc_);
case '|':
if (curr != '|' && curr != '=')
return iw5::parser::make_BITWISE_OR(loc_);
return parser::make_BITWISE_OR(loc_);
reader_.advance();
if (last == '|')
return iw5::parser::make_OR(loc_);
return parser::make_OR(loc_);
return iw5::parser::make_ASSIGN_BW_OR(loc_);
return parser::make_ASSIGN_BW_OR(loc_);
case '&':
if (curr != '&' && curr != '=' && curr != '"' && curr != '\'')
return iw5::parser::make_BITWISE_AND(loc_);
return parser::make_BITWISE_AND(loc_);
reader_.advance();
if (last == '&')
return iw5::parser::make_AND(loc_);
return parser::make_AND(loc_);
if (last == '=')
return iw5::parser::make_ASSIGN_BW_AND(loc_);
return parser::make_ASSIGN_BW_AND(loc_);
state_ = state::localize;
goto lex_string;
case '^':
if (curr != '=')
return iw5::parser::make_BITWISE_EXOR(loc_);
return parser::make_BITWISE_EXOR(loc_);
reader_.advance();
return iw5::parser::make_ASSIGN_BW_EXOR(loc_);
return parser::make_ASSIGN_BW_EXOR(loc_);
case '!':
if (curr != '=')
return iw5::parser::make_NOT(loc_);
return parser::make_NOT(loc_);
reader_.advance();
return iw5::parser::make_INEQUALITY(loc_);
return parser::make_INEQUALITY(loc_);
case '~':
return iw5::parser::make_COMPLEMENT(loc_);
return parser::make_COMPLEMENT(loc_);
case '<':
if (curr != '<' && curr != '=')
return iw5::parser::make_LESS(loc_);
return parser::make_LESS(loc_);
reader_.advance();
if (last == '=')
return iw5::parser::make_LESS_EQUAL(loc_);
return parser::make_LESS_EQUAL(loc_);
if (curr != '=')
return iw5::parser::make_LSHIFT(loc_);
return parser::make_LSHIFT(loc_);
reader_.advance();
return iw5::parser::make_ASSIGN_LSHIFT(loc_);
return parser::make_ASSIGN_LSHIFT(loc_);
case '>':
if (curr != '>' && curr != '=')
return iw5::parser::make_GREATER(loc_);
return parser::make_GREATER(loc_);
reader_.advance();
if (last == '=')
return iw5::parser::make_GREATER_EQUAL(loc_);
return parser::make_GREATER_EQUAL(loc_);
if (curr != '=')
return iw5::parser::make_RSHIFT(loc_);
return parser::make_RSHIFT(loc_);
reader_.advance();
return iw5::parser::make_ASSIGN_RSHIFT(loc_);
return parser::make_ASSIGN_RSHIFT(loc_);
default:
lex_name_or_number:
if (last >= '0' && last <= '9')
@ -496,9 +445,9 @@ lex_string:
}
if (state_ == state::localize)
return iw5::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return iw5::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
lex_name:
buffer_.push(last);
@ -533,44 +482,55 @@ lex_name:
if (std::string_view(buffer_.data, buffer_.length) == "size")
{
return iw5::parser::make_SIZE(loc_);
return parser::make_SIZE(loc_);
}
return iw5::parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
}
else if (state_ == state::preprocessor)
{
if (path)
throw comp_error(loc_, "invalid preprocessor directive");
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
auto token = parser::token::IW5UNDEF;
if (key != keyword::KW_INVALID)
return keyword_token(key);
if (buffer_.length < 16)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
// TODO: call preprocessor(key);
if(itr != keyword_map.end())
{
if (itr->second > parser::token::HSENDIF)
return parser::symbol_type(itr->second, loc_);
token = itr->second;
}
}
// TODO: call preprocessor(token);
throw comp_error(loc_, "unknown preprocessor directive");
state_ = state::start;
continue;
}
else
{
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
if (buffer_.length < 17)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
if (key != keyword::KW_INVALID)
return keyword_token(key);
if(itr != keyword_map.end())
return parser::symbol_type(itr->second, loc_);
}
if (path)
{
if (buffer_.data[buffer_.length - 1] == '/')
throw comp_error(loc_, "invalid path end '\\'");
//return iw5::parser::make_PATH(xsk::gsc::iw5::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return iw5::parser::make_PATH(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_PATH(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
//return iw5::parser::make_IDENTIFIER(xsk::gsc::iw5::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return iw5::parser::make_IDENTIFIER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_IDENTIFIER(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
lex_number:
@ -621,9 +581,9 @@ lex_number:
throw comp_error(loc_, "invalid number literal");
if (state_ == state::field || dot || flt)
return iw5::parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return iw5::parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
}
else if (curr == 'o')
{
@ -655,7 +615,7 @@ lex_number:
if (last == '\'' || buffer_.length <= 0)
throw comp_error(loc_, "invalid octal literal");
return iw5::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
}
else if (curr == 'b')
{
@ -689,7 +649,7 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid binary literal");
return iw5::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
}
else if (curr == 'x')
{
@ -723,176 +683,59 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid hexadecimal literal");
return iw5::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
}
// cant get here!
}
}
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;
}
return keyword::KW_INVALID;
}
std::unordered_map<std::string_view, keyword> lexer::keywords
const std::unordered_map<std::string_view, parser::token::token_kind_type> lexer::keyword_map
{{
/* { "#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 },
{ "#define", parser::token::HSDEFINE },
{ "#undef", parser::token::HSUNDEF },
{ "#ifdef", parser::token::HSIFDEF },
{ "#ifndef", parser::token::HSIFNDEF },
{ "#if", parser::token::HSIF },
{ "#elif", parser::token::HSELIF },
{ "#else", parser::token::HSELSE },
{ "#endif", parser::token::HSENDIF },
{ "#inline", parser::token::INLINE },
{ "#include", parser::token::INCLUDE },
{ "#using_animtree", parser::token::USINGTREE },
{ "#animtree", parser::token::ANIMTREE },
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
{ "if", parser::token::IF },
{ "else", parser::token::ELSE },
{ "do", parser::token::DO },
{ "while", parser::token::WHILE },
{ "for", parser::token::FOR },
{ "foreach", parser::token::FOREACH },
{ "in", parser::token::IN },
{ "switch", parser::token::SWITCH },
{ "case", parser::token::CASE },
{ "default", parser::token::DEFAULT },
{ "break", parser::token::BREAK },
{ "continue", parser::token::CONTINUE },
{ "return", parser::token::RETURN },
{ "breakpoint", parser::token::BREAKPOINT },
{ "prof_begin", parser::token::PROFBEGIN },
{ "prof_end", parser::token::PROFEND },
{ "thread", parser::token::THREAD },
{ "childthread", parser::token::CHILDTHREAD },
{ "thisthread", parser::token::THISTHREAD },
{ "call", parser::token::CALL },
{ "true", parser::token::TRUE },
{ "false", parser::token::FALSE },
{ "undefined", parser::token::UNDEFINED },
{ "game", parser::token::GAME },
{ "self", parser::token::SELF },
{ "anim", parser::token::ANIM },
{ "level", parser::token::LEVEL },
}};
} // namespace xsk::gsc::iw5

View File

@ -10,8 +10,6 @@
namespace xsk::gsc::iw5
{
enum class keyword;
constexpr size_t max_buf_size = 0x2000;
struct buffer
@ -53,26 +51,22 @@ class lexer
reader reader_;
buffer buffer_;
location loc_;
build mode_;
std::stack<location> locs_;
std::stack<reader> readers_;
std::uint32_t header_top_;
state state_;
build mode_;
bool indev_;
public:
lexer(const std::string& name, const char* data, size_t size);
auto lex() -> xsk::gsc::iw5::parser::symbol_type;
auto lex() -> parser::symbol_type;
void push_header(const std::string& file);
void pop_header();
void restrict_header(const xsk::gsc::location& loc);
void ban_header(const location& loc);
private:
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<std::string_view, keyword> keywords;
static const std::unordered_map<std::string_view, parser::token::token_kind_type> keyword_map;
};
} // namespace xsk::gsc::iw5

File diff suppressed because it is too large Load Diff

View File

@ -674,108 +674,116 @@ namespace xsk { namespace gsc { namespace iw5 {
IW5EOF = 0, // "end of file"
IW5error = 1, // error
IW5UNDEF = 2, // "invalid token"
DEVBEGIN = 3, // "/#"
DEVEND = 4, // "#/"
INLINE = 5, // "#inline"
INCLUDE = 6, // "#include"
USINGTREE = 7, // "#using_animtree"
ANIMTREE = 8, // "#animtree"
ENDON = 9, // "endon"
NOTIFY = 10, // "notify"
WAIT = 11, // "wait"
WAITTILL = 12, // "waittill"
WAITTILLMATCH = 13, // "waittillmatch"
WAITTILLFRAMEEND = 14, // "waittillframeend"
IF = 15, // "if"
ELSE = 16, // "else"
DO = 17, // "do"
WHILE = 18, // "while"
FOR = 19, // "for"
FOREACH = 20, // "foreach"
IN = 21, // "in"
SWITCH = 22, // "switch"
CASE = 23, // "case"
DEFAULT = 24, // "default"
BREAK = 25, // "break"
CONTINUE = 26, // "continue"
RETURN = 27, // "return"
BREAKPOINT = 28, // "breakpoint"
PROFBEGIN = 29, // "prof_begin"
PROFEND = 30, // "prof_end"
THREAD = 31, // "thread"
CHILDTHREAD = 32, // "childthread"
THISTHREAD = 33, // "thisthread"
CALL = 34, // "call"
TRUE = 35, // "true"
FALSE = 36, // "false"
UNDEFINED = 37, // "undefined"
SIZE = 38, // ".size"
GAME = 39, // "game"
SELF = 40, // "self"
ANIM = 41, // "anim"
LEVEL = 42, // "level"
LPAREN = 43, // "("
RPAREN = 44, // ")"
LBRACE = 45, // "{"
RBRACE = 46, // "}"
LBRACKET = 47, // "["
RBRACKET = 48, // "]"
COMMA = 49, // ","
DOT = 50, // "."
DOUBLECOLON = 51, // "::"
COLON = 52, // ":"
SEMICOLON = 53, // ";"
QMARK = 54, // "?"
INCREMENT = 55, // "++"
DECREMENT = 56, // "--"
LSHIFT = 57, // "<<"
RSHIFT = 58, // ">>"
OR = 59, // "||"
AND = 60, // "&&"
EQUALITY = 61, // "=="
INEQUALITY = 62, // "!="
LESS_EQUAL = 63, // "<="
GREATER_EQUAL = 64, // ">="
LESS = 65, // "<"
GREATER = 66, // ">"
NOT = 67, // "!"
COMPLEMENT = 68, // "~"
ASSIGN = 69, // "="
ASSIGN_ADD = 70, // "+="
ASSIGN_SUB = 71, // "-="
ASSIGN_MUL = 72, // "*="
ASSIGN_DIV = 73, // "/="
ASSIGN_MOD = 74, // "%="
ASSIGN_BW_OR = 75, // "|="
ASSIGN_BW_AND = 76, // "&="
ASSIGN_BW_EXOR = 77, // "^="
ASSIGN_RSHIFT = 78, // ">>="
ASSIGN_LSHIFT = 79, // "<<="
BITWISE_OR = 80, // "|"
BITWISE_AND = 81, // "&"
BITWISE_EXOR = 82, // "^"
ADD = 83, // "+"
SUB = 84, // "-"
MUL = 85, // "*"
DIV = 86, // "/"
MOD = 87, // "%"
FIELD = 88, // "field"
PATH = 89, // "path"
IDENTIFIER = 90, // "identifier"
STRING = 91, // "string literal"
ISTRING = 92, // "localized string"
COLOR = 93, // "color"
FLOAT = 94, // "float"
INTEGER = 95, // "integer"
ADD_ARRAY = 96, // ADD_ARRAY
THEN = 97, // THEN
TERN = 98, // TERN
NEG = 99, // NEG
ANIMREF = 100, // ANIMREF
PREINC = 101, // PREINC
PREDEC = 102, // PREDEC
POSTINC = 103, // POSTINC
POSTDEC = 104 // POSTDEC
HSDEFINE = 3, // "#define"
HSUNDEF = 4, // "#undef"
HSIFDEF = 5, // "#ifdef"
HSIFNDEF = 6, // "#ifndef"
HSIF = 7, // "#if"
HSELIF = 8, // "#elif"
HSELSE = 9, // "#else"
HSENDIF = 10, // "#endif"
DEVBEGIN = 11, // "/#"
DEVEND = 12, // "#/"
INLINE = 13, // "#inline"
INCLUDE = 14, // "#include"
USINGTREE = 15, // "#using_animtree"
ANIMTREE = 16, // "#animtree"
ENDON = 17, // "endon"
NOTIFY = 18, // "notify"
WAIT = 19, // "wait"
WAITTILL = 20, // "waittill"
WAITTILLMATCH = 21, // "waittillmatch"
WAITTILLFRAMEEND = 22, // "waittillframeend"
IF = 23, // "if"
ELSE = 24, // "else"
DO = 25, // "do"
WHILE = 26, // "while"
FOR = 27, // "for"
FOREACH = 28, // "foreach"
IN = 29, // "in"
SWITCH = 30, // "switch"
CASE = 31, // "case"
DEFAULT = 32, // "default"
BREAK = 33, // "break"
CONTINUE = 34, // "continue"
RETURN = 35, // "return"
BREAKPOINT = 36, // "breakpoint"
PROFBEGIN = 37, // "prof_begin"
PROFEND = 38, // "prof_end"
THREAD = 39, // "thread"
CHILDTHREAD = 40, // "childthread"
THISTHREAD = 41, // "thisthread"
CALL = 42, // "call"
TRUE = 43, // "true"
FALSE = 44, // "false"
UNDEFINED = 45, // "undefined"
SIZE = 46, // ".size"
GAME = 47, // "game"
SELF = 48, // "self"
ANIM = 49, // "anim"
LEVEL = 50, // "level"
LPAREN = 51, // "("
RPAREN = 52, // ")"
LBRACE = 53, // "{"
RBRACE = 54, // "}"
LBRACKET = 55, // "["
RBRACKET = 56, // "]"
COMMA = 57, // ","
DOT = 58, // "."
DOUBLECOLON = 59, // "::"
COLON = 60, // ":"
SEMICOLON = 61, // ";"
QMARK = 62, // "?"
INCREMENT = 63, // "++"
DECREMENT = 64, // "--"
LSHIFT = 65, // "<<"
RSHIFT = 66, // ">>"
OR = 67, // "||"
AND = 68, // "&&"
EQUALITY = 69, // "=="
INEQUALITY = 70, // "!="
LESS_EQUAL = 71, // "<="
GREATER_EQUAL = 72, // ">="
LESS = 73, // "<"
GREATER = 74, // ">"
NOT = 75, // "!"
COMPLEMENT = 76, // "~"
ASSIGN = 77, // "="
ASSIGN_ADD = 78, // "+="
ASSIGN_SUB = 79, // "-="
ASSIGN_MUL = 80, // "*="
ASSIGN_DIV = 81, // "/="
ASSIGN_MOD = 82, // "%="
ASSIGN_BW_OR = 83, // "|="
ASSIGN_BW_AND = 84, // "&="
ASSIGN_BW_EXOR = 85, // "^="
ASSIGN_RSHIFT = 86, // ">>="
ASSIGN_LSHIFT = 87, // "<<="
BITWISE_OR = 88, // "|"
BITWISE_AND = 89, // "&"
BITWISE_EXOR = 90, // "^"
ADD = 91, // "+"
SUB = 92, // "-"
MUL = 93, // "*"
DIV = 94, // "/"
MOD = 95, // "%"
FIELD = 96, // "field"
PATH = 97, // "path"
IDENTIFIER = 98, // "identifier"
STRING = 99, // "string literal"
ISTRING = 100, // "localized string"
COLOR = 101, // "color"
FLOAT = 102, // "float"
INTEGER = 103, // "integer"
ADD_ARRAY = 104, // ADD_ARRAY
THEN = 105, // THEN
TERN = 106, // TERN
NEG = 107, // NEG
ANIMREF = 108, // ANIMREF
PREINC = 109, // PREINC
PREDEC = 110, // PREDEC
POSTINC = 111, // POSTINC
POSTDEC = 112 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -792,193 +800,201 @@ namespace xsk { namespace gsc { namespace iw5 {
{
enum symbol_kind_type
{
YYNTOKENS = 105, ///< Number of tokens.
YYNTOKENS = 113, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_DEVBEGIN = 3, // "/#"
S_DEVEND = 4, // "#/"
S_INLINE = 5, // "#inline"
S_INCLUDE = 6, // "#include"
S_USINGTREE = 7, // "#using_animtree"
S_ANIMTREE = 8, // "#animtree"
S_ENDON = 9, // "endon"
S_NOTIFY = 10, // "notify"
S_WAIT = 11, // "wait"
S_WAITTILL = 12, // "waittill"
S_WAITTILLMATCH = 13, // "waittillmatch"
S_WAITTILLFRAMEEND = 14, // "waittillframeend"
S_IF = 15, // "if"
S_ELSE = 16, // "else"
S_DO = 17, // "do"
S_WHILE = 18, // "while"
S_FOR = 19, // "for"
S_FOREACH = 20, // "foreach"
S_IN = 21, // "in"
S_SWITCH = 22, // "switch"
S_CASE = 23, // "case"
S_DEFAULT = 24, // "default"
S_BREAK = 25, // "break"
S_CONTINUE = 26, // "continue"
S_RETURN = 27, // "return"
S_BREAKPOINT = 28, // "breakpoint"
S_PROFBEGIN = 29, // "prof_begin"
S_PROFEND = 30, // "prof_end"
S_THREAD = 31, // "thread"
S_CHILDTHREAD = 32, // "childthread"
S_THISTHREAD = 33, // "thisthread"
S_CALL = 34, // "call"
S_TRUE = 35, // "true"
S_FALSE = 36, // "false"
S_UNDEFINED = 37, // "undefined"
S_SIZE = 38, // ".size"
S_GAME = 39, // "game"
S_SELF = 40, // "self"
S_ANIM = 41, // "anim"
S_LEVEL = 42, // "level"
S_LPAREN = 43, // "("
S_RPAREN = 44, // ")"
S_LBRACE = 45, // "{"
S_RBRACE = 46, // "}"
S_LBRACKET = 47, // "["
S_RBRACKET = 48, // "]"
S_COMMA = 49, // ","
S_DOT = 50, // "."
S_DOUBLECOLON = 51, // "::"
S_COLON = 52, // ":"
S_SEMICOLON = 53, // ";"
S_QMARK = 54, // "?"
S_INCREMENT = 55, // "++"
S_DECREMENT = 56, // "--"
S_LSHIFT = 57, // "<<"
S_RSHIFT = 58, // ">>"
S_OR = 59, // "||"
S_AND = 60, // "&&"
S_EQUALITY = 61, // "=="
S_INEQUALITY = 62, // "!="
S_LESS_EQUAL = 63, // "<="
S_GREATER_EQUAL = 64, // ">="
S_LESS = 65, // "<"
S_GREATER = 66, // ">"
S_NOT = 67, // "!"
S_COMPLEMENT = 68, // "~"
S_ASSIGN = 69, // "="
S_ASSIGN_ADD = 70, // "+="
S_ASSIGN_SUB = 71, // "-="
S_ASSIGN_MUL = 72, // "*="
S_ASSIGN_DIV = 73, // "/="
S_ASSIGN_MOD = 74, // "%="
S_ASSIGN_BW_OR = 75, // "|="
S_ASSIGN_BW_AND = 76, // "&="
S_ASSIGN_BW_EXOR = 77, // "^="
S_ASSIGN_RSHIFT = 78, // ">>="
S_ASSIGN_LSHIFT = 79, // "<<="
S_BITWISE_OR = 80, // "|"
S_BITWISE_AND = 81, // "&"
S_BITWISE_EXOR = 82, // "^"
S_ADD = 83, // "+"
S_SUB = 84, // "-"
S_MUL = 85, // "*"
S_DIV = 86, // "/"
S_MOD = 87, // "%"
S_FIELD = 88, // "field"
S_PATH = 89, // "path"
S_IDENTIFIER = 90, // "identifier"
S_STRING = 91, // "string literal"
S_ISTRING = 92, // "localized string"
S_COLOR = 93, // "color"
S_FLOAT = 94, // "float"
S_INTEGER = 95, // "integer"
S_ADD_ARRAY = 96, // ADD_ARRAY
S_THEN = 97, // THEN
S_TERN = 98, // TERN
S_NEG = 99, // NEG
S_ANIMREF = 100, // ANIMREF
S_PREINC = 101, // PREINC
S_PREDEC = 102, // PREDEC
S_POSTINC = 103, // POSTINC
S_POSTDEC = 104, // POSTDEC
S_YYACCEPT = 105, // $accept
S_root = 106, // root
S_program = 107, // program
S_inline = 108, // inline
S_include = 109, // include
S_declaration = 110, // declaration
S_decl_usingtree = 111, // decl_usingtree
S_decl_constant = 112, // decl_constant
S_decl_thread = 113, // decl_thread
S_stmt = 114, // stmt
S_stmt_dev = 115, // stmt_dev
S_stmt_block = 116, // stmt_block
S_stmt_list = 117, // stmt_list
S_stmt_expr = 118, // stmt_expr
S_stmt_call = 119, // stmt_call
S_stmt_assign = 120, // stmt_assign
S_stmt_endon = 121, // stmt_endon
S_stmt_notify = 122, // stmt_notify
S_stmt_wait = 123, // stmt_wait
S_stmt_waittill = 124, // stmt_waittill
S_stmt_waittillmatch = 125, // stmt_waittillmatch
S_stmt_waittillframeend = 126, // stmt_waittillframeend
S_stmt_if = 127, // stmt_if
S_stmt_ifelse = 128, // stmt_ifelse
S_stmt_while = 129, // stmt_while
S_stmt_dowhile = 130, // stmt_dowhile
S_stmt_for = 131, // stmt_for
S_stmt_foreach = 132, // stmt_foreach
S_stmt_switch = 133, // stmt_switch
S_stmt_case = 134, // stmt_case
S_stmt_default = 135, // stmt_default
S_stmt_break = 136, // stmt_break
S_stmt_continue = 137, // stmt_continue
S_stmt_return = 138, // stmt_return
S_stmt_breakpoint = 139, // stmt_breakpoint
S_stmt_prof_begin = 140, // stmt_prof_begin
S_stmt_prof_end = 141, // stmt_prof_end
S_expr = 142, // expr
S_expr_or_empty = 143, // expr_or_empty
S_expr_assign = 144, // expr_assign
S_expr_increment = 145, // expr_increment
S_expr_decrement = 146, // expr_decrement
S_expr_ternary = 147, // expr_ternary
S_expr_binary = 148, // expr_binary
S_expr_primitive = 149, // expr_primitive
S_expr_complement = 150, // expr_complement
S_expr_not = 151, // expr_not
S_expr_call = 152, // expr_call
S_expr_method = 153, // expr_method
S_expr_function = 154, // expr_function
S_expr_pointer = 155, // expr_pointer
S_expr_add_array = 156, // expr_add_array
S_expr_parameters = 157, // expr_parameters
S_expr_arguments = 158, // expr_arguments
S_expr_arguments_no_empty = 159, // expr_arguments_no_empty
S_expr_reference = 160, // expr_reference
S_expr_array = 161, // expr_array
S_expr_field = 162, // expr_field
S_expr_size = 163, // expr_size
S_expr_paren = 164, // expr_paren
S_expr_object = 165, // expr_object
S_expr_thisthread = 166, // expr_thisthread
S_expr_empty_array = 167, // expr_empty_array
S_expr_undefined = 168, // expr_undefined
S_expr_game = 169, // expr_game
S_expr_self = 170, // expr_self
S_expr_anim = 171, // expr_anim
S_expr_level = 172, // expr_level
S_expr_animation = 173, // expr_animation
S_expr_animtree = 174, // expr_animtree
S_expr_identifier = 175, // expr_identifier
S_expr_path = 176, // expr_path
S_expr_istring = 177, // expr_istring
S_expr_string = 178, // expr_string
S_expr_color = 179, // expr_color
S_expr_vector = 180, // expr_vector
S_expr_float = 181, // expr_float
S_expr_integer = 182, // expr_integer
S_expr_false = 183, // expr_false
S_expr_true = 184 // expr_true
S_HSDEFINE = 3, // "#define"
S_HSUNDEF = 4, // "#undef"
S_HSIFDEF = 5, // "#ifdef"
S_HSIFNDEF = 6, // "#ifndef"
S_HSIF = 7, // "#if"
S_HSELIF = 8, // "#elif"
S_HSELSE = 9, // "#else"
S_HSENDIF = 10, // "#endif"
S_DEVBEGIN = 11, // "/#"
S_DEVEND = 12, // "#/"
S_INLINE = 13, // "#inline"
S_INCLUDE = 14, // "#include"
S_USINGTREE = 15, // "#using_animtree"
S_ANIMTREE = 16, // "#animtree"
S_ENDON = 17, // "endon"
S_NOTIFY = 18, // "notify"
S_WAIT = 19, // "wait"
S_WAITTILL = 20, // "waittill"
S_WAITTILLMATCH = 21, // "waittillmatch"
S_WAITTILLFRAMEEND = 22, // "waittillframeend"
S_IF = 23, // "if"
S_ELSE = 24, // "else"
S_DO = 25, // "do"
S_WHILE = 26, // "while"
S_FOR = 27, // "for"
S_FOREACH = 28, // "foreach"
S_IN = 29, // "in"
S_SWITCH = 30, // "switch"
S_CASE = 31, // "case"
S_DEFAULT = 32, // "default"
S_BREAK = 33, // "break"
S_CONTINUE = 34, // "continue"
S_RETURN = 35, // "return"
S_BREAKPOINT = 36, // "breakpoint"
S_PROFBEGIN = 37, // "prof_begin"
S_PROFEND = 38, // "prof_end"
S_THREAD = 39, // "thread"
S_CHILDTHREAD = 40, // "childthread"
S_THISTHREAD = 41, // "thisthread"
S_CALL = 42, // "call"
S_TRUE = 43, // "true"
S_FALSE = 44, // "false"
S_UNDEFINED = 45, // "undefined"
S_SIZE = 46, // ".size"
S_GAME = 47, // "game"
S_SELF = 48, // "self"
S_ANIM = 49, // "anim"
S_LEVEL = 50, // "level"
S_LPAREN = 51, // "("
S_RPAREN = 52, // ")"
S_LBRACE = 53, // "{"
S_RBRACE = 54, // "}"
S_LBRACKET = 55, // "["
S_RBRACKET = 56, // "]"
S_COMMA = 57, // ","
S_DOT = 58, // "."
S_DOUBLECOLON = 59, // "::"
S_COLON = 60, // ":"
S_SEMICOLON = 61, // ";"
S_QMARK = 62, // "?"
S_INCREMENT = 63, // "++"
S_DECREMENT = 64, // "--"
S_LSHIFT = 65, // "<<"
S_RSHIFT = 66, // ">>"
S_OR = 67, // "||"
S_AND = 68, // "&&"
S_EQUALITY = 69, // "=="
S_INEQUALITY = 70, // "!="
S_LESS_EQUAL = 71, // "<="
S_GREATER_EQUAL = 72, // ">="
S_LESS = 73, // "<"
S_GREATER = 74, // ">"
S_NOT = 75, // "!"
S_COMPLEMENT = 76, // "~"
S_ASSIGN = 77, // "="
S_ASSIGN_ADD = 78, // "+="
S_ASSIGN_SUB = 79, // "-="
S_ASSIGN_MUL = 80, // "*="
S_ASSIGN_DIV = 81, // "/="
S_ASSIGN_MOD = 82, // "%="
S_ASSIGN_BW_OR = 83, // "|="
S_ASSIGN_BW_AND = 84, // "&="
S_ASSIGN_BW_EXOR = 85, // "^="
S_ASSIGN_RSHIFT = 86, // ">>="
S_ASSIGN_LSHIFT = 87, // "<<="
S_BITWISE_OR = 88, // "|"
S_BITWISE_AND = 89, // "&"
S_BITWISE_EXOR = 90, // "^"
S_ADD = 91, // "+"
S_SUB = 92, // "-"
S_MUL = 93, // "*"
S_DIV = 94, // "/"
S_MOD = 95, // "%"
S_FIELD = 96, // "field"
S_PATH = 97, // "path"
S_IDENTIFIER = 98, // "identifier"
S_STRING = 99, // "string literal"
S_ISTRING = 100, // "localized string"
S_COLOR = 101, // "color"
S_FLOAT = 102, // "float"
S_INTEGER = 103, // "integer"
S_ADD_ARRAY = 104, // ADD_ARRAY
S_THEN = 105, // THEN
S_TERN = 106, // TERN
S_NEG = 107, // NEG
S_ANIMREF = 108, // ANIMREF
S_PREINC = 109, // PREINC
S_PREDEC = 110, // PREDEC
S_POSTINC = 111, // POSTINC
S_POSTDEC = 112, // POSTDEC
S_YYACCEPT = 113, // $accept
S_root = 114, // root
S_program = 115, // program
S_inline = 116, // inline
S_include = 117, // include
S_declaration = 118, // declaration
S_decl_usingtree = 119, // decl_usingtree
S_decl_constant = 120, // decl_constant
S_decl_thread = 121, // decl_thread
S_stmt = 122, // stmt
S_stmt_dev = 123, // stmt_dev
S_stmt_block = 124, // stmt_block
S_stmt_list = 125, // stmt_list
S_stmt_expr = 126, // stmt_expr
S_stmt_call = 127, // stmt_call
S_stmt_assign = 128, // stmt_assign
S_stmt_endon = 129, // stmt_endon
S_stmt_notify = 130, // stmt_notify
S_stmt_wait = 131, // stmt_wait
S_stmt_waittill = 132, // stmt_waittill
S_stmt_waittillmatch = 133, // stmt_waittillmatch
S_stmt_waittillframeend = 134, // stmt_waittillframeend
S_stmt_if = 135, // stmt_if
S_stmt_ifelse = 136, // stmt_ifelse
S_stmt_while = 137, // stmt_while
S_stmt_dowhile = 138, // stmt_dowhile
S_stmt_for = 139, // stmt_for
S_stmt_foreach = 140, // stmt_foreach
S_stmt_switch = 141, // stmt_switch
S_stmt_case = 142, // stmt_case
S_stmt_default = 143, // stmt_default
S_stmt_break = 144, // stmt_break
S_stmt_continue = 145, // stmt_continue
S_stmt_return = 146, // stmt_return
S_stmt_breakpoint = 147, // stmt_breakpoint
S_stmt_prof_begin = 148, // stmt_prof_begin
S_stmt_prof_end = 149, // stmt_prof_end
S_expr = 150, // expr
S_expr_or_empty = 151, // expr_or_empty
S_expr_assign = 152, // expr_assign
S_expr_increment = 153, // expr_increment
S_expr_decrement = 154, // expr_decrement
S_expr_ternary = 155, // expr_ternary
S_expr_binary = 156, // expr_binary
S_expr_primitive = 157, // expr_primitive
S_expr_complement = 158, // expr_complement
S_expr_not = 159, // expr_not
S_expr_call = 160, // expr_call
S_expr_method = 161, // expr_method
S_expr_function = 162, // expr_function
S_expr_pointer = 163, // expr_pointer
S_expr_add_array = 164, // expr_add_array
S_expr_parameters = 165, // expr_parameters
S_expr_arguments = 166, // expr_arguments
S_expr_arguments_no_empty = 167, // expr_arguments_no_empty
S_expr_reference = 168, // expr_reference
S_expr_array = 169, // expr_array
S_expr_field = 170, // expr_field
S_expr_size = 171, // expr_size
S_expr_paren = 172, // expr_paren
S_expr_object = 173, // expr_object
S_expr_thisthread = 174, // expr_thisthread
S_expr_empty_array = 175, // expr_empty_array
S_expr_undefined = 176, // expr_undefined
S_expr_game = 177, // expr_game
S_expr_self = 178, // expr_self
S_expr_anim = 179, // expr_anim
S_expr_level = 180, // expr_level
S_expr_animation = 181, // expr_animation
S_expr_animtree = 182, // expr_animtree
S_expr_identifier = 183, // expr_identifier
S_expr_path = 184, // expr_path
S_expr_istring = 185, // expr_istring
S_expr_string = 186, // expr_string
S_expr_color = 187, // expr_color
S_expr_vector = 188, // expr_vector
S_expr_float = 189, // expr_float
S_expr_integer = 190, // expr_integer
S_expr_false = 191, // expr_false
S_expr_true = 192 // expr_true
};
};
@ -2751,6 +2767,126 @@ switch (yykind)
return symbol_type (token::IW5UNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSDEFINE (location_type l)
{
return symbol_type (token::HSDEFINE, std::move (l));
}
#else
static
symbol_type
make_HSDEFINE (const location_type& l)
{
return symbol_type (token::HSDEFINE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSUNDEF (location_type l)
{
return symbol_type (token::HSUNDEF, std::move (l));
}
#else
static
symbol_type
make_HSUNDEF (const location_type& l)
{
return symbol_type (token::HSUNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFDEF (location_type l)
{
return symbol_type (token::HSIFDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFDEF (const location_type& l)
{
return symbol_type (token::HSIFDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFNDEF (location_type l)
{
return symbol_type (token::HSIFNDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFNDEF (const location_type& l)
{
return symbol_type (token::HSIFNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIF (location_type l)
{
return symbol_type (token::HSIF, std::move (l));
}
#else
static
symbol_type
make_HSIF (const location_type& l)
{
return symbol_type (token::HSIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELIF (location_type l)
{
return symbol_type (token::HSELIF, std::move (l));
}
#else
static
symbol_type
make_HSELIF (const location_type& l)
{
return symbol_type (token::HSELIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELSE (location_type l)
{
return symbol_type (token::HSELSE, std::move (l));
}
#else
static
symbol_type
make_HSELSE (const location_type& l)
{
return symbol_type (token::HSELSE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSENDIF (location_type l)
{
return symbol_type (token::HSENDIF, std::move (l));
}
#else
static
symbol_type
make_HSENDIF (const location_type& l)
{
return symbol_type (token::HSENDIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -5311,7 +5447,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw5
#line 5315 "parser.hpp"
#line 5451 "parser.hpp"

View File

@ -16,57 +16,6 @@ xsk::gsc::iw6::parser::symbol_type IW6lex(xsk::gsc::iw6::lexer& lexer)
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() : length(0)
{
data = static_cast<char*>(std::malloc(max_buf_size));
@ -129,7 +78,7 @@ void reader::advance()
}
}
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(xsk::gsc::location(&name)),
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(location(&name)),
mode_(build::dev), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
{
reader_.init(data, size);
@ -140,7 +89,7 @@ void lexer::push_header(const std::string& file)
try
{
if (header_top_++ >= 10)
throw xsk::gsc::error("maximum gsh depth exceeded '10'");
throw comp_error(loc_, "maximum gsh depth exceeded '10'");
auto data = resolver::file_data(file + ".gsh");
@ -151,7 +100,7 @@ void lexer::push_header(const std::string& file)
}
catch (const std::exception& e)
{
throw xsk::gsc::error("parsing header file '" + file + "': " + e.what());
throw error("parsing header file '" + file + "': " + e.what());
}
}
@ -164,7 +113,7 @@ void lexer::pop_header()
readers_.pop();
}
void lexer::restrict_header(const xsk::gsc::location& loc)
void lexer::ban_header(const location& loc)
{
if (header_top_ > 0)
{
@ -172,7 +121,7 @@ void lexer::restrict_header(const xsk::gsc::location& loc)
}
}
auto lexer::lex() -> xsk::gsc::iw6::parser::symbol_type
auto lexer::lex() -> parser::symbol_type
{
buffer_.length = 0;
state_ = state::start;
@ -193,7 +142,7 @@ auto lexer::lex() -> xsk::gsc::iw6::parser::symbol_type
if (header_top_ > 0)
pop_header();
else
return iw6::parser::make_IW6EOF(loc_);
return parser::make_IW6EOF(loc_);
}
reader_.advance();
@ -211,22 +160,22 @@ auto lexer::lex() -> xsk::gsc::iw6::parser::symbol_type
continue;
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
return iw6::parser::make_DIV(loc_);
return parser::make_DIV(loc_);
reader_.advance();
if (last == '=')
return iw6::parser::make_ASSIGN_DIV(loc_);
return parser::make_ASSIGN_DIV(loc_);
if (last == '#')
{
if (indev_)
throw comp_error(loc_, "cannot recurse devblock ('/#')");
if (mode_ == xsk::gsc::build::dev)
if (mode_ == build::dev)
{
indev_ = true;
return iw6::parser::make_DEVBEGIN(loc_);
return parser::make_DEVBEGIN(loc_);
}
else
{
@ -290,7 +239,7 @@ auto lexer::lex() -> xsk::gsc::iw6::parser::symbol_type
indev_ = false;
reader_.advance();
return iw6::parser::make_DEVEND(loc_);
return parser::make_DEVEND(loc_);
}
buffer_.push(last);
@ -303,12 +252,12 @@ auto lexer::lex() -> xsk::gsc::iw6::parser::symbol_type
goto lex_name;
case '*':
if (curr != '/' && curr != '=')
return iw6::parser::make_MUL(loc_);
return parser::make_MUL(loc_);
reader_.advance();
if (last == '=')
return iw6::parser::make_ASSIGN_MUL(loc_);
return parser::make_ASSIGN_MUL(loc_);
throw comp_error(loc_, "unmatched multiline comment end ('*/')");
case '"':
@ -323,127 +272,127 @@ auto lexer::lex() -> xsk::gsc::iw6::parser::symbol_type
state_ = state::field;
goto lex_name_or_number;
case '(':
return iw6::parser::make_LPAREN(loc_);
return parser::make_LPAREN(loc_);
case ')':
return iw6::parser::make_RPAREN(loc_);
return parser::make_RPAREN(loc_);
case '{':
return iw6::parser::make_LBRACE(loc_);
return parser::make_LBRACE(loc_);
case '}':
return iw6::parser::make_RBRACE(loc_);
return parser::make_RBRACE(loc_);
case '[':
return iw6::parser::make_LBRACKET(loc_);
return parser::make_LBRACKET(loc_);
case ']':
return iw6::parser::make_RBRACKET(loc_);
return parser::make_RBRACKET(loc_);
case ',':
return iw6::parser::make_COMMA(loc_);
return parser::make_COMMA(loc_);
case ';':
return iw6::parser::make_SEMICOLON(loc_);
return parser::make_SEMICOLON(loc_);
case ':':
if (curr != ':')
return iw6::parser::make_COLON(loc_);
return parser::make_COLON(loc_);
reader_.advance();
return iw6::parser::make_DOUBLECOLON(loc_);
return parser::make_DOUBLECOLON(loc_);
case '?':
return iw6::parser::make_QMARK(loc_);
return parser::make_QMARK(loc_);
case '=':
if (curr != '=')
return iw6::parser::make_ASSIGN(loc_);
return parser::make_ASSIGN(loc_);
reader_.advance();
return iw6::parser::make_EQUALITY(loc_);
return parser::make_EQUALITY(loc_);
case '+':
if (curr != '+' && curr != '=')
return iw6::parser::make_ADD(loc_);
return parser::make_ADD(loc_);
reader_.advance();
if (last == '+')
return iw6::parser::make_INCREMENT(loc_);
return parser::make_INCREMENT(loc_);
return iw6::parser::make_ASSIGN_ADD(loc_);
return parser::make_ASSIGN_ADD(loc_);
case '-':
if (curr != '-' && curr != '=')
return iw6::parser::make_SUB(loc_);
return parser::make_SUB(loc_);
reader_.advance();
if (last == '-')
return iw6::parser::make_DECREMENT(loc_);
return parser::make_DECREMENT(loc_);
return iw6::parser::make_ASSIGN_SUB(loc_);
return parser::make_ASSIGN_SUB(loc_);
case '%':
if (curr != '=')
return iw6::parser::make_MOD(loc_);
return parser::make_MOD(loc_);
reader_.advance();
return iw6::parser::make_ASSIGN_MOD(loc_);
return parser::make_ASSIGN_MOD(loc_);
case '|':
if (curr != '|' && curr != '=')
return iw6::parser::make_BITWISE_OR(loc_);
return parser::make_BITWISE_OR(loc_);
reader_.advance();
if (last == '|')
return iw6::parser::make_OR(loc_);
return parser::make_OR(loc_);
return iw6::parser::make_ASSIGN_BW_OR(loc_);
return parser::make_ASSIGN_BW_OR(loc_);
case '&':
if (curr != '&' && curr != '=' && curr != '"' && curr != '\'')
return iw6::parser::make_BITWISE_AND(loc_);
return parser::make_BITWISE_AND(loc_);
reader_.advance();
if (last == '&')
return iw6::parser::make_AND(loc_);
return parser::make_AND(loc_);
if (last == '=')
return iw6::parser::make_ASSIGN_BW_AND(loc_);
return parser::make_ASSIGN_BW_AND(loc_);
state_ = state::localize;
goto lex_string;
case '^':
if (curr != '=')
return iw6::parser::make_BITWISE_EXOR(loc_);
return parser::make_BITWISE_EXOR(loc_);
reader_.advance();
return iw6::parser::make_ASSIGN_BW_EXOR(loc_);
return parser::make_ASSIGN_BW_EXOR(loc_);
case '!':
if (curr != '=')
return iw6::parser::make_NOT(loc_);
return parser::make_NOT(loc_);
reader_.advance();
return iw6::parser::make_INEQUALITY(loc_);
return parser::make_INEQUALITY(loc_);
case '~':
return iw6::parser::make_COMPLEMENT(loc_);
return parser::make_COMPLEMENT(loc_);
case '<':
if (curr != '<' && curr != '=')
return iw6::parser::make_LESS(loc_);
return parser::make_LESS(loc_);
reader_.advance();
if (last == '=')
return iw6::parser::make_LESS_EQUAL(loc_);
return parser::make_LESS_EQUAL(loc_);
if (curr != '=')
return iw6::parser::make_LSHIFT(loc_);
return parser::make_LSHIFT(loc_);
reader_.advance();
return iw6::parser::make_ASSIGN_LSHIFT(loc_);
return parser::make_ASSIGN_LSHIFT(loc_);
case '>':
if (curr != '>' && curr != '=')
return iw6::parser::make_GREATER(loc_);
return parser::make_GREATER(loc_);
reader_.advance();
if (last == '=')
return iw6::parser::make_GREATER_EQUAL(loc_);
return parser::make_GREATER_EQUAL(loc_);
if (curr != '=')
return iw6::parser::make_RSHIFT(loc_);
return parser::make_RSHIFT(loc_);
reader_.advance();
return iw6::parser::make_ASSIGN_RSHIFT(loc_);
return parser::make_ASSIGN_RSHIFT(loc_);
default:
lex_name_or_number:
if (last >= '0' && last <= '9')
@ -496,9 +445,9 @@ lex_string:
}
if (state_ == state::localize)
return iw6::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return iw6::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
lex_name:
buffer_.push(last);
@ -533,44 +482,55 @@ lex_name:
if (std::string_view(buffer_.data, buffer_.length) == "size")
{
return iw6::parser::make_SIZE(loc_);
return parser::make_SIZE(loc_);
}
return iw6::parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
}
else if (state_ == state::preprocessor)
{
if (path)
throw comp_error(loc_, "invalid preprocessor directive");
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
auto token = parser::token::IW6UNDEF;
if (key != keyword::KW_INVALID)
return keyword_token(key);
if (buffer_.length < 16)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
// TODO: call preprocessor(key);
if(itr != keyword_map.end())
{
if (itr->second > parser::token::HSENDIF)
return parser::symbol_type(itr->second, loc_);
token = itr->second;
}
}
// TODO: call preprocessor(token);
throw comp_error(loc_, "unknown preprocessor directive");
state_ = state::start;
continue;
}
else
{
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
if (buffer_.length < 17)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
if (key != keyword::KW_INVALID)
return keyword_token(key);
if(itr != keyword_map.end())
return parser::symbol_type(itr->second, loc_);
}
if (path)
{
if (buffer_.data[buffer_.length - 1] == '/')
throw comp_error(loc_, "invalid path end '\\'");
//return iw6::parser::make_PATH(xsk::gsc::iw6::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return iw6::parser::make_PATH(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_PATH(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
//return iw6::parser::make_IDENTIFIER(xsk::gsc::iw6::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return iw6::parser::make_IDENTIFIER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_IDENTIFIER(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
lex_number:
@ -621,9 +581,9 @@ lex_number:
throw comp_error(loc_, "invalid number literal");
if (state_ == state::field || dot || flt)
return iw6::parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return iw6::parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
}
else if (curr == 'o')
{
@ -655,7 +615,7 @@ lex_number:
if (last == '\'' || buffer_.length <= 0)
throw comp_error(loc_, "invalid octal literal");
return iw6::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
}
else if (curr == 'b')
{
@ -689,7 +649,7 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid binary literal");
return iw6::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
}
else if (curr == 'x')
{
@ -723,176 +683,59 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid hexadecimal literal");
return iw6::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
}
// cant get here!
}
}
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;
}
return keyword::KW_INVALID;
}
std::unordered_map<std::string_view, keyword> lexer::keywords
const std::unordered_map<std::string_view, parser::token::token_kind_type> lexer::keyword_map
{{
/* { "#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 },
{ "#define", parser::token::HSDEFINE },
{ "#undef", parser::token::HSUNDEF },
{ "#ifdef", parser::token::HSIFDEF },
{ "#ifndef", parser::token::HSIFNDEF },
{ "#if", parser::token::HSIF },
{ "#elif", parser::token::HSELIF },
{ "#else", parser::token::HSELSE },
{ "#endif", parser::token::HSENDIF },
{ "#inline", parser::token::INLINE },
{ "#include", parser::token::INCLUDE },
{ "#using_animtree", parser::token::USINGTREE },
{ "#animtree", parser::token::ANIMTREE },
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
{ "if", parser::token::IF },
{ "else", parser::token::ELSE },
{ "do", parser::token::DO },
{ "while", parser::token::WHILE },
{ "for", parser::token::FOR },
{ "foreach", parser::token::FOREACH },
{ "in", parser::token::IN },
{ "switch", parser::token::SWITCH },
{ "case", parser::token::CASE },
{ "default", parser::token::DEFAULT },
{ "break", parser::token::BREAK },
{ "continue", parser::token::CONTINUE },
{ "return", parser::token::RETURN },
{ "breakpoint", parser::token::BREAKPOINT },
{ "prof_begin", parser::token::PROFBEGIN },
{ "prof_end", parser::token::PROFEND },
{ "thread", parser::token::THREAD },
{ "childthread", parser::token::CHILDTHREAD },
{ "thisthread", parser::token::THISTHREAD },
{ "call", parser::token::CALL },
{ "true", parser::token::TRUE },
{ "false", parser::token::FALSE },
{ "undefined", parser::token::UNDEFINED },
{ "game", parser::token::GAME },
{ "self", parser::token::SELF },
{ "anim", parser::token::ANIM },
{ "level", parser::token::LEVEL },
}};
} // namespace xsk::gsc::iw6

View File

@ -10,8 +10,6 @@
namespace xsk::gsc::iw6
{
enum class keyword;
constexpr size_t max_buf_size = 0x2000;
struct buffer
@ -53,26 +51,22 @@ class lexer
reader reader_;
buffer buffer_;
location loc_;
build mode_;
std::stack<location> locs_;
std::stack<reader> readers_;
std::uint32_t header_top_;
state state_;
build mode_;
bool indev_;
public:
lexer(const std::string& name, const char* data, size_t size);
auto lex() -> xsk::gsc::iw6::parser::symbol_type;
auto lex() -> parser::symbol_type;
void push_header(const std::string& file);
void pop_header();
void restrict_header(const xsk::gsc::location& loc);
void ban_header(const location& loc);
private:
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<std::string_view, keyword> keywords;
static const std::unordered_map<std::string_view, parser::token::token_kind_type> keyword_map;
};
} // namespace xsk::gsc::iw6

File diff suppressed because it is too large Load Diff

View File

@ -674,108 +674,116 @@ namespace xsk { namespace gsc { namespace iw6 {
IW6EOF = 0, // "end of file"
IW6error = 1, // error
IW6UNDEF = 2, // "invalid token"
DEVBEGIN = 3, // "/#"
DEVEND = 4, // "#/"
INLINE = 5, // "#inline"
INCLUDE = 6, // "#include"
USINGTREE = 7, // "#using_animtree"
ANIMTREE = 8, // "#animtree"
ENDON = 9, // "endon"
NOTIFY = 10, // "notify"
WAIT = 11, // "wait"
WAITTILL = 12, // "waittill"
WAITTILLMATCH = 13, // "waittillmatch"
WAITTILLFRAMEEND = 14, // "waittillframeend"
IF = 15, // "if"
ELSE = 16, // "else"
DO = 17, // "do"
WHILE = 18, // "while"
FOR = 19, // "for"
FOREACH = 20, // "foreach"
IN = 21, // "in"
SWITCH = 22, // "switch"
CASE = 23, // "case"
DEFAULT = 24, // "default"
BREAK = 25, // "break"
CONTINUE = 26, // "continue"
RETURN = 27, // "return"
BREAKPOINT = 28, // "breakpoint"
PROFBEGIN = 29, // "prof_begin"
PROFEND = 30, // "prof_end"
THREAD = 31, // "thread"
CHILDTHREAD = 32, // "childthread"
THISTHREAD = 33, // "thisthread"
CALL = 34, // "call"
TRUE = 35, // "true"
FALSE = 36, // "false"
UNDEFINED = 37, // "undefined"
SIZE = 38, // ".size"
GAME = 39, // "game"
SELF = 40, // "self"
ANIM = 41, // "anim"
LEVEL = 42, // "level"
LPAREN = 43, // "("
RPAREN = 44, // ")"
LBRACE = 45, // "{"
RBRACE = 46, // "}"
LBRACKET = 47, // "["
RBRACKET = 48, // "]"
COMMA = 49, // ","
DOT = 50, // "."
DOUBLECOLON = 51, // "::"
COLON = 52, // ":"
SEMICOLON = 53, // ";"
QMARK = 54, // "?"
INCREMENT = 55, // "++"
DECREMENT = 56, // "--"
LSHIFT = 57, // "<<"
RSHIFT = 58, // ">>"
OR = 59, // "||"
AND = 60, // "&&"
EQUALITY = 61, // "=="
INEQUALITY = 62, // "!="
LESS_EQUAL = 63, // "<="
GREATER_EQUAL = 64, // ">="
LESS = 65, // "<"
GREATER = 66, // ">"
NOT = 67, // "!"
COMPLEMENT = 68, // "~"
ASSIGN = 69, // "="
ASSIGN_ADD = 70, // "+="
ASSIGN_SUB = 71, // "-="
ASSIGN_MUL = 72, // "*="
ASSIGN_DIV = 73, // "/="
ASSIGN_MOD = 74, // "%="
ASSIGN_BW_OR = 75, // "|="
ASSIGN_BW_AND = 76, // "&="
ASSIGN_BW_EXOR = 77, // "^="
ASSIGN_RSHIFT = 78, // ">>="
ASSIGN_LSHIFT = 79, // "<<="
BITWISE_OR = 80, // "|"
BITWISE_AND = 81, // "&"
BITWISE_EXOR = 82, // "^"
ADD = 83, // "+"
SUB = 84, // "-"
MUL = 85, // "*"
DIV = 86, // "/"
MOD = 87, // "%"
FIELD = 88, // "field"
PATH = 89, // "path"
IDENTIFIER = 90, // "identifier"
STRING = 91, // "string literal"
ISTRING = 92, // "localized string"
COLOR = 93, // "color"
FLOAT = 94, // "float"
INTEGER = 95, // "integer"
ADD_ARRAY = 96, // ADD_ARRAY
THEN = 97, // THEN
TERN = 98, // TERN
NEG = 99, // NEG
ANIMREF = 100, // ANIMREF
PREINC = 101, // PREINC
PREDEC = 102, // PREDEC
POSTINC = 103, // POSTINC
POSTDEC = 104 // POSTDEC
HSDEFINE = 3, // "#define"
HSUNDEF = 4, // "#undef"
HSIFDEF = 5, // "#ifdef"
HSIFNDEF = 6, // "#ifndef"
HSIF = 7, // "#if"
HSELIF = 8, // "#elif"
HSELSE = 9, // "#else"
HSENDIF = 10, // "#endif"
DEVBEGIN = 11, // "/#"
DEVEND = 12, // "#/"
INLINE = 13, // "#inline"
INCLUDE = 14, // "#include"
USINGTREE = 15, // "#using_animtree"
ANIMTREE = 16, // "#animtree"
ENDON = 17, // "endon"
NOTIFY = 18, // "notify"
WAIT = 19, // "wait"
WAITTILL = 20, // "waittill"
WAITTILLMATCH = 21, // "waittillmatch"
WAITTILLFRAMEEND = 22, // "waittillframeend"
IF = 23, // "if"
ELSE = 24, // "else"
DO = 25, // "do"
WHILE = 26, // "while"
FOR = 27, // "for"
FOREACH = 28, // "foreach"
IN = 29, // "in"
SWITCH = 30, // "switch"
CASE = 31, // "case"
DEFAULT = 32, // "default"
BREAK = 33, // "break"
CONTINUE = 34, // "continue"
RETURN = 35, // "return"
BREAKPOINT = 36, // "breakpoint"
PROFBEGIN = 37, // "prof_begin"
PROFEND = 38, // "prof_end"
THREAD = 39, // "thread"
CHILDTHREAD = 40, // "childthread"
THISTHREAD = 41, // "thisthread"
CALL = 42, // "call"
TRUE = 43, // "true"
FALSE = 44, // "false"
UNDEFINED = 45, // "undefined"
SIZE = 46, // ".size"
GAME = 47, // "game"
SELF = 48, // "self"
ANIM = 49, // "anim"
LEVEL = 50, // "level"
LPAREN = 51, // "("
RPAREN = 52, // ")"
LBRACE = 53, // "{"
RBRACE = 54, // "}"
LBRACKET = 55, // "["
RBRACKET = 56, // "]"
COMMA = 57, // ","
DOT = 58, // "."
DOUBLECOLON = 59, // "::"
COLON = 60, // ":"
SEMICOLON = 61, // ";"
QMARK = 62, // "?"
INCREMENT = 63, // "++"
DECREMENT = 64, // "--"
LSHIFT = 65, // "<<"
RSHIFT = 66, // ">>"
OR = 67, // "||"
AND = 68, // "&&"
EQUALITY = 69, // "=="
INEQUALITY = 70, // "!="
LESS_EQUAL = 71, // "<="
GREATER_EQUAL = 72, // ">="
LESS = 73, // "<"
GREATER = 74, // ">"
NOT = 75, // "!"
COMPLEMENT = 76, // "~"
ASSIGN = 77, // "="
ASSIGN_ADD = 78, // "+="
ASSIGN_SUB = 79, // "-="
ASSIGN_MUL = 80, // "*="
ASSIGN_DIV = 81, // "/="
ASSIGN_MOD = 82, // "%="
ASSIGN_BW_OR = 83, // "|="
ASSIGN_BW_AND = 84, // "&="
ASSIGN_BW_EXOR = 85, // "^="
ASSIGN_RSHIFT = 86, // ">>="
ASSIGN_LSHIFT = 87, // "<<="
BITWISE_OR = 88, // "|"
BITWISE_AND = 89, // "&"
BITWISE_EXOR = 90, // "^"
ADD = 91, // "+"
SUB = 92, // "-"
MUL = 93, // "*"
DIV = 94, // "/"
MOD = 95, // "%"
FIELD = 96, // "field"
PATH = 97, // "path"
IDENTIFIER = 98, // "identifier"
STRING = 99, // "string literal"
ISTRING = 100, // "localized string"
COLOR = 101, // "color"
FLOAT = 102, // "float"
INTEGER = 103, // "integer"
ADD_ARRAY = 104, // ADD_ARRAY
THEN = 105, // THEN
TERN = 106, // TERN
NEG = 107, // NEG
ANIMREF = 108, // ANIMREF
PREINC = 109, // PREINC
PREDEC = 110, // PREDEC
POSTINC = 111, // POSTINC
POSTDEC = 112 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -792,193 +800,201 @@ namespace xsk { namespace gsc { namespace iw6 {
{
enum symbol_kind_type
{
YYNTOKENS = 105, ///< Number of tokens.
YYNTOKENS = 113, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_DEVBEGIN = 3, // "/#"
S_DEVEND = 4, // "#/"
S_INLINE = 5, // "#inline"
S_INCLUDE = 6, // "#include"
S_USINGTREE = 7, // "#using_animtree"
S_ANIMTREE = 8, // "#animtree"
S_ENDON = 9, // "endon"
S_NOTIFY = 10, // "notify"
S_WAIT = 11, // "wait"
S_WAITTILL = 12, // "waittill"
S_WAITTILLMATCH = 13, // "waittillmatch"
S_WAITTILLFRAMEEND = 14, // "waittillframeend"
S_IF = 15, // "if"
S_ELSE = 16, // "else"
S_DO = 17, // "do"
S_WHILE = 18, // "while"
S_FOR = 19, // "for"
S_FOREACH = 20, // "foreach"
S_IN = 21, // "in"
S_SWITCH = 22, // "switch"
S_CASE = 23, // "case"
S_DEFAULT = 24, // "default"
S_BREAK = 25, // "break"
S_CONTINUE = 26, // "continue"
S_RETURN = 27, // "return"
S_BREAKPOINT = 28, // "breakpoint"
S_PROFBEGIN = 29, // "prof_begin"
S_PROFEND = 30, // "prof_end"
S_THREAD = 31, // "thread"
S_CHILDTHREAD = 32, // "childthread"
S_THISTHREAD = 33, // "thisthread"
S_CALL = 34, // "call"
S_TRUE = 35, // "true"
S_FALSE = 36, // "false"
S_UNDEFINED = 37, // "undefined"
S_SIZE = 38, // ".size"
S_GAME = 39, // "game"
S_SELF = 40, // "self"
S_ANIM = 41, // "anim"
S_LEVEL = 42, // "level"
S_LPAREN = 43, // "("
S_RPAREN = 44, // ")"
S_LBRACE = 45, // "{"
S_RBRACE = 46, // "}"
S_LBRACKET = 47, // "["
S_RBRACKET = 48, // "]"
S_COMMA = 49, // ","
S_DOT = 50, // "."
S_DOUBLECOLON = 51, // "::"
S_COLON = 52, // ":"
S_SEMICOLON = 53, // ";"
S_QMARK = 54, // "?"
S_INCREMENT = 55, // "++"
S_DECREMENT = 56, // "--"
S_LSHIFT = 57, // "<<"
S_RSHIFT = 58, // ">>"
S_OR = 59, // "||"
S_AND = 60, // "&&"
S_EQUALITY = 61, // "=="
S_INEQUALITY = 62, // "!="
S_LESS_EQUAL = 63, // "<="
S_GREATER_EQUAL = 64, // ">="
S_LESS = 65, // "<"
S_GREATER = 66, // ">"
S_NOT = 67, // "!"
S_COMPLEMENT = 68, // "~"
S_ASSIGN = 69, // "="
S_ASSIGN_ADD = 70, // "+="
S_ASSIGN_SUB = 71, // "-="
S_ASSIGN_MUL = 72, // "*="
S_ASSIGN_DIV = 73, // "/="
S_ASSIGN_MOD = 74, // "%="
S_ASSIGN_BW_OR = 75, // "|="
S_ASSIGN_BW_AND = 76, // "&="
S_ASSIGN_BW_EXOR = 77, // "^="
S_ASSIGN_RSHIFT = 78, // ">>="
S_ASSIGN_LSHIFT = 79, // "<<="
S_BITWISE_OR = 80, // "|"
S_BITWISE_AND = 81, // "&"
S_BITWISE_EXOR = 82, // "^"
S_ADD = 83, // "+"
S_SUB = 84, // "-"
S_MUL = 85, // "*"
S_DIV = 86, // "/"
S_MOD = 87, // "%"
S_FIELD = 88, // "field"
S_PATH = 89, // "path"
S_IDENTIFIER = 90, // "identifier"
S_STRING = 91, // "string literal"
S_ISTRING = 92, // "localized string"
S_COLOR = 93, // "color"
S_FLOAT = 94, // "float"
S_INTEGER = 95, // "integer"
S_ADD_ARRAY = 96, // ADD_ARRAY
S_THEN = 97, // THEN
S_TERN = 98, // TERN
S_NEG = 99, // NEG
S_ANIMREF = 100, // ANIMREF
S_PREINC = 101, // PREINC
S_PREDEC = 102, // PREDEC
S_POSTINC = 103, // POSTINC
S_POSTDEC = 104, // POSTDEC
S_YYACCEPT = 105, // $accept
S_root = 106, // root
S_program = 107, // program
S_inline = 108, // inline
S_include = 109, // include
S_declaration = 110, // declaration
S_decl_usingtree = 111, // decl_usingtree
S_decl_constant = 112, // decl_constant
S_decl_thread = 113, // decl_thread
S_stmt = 114, // stmt
S_stmt_dev = 115, // stmt_dev
S_stmt_block = 116, // stmt_block
S_stmt_list = 117, // stmt_list
S_stmt_expr = 118, // stmt_expr
S_stmt_call = 119, // stmt_call
S_stmt_assign = 120, // stmt_assign
S_stmt_endon = 121, // stmt_endon
S_stmt_notify = 122, // stmt_notify
S_stmt_wait = 123, // stmt_wait
S_stmt_waittill = 124, // stmt_waittill
S_stmt_waittillmatch = 125, // stmt_waittillmatch
S_stmt_waittillframeend = 126, // stmt_waittillframeend
S_stmt_if = 127, // stmt_if
S_stmt_ifelse = 128, // stmt_ifelse
S_stmt_while = 129, // stmt_while
S_stmt_dowhile = 130, // stmt_dowhile
S_stmt_for = 131, // stmt_for
S_stmt_foreach = 132, // stmt_foreach
S_stmt_switch = 133, // stmt_switch
S_stmt_case = 134, // stmt_case
S_stmt_default = 135, // stmt_default
S_stmt_break = 136, // stmt_break
S_stmt_continue = 137, // stmt_continue
S_stmt_return = 138, // stmt_return
S_stmt_breakpoint = 139, // stmt_breakpoint
S_stmt_prof_begin = 140, // stmt_prof_begin
S_stmt_prof_end = 141, // stmt_prof_end
S_expr = 142, // expr
S_expr_or_empty = 143, // expr_or_empty
S_expr_assign = 144, // expr_assign
S_expr_increment = 145, // expr_increment
S_expr_decrement = 146, // expr_decrement
S_expr_ternary = 147, // expr_ternary
S_expr_binary = 148, // expr_binary
S_expr_primitive = 149, // expr_primitive
S_expr_complement = 150, // expr_complement
S_expr_not = 151, // expr_not
S_expr_call = 152, // expr_call
S_expr_method = 153, // expr_method
S_expr_function = 154, // expr_function
S_expr_pointer = 155, // expr_pointer
S_expr_add_array = 156, // expr_add_array
S_expr_parameters = 157, // expr_parameters
S_expr_arguments = 158, // expr_arguments
S_expr_arguments_no_empty = 159, // expr_arguments_no_empty
S_expr_reference = 160, // expr_reference
S_expr_array = 161, // expr_array
S_expr_field = 162, // expr_field
S_expr_size = 163, // expr_size
S_expr_paren = 164, // expr_paren
S_expr_object = 165, // expr_object
S_expr_thisthread = 166, // expr_thisthread
S_expr_empty_array = 167, // expr_empty_array
S_expr_undefined = 168, // expr_undefined
S_expr_game = 169, // expr_game
S_expr_self = 170, // expr_self
S_expr_anim = 171, // expr_anim
S_expr_level = 172, // expr_level
S_expr_animation = 173, // expr_animation
S_expr_animtree = 174, // expr_animtree
S_expr_identifier = 175, // expr_identifier
S_expr_path = 176, // expr_path
S_expr_istring = 177, // expr_istring
S_expr_string = 178, // expr_string
S_expr_color = 179, // expr_color
S_expr_vector = 180, // expr_vector
S_expr_float = 181, // expr_float
S_expr_integer = 182, // expr_integer
S_expr_false = 183, // expr_false
S_expr_true = 184 // expr_true
S_HSDEFINE = 3, // "#define"
S_HSUNDEF = 4, // "#undef"
S_HSIFDEF = 5, // "#ifdef"
S_HSIFNDEF = 6, // "#ifndef"
S_HSIF = 7, // "#if"
S_HSELIF = 8, // "#elif"
S_HSELSE = 9, // "#else"
S_HSENDIF = 10, // "#endif"
S_DEVBEGIN = 11, // "/#"
S_DEVEND = 12, // "#/"
S_INLINE = 13, // "#inline"
S_INCLUDE = 14, // "#include"
S_USINGTREE = 15, // "#using_animtree"
S_ANIMTREE = 16, // "#animtree"
S_ENDON = 17, // "endon"
S_NOTIFY = 18, // "notify"
S_WAIT = 19, // "wait"
S_WAITTILL = 20, // "waittill"
S_WAITTILLMATCH = 21, // "waittillmatch"
S_WAITTILLFRAMEEND = 22, // "waittillframeend"
S_IF = 23, // "if"
S_ELSE = 24, // "else"
S_DO = 25, // "do"
S_WHILE = 26, // "while"
S_FOR = 27, // "for"
S_FOREACH = 28, // "foreach"
S_IN = 29, // "in"
S_SWITCH = 30, // "switch"
S_CASE = 31, // "case"
S_DEFAULT = 32, // "default"
S_BREAK = 33, // "break"
S_CONTINUE = 34, // "continue"
S_RETURN = 35, // "return"
S_BREAKPOINT = 36, // "breakpoint"
S_PROFBEGIN = 37, // "prof_begin"
S_PROFEND = 38, // "prof_end"
S_THREAD = 39, // "thread"
S_CHILDTHREAD = 40, // "childthread"
S_THISTHREAD = 41, // "thisthread"
S_CALL = 42, // "call"
S_TRUE = 43, // "true"
S_FALSE = 44, // "false"
S_UNDEFINED = 45, // "undefined"
S_SIZE = 46, // ".size"
S_GAME = 47, // "game"
S_SELF = 48, // "self"
S_ANIM = 49, // "anim"
S_LEVEL = 50, // "level"
S_LPAREN = 51, // "("
S_RPAREN = 52, // ")"
S_LBRACE = 53, // "{"
S_RBRACE = 54, // "}"
S_LBRACKET = 55, // "["
S_RBRACKET = 56, // "]"
S_COMMA = 57, // ","
S_DOT = 58, // "."
S_DOUBLECOLON = 59, // "::"
S_COLON = 60, // ":"
S_SEMICOLON = 61, // ";"
S_QMARK = 62, // "?"
S_INCREMENT = 63, // "++"
S_DECREMENT = 64, // "--"
S_LSHIFT = 65, // "<<"
S_RSHIFT = 66, // ">>"
S_OR = 67, // "||"
S_AND = 68, // "&&"
S_EQUALITY = 69, // "=="
S_INEQUALITY = 70, // "!="
S_LESS_EQUAL = 71, // "<="
S_GREATER_EQUAL = 72, // ">="
S_LESS = 73, // "<"
S_GREATER = 74, // ">"
S_NOT = 75, // "!"
S_COMPLEMENT = 76, // "~"
S_ASSIGN = 77, // "="
S_ASSIGN_ADD = 78, // "+="
S_ASSIGN_SUB = 79, // "-="
S_ASSIGN_MUL = 80, // "*="
S_ASSIGN_DIV = 81, // "/="
S_ASSIGN_MOD = 82, // "%="
S_ASSIGN_BW_OR = 83, // "|="
S_ASSIGN_BW_AND = 84, // "&="
S_ASSIGN_BW_EXOR = 85, // "^="
S_ASSIGN_RSHIFT = 86, // ">>="
S_ASSIGN_LSHIFT = 87, // "<<="
S_BITWISE_OR = 88, // "|"
S_BITWISE_AND = 89, // "&"
S_BITWISE_EXOR = 90, // "^"
S_ADD = 91, // "+"
S_SUB = 92, // "-"
S_MUL = 93, // "*"
S_DIV = 94, // "/"
S_MOD = 95, // "%"
S_FIELD = 96, // "field"
S_PATH = 97, // "path"
S_IDENTIFIER = 98, // "identifier"
S_STRING = 99, // "string literal"
S_ISTRING = 100, // "localized string"
S_COLOR = 101, // "color"
S_FLOAT = 102, // "float"
S_INTEGER = 103, // "integer"
S_ADD_ARRAY = 104, // ADD_ARRAY
S_THEN = 105, // THEN
S_TERN = 106, // TERN
S_NEG = 107, // NEG
S_ANIMREF = 108, // ANIMREF
S_PREINC = 109, // PREINC
S_PREDEC = 110, // PREDEC
S_POSTINC = 111, // POSTINC
S_POSTDEC = 112, // POSTDEC
S_YYACCEPT = 113, // $accept
S_root = 114, // root
S_program = 115, // program
S_inline = 116, // inline
S_include = 117, // include
S_declaration = 118, // declaration
S_decl_usingtree = 119, // decl_usingtree
S_decl_constant = 120, // decl_constant
S_decl_thread = 121, // decl_thread
S_stmt = 122, // stmt
S_stmt_dev = 123, // stmt_dev
S_stmt_block = 124, // stmt_block
S_stmt_list = 125, // stmt_list
S_stmt_expr = 126, // stmt_expr
S_stmt_call = 127, // stmt_call
S_stmt_assign = 128, // stmt_assign
S_stmt_endon = 129, // stmt_endon
S_stmt_notify = 130, // stmt_notify
S_stmt_wait = 131, // stmt_wait
S_stmt_waittill = 132, // stmt_waittill
S_stmt_waittillmatch = 133, // stmt_waittillmatch
S_stmt_waittillframeend = 134, // stmt_waittillframeend
S_stmt_if = 135, // stmt_if
S_stmt_ifelse = 136, // stmt_ifelse
S_stmt_while = 137, // stmt_while
S_stmt_dowhile = 138, // stmt_dowhile
S_stmt_for = 139, // stmt_for
S_stmt_foreach = 140, // stmt_foreach
S_stmt_switch = 141, // stmt_switch
S_stmt_case = 142, // stmt_case
S_stmt_default = 143, // stmt_default
S_stmt_break = 144, // stmt_break
S_stmt_continue = 145, // stmt_continue
S_stmt_return = 146, // stmt_return
S_stmt_breakpoint = 147, // stmt_breakpoint
S_stmt_prof_begin = 148, // stmt_prof_begin
S_stmt_prof_end = 149, // stmt_prof_end
S_expr = 150, // expr
S_expr_or_empty = 151, // expr_or_empty
S_expr_assign = 152, // expr_assign
S_expr_increment = 153, // expr_increment
S_expr_decrement = 154, // expr_decrement
S_expr_ternary = 155, // expr_ternary
S_expr_binary = 156, // expr_binary
S_expr_primitive = 157, // expr_primitive
S_expr_complement = 158, // expr_complement
S_expr_not = 159, // expr_not
S_expr_call = 160, // expr_call
S_expr_method = 161, // expr_method
S_expr_function = 162, // expr_function
S_expr_pointer = 163, // expr_pointer
S_expr_add_array = 164, // expr_add_array
S_expr_parameters = 165, // expr_parameters
S_expr_arguments = 166, // expr_arguments
S_expr_arguments_no_empty = 167, // expr_arguments_no_empty
S_expr_reference = 168, // expr_reference
S_expr_array = 169, // expr_array
S_expr_field = 170, // expr_field
S_expr_size = 171, // expr_size
S_expr_paren = 172, // expr_paren
S_expr_object = 173, // expr_object
S_expr_thisthread = 174, // expr_thisthread
S_expr_empty_array = 175, // expr_empty_array
S_expr_undefined = 176, // expr_undefined
S_expr_game = 177, // expr_game
S_expr_self = 178, // expr_self
S_expr_anim = 179, // expr_anim
S_expr_level = 180, // expr_level
S_expr_animation = 181, // expr_animation
S_expr_animtree = 182, // expr_animtree
S_expr_identifier = 183, // expr_identifier
S_expr_path = 184, // expr_path
S_expr_istring = 185, // expr_istring
S_expr_string = 186, // expr_string
S_expr_color = 187, // expr_color
S_expr_vector = 188, // expr_vector
S_expr_float = 189, // expr_float
S_expr_integer = 190, // expr_integer
S_expr_false = 191, // expr_false
S_expr_true = 192 // expr_true
};
};
@ -2751,6 +2767,126 @@ switch (yykind)
return symbol_type (token::IW6UNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSDEFINE (location_type l)
{
return symbol_type (token::HSDEFINE, std::move (l));
}
#else
static
symbol_type
make_HSDEFINE (const location_type& l)
{
return symbol_type (token::HSDEFINE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSUNDEF (location_type l)
{
return symbol_type (token::HSUNDEF, std::move (l));
}
#else
static
symbol_type
make_HSUNDEF (const location_type& l)
{
return symbol_type (token::HSUNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFDEF (location_type l)
{
return symbol_type (token::HSIFDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFDEF (const location_type& l)
{
return symbol_type (token::HSIFDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFNDEF (location_type l)
{
return symbol_type (token::HSIFNDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFNDEF (const location_type& l)
{
return symbol_type (token::HSIFNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIF (location_type l)
{
return symbol_type (token::HSIF, std::move (l));
}
#else
static
symbol_type
make_HSIF (const location_type& l)
{
return symbol_type (token::HSIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELIF (location_type l)
{
return symbol_type (token::HSELIF, std::move (l));
}
#else
static
symbol_type
make_HSELIF (const location_type& l)
{
return symbol_type (token::HSELIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELSE (location_type l)
{
return symbol_type (token::HSELSE, std::move (l));
}
#else
static
symbol_type
make_HSELSE (const location_type& l)
{
return symbol_type (token::HSELSE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSENDIF (location_type l)
{
return symbol_type (token::HSENDIF, std::move (l));
}
#else
static
symbol_type
make_HSENDIF (const location_type& l)
{
return symbol_type (token::HSENDIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -5311,7 +5447,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw6
#line 5315 "parser.hpp"
#line 5451 "parser.hpp"

View File

@ -16,57 +16,6 @@ xsk::gsc::iw7::parser::symbol_type IW7lex(xsk::gsc::iw7::lexer& lexer)
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() : length(0)
{
data = static_cast<char*>(std::malloc(max_buf_size));
@ -129,7 +78,7 @@ void reader::advance()
}
}
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(xsk::gsc::location(&name)),
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(location(&name)),
mode_(build::dev), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
{
reader_.init(data, size);
@ -140,7 +89,7 @@ void lexer::push_header(const std::string& file)
try
{
if (header_top_++ >= 10)
throw xsk::gsc::error("maximum gsh depth exceeded '10'");
throw comp_error(loc_, "maximum gsh depth exceeded '10'");
auto data = resolver::file_data(file + ".gsh");
@ -151,7 +100,7 @@ void lexer::push_header(const std::string& file)
}
catch (const std::exception& e)
{
throw xsk::gsc::error("parsing header file '" + file + "': " + e.what());
throw error("parsing header file '" + file + "': " + e.what());
}
}
@ -164,7 +113,7 @@ void lexer::pop_header()
readers_.pop();
}
void lexer::restrict_header(const xsk::gsc::location& loc)
void lexer::ban_header(const location& loc)
{
if (header_top_ > 0)
{
@ -172,7 +121,7 @@ void lexer::restrict_header(const xsk::gsc::location& loc)
}
}
auto lexer::lex() -> xsk::gsc::iw7::parser::symbol_type
auto lexer::lex() -> parser::symbol_type
{
buffer_.length = 0;
state_ = state::start;
@ -193,7 +142,7 @@ auto lexer::lex() -> xsk::gsc::iw7::parser::symbol_type
if (header_top_ > 0)
pop_header();
else
return iw7::parser::make_IW7EOF(loc_);
return parser::make_IW7EOF(loc_);
}
reader_.advance();
@ -211,22 +160,22 @@ auto lexer::lex() -> xsk::gsc::iw7::parser::symbol_type
continue;
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
return iw7::parser::make_DIV(loc_);
return parser::make_DIV(loc_);
reader_.advance();
if (last == '=')
return iw7::parser::make_ASSIGN_DIV(loc_);
return parser::make_ASSIGN_DIV(loc_);
if (last == '#')
{
if (indev_)
throw comp_error(loc_, "cannot recurse devblock ('/#')");
if (mode_ == xsk::gsc::build::dev)
if (mode_ == build::dev)
{
indev_ = true;
return iw7::parser::make_DEVBEGIN(loc_);
return parser::make_DEVBEGIN(loc_);
}
else
{
@ -290,7 +239,7 @@ auto lexer::lex() -> xsk::gsc::iw7::parser::symbol_type
indev_ = false;
reader_.advance();
return iw7::parser::make_DEVEND(loc_);
return parser::make_DEVEND(loc_);
}
buffer_.push(last);
@ -303,12 +252,12 @@ auto lexer::lex() -> xsk::gsc::iw7::parser::symbol_type
goto lex_name;
case '*':
if (curr != '/' && curr != '=')
return iw7::parser::make_MUL(loc_);
return parser::make_MUL(loc_);
reader_.advance();
if (last == '=')
return iw7::parser::make_ASSIGN_MUL(loc_);
return parser::make_ASSIGN_MUL(loc_);
throw comp_error(loc_, "unmatched multiline comment end ('*/')");
case '"':
@ -323,127 +272,127 @@ auto lexer::lex() -> xsk::gsc::iw7::parser::symbol_type
state_ = state::field;
goto lex_name_or_number;
case '(':
return iw7::parser::make_LPAREN(loc_);
return parser::make_LPAREN(loc_);
case ')':
return iw7::parser::make_RPAREN(loc_);
return parser::make_RPAREN(loc_);
case '{':
return iw7::parser::make_LBRACE(loc_);
return parser::make_LBRACE(loc_);
case '}':
return iw7::parser::make_RBRACE(loc_);
return parser::make_RBRACE(loc_);
case '[':
return iw7::parser::make_LBRACKET(loc_);
return parser::make_LBRACKET(loc_);
case ']':
return iw7::parser::make_RBRACKET(loc_);
return parser::make_RBRACKET(loc_);
case ',':
return iw7::parser::make_COMMA(loc_);
return parser::make_COMMA(loc_);
case ';':
return iw7::parser::make_SEMICOLON(loc_);
return parser::make_SEMICOLON(loc_);
case ':':
if (curr != ':')
return iw7::parser::make_COLON(loc_);
return parser::make_COLON(loc_);
reader_.advance();
return iw7::parser::make_DOUBLECOLON(loc_);
return parser::make_DOUBLECOLON(loc_);
case '?':
return iw7::parser::make_QMARK(loc_);
return parser::make_QMARK(loc_);
case '=':
if (curr != '=')
return iw7::parser::make_ASSIGN(loc_);
return parser::make_ASSIGN(loc_);
reader_.advance();
return iw7::parser::make_EQUALITY(loc_);
return parser::make_EQUALITY(loc_);
case '+':
if (curr != '+' && curr != '=')
return iw7::parser::make_ADD(loc_);
return parser::make_ADD(loc_);
reader_.advance();
if (last == '+')
return iw7::parser::make_INCREMENT(loc_);
return parser::make_INCREMENT(loc_);
return iw7::parser::make_ASSIGN_ADD(loc_);
return parser::make_ASSIGN_ADD(loc_);
case '-':
if (curr != '-' && curr != '=')
return iw7::parser::make_SUB(loc_);
return parser::make_SUB(loc_);
reader_.advance();
if (last == '-')
return iw7::parser::make_DECREMENT(loc_);
return parser::make_DECREMENT(loc_);
return iw7::parser::make_ASSIGN_SUB(loc_);
return parser::make_ASSIGN_SUB(loc_);
case '%':
if (curr != '=')
return iw7::parser::make_MOD(loc_);
return parser::make_MOD(loc_);
reader_.advance();
return iw7::parser::make_ASSIGN_MOD(loc_);
return parser::make_ASSIGN_MOD(loc_);
case '|':
if (curr != '|' && curr != '=')
return iw7::parser::make_BITWISE_OR(loc_);
return parser::make_BITWISE_OR(loc_);
reader_.advance();
if (last == '|')
return iw7::parser::make_OR(loc_);
return parser::make_OR(loc_);
return iw7::parser::make_ASSIGN_BW_OR(loc_);
return parser::make_ASSIGN_BW_OR(loc_);
case '&':
if (curr != '&' && curr != '=' && curr != '"' && curr != '\'')
return iw7::parser::make_BITWISE_AND(loc_);
return parser::make_BITWISE_AND(loc_);
reader_.advance();
if (last == '&')
return iw7::parser::make_AND(loc_);
return parser::make_AND(loc_);
if (last == '=')
return iw7::parser::make_ASSIGN_BW_AND(loc_);
return parser::make_ASSIGN_BW_AND(loc_);
state_ = state::localize;
goto lex_string;
case '^':
if (curr != '=')
return iw7::parser::make_BITWISE_EXOR(loc_);
return parser::make_BITWISE_EXOR(loc_);
reader_.advance();
return iw7::parser::make_ASSIGN_BW_EXOR(loc_);
return parser::make_ASSIGN_BW_EXOR(loc_);
case '!':
if (curr != '=')
return iw7::parser::make_NOT(loc_);
return parser::make_NOT(loc_);
reader_.advance();
return iw7::parser::make_INEQUALITY(loc_);
return parser::make_INEQUALITY(loc_);
case '~':
return iw7::parser::make_COMPLEMENT(loc_);
return parser::make_COMPLEMENT(loc_);
case '<':
if (curr != '<' && curr != '=')
return iw7::parser::make_LESS(loc_);
return parser::make_LESS(loc_);
reader_.advance();
if (last == '=')
return iw7::parser::make_LESS_EQUAL(loc_);
return parser::make_LESS_EQUAL(loc_);
if (curr != '=')
return iw7::parser::make_LSHIFT(loc_);
return parser::make_LSHIFT(loc_);
reader_.advance();
return iw7::parser::make_ASSIGN_LSHIFT(loc_);
return parser::make_ASSIGN_LSHIFT(loc_);
case '>':
if (curr != '>' && curr != '=')
return iw7::parser::make_GREATER(loc_);
return parser::make_GREATER(loc_);
reader_.advance();
if (last == '=')
return iw7::parser::make_GREATER_EQUAL(loc_);
return parser::make_GREATER_EQUAL(loc_);
if (curr != '=')
return iw7::parser::make_RSHIFT(loc_);
return parser::make_RSHIFT(loc_);
reader_.advance();
return iw7::parser::make_ASSIGN_RSHIFT(loc_);
return parser::make_ASSIGN_RSHIFT(loc_);
default:
lex_name_or_number:
if (last >= '0' && last <= '9')
@ -496,9 +445,9 @@ lex_string:
}
if (state_ == state::localize)
return iw7::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return iw7::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
lex_name:
buffer_.push(last);
@ -533,44 +482,55 @@ lex_name:
if (std::string_view(buffer_.data, buffer_.length) == "size")
{
return iw7::parser::make_SIZE(loc_);
return parser::make_SIZE(loc_);
}
return iw7::parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
}
else if (state_ == state::preprocessor)
{
if (path)
throw comp_error(loc_, "invalid preprocessor directive");
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
auto token = parser::token::IW7UNDEF;
if (key != keyword::KW_INVALID)
return keyword_token(key);
if (buffer_.length < 16)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
// TODO: call preprocessor(key);
if(itr != keyword_map.end())
{
if (itr->second > parser::token::HSENDIF)
return parser::symbol_type(itr->second, loc_);
token = itr->second;
}
}
// TODO: call preprocessor(token);
throw comp_error(loc_, "unknown preprocessor directive");
state_ = state::start;
continue;
}
else
{
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
if (buffer_.length < 17)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
if (key != keyword::KW_INVALID)
return keyword_token(key);
if(itr != keyword_map.end())
return parser::symbol_type(itr->second, loc_);
}
if (path)
{
if (buffer_.data[buffer_.length - 1] == '/')
throw comp_error(loc_, "invalid path end '\\'");
//return iw7::parser::make_PATH(xsk::gsc::iw7::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return iw7::parser::make_PATH(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_PATH(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
//return iw7::parser::make_IDENTIFIER(xsk::gsc::iw7::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return iw7::parser::make_IDENTIFIER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_IDENTIFIER(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
lex_number:
@ -621,9 +581,9 @@ lex_number:
throw comp_error(loc_, "invalid number literal");
if (state_ == state::field || dot || flt)
return iw7::parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return iw7::parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
}
else if (curr == 'o')
{
@ -655,7 +615,7 @@ lex_number:
if (last == '\'' || buffer_.length <= 0)
throw comp_error(loc_, "invalid octal literal");
return iw7::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
}
else if (curr == 'b')
{
@ -689,7 +649,7 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid binary literal");
return iw7::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
}
else if (curr == 'x')
{
@ -723,176 +683,59 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid hexadecimal literal");
return iw7::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
}
// cant get here!
}
}
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;
}
return keyword::KW_INVALID;
}
std::unordered_map<std::string_view, keyword> lexer::keywords
const std::unordered_map<std::string_view, parser::token::token_kind_type> lexer::keyword_map
{{
/* { "#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 },
{ "#define", parser::token::HSDEFINE },
{ "#undef", parser::token::HSUNDEF },
{ "#ifdef", parser::token::HSIFDEF },
{ "#ifndef", parser::token::HSIFNDEF },
{ "#if", parser::token::HSIF },
{ "#elif", parser::token::HSELIF },
{ "#else", parser::token::HSELSE },
{ "#endif", parser::token::HSENDIF },
{ "#inline", parser::token::INLINE },
{ "#include", parser::token::INCLUDE },
{ "#using_animtree", parser::token::USINGTREE },
{ "#animtree", parser::token::ANIMTREE },
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
{ "if", parser::token::IF },
{ "else", parser::token::ELSE },
{ "do", parser::token::DO },
{ "while", parser::token::WHILE },
{ "for", parser::token::FOR },
{ "foreach", parser::token::FOREACH },
{ "in", parser::token::IN },
{ "switch", parser::token::SWITCH },
{ "case", parser::token::CASE },
{ "default", parser::token::DEFAULT },
{ "break", parser::token::BREAK },
{ "continue", parser::token::CONTINUE },
{ "return", parser::token::RETURN },
{ "breakpoint", parser::token::BREAKPOINT },
{ "prof_begin", parser::token::PROFBEGIN },
{ "prof_end", parser::token::PROFEND },
{ "thread", parser::token::THREAD },
{ "childthread", parser::token::CHILDTHREAD },
{ "thisthread", parser::token::THISTHREAD },
{ "call", parser::token::CALL },
{ "true", parser::token::TRUE },
{ "false", parser::token::FALSE },
{ "undefined", parser::token::UNDEFINED },
{ "game", parser::token::GAME },
{ "self", parser::token::SELF },
{ "anim", parser::token::ANIM },
{ "level", parser::token::LEVEL },
}};
} // namespace xsk::gsc::iw7

View File

@ -10,8 +10,6 @@
namespace xsk::gsc::iw7
{
enum class keyword;
constexpr size_t max_buf_size = 0x2000;
struct buffer
@ -53,26 +51,22 @@ class lexer
reader reader_;
buffer buffer_;
location loc_;
build mode_;
std::stack<location> locs_;
std::stack<reader> readers_;
std::uint32_t header_top_;
state state_;
build mode_;
bool indev_;
public:
lexer(const std::string& name, const char* data, size_t size);
auto lex() -> xsk::gsc::iw7::parser::symbol_type;
auto lex() -> parser::symbol_type;
void push_header(const std::string& file);
void pop_header();
void restrict_header(const xsk::gsc::location& loc);
void ban_header(const location& loc);
private:
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<std::string_view, keyword> keywords;
static const std::unordered_map<std::string_view, parser::token::token_kind_type> keyword_map;
};
} // namespace xsk::gsc::iw7

File diff suppressed because it is too large Load Diff

View File

@ -674,108 +674,116 @@ namespace xsk { namespace gsc { namespace iw7 {
IW7EOF = 0, // "end of file"
IW7error = 1, // error
IW7UNDEF = 2, // "invalid token"
DEVBEGIN = 3, // "/#"
DEVEND = 4, // "#/"
INLINE = 5, // "#inline"
INCLUDE = 6, // "#include"
USINGTREE = 7, // "#using_animtree"
ANIMTREE = 8, // "#animtree"
ENDON = 9, // "endon"
NOTIFY = 10, // "notify"
WAIT = 11, // "wait"
WAITTILL = 12, // "waittill"
WAITTILLMATCH = 13, // "waittillmatch"
WAITTILLFRAMEEND = 14, // "waittillframeend"
IF = 15, // "if"
ELSE = 16, // "else"
DO = 17, // "do"
WHILE = 18, // "while"
FOR = 19, // "for"
FOREACH = 20, // "foreach"
IN = 21, // "in"
SWITCH = 22, // "switch"
CASE = 23, // "case"
DEFAULT = 24, // "default"
BREAK = 25, // "break"
CONTINUE = 26, // "continue"
RETURN = 27, // "return"
BREAKPOINT = 28, // "breakpoint"
PROFBEGIN = 29, // "prof_begin"
PROFEND = 30, // "prof_end"
THREAD = 31, // "thread"
CHILDTHREAD = 32, // "childthread"
THISTHREAD = 33, // "thisthread"
CALL = 34, // "call"
TRUE = 35, // "true"
FALSE = 36, // "false"
UNDEFINED = 37, // "undefined"
SIZE = 38, // ".size"
GAME = 39, // "game"
SELF = 40, // "self"
ANIM = 41, // "anim"
LEVEL = 42, // "level"
LPAREN = 43, // "("
RPAREN = 44, // ")"
LBRACE = 45, // "{"
RBRACE = 46, // "}"
LBRACKET = 47, // "["
RBRACKET = 48, // "]"
COMMA = 49, // ","
DOT = 50, // "."
DOUBLECOLON = 51, // "::"
COLON = 52, // ":"
SEMICOLON = 53, // ";"
QMARK = 54, // "?"
INCREMENT = 55, // "++"
DECREMENT = 56, // "--"
LSHIFT = 57, // "<<"
RSHIFT = 58, // ">>"
OR = 59, // "||"
AND = 60, // "&&"
EQUALITY = 61, // "=="
INEQUALITY = 62, // "!="
LESS_EQUAL = 63, // "<="
GREATER_EQUAL = 64, // ">="
LESS = 65, // "<"
GREATER = 66, // ">"
NOT = 67, // "!"
COMPLEMENT = 68, // "~"
ASSIGN = 69, // "="
ASSIGN_ADD = 70, // "+="
ASSIGN_SUB = 71, // "-="
ASSIGN_MUL = 72, // "*="
ASSIGN_DIV = 73, // "/="
ASSIGN_MOD = 74, // "%="
ASSIGN_BW_OR = 75, // "|="
ASSIGN_BW_AND = 76, // "&="
ASSIGN_BW_EXOR = 77, // "^="
ASSIGN_RSHIFT = 78, // ">>="
ASSIGN_LSHIFT = 79, // "<<="
BITWISE_OR = 80, // "|"
BITWISE_AND = 81, // "&"
BITWISE_EXOR = 82, // "^"
ADD = 83, // "+"
SUB = 84, // "-"
MUL = 85, // "*"
DIV = 86, // "/"
MOD = 87, // "%"
FIELD = 88, // "field"
PATH = 89, // "path"
IDENTIFIER = 90, // "identifier"
STRING = 91, // "string literal"
ISTRING = 92, // "localized string"
COLOR = 93, // "color"
FLOAT = 94, // "float"
INTEGER = 95, // "integer"
ADD_ARRAY = 96, // ADD_ARRAY
THEN = 97, // THEN
TERN = 98, // TERN
NEG = 99, // NEG
ANIMREF = 100, // ANIMREF
PREINC = 101, // PREINC
PREDEC = 102, // PREDEC
POSTINC = 103, // POSTINC
POSTDEC = 104 // POSTDEC
HSDEFINE = 3, // "#define"
HSUNDEF = 4, // "#undef"
HSIFDEF = 5, // "#ifdef"
HSIFNDEF = 6, // "#ifndef"
HSIF = 7, // "#if"
HSELIF = 8, // "#elif"
HSELSE = 9, // "#else"
HSENDIF = 10, // "#endif"
DEVBEGIN = 11, // "/#"
DEVEND = 12, // "#/"
INLINE = 13, // "#inline"
INCLUDE = 14, // "#include"
USINGTREE = 15, // "#using_animtree"
ANIMTREE = 16, // "#animtree"
ENDON = 17, // "endon"
NOTIFY = 18, // "notify"
WAIT = 19, // "wait"
WAITTILL = 20, // "waittill"
WAITTILLMATCH = 21, // "waittillmatch"
WAITTILLFRAMEEND = 22, // "waittillframeend"
IF = 23, // "if"
ELSE = 24, // "else"
DO = 25, // "do"
WHILE = 26, // "while"
FOR = 27, // "for"
FOREACH = 28, // "foreach"
IN = 29, // "in"
SWITCH = 30, // "switch"
CASE = 31, // "case"
DEFAULT = 32, // "default"
BREAK = 33, // "break"
CONTINUE = 34, // "continue"
RETURN = 35, // "return"
BREAKPOINT = 36, // "breakpoint"
PROFBEGIN = 37, // "prof_begin"
PROFEND = 38, // "prof_end"
THREAD = 39, // "thread"
CHILDTHREAD = 40, // "childthread"
THISTHREAD = 41, // "thisthread"
CALL = 42, // "call"
TRUE = 43, // "true"
FALSE = 44, // "false"
UNDEFINED = 45, // "undefined"
SIZE = 46, // ".size"
GAME = 47, // "game"
SELF = 48, // "self"
ANIM = 49, // "anim"
LEVEL = 50, // "level"
LPAREN = 51, // "("
RPAREN = 52, // ")"
LBRACE = 53, // "{"
RBRACE = 54, // "}"
LBRACKET = 55, // "["
RBRACKET = 56, // "]"
COMMA = 57, // ","
DOT = 58, // "."
DOUBLECOLON = 59, // "::"
COLON = 60, // ":"
SEMICOLON = 61, // ";"
QMARK = 62, // "?"
INCREMENT = 63, // "++"
DECREMENT = 64, // "--"
LSHIFT = 65, // "<<"
RSHIFT = 66, // ">>"
OR = 67, // "||"
AND = 68, // "&&"
EQUALITY = 69, // "=="
INEQUALITY = 70, // "!="
LESS_EQUAL = 71, // "<="
GREATER_EQUAL = 72, // ">="
LESS = 73, // "<"
GREATER = 74, // ">"
NOT = 75, // "!"
COMPLEMENT = 76, // "~"
ASSIGN = 77, // "="
ASSIGN_ADD = 78, // "+="
ASSIGN_SUB = 79, // "-="
ASSIGN_MUL = 80, // "*="
ASSIGN_DIV = 81, // "/="
ASSIGN_MOD = 82, // "%="
ASSIGN_BW_OR = 83, // "|="
ASSIGN_BW_AND = 84, // "&="
ASSIGN_BW_EXOR = 85, // "^="
ASSIGN_RSHIFT = 86, // ">>="
ASSIGN_LSHIFT = 87, // "<<="
BITWISE_OR = 88, // "|"
BITWISE_AND = 89, // "&"
BITWISE_EXOR = 90, // "^"
ADD = 91, // "+"
SUB = 92, // "-"
MUL = 93, // "*"
DIV = 94, // "/"
MOD = 95, // "%"
FIELD = 96, // "field"
PATH = 97, // "path"
IDENTIFIER = 98, // "identifier"
STRING = 99, // "string literal"
ISTRING = 100, // "localized string"
COLOR = 101, // "color"
FLOAT = 102, // "float"
INTEGER = 103, // "integer"
ADD_ARRAY = 104, // ADD_ARRAY
THEN = 105, // THEN
TERN = 106, // TERN
NEG = 107, // NEG
ANIMREF = 108, // ANIMREF
PREINC = 109, // PREINC
PREDEC = 110, // PREDEC
POSTINC = 111, // POSTINC
POSTDEC = 112 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -792,193 +800,201 @@ namespace xsk { namespace gsc { namespace iw7 {
{
enum symbol_kind_type
{
YYNTOKENS = 105, ///< Number of tokens.
YYNTOKENS = 113, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_DEVBEGIN = 3, // "/#"
S_DEVEND = 4, // "#/"
S_INLINE = 5, // "#inline"
S_INCLUDE = 6, // "#include"
S_USINGTREE = 7, // "#using_animtree"
S_ANIMTREE = 8, // "#animtree"
S_ENDON = 9, // "endon"
S_NOTIFY = 10, // "notify"
S_WAIT = 11, // "wait"
S_WAITTILL = 12, // "waittill"
S_WAITTILLMATCH = 13, // "waittillmatch"
S_WAITTILLFRAMEEND = 14, // "waittillframeend"
S_IF = 15, // "if"
S_ELSE = 16, // "else"
S_DO = 17, // "do"
S_WHILE = 18, // "while"
S_FOR = 19, // "for"
S_FOREACH = 20, // "foreach"
S_IN = 21, // "in"
S_SWITCH = 22, // "switch"
S_CASE = 23, // "case"
S_DEFAULT = 24, // "default"
S_BREAK = 25, // "break"
S_CONTINUE = 26, // "continue"
S_RETURN = 27, // "return"
S_BREAKPOINT = 28, // "breakpoint"
S_PROFBEGIN = 29, // "prof_begin"
S_PROFEND = 30, // "prof_end"
S_THREAD = 31, // "thread"
S_CHILDTHREAD = 32, // "childthread"
S_THISTHREAD = 33, // "thisthread"
S_CALL = 34, // "call"
S_TRUE = 35, // "true"
S_FALSE = 36, // "false"
S_UNDEFINED = 37, // "undefined"
S_SIZE = 38, // ".size"
S_GAME = 39, // "game"
S_SELF = 40, // "self"
S_ANIM = 41, // "anim"
S_LEVEL = 42, // "level"
S_LPAREN = 43, // "("
S_RPAREN = 44, // ")"
S_LBRACE = 45, // "{"
S_RBRACE = 46, // "}"
S_LBRACKET = 47, // "["
S_RBRACKET = 48, // "]"
S_COMMA = 49, // ","
S_DOT = 50, // "."
S_DOUBLECOLON = 51, // "::"
S_COLON = 52, // ":"
S_SEMICOLON = 53, // ";"
S_QMARK = 54, // "?"
S_INCREMENT = 55, // "++"
S_DECREMENT = 56, // "--"
S_LSHIFT = 57, // "<<"
S_RSHIFT = 58, // ">>"
S_OR = 59, // "||"
S_AND = 60, // "&&"
S_EQUALITY = 61, // "=="
S_INEQUALITY = 62, // "!="
S_LESS_EQUAL = 63, // "<="
S_GREATER_EQUAL = 64, // ">="
S_LESS = 65, // "<"
S_GREATER = 66, // ">"
S_NOT = 67, // "!"
S_COMPLEMENT = 68, // "~"
S_ASSIGN = 69, // "="
S_ASSIGN_ADD = 70, // "+="
S_ASSIGN_SUB = 71, // "-="
S_ASSIGN_MUL = 72, // "*="
S_ASSIGN_DIV = 73, // "/="
S_ASSIGN_MOD = 74, // "%="
S_ASSIGN_BW_OR = 75, // "|="
S_ASSIGN_BW_AND = 76, // "&="
S_ASSIGN_BW_EXOR = 77, // "^="
S_ASSIGN_RSHIFT = 78, // ">>="
S_ASSIGN_LSHIFT = 79, // "<<="
S_BITWISE_OR = 80, // "|"
S_BITWISE_AND = 81, // "&"
S_BITWISE_EXOR = 82, // "^"
S_ADD = 83, // "+"
S_SUB = 84, // "-"
S_MUL = 85, // "*"
S_DIV = 86, // "/"
S_MOD = 87, // "%"
S_FIELD = 88, // "field"
S_PATH = 89, // "path"
S_IDENTIFIER = 90, // "identifier"
S_STRING = 91, // "string literal"
S_ISTRING = 92, // "localized string"
S_COLOR = 93, // "color"
S_FLOAT = 94, // "float"
S_INTEGER = 95, // "integer"
S_ADD_ARRAY = 96, // ADD_ARRAY
S_THEN = 97, // THEN
S_TERN = 98, // TERN
S_NEG = 99, // NEG
S_ANIMREF = 100, // ANIMREF
S_PREINC = 101, // PREINC
S_PREDEC = 102, // PREDEC
S_POSTINC = 103, // POSTINC
S_POSTDEC = 104, // POSTDEC
S_YYACCEPT = 105, // $accept
S_root = 106, // root
S_program = 107, // program
S_inline = 108, // inline
S_include = 109, // include
S_declaration = 110, // declaration
S_decl_usingtree = 111, // decl_usingtree
S_decl_constant = 112, // decl_constant
S_decl_thread = 113, // decl_thread
S_stmt = 114, // stmt
S_stmt_dev = 115, // stmt_dev
S_stmt_block = 116, // stmt_block
S_stmt_list = 117, // stmt_list
S_stmt_expr = 118, // stmt_expr
S_stmt_call = 119, // stmt_call
S_stmt_assign = 120, // stmt_assign
S_stmt_endon = 121, // stmt_endon
S_stmt_notify = 122, // stmt_notify
S_stmt_wait = 123, // stmt_wait
S_stmt_waittill = 124, // stmt_waittill
S_stmt_waittillmatch = 125, // stmt_waittillmatch
S_stmt_waittillframeend = 126, // stmt_waittillframeend
S_stmt_if = 127, // stmt_if
S_stmt_ifelse = 128, // stmt_ifelse
S_stmt_while = 129, // stmt_while
S_stmt_dowhile = 130, // stmt_dowhile
S_stmt_for = 131, // stmt_for
S_stmt_foreach = 132, // stmt_foreach
S_stmt_switch = 133, // stmt_switch
S_stmt_case = 134, // stmt_case
S_stmt_default = 135, // stmt_default
S_stmt_break = 136, // stmt_break
S_stmt_continue = 137, // stmt_continue
S_stmt_return = 138, // stmt_return
S_stmt_breakpoint = 139, // stmt_breakpoint
S_stmt_prof_begin = 140, // stmt_prof_begin
S_stmt_prof_end = 141, // stmt_prof_end
S_expr = 142, // expr
S_expr_or_empty = 143, // expr_or_empty
S_expr_assign = 144, // expr_assign
S_expr_increment = 145, // expr_increment
S_expr_decrement = 146, // expr_decrement
S_expr_ternary = 147, // expr_ternary
S_expr_binary = 148, // expr_binary
S_expr_primitive = 149, // expr_primitive
S_expr_complement = 150, // expr_complement
S_expr_not = 151, // expr_not
S_expr_call = 152, // expr_call
S_expr_method = 153, // expr_method
S_expr_function = 154, // expr_function
S_expr_pointer = 155, // expr_pointer
S_expr_add_array = 156, // expr_add_array
S_expr_parameters = 157, // expr_parameters
S_expr_arguments = 158, // expr_arguments
S_expr_arguments_no_empty = 159, // expr_arguments_no_empty
S_expr_reference = 160, // expr_reference
S_expr_array = 161, // expr_array
S_expr_field = 162, // expr_field
S_expr_size = 163, // expr_size
S_expr_paren = 164, // expr_paren
S_expr_object = 165, // expr_object
S_expr_thisthread = 166, // expr_thisthread
S_expr_empty_array = 167, // expr_empty_array
S_expr_undefined = 168, // expr_undefined
S_expr_game = 169, // expr_game
S_expr_self = 170, // expr_self
S_expr_anim = 171, // expr_anim
S_expr_level = 172, // expr_level
S_expr_animation = 173, // expr_animation
S_expr_animtree = 174, // expr_animtree
S_expr_identifier = 175, // expr_identifier
S_expr_path = 176, // expr_path
S_expr_istring = 177, // expr_istring
S_expr_string = 178, // expr_string
S_expr_color = 179, // expr_color
S_expr_vector = 180, // expr_vector
S_expr_float = 181, // expr_float
S_expr_integer = 182, // expr_integer
S_expr_false = 183, // expr_false
S_expr_true = 184 // expr_true
S_HSDEFINE = 3, // "#define"
S_HSUNDEF = 4, // "#undef"
S_HSIFDEF = 5, // "#ifdef"
S_HSIFNDEF = 6, // "#ifndef"
S_HSIF = 7, // "#if"
S_HSELIF = 8, // "#elif"
S_HSELSE = 9, // "#else"
S_HSENDIF = 10, // "#endif"
S_DEVBEGIN = 11, // "/#"
S_DEVEND = 12, // "#/"
S_INLINE = 13, // "#inline"
S_INCLUDE = 14, // "#include"
S_USINGTREE = 15, // "#using_animtree"
S_ANIMTREE = 16, // "#animtree"
S_ENDON = 17, // "endon"
S_NOTIFY = 18, // "notify"
S_WAIT = 19, // "wait"
S_WAITTILL = 20, // "waittill"
S_WAITTILLMATCH = 21, // "waittillmatch"
S_WAITTILLFRAMEEND = 22, // "waittillframeend"
S_IF = 23, // "if"
S_ELSE = 24, // "else"
S_DO = 25, // "do"
S_WHILE = 26, // "while"
S_FOR = 27, // "for"
S_FOREACH = 28, // "foreach"
S_IN = 29, // "in"
S_SWITCH = 30, // "switch"
S_CASE = 31, // "case"
S_DEFAULT = 32, // "default"
S_BREAK = 33, // "break"
S_CONTINUE = 34, // "continue"
S_RETURN = 35, // "return"
S_BREAKPOINT = 36, // "breakpoint"
S_PROFBEGIN = 37, // "prof_begin"
S_PROFEND = 38, // "prof_end"
S_THREAD = 39, // "thread"
S_CHILDTHREAD = 40, // "childthread"
S_THISTHREAD = 41, // "thisthread"
S_CALL = 42, // "call"
S_TRUE = 43, // "true"
S_FALSE = 44, // "false"
S_UNDEFINED = 45, // "undefined"
S_SIZE = 46, // ".size"
S_GAME = 47, // "game"
S_SELF = 48, // "self"
S_ANIM = 49, // "anim"
S_LEVEL = 50, // "level"
S_LPAREN = 51, // "("
S_RPAREN = 52, // ")"
S_LBRACE = 53, // "{"
S_RBRACE = 54, // "}"
S_LBRACKET = 55, // "["
S_RBRACKET = 56, // "]"
S_COMMA = 57, // ","
S_DOT = 58, // "."
S_DOUBLECOLON = 59, // "::"
S_COLON = 60, // ":"
S_SEMICOLON = 61, // ";"
S_QMARK = 62, // "?"
S_INCREMENT = 63, // "++"
S_DECREMENT = 64, // "--"
S_LSHIFT = 65, // "<<"
S_RSHIFT = 66, // ">>"
S_OR = 67, // "||"
S_AND = 68, // "&&"
S_EQUALITY = 69, // "=="
S_INEQUALITY = 70, // "!="
S_LESS_EQUAL = 71, // "<="
S_GREATER_EQUAL = 72, // ">="
S_LESS = 73, // "<"
S_GREATER = 74, // ">"
S_NOT = 75, // "!"
S_COMPLEMENT = 76, // "~"
S_ASSIGN = 77, // "="
S_ASSIGN_ADD = 78, // "+="
S_ASSIGN_SUB = 79, // "-="
S_ASSIGN_MUL = 80, // "*="
S_ASSIGN_DIV = 81, // "/="
S_ASSIGN_MOD = 82, // "%="
S_ASSIGN_BW_OR = 83, // "|="
S_ASSIGN_BW_AND = 84, // "&="
S_ASSIGN_BW_EXOR = 85, // "^="
S_ASSIGN_RSHIFT = 86, // ">>="
S_ASSIGN_LSHIFT = 87, // "<<="
S_BITWISE_OR = 88, // "|"
S_BITWISE_AND = 89, // "&"
S_BITWISE_EXOR = 90, // "^"
S_ADD = 91, // "+"
S_SUB = 92, // "-"
S_MUL = 93, // "*"
S_DIV = 94, // "/"
S_MOD = 95, // "%"
S_FIELD = 96, // "field"
S_PATH = 97, // "path"
S_IDENTIFIER = 98, // "identifier"
S_STRING = 99, // "string literal"
S_ISTRING = 100, // "localized string"
S_COLOR = 101, // "color"
S_FLOAT = 102, // "float"
S_INTEGER = 103, // "integer"
S_ADD_ARRAY = 104, // ADD_ARRAY
S_THEN = 105, // THEN
S_TERN = 106, // TERN
S_NEG = 107, // NEG
S_ANIMREF = 108, // ANIMREF
S_PREINC = 109, // PREINC
S_PREDEC = 110, // PREDEC
S_POSTINC = 111, // POSTINC
S_POSTDEC = 112, // POSTDEC
S_YYACCEPT = 113, // $accept
S_root = 114, // root
S_program = 115, // program
S_inline = 116, // inline
S_include = 117, // include
S_declaration = 118, // declaration
S_decl_usingtree = 119, // decl_usingtree
S_decl_constant = 120, // decl_constant
S_decl_thread = 121, // decl_thread
S_stmt = 122, // stmt
S_stmt_dev = 123, // stmt_dev
S_stmt_block = 124, // stmt_block
S_stmt_list = 125, // stmt_list
S_stmt_expr = 126, // stmt_expr
S_stmt_call = 127, // stmt_call
S_stmt_assign = 128, // stmt_assign
S_stmt_endon = 129, // stmt_endon
S_stmt_notify = 130, // stmt_notify
S_stmt_wait = 131, // stmt_wait
S_stmt_waittill = 132, // stmt_waittill
S_stmt_waittillmatch = 133, // stmt_waittillmatch
S_stmt_waittillframeend = 134, // stmt_waittillframeend
S_stmt_if = 135, // stmt_if
S_stmt_ifelse = 136, // stmt_ifelse
S_stmt_while = 137, // stmt_while
S_stmt_dowhile = 138, // stmt_dowhile
S_stmt_for = 139, // stmt_for
S_stmt_foreach = 140, // stmt_foreach
S_stmt_switch = 141, // stmt_switch
S_stmt_case = 142, // stmt_case
S_stmt_default = 143, // stmt_default
S_stmt_break = 144, // stmt_break
S_stmt_continue = 145, // stmt_continue
S_stmt_return = 146, // stmt_return
S_stmt_breakpoint = 147, // stmt_breakpoint
S_stmt_prof_begin = 148, // stmt_prof_begin
S_stmt_prof_end = 149, // stmt_prof_end
S_expr = 150, // expr
S_expr_or_empty = 151, // expr_or_empty
S_expr_assign = 152, // expr_assign
S_expr_increment = 153, // expr_increment
S_expr_decrement = 154, // expr_decrement
S_expr_ternary = 155, // expr_ternary
S_expr_binary = 156, // expr_binary
S_expr_primitive = 157, // expr_primitive
S_expr_complement = 158, // expr_complement
S_expr_not = 159, // expr_not
S_expr_call = 160, // expr_call
S_expr_method = 161, // expr_method
S_expr_function = 162, // expr_function
S_expr_pointer = 163, // expr_pointer
S_expr_add_array = 164, // expr_add_array
S_expr_parameters = 165, // expr_parameters
S_expr_arguments = 166, // expr_arguments
S_expr_arguments_no_empty = 167, // expr_arguments_no_empty
S_expr_reference = 168, // expr_reference
S_expr_array = 169, // expr_array
S_expr_field = 170, // expr_field
S_expr_size = 171, // expr_size
S_expr_paren = 172, // expr_paren
S_expr_object = 173, // expr_object
S_expr_thisthread = 174, // expr_thisthread
S_expr_empty_array = 175, // expr_empty_array
S_expr_undefined = 176, // expr_undefined
S_expr_game = 177, // expr_game
S_expr_self = 178, // expr_self
S_expr_anim = 179, // expr_anim
S_expr_level = 180, // expr_level
S_expr_animation = 181, // expr_animation
S_expr_animtree = 182, // expr_animtree
S_expr_identifier = 183, // expr_identifier
S_expr_path = 184, // expr_path
S_expr_istring = 185, // expr_istring
S_expr_string = 186, // expr_string
S_expr_color = 187, // expr_color
S_expr_vector = 188, // expr_vector
S_expr_float = 189, // expr_float
S_expr_integer = 190, // expr_integer
S_expr_false = 191, // expr_false
S_expr_true = 192 // expr_true
};
};
@ -2751,6 +2767,126 @@ switch (yykind)
return symbol_type (token::IW7UNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSDEFINE (location_type l)
{
return symbol_type (token::HSDEFINE, std::move (l));
}
#else
static
symbol_type
make_HSDEFINE (const location_type& l)
{
return symbol_type (token::HSDEFINE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSUNDEF (location_type l)
{
return symbol_type (token::HSUNDEF, std::move (l));
}
#else
static
symbol_type
make_HSUNDEF (const location_type& l)
{
return symbol_type (token::HSUNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFDEF (location_type l)
{
return symbol_type (token::HSIFDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFDEF (const location_type& l)
{
return symbol_type (token::HSIFDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFNDEF (location_type l)
{
return symbol_type (token::HSIFNDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFNDEF (const location_type& l)
{
return symbol_type (token::HSIFNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIF (location_type l)
{
return symbol_type (token::HSIF, std::move (l));
}
#else
static
symbol_type
make_HSIF (const location_type& l)
{
return symbol_type (token::HSIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELIF (location_type l)
{
return symbol_type (token::HSELIF, std::move (l));
}
#else
static
symbol_type
make_HSELIF (const location_type& l)
{
return symbol_type (token::HSELIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELSE (location_type l)
{
return symbol_type (token::HSELSE, std::move (l));
}
#else
static
symbol_type
make_HSELSE (const location_type& l)
{
return symbol_type (token::HSELSE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSENDIF (location_type l)
{
return symbol_type (token::HSENDIF, std::move (l));
}
#else
static
symbol_type
make_HSENDIF (const location_type& l)
{
return symbol_type (token::HSENDIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -5311,7 +5447,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw7
#line 5315 "parser.hpp"
#line 5451 "parser.hpp"

View File

@ -16,60 +16,6 @@ xsk::gsc::iw8::parser::symbol_type IW8lex(xsk::gsc::iw8::lexer& lexer)
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() : length(0)
{
data = static_cast<char*>(std::malloc(max_buf_size));
@ -132,7 +78,7 @@ void reader::advance()
}
}
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(xsk::gsc::location(&name)),
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(location(&name)),
mode_(build::dev), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
{
reader_.init(data, size);
@ -143,7 +89,7 @@ void lexer::push_header(const std::string& file)
try
{
if (header_top_++ >= 10)
throw xsk::gsc::error("maximum gsh depth exceeded '10'");
throw comp_error(loc_, "maximum gsh depth exceeded '10'");
auto data = resolver::file_data(file + ".gsh");
@ -154,7 +100,7 @@ void lexer::push_header(const std::string& file)
}
catch (const std::exception& e)
{
throw xsk::gsc::error("parsing header file '" + file + "': " + e.what());
throw error("parsing header file '" + file + "': " + e.what());
}
}
@ -167,7 +113,7 @@ void lexer::pop_header()
readers_.pop();
}
void lexer::restrict_header(const xsk::gsc::location& loc)
void lexer::ban_header(const location& loc)
{
if (header_top_ > 0)
{
@ -175,7 +121,7 @@ void lexer::restrict_header(const xsk::gsc::location& loc)
}
}
auto lexer::lex() -> xsk::gsc::iw8::parser::symbol_type
auto lexer::lex() -> parser::symbol_type
{
buffer_.length = 0;
state_ = state::start;
@ -196,7 +142,7 @@ auto lexer::lex() -> xsk::gsc::iw8::parser::symbol_type
if (header_top_ > 0)
pop_header();
else
return iw8::parser::make_IW8EOF(loc_);
return parser::make_IW8EOF(loc_);
}
reader_.advance();
@ -214,22 +160,22 @@ auto lexer::lex() -> xsk::gsc::iw8::parser::symbol_type
continue;
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
return iw8::parser::make_DIV(loc_);
return parser::make_DIV(loc_);
reader_.advance();
if (last == '=')
return iw8::parser::make_ASSIGN_DIV(loc_);
return parser::make_ASSIGN_DIV(loc_);
if (last == '#')
{
if (indev_)
throw comp_error(loc_, "cannot recurse devblock ('/#')");
if (mode_ == xsk::gsc::build::dev)
if (mode_ == build::dev)
{
indev_ = true;
return iw8::parser::make_DEVBEGIN(loc_);
return parser::make_DEVBEGIN(loc_);
}
else
{
@ -293,7 +239,7 @@ auto lexer::lex() -> xsk::gsc::iw8::parser::symbol_type
indev_ = false;
reader_.advance();
return iw8::parser::make_DEVEND(loc_);
return parser::make_DEVEND(loc_);
}
buffer_.push(last);
@ -306,12 +252,12 @@ auto lexer::lex() -> xsk::gsc::iw8::parser::symbol_type
goto lex_name;
case '*':
if (curr != '/' && curr != '=')
return iw8::parser::make_MUL(loc_);
return parser::make_MUL(loc_);
reader_.advance();
if (last == '=')
return iw8::parser::make_ASSIGN_MUL(loc_);
return parser::make_ASSIGN_MUL(loc_);
throw comp_error(loc_, "unmatched multiline comment end ('*/')");
case '"':
@ -326,127 +272,127 @@ auto lexer::lex() -> xsk::gsc::iw8::parser::symbol_type
state_ = state::field;
goto lex_name_or_number;
case '(':
return iw8::parser::make_LPAREN(loc_);
return parser::make_LPAREN(loc_);
case ')':
return iw8::parser::make_RPAREN(loc_);
return parser::make_RPAREN(loc_);
case '{':
return iw8::parser::make_LBRACE(loc_);
return parser::make_LBRACE(loc_);
case '}':
return iw8::parser::make_RBRACE(loc_);
return parser::make_RBRACE(loc_);
case '[':
return iw8::parser::make_LBRACKET(loc_);
return parser::make_LBRACKET(loc_);
case ']':
return iw8::parser::make_RBRACKET(loc_);
return parser::make_RBRACKET(loc_);
case ',':
return iw8::parser::make_COMMA(loc_);
return parser::make_COMMA(loc_);
case ';':
return iw8::parser::make_SEMICOLON(loc_);
return parser::make_SEMICOLON(loc_);
case ':':
if (curr != ':')
return iw8::parser::make_COLON(loc_);
return parser::make_COLON(loc_);
reader_.advance();
return iw8::parser::make_DOUBLECOLON(loc_);
return parser::make_DOUBLECOLON(loc_);
case '?':
return iw8::parser::make_QMARK(loc_);
return parser::make_QMARK(loc_);
case '=':
if (curr != '=')
return iw8::parser::make_ASSIGN(loc_);
return parser::make_ASSIGN(loc_);
reader_.advance();
return iw8::parser::make_EQUALITY(loc_);
return parser::make_EQUALITY(loc_);
case '+':
if (curr != '+' && curr != '=')
return iw8::parser::make_ADD(loc_);
return parser::make_ADD(loc_);
reader_.advance();
if (last == '+')
return iw8::parser::make_INCREMENT(loc_);
return parser::make_INCREMENT(loc_);
return iw8::parser::make_ASSIGN_ADD(loc_);
return parser::make_ASSIGN_ADD(loc_);
case '-':
if (curr != '-' && curr != '=')
return iw8::parser::make_SUB(loc_);
return parser::make_SUB(loc_);
reader_.advance();
if (last == '-')
return iw8::parser::make_DECREMENT(loc_);
return parser::make_DECREMENT(loc_);
return iw8::parser::make_ASSIGN_SUB(loc_);
return parser::make_ASSIGN_SUB(loc_);
case '%':
if (curr != '=')
return iw8::parser::make_MOD(loc_);
return parser::make_MOD(loc_);
reader_.advance();
return iw8::parser::make_ASSIGN_MOD(loc_);
return parser::make_ASSIGN_MOD(loc_);
case '|':
if (curr != '|' && curr != '=')
return iw8::parser::make_BITWISE_OR(loc_);
return parser::make_BITWISE_OR(loc_);
reader_.advance();
if (last == '|')
return iw8::parser::make_OR(loc_);
return parser::make_OR(loc_);
return iw8::parser::make_ASSIGN_BW_OR(loc_);
return parser::make_ASSIGN_BW_OR(loc_);
case '&':
if (curr != '&' && curr != '=' && curr != '"' && curr != '\'')
return iw8::parser::make_BITWISE_AND(loc_);
return parser::make_BITWISE_AND(loc_);
reader_.advance();
if (last == '&')
return iw8::parser::make_AND(loc_);
return parser::make_AND(loc_);
if (last == '=')
return iw8::parser::make_ASSIGN_BW_AND(loc_);
return parser::make_ASSIGN_BW_AND(loc_);
state_ = state::localize;
goto lex_string;
case '^':
if (curr != '=')
return iw8::parser::make_BITWISE_EXOR(loc_);
return parser::make_BITWISE_EXOR(loc_);
reader_.advance();
return iw8::parser::make_ASSIGN_BW_EXOR(loc_);
return parser::make_ASSIGN_BW_EXOR(loc_);
case '!':
if (curr != '=')
return iw8::parser::make_NOT(loc_);
return parser::make_NOT(loc_);
reader_.advance();
return iw8::parser::make_INEQUALITY(loc_);
return parser::make_INEQUALITY(loc_);
case '~':
return iw8::parser::make_COMPLEMENT(loc_);
return parser::make_COMPLEMENT(loc_);
case '<':
if (curr != '<' && curr != '=')
return iw8::parser::make_LESS(loc_);
return parser::make_LESS(loc_);
reader_.advance();
if (last == '=')
return iw8::parser::make_LESS_EQUAL(loc_);
return parser::make_LESS_EQUAL(loc_);
if (curr != '=')
return iw8::parser::make_LSHIFT(loc_);
return parser::make_LSHIFT(loc_);
reader_.advance();
return iw8::parser::make_ASSIGN_LSHIFT(loc_);
return parser::make_ASSIGN_LSHIFT(loc_);
case '>':
if (curr != '>' && curr != '=')
return iw8::parser::make_GREATER(loc_);
return parser::make_GREATER(loc_);
reader_.advance();
if (last == '=')
return iw8::parser::make_GREATER_EQUAL(loc_);
return parser::make_GREATER_EQUAL(loc_);
if (curr != '=')
return iw8::parser::make_RSHIFT(loc_);
return parser::make_RSHIFT(loc_);
reader_.advance();
return iw8::parser::make_ASSIGN_RSHIFT(loc_);
return parser::make_ASSIGN_RSHIFT(loc_);
default:
lex_name_or_number:
if (last >= '0' && last <= '9')
@ -499,9 +445,9 @@ lex_string:
}
if (state_ == state::localize)
return iw8::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return iw8::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
lex_name:
buffer_.push(last);
@ -536,22 +482,32 @@ lex_name:
if (std::string_view(buffer_.data, buffer_.length) == "size")
{
return iw8::parser::make_SIZE(loc_);
return parser::make_SIZE(loc_);
}
return iw8::parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
}
else if (state_ == state::preprocessor)
{
if (path)
throw comp_error(loc_, "invalid preprocessor directive");
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
auto token = parser::token::IW8UNDEF;
if (key != keyword::KW_INVALID)
return keyword_token(key);
if (buffer_.length < 16)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
// TODO: call preprocessor(key);
if(itr != keyword_map.end())
{
if (itr->second > parser::token::HSENDIF)
return parser::symbol_type(itr->second, loc_);
token = itr->second;
}
}
// TODO: call preprocessor(token);
throw comp_error(loc_, "unknown preprocessor directive");
state_ = state::start;
continue;
@ -569,22 +525,23 @@ lex_name:
}
}
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
if (buffer_.length < 17)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
if (key != keyword::KW_INVALID)
return keyword_token(key);
if(itr != keyword_map.end())
return parser::symbol_type(itr->second, loc_);
}
if (path)
{
if (buffer_.data[buffer_.length - 1] == '/')
throw comp_error(loc_, "invalid path end '\\'");
//return iw8::parser::make_PATH(xsk::gsc::iw8::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return iw8::parser::make_PATH(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_PATH(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
//return iw8::parser::make_IDENTIFIER(xsk::gsc::iw8::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return iw8::parser::make_IDENTIFIER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_IDENTIFIER(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
lex_number:
@ -635,9 +592,9 @@ lex_number:
throw comp_error(loc_, "invalid number literal");
if (state_ == state::field || dot || flt)
return iw8::parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return iw8::parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
}
else if (curr == 'o')
{
@ -669,7 +626,7 @@ lex_number:
if (last == '\'' || buffer_.length <= 0)
throw comp_error(loc_, "invalid octal literal");
return iw8::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
}
else if (curr == 'b')
{
@ -703,7 +660,7 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid binary literal");
return iw8::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
}
else if (curr == 'x')
{
@ -737,185 +694,62 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid hexadecimal literal");
return iw8::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
}
// cant get here!
}
}
auto lexer::keyword_token(keyword k) -> xsk::gsc::iw8::parser::symbol_type
{
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!");
}
}
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;
}
return keyword::KW_INVALID;
}
std::unordered_map<std::string_view, keyword> lexer::keywords
const std::unordered_map<std::string_view, parser::token::token_kind_type> lexer::keyword_map
{{
/* { "#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 },
{ "#define", parser::token::HSDEFINE },
{ "#undef", parser::token::HSUNDEF },
{ "#ifdef", parser::token::HSIFDEF },
{ "#ifndef", parser::token::HSIFNDEF },
{ "#if", parser::token::HSIF },
{ "#elif", parser::token::HSELIF },
{ "#else", parser::token::HSELSE },
{ "#endif", parser::token::HSENDIF },
{ "#inline", parser::token::INLINE },
{ "#include", parser::token::INCLUDE },
{ "#using_animtree", parser::token::USINGTREE },
{ "#animtree", parser::token::ANIMTREE },
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
{ "waitframe", parser::token::WAITFRAME },
{ "if", parser::token::IF },
{ "else", parser::token::ELSE },
{ "do", parser::token::DO },
{ "while", parser::token::WHILE },
{ "for", parser::token::FOR },
{ "foreach", parser::token::FOREACH },
{ "in", parser::token::IN },
{ "switch", parser::token::SWITCH },
{ "case", parser::token::CASE },
{ "default", parser::token::DEFAULT },
{ "break", parser::token::BREAK },
{ "continue", parser::token::CONTINUE },
{ "return", parser::token::RETURN },
{ "breakpoint", parser::token::BREAKPOINT },
{ "prof_begin", parser::token::PROFBEGIN },
{ "prof_end", parser::token::PROFEND },
{ "thread", parser::token::THREAD },
{ "childthread", parser::token::CHILDTHREAD },
{ "thisthread", parser::token::THISTHREAD },
{ "call", parser::token::CALL },
{ "true", parser::token::TRUE },
{ "false", parser::token::FALSE },
{ "undefined", parser::token::UNDEFINED },
{ "game", parser::token::GAME },
{ "self", parser::token::SELF },
{ "anim", parser::token::ANIM },
{ "level", parser::token::LEVEL },
{ "isdefined", parser::token::ISDEFINED },
{ "istrue", parser::token::ISTRUE },
}};
} // namespace xsk::gsc::iw8

View File

@ -10,8 +10,6 @@
namespace xsk::gsc::iw8
{
enum class keyword;
constexpr size_t max_buf_size = 0x2000;
struct buffer
@ -53,26 +51,22 @@ class lexer
reader reader_;
buffer buffer_;
location loc_;
build mode_;
std::stack<location> locs_;
std::stack<reader> readers_;
std::uint32_t header_top_;
state state_;
build mode_;
bool indev_;
public:
lexer(const std::string& name, const char* data, size_t size);
auto lex() -> xsk::gsc::iw8::parser::symbol_type;
auto lex() -> parser::symbol_type;
void push_header(const std::string& file);
void pop_header();
void restrict_header(const xsk::gsc::location& loc);
void ban_header(const location& loc);
private:
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<std::string_view, keyword> keywords;
static const std::unordered_map<std::string_view, parser::token::token_kind_type> keyword_map;
};
} // namespace xsk::gsc::iw8

File diff suppressed because it is too large Load Diff

View File

@ -683,111 +683,119 @@ namespace xsk { namespace gsc { namespace iw8 {
IW8EOF = 0, // "end of file"
IW8error = 1, // error
IW8UNDEF = 2, // "invalid token"
DEVBEGIN = 3, // "/#"
DEVEND = 4, // "#/"
INLINE = 5, // "#inline"
INCLUDE = 6, // "#include"
USINGTREE = 7, // "#using_animtree"
ANIMTREE = 8, // "#animtree"
ENDON = 9, // "endon"
NOTIFY = 10, // "notify"
WAIT = 11, // "wait"
WAITTILL = 12, // "waittill"
WAITTILLMATCH = 13, // "waittillmatch"
WAITTILLFRAMEEND = 14, // "waittillframeend"
WAITFRAME = 15, // "waitframe"
IF = 16, // "if"
ELSE = 17, // "else"
DO = 18, // "do"
WHILE = 19, // "while"
FOR = 20, // "for"
FOREACH = 21, // "foreach"
IN = 22, // "in"
SWITCH = 23, // "switch"
CASE = 24, // "case"
DEFAULT = 25, // "default"
BREAK = 26, // "break"
CONTINUE = 27, // "continue"
RETURN = 28, // "return"
BREAKPOINT = 29, // "breakpoint"
PROFBEGIN = 30, // "prof_begin"
PROFEND = 31, // "prof_end"
THREAD = 32, // "thread"
CHILDTHREAD = 33, // "childthread"
THISTHREAD = 34, // "thisthread"
CALL = 35, // "call"
TRUE = 36, // "true"
FALSE = 37, // "false"
UNDEFINED = 38, // "undefined"
SIZE = 39, // ".size"
GAME = 40, // "game"
SELF = 41, // "self"
ANIM = 42, // "anim"
LEVEL = 43, // "level"
ISDEFINED = 44, // "isdefined"
ISTRUE = 45, // "istrue"
LPAREN = 46, // "("
RPAREN = 47, // ")"
LBRACE = 48, // "{"
RBRACE = 49, // "}"
LBRACKET = 50, // "["
RBRACKET = 51, // "]"
COMMA = 52, // ","
DOT = 53, // "."
DOUBLECOLON = 54, // "::"
COLON = 55, // ":"
SEMICOLON = 56, // ";"
QMARK = 57, // "?"
INCREMENT = 58, // "++"
DECREMENT = 59, // "--"
LSHIFT = 60, // "<<"
RSHIFT = 61, // ">>"
OR = 62, // "||"
AND = 63, // "&&"
EQUALITY = 64, // "=="
INEQUALITY = 65, // "!="
LESS_EQUAL = 66, // "<="
GREATER_EQUAL = 67, // ">="
LESS = 68, // "<"
GREATER = 69, // ">"
NOT = 70, // "!"
COMPLEMENT = 71, // "~"
ASSIGN = 72, // "="
ASSIGN_ADD = 73, // "+="
ASSIGN_SUB = 74, // "-="
ASSIGN_MUL = 75, // "*="
ASSIGN_DIV = 76, // "/="
ASSIGN_MOD = 77, // "%="
ASSIGN_BW_OR = 78, // "|="
ASSIGN_BW_AND = 79, // "&="
ASSIGN_BW_EXOR = 80, // "^="
ASSIGN_RSHIFT = 81, // ">>="
ASSIGN_LSHIFT = 82, // "<<="
BITWISE_OR = 83, // "|"
BITWISE_AND = 84, // "&"
BITWISE_EXOR = 85, // "^"
ADD = 86, // "+"
SUB = 87, // "-"
MUL = 88, // "*"
DIV = 89, // "/"
MOD = 90, // "%"
FIELD = 91, // "field"
PATH = 92, // "path"
IDENTIFIER = 93, // "identifier"
STRING = 94, // "string literal"
ISTRING = 95, // "localized string"
COLOR = 96, // "color"
FLOAT = 97, // "float"
INTEGER = 98, // "integer"
ADD_ARRAY = 99, // ADD_ARRAY
THEN = 100, // THEN
TERN = 101, // TERN
NEG = 102, // NEG
ANIMREF = 103, // ANIMREF
PREINC = 104, // PREINC
PREDEC = 105, // PREDEC
POSTINC = 106, // POSTINC
POSTDEC = 107 // POSTDEC
HSDEFINE = 3, // "#define"
HSUNDEF = 4, // "#undef"
HSIFDEF = 5, // "#ifdef"
HSIFNDEF = 6, // "#ifndef"
HSIF = 7, // "#if"
HSELIF = 8, // "#elif"
HSELSE = 9, // "#else"
HSENDIF = 10, // "#endif"
DEVBEGIN = 11, // "/#"
DEVEND = 12, // "#/"
INLINE = 13, // "#inline"
INCLUDE = 14, // "#include"
USINGTREE = 15, // "#using_animtree"
ANIMTREE = 16, // "#animtree"
ENDON = 17, // "endon"
NOTIFY = 18, // "notify"
WAIT = 19, // "wait"
WAITTILL = 20, // "waittill"
WAITTILLMATCH = 21, // "waittillmatch"
WAITTILLFRAMEEND = 22, // "waittillframeend"
WAITFRAME = 23, // "waitframe"
IF = 24, // "if"
ELSE = 25, // "else"
DO = 26, // "do"
WHILE = 27, // "while"
FOR = 28, // "for"
FOREACH = 29, // "foreach"
IN = 30, // "in"
SWITCH = 31, // "switch"
CASE = 32, // "case"
DEFAULT = 33, // "default"
BREAK = 34, // "break"
CONTINUE = 35, // "continue"
RETURN = 36, // "return"
BREAKPOINT = 37, // "breakpoint"
PROFBEGIN = 38, // "prof_begin"
PROFEND = 39, // "prof_end"
THREAD = 40, // "thread"
CHILDTHREAD = 41, // "childthread"
THISTHREAD = 42, // "thisthread"
CALL = 43, // "call"
TRUE = 44, // "true"
FALSE = 45, // "false"
UNDEFINED = 46, // "undefined"
SIZE = 47, // ".size"
GAME = 48, // "game"
SELF = 49, // "self"
ANIM = 50, // "anim"
LEVEL = 51, // "level"
ISDEFINED = 52, // "isdefined"
ISTRUE = 53, // "istrue"
LPAREN = 54, // "("
RPAREN = 55, // ")"
LBRACE = 56, // "{"
RBRACE = 57, // "}"
LBRACKET = 58, // "["
RBRACKET = 59, // "]"
COMMA = 60, // ","
DOT = 61, // "."
DOUBLECOLON = 62, // "::"
COLON = 63, // ":"
SEMICOLON = 64, // ";"
QMARK = 65, // "?"
INCREMENT = 66, // "++"
DECREMENT = 67, // "--"
LSHIFT = 68, // "<<"
RSHIFT = 69, // ">>"
OR = 70, // "||"
AND = 71, // "&&"
EQUALITY = 72, // "=="
INEQUALITY = 73, // "!="
LESS_EQUAL = 74, // "<="
GREATER_EQUAL = 75, // ">="
LESS = 76, // "<"
GREATER = 77, // ">"
NOT = 78, // "!"
COMPLEMENT = 79, // "~"
ASSIGN = 80, // "="
ASSIGN_ADD = 81, // "+="
ASSIGN_SUB = 82, // "-="
ASSIGN_MUL = 83, // "*="
ASSIGN_DIV = 84, // "/="
ASSIGN_MOD = 85, // "%="
ASSIGN_BW_OR = 86, // "|="
ASSIGN_BW_AND = 87, // "&="
ASSIGN_BW_EXOR = 88, // "^="
ASSIGN_RSHIFT = 89, // ">>="
ASSIGN_LSHIFT = 90, // "<<="
BITWISE_OR = 91, // "|"
BITWISE_AND = 92, // "&"
BITWISE_EXOR = 93, // "^"
ADD = 94, // "+"
SUB = 95, // "-"
MUL = 96, // "*"
DIV = 97, // "/"
MOD = 98, // "%"
FIELD = 99, // "field"
PATH = 100, // "path"
IDENTIFIER = 101, // "identifier"
STRING = 102, // "string literal"
ISTRING = 103, // "localized string"
COLOR = 104, // "color"
FLOAT = 105, // "float"
INTEGER = 106, // "integer"
ADD_ARRAY = 107, // ADD_ARRAY
THEN = 108, // THEN
TERN = 109, // TERN
NEG = 110, // NEG
ANIMREF = 111, // ANIMREF
PREINC = 112, // PREINC
PREDEC = 113, // PREDEC
POSTINC = 114, // POSTINC
POSTDEC = 115 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -804,199 +812,207 @@ namespace xsk { namespace gsc { namespace iw8 {
{
enum symbol_kind_type
{
YYNTOKENS = 108, ///< Number of tokens.
YYNTOKENS = 116, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_DEVBEGIN = 3, // "/#"
S_DEVEND = 4, // "#/"
S_INLINE = 5, // "#inline"
S_INCLUDE = 6, // "#include"
S_USINGTREE = 7, // "#using_animtree"
S_ANIMTREE = 8, // "#animtree"
S_ENDON = 9, // "endon"
S_NOTIFY = 10, // "notify"
S_WAIT = 11, // "wait"
S_WAITTILL = 12, // "waittill"
S_WAITTILLMATCH = 13, // "waittillmatch"
S_WAITTILLFRAMEEND = 14, // "waittillframeend"
S_WAITFRAME = 15, // "waitframe"
S_IF = 16, // "if"
S_ELSE = 17, // "else"
S_DO = 18, // "do"
S_WHILE = 19, // "while"
S_FOR = 20, // "for"
S_FOREACH = 21, // "foreach"
S_IN = 22, // "in"
S_SWITCH = 23, // "switch"
S_CASE = 24, // "case"
S_DEFAULT = 25, // "default"
S_BREAK = 26, // "break"
S_CONTINUE = 27, // "continue"
S_RETURN = 28, // "return"
S_BREAKPOINT = 29, // "breakpoint"
S_PROFBEGIN = 30, // "prof_begin"
S_PROFEND = 31, // "prof_end"
S_THREAD = 32, // "thread"
S_CHILDTHREAD = 33, // "childthread"
S_THISTHREAD = 34, // "thisthread"
S_CALL = 35, // "call"
S_TRUE = 36, // "true"
S_FALSE = 37, // "false"
S_UNDEFINED = 38, // "undefined"
S_SIZE = 39, // ".size"
S_GAME = 40, // "game"
S_SELF = 41, // "self"
S_ANIM = 42, // "anim"
S_LEVEL = 43, // "level"
S_ISDEFINED = 44, // "isdefined"
S_ISTRUE = 45, // "istrue"
S_LPAREN = 46, // "("
S_RPAREN = 47, // ")"
S_LBRACE = 48, // "{"
S_RBRACE = 49, // "}"
S_LBRACKET = 50, // "["
S_RBRACKET = 51, // "]"
S_COMMA = 52, // ","
S_DOT = 53, // "."
S_DOUBLECOLON = 54, // "::"
S_COLON = 55, // ":"
S_SEMICOLON = 56, // ";"
S_QMARK = 57, // "?"
S_INCREMENT = 58, // "++"
S_DECREMENT = 59, // "--"
S_LSHIFT = 60, // "<<"
S_RSHIFT = 61, // ">>"
S_OR = 62, // "||"
S_AND = 63, // "&&"
S_EQUALITY = 64, // "=="
S_INEQUALITY = 65, // "!="
S_LESS_EQUAL = 66, // "<="
S_GREATER_EQUAL = 67, // ">="
S_LESS = 68, // "<"
S_GREATER = 69, // ">"
S_NOT = 70, // "!"
S_COMPLEMENT = 71, // "~"
S_ASSIGN = 72, // "="
S_ASSIGN_ADD = 73, // "+="
S_ASSIGN_SUB = 74, // "-="
S_ASSIGN_MUL = 75, // "*="
S_ASSIGN_DIV = 76, // "/="
S_ASSIGN_MOD = 77, // "%="
S_ASSIGN_BW_OR = 78, // "|="
S_ASSIGN_BW_AND = 79, // "&="
S_ASSIGN_BW_EXOR = 80, // "^="
S_ASSIGN_RSHIFT = 81, // ">>="
S_ASSIGN_LSHIFT = 82, // "<<="
S_BITWISE_OR = 83, // "|"
S_BITWISE_AND = 84, // "&"
S_BITWISE_EXOR = 85, // "^"
S_ADD = 86, // "+"
S_SUB = 87, // "-"
S_MUL = 88, // "*"
S_DIV = 89, // "/"
S_MOD = 90, // "%"
S_FIELD = 91, // "field"
S_PATH = 92, // "path"
S_IDENTIFIER = 93, // "identifier"
S_STRING = 94, // "string literal"
S_ISTRING = 95, // "localized string"
S_COLOR = 96, // "color"
S_FLOAT = 97, // "float"
S_INTEGER = 98, // "integer"
S_ADD_ARRAY = 99, // ADD_ARRAY
S_THEN = 100, // THEN
S_TERN = 101, // TERN
S_NEG = 102, // NEG
S_ANIMREF = 103, // ANIMREF
S_PREINC = 104, // PREINC
S_PREDEC = 105, // PREDEC
S_POSTINC = 106, // POSTINC
S_POSTDEC = 107, // POSTDEC
S_YYACCEPT = 108, // $accept
S_root = 109, // root
S_program = 110, // program
S_inline = 111, // inline
S_include = 112, // include
S_declaration = 113, // declaration
S_decl_usingtree = 114, // decl_usingtree
S_decl_constant = 115, // decl_constant
S_decl_thread = 116, // decl_thread
S_stmt = 117, // stmt
S_stmt_dev = 118, // stmt_dev
S_stmt_block = 119, // stmt_block
S_stmt_list = 120, // stmt_list
S_stmt_expr = 121, // stmt_expr
S_stmt_call = 122, // stmt_call
S_stmt_assign = 123, // stmt_assign
S_stmt_endon = 124, // stmt_endon
S_stmt_notify = 125, // stmt_notify
S_stmt_wait = 126, // stmt_wait
S_stmt_waittill = 127, // stmt_waittill
S_stmt_waittillmatch = 128, // stmt_waittillmatch
S_stmt_waittillframeend = 129, // stmt_waittillframeend
S_stmt_waitframe = 130, // stmt_waitframe
S_stmt_if = 131, // stmt_if
S_stmt_ifelse = 132, // stmt_ifelse
S_stmt_while = 133, // stmt_while
S_stmt_dowhile = 134, // stmt_dowhile
S_stmt_for = 135, // stmt_for
S_stmt_foreach = 136, // stmt_foreach
S_stmt_switch = 137, // stmt_switch
S_stmt_case = 138, // stmt_case
S_stmt_default = 139, // stmt_default
S_stmt_break = 140, // stmt_break
S_stmt_continue = 141, // stmt_continue
S_stmt_return = 142, // stmt_return
S_stmt_breakpoint = 143, // stmt_breakpoint
S_stmt_prof_begin = 144, // stmt_prof_begin
S_stmt_prof_end = 145, // stmt_prof_end
S_expr = 146, // expr
S_expr_or_empty = 147, // expr_or_empty
S_expr_assign = 148, // expr_assign
S_expr_increment = 149, // expr_increment
S_expr_decrement = 150, // expr_decrement
S_expr_ternary = 151, // expr_ternary
S_expr_binary = 152, // expr_binary
S_expr_primitive = 153, // expr_primitive
S_expr_complement = 154, // expr_complement
S_expr_not = 155, // expr_not
S_expr_call = 156, // expr_call
S_expr_method = 157, // expr_method
S_expr_function = 158, // expr_function
S_expr_pointer = 159, // expr_pointer
S_expr_add_array = 160, // expr_add_array
S_expr_parameters = 161, // expr_parameters
S_expr_arguments = 162, // expr_arguments
S_expr_arguments_no_empty = 163, // expr_arguments_no_empty
S_expr_isdefined = 164, // expr_isdefined
S_expr_istrue = 165, // expr_istrue
S_expr_reference = 166, // expr_reference
S_expr_array = 167, // expr_array
S_expr_field = 168, // expr_field
S_expr_size = 169, // expr_size
S_expr_paren = 170, // expr_paren
S_expr_object = 171, // expr_object
S_expr_thisthread = 172, // expr_thisthread
S_expr_empty_array = 173, // expr_empty_array
S_expr_undefined = 174, // expr_undefined
S_expr_game = 175, // expr_game
S_expr_self = 176, // expr_self
S_expr_anim = 177, // expr_anim
S_expr_level = 178, // expr_level
S_expr_animation = 179, // expr_animation
S_expr_animtree = 180, // expr_animtree
S_expr_identifier = 181, // expr_identifier
S_expr_path = 182, // expr_path
S_expr_istring = 183, // expr_istring
S_expr_string = 184, // expr_string
S_expr_color = 185, // expr_color
S_expr_vector = 186, // expr_vector
S_expr_float = 187, // expr_float
S_expr_integer = 188, // expr_integer
S_expr_false = 189, // expr_false
S_expr_true = 190 // expr_true
S_HSDEFINE = 3, // "#define"
S_HSUNDEF = 4, // "#undef"
S_HSIFDEF = 5, // "#ifdef"
S_HSIFNDEF = 6, // "#ifndef"
S_HSIF = 7, // "#if"
S_HSELIF = 8, // "#elif"
S_HSELSE = 9, // "#else"
S_HSENDIF = 10, // "#endif"
S_DEVBEGIN = 11, // "/#"
S_DEVEND = 12, // "#/"
S_INLINE = 13, // "#inline"
S_INCLUDE = 14, // "#include"
S_USINGTREE = 15, // "#using_animtree"
S_ANIMTREE = 16, // "#animtree"
S_ENDON = 17, // "endon"
S_NOTIFY = 18, // "notify"
S_WAIT = 19, // "wait"
S_WAITTILL = 20, // "waittill"
S_WAITTILLMATCH = 21, // "waittillmatch"
S_WAITTILLFRAMEEND = 22, // "waittillframeend"
S_WAITFRAME = 23, // "waitframe"
S_IF = 24, // "if"
S_ELSE = 25, // "else"
S_DO = 26, // "do"
S_WHILE = 27, // "while"
S_FOR = 28, // "for"
S_FOREACH = 29, // "foreach"
S_IN = 30, // "in"
S_SWITCH = 31, // "switch"
S_CASE = 32, // "case"
S_DEFAULT = 33, // "default"
S_BREAK = 34, // "break"
S_CONTINUE = 35, // "continue"
S_RETURN = 36, // "return"
S_BREAKPOINT = 37, // "breakpoint"
S_PROFBEGIN = 38, // "prof_begin"
S_PROFEND = 39, // "prof_end"
S_THREAD = 40, // "thread"
S_CHILDTHREAD = 41, // "childthread"
S_THISTHREAD = 42, // "thisthread"
S_CALL = 43, // "call"
S_TRUE = 44, // "true"
S_FALSE = 45, // "false"
S_UNDEFINED = 46, // "undefined"
S_SIZE = 47, // ".size"
S_GAME = 48, // "game"
S_SELF = 49, // "self"
S_ANIM = 50, // "anim"
S_LEVEL = 51, // "level"
S_ISDEFINED = 52, // "isdefined"
S_ISTRUE = 53, // "istrue"
S_LPAREN = 54, // "("
S_RPAREN = 55, // ")"
S_LBRACE = 56, // "{"
S_RBRACE = 57, // "}"
S_LBRACKET = 58, // "["
S_RBRACKET = 59, // "]"
S_COMMA = 60, // ","
S_DOT = 61, // "."
S_DOUBLECOLON = 62, // "::"
S_COLON = 63, // ":"
S_SEMICOLON = 64, // ";"
S_QMARK = 65, // "?"
S_INCREMENT = 66, // "++"
S_DECREMENT = 67, // "--"
S_LSHIFT = 68, // "<<"
S_RSHIFT = 69, // ">>"
S_OR = 70, // "||"
S_AND = 71, // "&&"
S_EQUALITY = 72, // "=="
S_INEQUALITY = 73, // "!="
S_LESS_EQUAL = 74, // "<="
S_GREATER_EQUAL = 75, // ">="
S_LESS = 76, // "<"
S_GREATER = 77, // ">"
S_NOT = 78, // "!"
S_COMPLEMENT = 79, // "~"
S_ASSIGN = 80, // "="
S_ASSIGN_ADD = 81, // "+="
S_ASSIGN_SUB = 82, // "-="
S_ASSIGN_MUL = 83, // "*="
S_ASSIGN_DIV = 84, // "/="
S_ASSIGN_MOD = 85, // "%="
S_ASSIGN_BW_OR = 86, // "|="
S_ASSIGN_BW_AND = 87, // "&="
S_ASSIGN_BW_EXOR = 88, // "^="
S_ASSIGN_RSHIFT = 89, // ">>="
S_ASSIGN_LSHIFT = 90, // "<<="
S_BITWISE_OR = 91, // "|"
S_BITWISE_AND = 92, // "&"
S_BITWISE_EXOR = 93, // "^"
S_ADD = 94, // "+"
S_SUB = 95, // "-"
S_MUL = 96, // "*"
S_DIV = 97, // "/"
S_MOD = 98, // "%"
S_FIELD = 99, // "field"
S_PATH = 100, // "path"
S_IDENTIFIER = 101, // "identifier"
S_STRING = 102, // "string literal"
S_ISTRING = 103, // "localized string"
S_COLOR = 104, // "color"
S_FLOAT = 105, // "float"
S_INTEGER = 106, // "integer"
S_ADD_ARRAY = 107, // ADD_ARRAY
S_THEN = 108, // THEN
S_TERN = 109, // TERN
S_NEG = 110, // NEG
S_ANIMREF = 111, // ANIMREF
S_PREINC = 112, // PREINC
S_PREDEC = 113, // PREDEC
S_POSTINC = 114, // POSTINC
S_POSTDEC = 115, // POSTDEC
S_YYACCEPT = 116, // $accept
S_root = 117, // root
S_program = 118, // program
S_inline = 119, // inline
S_include = 120, // include
S_declaration = 121, // declaration
S_decl_usingtree = 122, // decl_usingtree
S_decl_constant = 123, // decl_constant
S_decl_thread = 124, // decl_thread
S_stmt = 125, // stmt
S_stmt_dev = 126, // stmt_dev
S_stmt_block = 127, // stmt_block
S_stmt_list = 128, // stmt_list
S_stmt_expr = 129, // stmt_expr
S_stmt_call = 130, // stmt_call
S_stmt_assign = 131, // stmt_assign
S_stmt_endon = 132, // stmt_endon
S_stmt_notify = 133, // stmt_notify
S_stmt_wait = 134, // stmt_wait
S_stmt_waittill = 135, // stmt_waittill
S_stmt_waittillmatch = 136, // stmt_waittillmatch
S_stmt_waittillframeend = 137, // stmt_waittillframeend
S_stmt_waitframe = 138, // stmt_waitframe
S_stmt_if = 139, // stmt_if
S_stmt_ifelse = 140, // stmt_ifelse
S_stmt_while = 141, // stmt_while
S_stmt_dowhile = 142, // stmt_dowhile
S_stmt_for = 143, // stmt_for
S_stmt_foreach = 144, // stmt_foreach
S_stmt_switch = 145, // stmt_switch
S_stmt_case = 146, // stmt_case
S_stmt_default = 147, // stmt_default
S_stmt_break = 148, // stmt_break
S_stmt_continue = 149, // stmt_continue
S_stmt_return = 150, // stmt_return
S_stmt_breakpoint = 151, // stmt_breakpoint
S_stmt_prof_begin = 152, // stmt_prof_begin
S_stmt_prof_end = 153, // stmt_prof_end
S_expr = 154, // expr
S_expr_or_empty = 155, // expr_or_empty
S_expr_assign = 156, // expr_assign
S_expr_increment = 157, // expr_increment
S_expr_decrement = 158, // expr_decrement
S_expr_ternary = 159, // expr_ternary
S_expr_binary = 160, // expr_binary
S_expr_primitive = 161, // expr_primitive
S_expr_complement = 162, // expr_complement
S_expr_not = 163, // expr_not
S_expr_call = 164, // expr_call
S_expr_method = 165, // expr_method
S_expr_function = 166, // expr_function
S_expr_pointer = 167, // expr_pointer
S_expr_add_array = 168, // expr_add_array
S_expr_parameters = 169, // expr_parameters
S_expr_arguments = 170, // expr_arguments
S_expr_arguments_no_empty = 171, // expr_arguments_no_empty
S_expr_isdefined = 172, // expr_isdefined
S_expr_istrue = 173, // expr_istrue
S_expr_reference = 174, // expr_reference
S_expr_array = 175, // expr_array
S_expr_field = 176, // expr_field
S_expr_size = 177, // expr_size
S_expr_paren = 178, // expr_paren
S_expr_object = 179, // expr_object
S_expr_thisthread = 180, // expr_thisthread
S_expr_empty_array = 181, // expr_empty_array
S_expr_undefined = 182, // expr_undefined
S_expr_game = 183, // expr_game
S_expr_self = 184, // expr_self
S_expr_anim = 185, // expr_anim
S_expr_level = 186, // expr_level
S_expr_animation = 187, // expr_animation
S_expr_animtree = 188, // expr_animtree
S_expr_identifier = 189, // expr_identifier
S_expr_path = 190, // expr_path
S_expr_istring = 191, // expr_istring
S_expr_string = 192, // expr_string
S_expr_color = 193, // expr_color
S_expr_vector = 194, // expr_vector
S_expr_float = 195, // expr_float
S_expr_integer = 196, // expr_integer
S_expr_false = 197, // expr_false
S_expr_true = 198 // expr_true
};
};
@ -2835,6 +2851,126 @@ switch (yykind)
return symbol_type (token::IW8UNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSDEFINE (location_type l)
{
return symbol_type (token::HSDEFINE, std::move (l));
}
#else
static
symbol_type
make_HSDEFINE (const location_type& l)
{
return symbol_type (token::HSDEFINE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSUNDEF (location_type l)
{
return symbol_type (token::HSUNDEF, std::move (l));
}
#else
static
symbol_type
make_HSUNDEF (const location_type& l)
{
return symbol_type (token::HSUNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFDEF (location_type l)
{
return symbol_type (token::HSIFDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFDEF (const location_type& l)
{
return symbol_type (token::HSIFDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFNDEF (location_type l)
{
return symbol_type (token::HSIFNDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFNDEF (const location_type& l)
{
return symbol_type (token::HSIFNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIF (location_type l)
{
return symbol_type (token::HSIF, std::move (l));
}
#else
static
symbol_type
make_HSIF (const location_type& l)
{
return symbol_type (token::HSIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELIF (location_type l)
{
return symbol_type (token::HSELIF, std::move (l));
}
#else
static
symbol_type
make_HSELIF (const location_type& l)
{
return symbol_type (token::HSELIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELSE (location_type l)
{
return symbol_type (token::HSELSE, std::move (l));
}
#else
static
symbol_type
make_HSELSE (const location_type& l)
{
return symbol_type (token::HSELSE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSENDIF (location_type l)
{
return symbol_type (token::HSENDIF, std::move (l));
}
#else
static
symbol_type
make_HSENDIF (const location_type& l)
{
return symbol_type (token::HSENDIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -5464,7 +5600,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw8
#line 5468 "parser.hpp"
#line 5604 "parser.hpp"

View File

@ -16,58 +16,6 @@ xsk::gsc::s1::parser::symbol_type S1lex(xsk::gsc::s1::lexer& lexer)
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() : length(0)
{
data = static_cast<char*>(std::malloc(max_buf_size));
@ -130,7 +78,7 @@ void reader::advance()
}
}
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(xsk::gsc::location(&name)),
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(location(&name)),
mode_(build::dev), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
{
reader_.init(data, size);
@ -141,7 +89,7 @@ void lexer::push_header(const std::string& file)
try
{
if (header_top_++ >= 10)
throw xsk::gsc::error("maximum gsh depth exceeded '10'");
throw comp_error(loc_, "maximum gsh depth exceeded '10'");
auto data = resolver::file_data(file + ".gsh");
@ -152,7 +100,7 @@ void lexer::push_header(const std::string& file)
}
catch (const std::exception& e)
{
throw xsk::gsc::error("parsing header file '" + file + "': " + e.what());
throw error("parsing header file '" + file + "': " + e.what());
}
}
@ -165,7 +113,7 @@ void lexer::pop_header()
readers_.pop();
}
void lexer::restrict_header(const xsk::gsc::location& loc)
void lexer::ban_header(const location& loc)
{
if (header_top_ > 0)
{
@ -173,7 +121,7 @@ void lexer::restrict_header(const xsk::gsc::location& loc)
}
}
auto lexer::lex() -> xsk::gsc::s1::parser::symbol_type
auto lexer::lex() -> parser::symbol_type
{
buffer_.length = 0;
state_ = state::start;
@ -194,7 +142,7 @@ auto lexer::lex() -> xsk::gsc::s1::parser::symbol_type
if (header_top_ > 0)
pop_header();
else
return s1::parser::make_S1EOF(loc_);
return parser::make_S1EOF(loc_);
}
reader_.advance();
@ -212,22 +160,22 @@ auto lexer::lex() -> xsk::gsc::s1::parser::symbol_type
continue;
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
return s1::parser::make_DIV(loc_);
return parser::make_DIV(loc_);
reader_.advance();
if (last == '=')
return s1::parser::make_ASSIGN_DIV(loc_);
return parser::make_ASSIGN_DIV(loc_);
if (last == '#')
{
if (indev_)
throw comp_error(loc_, "cannot recurse devblock ('/#')");
if (mode_ == xsk::gsc::build::dev)
if (mode_ == build::dev)
{
indev_ = true;
return s1::parser::make_DEVBEGIN(loc_);
return parser::make_DEVBEGIN(loc_);
}
else
{
@ -291,7 +239,7 @@ auto lexer::lex() -> xsk::gsc::s1::parser::symbol_type
indev_ = false;
reader_.advance();
return s1::parser::make_DEVEND(loc_);
return parser::make_DEVEND(loc_);
}
buffer_.push(last);
@ -304,12 +252,12 @@ auto lexer::lex() -> xsk::gsc::s1::parser::symbol_type
goto lex_name;
case '*':
if (curr != '/' && curr != '=')
return s1::parser::make_MUL(loc_);
return parser::make_MUL(loc_);
reader_.advance();
if (last == '=')
return s1::parser::make_ASSIGN_MUL(loc_);
return parser::make_ASSIGN_MUL(loc_);
throw comp_error(loc_, "unmatched multiline comment end ('*/')");
case '"':
@ -324,127 +272,127 @@ auto lexer::lex() -> xsk::gsc::s1::parser::symbol_type
state_ = state::field;
goto lex_name_or_number;
case '(':
return s1::parser::make_LPAREN(loc_);
return parser::make_LPAREN(loc_);
case ')':
return s1::parser::make_RPAREN(loc_);
return parser::make_RPAREN(loc_);
case '{':
return s1::parser::make_LBRACE(loc_);
return parser::make_LBRACE(loc_);
case '}':
return s1::parser::make_RBRACE(loc_);
return parser::make_RBRACE(loc_);
case '[':
return s1::parser::make_LBRACKET(loc_);
return parser::make_LBRACKET(loc_);
case ']':
return s1::parser::make_RBRACKET(loc_);
return parser::make_RBRACKET(loc_);
case ',':
return s1::parser::make_COMMA(loc_);
return parser::make_COMMA(loc_);
case ';':
return s1::parser::make_SEMICOLON(loc_);
return parser::make_SEMICOLON(loc_);
case ':':
if (curr != ':')
return s1::parser::make_COLON(loc_);
return parser::make_COLON(loc_);
reader_.advance();
return s1::parser::make_DOUBLECOLON(loc_);
return parser::make_DOUBLECOLON(loc_);
case '?':
return s1::parser::make_QMARK(loc_);
return parser::make_QMARK(loc_);
case '=':
if (curr != '=')
return s1::parser::make_ASSIGN(loc_);
return parser::make_ASSIGN(loc_);
reader_.advance();
return s1::parser::make_EQUALITY(loc_);
return parser::make_EQUALITY(loc_);
case '+':
if (curr != '+' && curr != '=')
return s1::parser::make_ADD(loc_);
return parser::make_ADD(loc_);
reader_.advance();
if (last == '+')
return s1::parser::make_INCREMENT(loc_);
return parser::make_INCREMENT(loc_);
return s1::parser::make_ASSIGN_ADD(loc_);
return parser::make_ASSIGN_ADD(loc_);
case '-':
if (curr != '-' && curr != '=')
return s1::parser::make_SUB(loc_);
return parser::make_SUB(loc_);
reader_.advance();
if (last == '-')
return s1::parser::make_DECREMENT(loc_);
return parser::make_DECREMENT(loc_);
return s1::parser::make_ASSIGN_SUB(loc_);
return parser::make_ASSIGN_SUB(loc_);
case '%':
if (curr != '=')
return s1::parser::make_MOD(loc_);
return parser::make_MOD(loc_);
reader_.advance();
return s1::parser::make_ASSIGN_MOD(loc_);
return parser::make_ASSIGN_MOD(loc_);
case '|':
if (curr != '|' && curr != '=')
return s1::parser::make_BITWISE_OR(loc_);
return parser::make_BITWISE_OR(loc_);
reader_.advance();
if (last == '|')
return s1::parser::make_OR(loc_);
return parser::make_OR(loc_);
return s1::parser::make_ASSIGN_BW_OR(loc_);
return parser::make_ASSIGN_BW_OR(loc_);
case '&':
if (curr != '&' && curr != '=' && curr != '"' && curr != '\'')
return s1::parser::make_BITWISE_AND(loc_);
return parser::make_BITWISE_AND(loc_);
reader_.advance();
if (last == '&')
return s1::parser::make_AND(loc_);
return parser::make_AND(loc_);
if (last == '=')
return s1::parser::make_ASSIGN_BW_AND(loc_);
return parser::make_ASSIGN_BW_AND(loc_);
state_ = state::localize;
goto lex_string;
case '^':
if (curr != '=')
return s1::parser::make_BITWISE_EXOR(loc_);
return parser::make_BITWISE_EXOR(loc_);
reader_.advance();
return s1::parser::make_ASSIGN_BW_EXOR(loc_);
return parser::make_ASSIGN_BW_EXOR(loc_);
case '!':
if (curr != '=')
return s1::parser::make_NOT(loc_);
return parser::make_NOT(loc_);
reader_.advance();
return s1::parser::make_INEQUALITY(loc_);
return parser::make_INEQUALITY(loc_);
case '~':
return s1::parser::make_COMPLEMENT(loc_);
return parser::make_COMPLEMENT(loc_);
case '<':
if (curr != '<' && curr != '=')
return s1::parser::make_LESS(loc_);
return parser::make_LESS(loc_);
reader_.advance();
if (last == '=')
return s1::parser::make_LESS_EQUAL(loc_);
return parser::make_LESS_EQUAL(loc_);
if (curr != '=')
return s1::parser::make_LSHIFT(loc_);
return parser::make_LSHIFT(loc_);
reader_.advance();
return s1::parser::make_ASSIGN_LSHIFT(loc_);
return parser::make_ASSIGN_LSHIFT(loc_);
case '>':
if (curr != '>' && curr != '=')
return s1::parser::make_GREATER(loc_);
return parser::make_GREATER(loc_);
reader_.advance();
if (last == '=')
return s1::parser::make_GREATER_EQUAL(loc_);
return parser::make_GREATER_EQUAL(loc_);
if (curr != '=')
return s1::parser::make_RSHIFT(loc_);
return parser::make_RSHIFT(loc_);
reader_.advance();
return s1::parser::make_ASSIGN_RSHIFT(loc_);
return parser::make_ASSIGN_RSHIFT(loc_);
default:
lex_name_or_number:
if (last >= '0' && last <= '9')
@ -497,9 +445,9 @@ lex_string:
}
if (state_ == state::localize)
return s1::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return s1::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
lex_name:
buffer_.push(last);
@ -534,44 +482,55 @@ lex_name:
if (std::string_view(buffer_.data, buffer_.length) == "size")
{
return s1::parser::make_SIZE(loc_);
return parser::make_SIZE(loc_);
}
return s1::parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
}
else if (state_ == state::preprocessor)
{
if (path)
throw comp_error(loc_, "invalid preprocessor directive");
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
auto token = parser::token::S1UNDEF;
if (key != keyword::KW_INVALID)
return keyword_token(key);
if (buffer_.length < 16)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
// TODO: call preprocessor(key);
if(itr != keyword_map.end())
{
if (itr->second > parser::token::HSENDIF)
return parser::symbol_type(itr->second, loc_);
token = itr->second;
}
}
// TODO: call preprocessor(token);
throw comp_error(loc_, "unknown preprocessor directive");
state_ = state::start;
continue;
}
else
{
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
if (buffer_.length < 17)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
if (key != keyword::KW_INVALID)
return keyword_token(key);
if(itr != keyword_map.end())
return parser::symbol_type(itr->second, loc_);
}
if (path)
{
if (buffer_.data[buffer_.length - 1] == '/')
throw comp_error(loc_, "invalid path end '\\'");
//return s1::parser::make_PATH(xsk::gsc::s1::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return s1::parser::make_PATH(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_PATH(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
//return s1::parser::make_IDENTIFIER(xsk::gsc::s1::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return s1::parser::make_IDENTIFIER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_IDENTIFIER(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
lex_number:
@ -622,9 +581,9 @@ lex_number:
throw comp_error(loc_, "invalid number literal");
if (state_ == state::field || dot || flt)
return s1::parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return s1::parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
}
else if (curr == 'o')
{
@ -656,7 +615,7 @@ lex_number:
if (last == '\'' || buffer_.length <= 0)
throw comp_error(loc_, "invalid octal literal");
return s1::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
}
else if (curr == 'b')
{
@ -690,7 +649,7 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid binary literal");
return s1::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
}
else if (curr == 'x')
{
@ -724,179 +683,60 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid hexadecimal literal");
return s1::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
}
// cant get here!
}
}
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;
}
return keyword::KW_INVALID;
}
std::unordered_map<std::string_view, keyword> lexer::keywords
const std::unordered_map<std::string_view, parser::token::token_kind_type> lexer::keyword_map
{{
/* { "#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 },
{ "#define", parser::token::HSDEFINE },
{ "#undef", parser::token::HSUNDEF },
{ "#ifdef", parser::token::HSIFDEF },
{ "#ifndef", parser::token::HSIFNDEF },
{ "#if", parser::token::HSIF },
{ "#elif", parser::token::HSELIF },
{ "#else", parser::token::HSELSE },
{ "#endif", parser::token::HSENDIF },
{ "#inline", parser::token::INLINE },
{ "#include", parser::token::INCLUDE },
{ "#using_animtree", parser::token::USINGTREE },
{ "#animtree", parser::token::ANIMTREE },
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
{ "waitframe", parser::token::WAITFRAME },
{ "if", parser::token::IF },
{ "else", parser::token::ELSE },
{ "do", parser::token::DO },
{ "while", parser::token::WHILE },
{ "for", parser::token::FOR },
{ "foreach", parser::token::FOREACH },
{ "in", parser::token::IN },
{ "switch", parser::token::SWITCH },
{ "case", parser::token::CASE },
{ "default", parser::token::DEFAULT },
{ "break", parser::token::BREAK },
{ "continue", parser::token::CONTINUE },
{ "return", parser::token::RETURN },
{ "breakpoint", parser::token::BREAKPOINT },
{ "prof_begin", parser::token::PROFBEGIN },
{ "prof_end", parser::token::PROFEND },
{ "thread", parser::token::THREAD },
{ "childthread", parser::token::CHILDTHREAD },
{ "thisthread", parser::token::THISTHREAD },
{ "call", parser::token::CALL },
{ "true", parser::token::TRUE },
{ "false", parser::token::FALSE },
{ "undefined", parser::token::UNDEFINED },
{ "game", parser::token::GAME },
{ "self", parser::token::SELF },
{ "anim", parser::token::ANIM },
{ "level", parser::token::LEVEL },
}};
} // namespace xsk::gsc::s1

View File

@ -10,8 +10,6 @@
namespace xsk::gsc::s1
{
enum class keyword;
constexpr size_t max_buf_size = 0x2000;
struct buffer
@ -53,26 +51,22 @@ class lexer
reader reader_;
buffer buffer_;
location loc_;
build mode_;
std::stack<location> locs_;
std::stack<reader> readers_;
std::uint32_t header_top_;
state state_;
build mode_;
bool indev_;
public:
lexer(const std::string& name, const char* data, size_t size);
auto lex() -> xsk::gsc::s1::parser::symbol_type;
auto lex() -> parser::symbol_type;
void push_header(const std::string& file);
void pop_header();
void restrict_header(const xsk::gsc::location& loc);
void ban_header(const location& loc);
private:
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<std::string_view, keyword> keywords;
static const std::unordered_map<std::string_view, parser::token::token_kind_type> keyword_map;
};
} // namespace xsk::gsc::s1

File diff suppressed because it is too large Load Diff

View File

@ -677,109 +677,117 @@ namespace xsk { namespace gsc { namespace s1 {
S1EOF = 0, // "end of file"
S1error = 1, // error
S1UNDEF = 2, // "invalid token"
DEVBEGIN = 3, // "/#"
DEVEND = 4, // "#/"
INLINE = 5, // "#inline"
INCLUDE = 6, // "#include"
USINGTREE = 7, // "#using_animtree"
ANIMTREE = 8, // "#animtree"
ENDON = 9, // "endon"
NOTIFY = 10, // "notify"
WAIT = 11, // "wait"
WAITTILL = 12, // "waittill"
WAITTILLMATCH = 13, // "waittillmatch"
WAITTILLFRAMEEND = 14, // "waittillframeend"
WAITFRAME = 15, // "waitframe"
IF = 16, // "if"
ELSE = 17, // "else"
DO = 18, // "do"
WHILE = 19, // "while"
FOR = 20, // "for"
FOREACH = 21, // "foreach"
IN = 22, // "in"
SWITCH = 23, // "switch"
CASE = 24, // "case"
DEFAULT = 25, // "default"
BREAK = 26, // "break"
CONTINUE = 27, // "continue"
RETURN = 28, // "return"
BREAKPOINT = 29, // "breakpoint"
PROFBEGIN = 30, // "prof_begin"
PROFEND = 31, // "prof_end"
THREAD = 32, // "thread"
CHILDTHREAD = 33, // "childthread"
THISTHREAD = 34, // "thisthread"
CALL = 35, // "call"
TRUE = 36, // "true"
FALSE = 37, // "false"
UNDEFINED = 38, // "undefined"
SIZE = 39, // ".size"
GAME = 40, // "game"
SELF = 41, // "self"
ANIM = 42, // "anim"
LEVEL = 43, // "level"
LPAREN = 44, // "("
RPAREN = 45, // ")"
LBRACE = 46, // "{"
RBRACE = 47, // "}"
LBRACKET = 48, // "["
RBRACKET = 49, // "]"
COMMA = 50, // ","
DOT = 51, // "."
DOUBLECOLON = 52, // "::"
COLON = 53, // ":"
SEMICOLON = 54, // ";"
QMARK = 55, // "?"
INCREMENT = 56, // "++"
DECREMENT = 57, // "--"
LSHIFT = 58, // "<<"
RSHIFT = 59, // ">>"
OR = 60, // "||"
AND = 61, // "&&"
EQUALITY = 62, // "=="
INEQUALITY = 63, // "!="
LESS_EQUAL = 64, // "<="
GREATER_EQUAL = 65, // ">="
LESS = 66, // "<"
GREATER = 67, // ">"
NOT = 68, // "!"
COMPLEMENT = 69, // "~"
ASSIGN = 70, // "="
ASSIGN_ADD = 71, // "+="
ASSIGN_SUB = 72, // "-="
ASSIGN_MUL = 73, // "*="
ASSIGN_DIV = 74, // "/="
ASSIGN_MOD = 75, // "%="
ASSIGN_BW_OR = 76, // "|="
ASSIGN_BW_AND = 77, // "&="
ASSIGN_BW_EXOR = 78, // "^="
ASSIGN_RSHIFT = 79, // ">>="
ASSIGN_LSHIFT = 80, // "<<="
BITWISE_OR = 81, // "|"
BITWISE_AND = 82, // "&"
BITWISE_EXOR = 83, // "^"
ADD = 84, // "+"
SUB = 85, // "-"
MUL = 86, // "*"
DIV = 87, // "/"
MOD = 88, // "%"
FIELD = 89, // "field"
PATH = 90, // "path"
IDENTIFIER = 91, // "identifier"
STRING = 92, // "string literal"
ISTRING = 93, // "localized string"
COLOR = 94, // "color"
FLOAT = 95, // "float"
INTEGER = 96, // "integer"
ADD_ARRAY = 97, // ADD_ARRAY
THEN = 98, // THEN
TERN = 99, // TERN
NEG = 100, // NEG
ANIMREF = 101, // ANIMREF
PREINC = 102, // PREINC
PREDEC = 103, // PREDEC
POSTINC = 104, // POSTINC
POSTDEC = 105 // POSTDEC
HSDEFINE = 3, // "#define"
HSUNDEF = 4, // "#undef"
HSIFDEF = 5, // "#ifdef"
HSIFNDEF = 6, // "#ifndef"
HSIF = 7, // "#if"
HSELIF = 8, // "#elif"
HSELSE = 9, // "#else"
HSENDIF = 10, // "#endif"
DEVBEGIN = 11, // "/#"
DEVEND = 12, // "#/"
INLINE = 13, // "#inline"
INCLUDE = 14, // "#include"
USINGTREE = 15, // "#using_animtree"
ANIMTREE = 16, // "#animtree"
ENDON = 17, // "endon"
NOTIFY = 18, // "notify"
WAIT = 19, // "wait"
WAITTILL = 20, // "waittill"
WAITTILLMATCH = 21, // "waittillmatch"
WAITTILLFRAMEEND = 22, // "waittillframeend"
WAITFRAME = 23, // "waitframe"
IF = 24, // "if"
ELSE = 25, // "else"
DO = 26, // "do"
WHILE = 27, // "while"
FOR = 28, // "for"
FOREACH = 29, // "foreach"
IN = 30, // "in"
SWITCH = 31, // "switch"
CASE = 32, // "case"
DEFAULT = 33, // "default"
BREAK = 34, // "break"
CONTINUE = 35, // "continue"
RETURN = 36, // "return"
BREAKPOINT = 37, // "breakpoint"
PROFBEGIN = 38, // "prof_begin"
PROFEND = 39, // "prof_end"
THREAD = 40, // "thread"
CHILDTHREAD = 41, // "childthread"
THISTHREAD = 42, // "thisthread"
CALL = 43, // "call"
TRUE = 44, // "true"
FALSE = 45, // "false"
UNDEFINED = 46, // "undefined"
SIZE = 47, // ".size"
GAME = 48, // "game"
SELF = 49, // "self"
ANIM = 50, // "anim"
LEVEL = 51, // "level"
LPAREN = 52, // "("
RPAREN = 53, // ")"
LBRACE = 54, // "{"
RBRACE = 55, // "}"
LBRACKET = 56, // "["
RBRACKET = 57, // "]"
COMMA = 58, // ","
DOT = 59, // "."
DOUBLECOLON = 60, // "::"
COLON = 61, // ":"
SEMICOLON = 62, // ";"
QMARK = 63, // "?"
INCREMENT = 64, // "++"
DECREMENT = 65, // "--"
LSHIFT = 66, // "<<"
RSHIFT = 67, // ">>"
OR = 68, // "||"
AND = 69, // "&&"
EQUALITY = 70, // "=="
INEQUALITY = 71, // "!="
LESS_EQUAL = 72, // "<="
GREATER_EQUAL = 73, // ">="
LESS = 74, // "<"
GREATER = 75, // ">"
NOT = 76, // "!"
COMPLEMENT = 77, // "~"
ASSIGN = 78, // "="
ASSIGN_ADD = 79, // "+="
ASSIGN_SUB = 80, // "-="
ASSIGN_MUL = 81, // "*="
ASSIGN_DIV = 82, // "/="
ASSIGN_MOD = 83, // "%="
ASSIGN_BW_OR = 84, // "|="
ASSIGN_BW_AND = 85, // "&="
ASSIGN_BW_EXOR = 86, // "^="
ASSIGN_RSHIFT = 87, // ">>="
ASSIGN_LSHIFT = 88, // "<<="
BITWISE_OR = 89, // "|"
BITWISE_AND = 90, // "&"
BITWISE_EXOR = 91, // "^"
ADD = 92, // "+"
SUB = 93, // "-"
MUL = 94, // "*"
DIV = 95, // "/"
MOD = 96, // "%"
FIELD = 97, // "field"
PATH = 98, // "path"
IDENTIFIER = 99, // "identifier"
STRING = 100, // "string literal"
ISTRING = 101, // "localized string"
COLOR = 102, // "color"
FLOAT = 103, // "float"
INTEGER = 104, // "integer"
ADD_ARRAY = 105, // ADD_ARRAY
THEN = 106, // THEN
TERN = 107, // TERN
NEG = 108, // NEG
ANIMREF = 109, // ANIMREF
PREINC = 110, // PREINC
PREDEC = 111, // PREDEC
POSTINC = 112, // POSTINC
POSTDEC = 113 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -796,195 +804,203 @@ namespace xsk { namespace gsc { namespace s1 {
{
enum symbol_kind_type
{
YYNTOKENS = 106, ///< Number of tokens.
YYNTOKENS = 114, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_DEVBEGIN = 3, // "/#"
S_DEVEND = 4, // "#/"
S_INLINE = 5, // "#inline"
S_INCLUDE = 6, // "#include"
S_USINGTREE = 7, // "#using_animtree"
S_ANIMTREE = 8, // "#animtree"
S_ENDON = 9, // "endon"
S_NOTIFY = 10, // "notify"
S_WAIT = 11, // "wait"
S_WAITTILL = 12, // "waittill"
S_WAITTILLMATCH = 13, // "waittillmatch"
S_WAITTILLFRAMEEND = 14, // "waittillframeend"
S_WAITFRAME = 15, // "waitframe"
S_IF = 16, // "if"
S_ELSE = 17, // "else"
S_DO = 18, // "do"
S_WHILE = 19, // "while"
S_FOR = 20, // "for"
S_FOREACH = 21, // "foreach"
S_IN = 22, // "in"
S_SWITCH = 23, // "switch"
S_CASE = 24, // "case"
S_DEFAULT = 25, // "default"
S_BREAK = 26, // "break"
S_CONTINUE = 27, // "continue"
S_RETURN = 28, // "return"
S_BREAKPOINT = 29, // "breakpoint"
S_PROFBEGIN = 30, // "prof_begin"
S_PROFEND = 31, // "prof_end"
S_THREAD = 32, // "thread"
S_CHILDTHREAD = 33, // "childthread"
S_THISTHREAD = 34, // "thisthread"
S_CALL = 35, // "call"
S_TRUE = 36, // "true"
S_FALSE = 37, // "false"
S_UNDEFINED = 38, // "undefined"
S_SIZE = 39, // ".size"
S_GAME = 40, // "game"
S_SELF = 41, // "self"
S_ANIM = 42, // "anim"
S_LEVEL = 43, // "level"
S_LPAREN = 44, // "("
S_RPAREN = 45, // ")"
S_LBRACE = 46, // "{"
S_RBRACE = 47, // "}"
S_LBRACKET = 48, // "["
S_RBRACKET = 49, // "]"
S_COMMA = 50, // ","
S_DOT = 51, // "."
S_DOUBLECOLON = 52, // "::"
S_COLON = 53, // ":"
S_SEMICOLON = 54, // ";"
S_QMARK = 55, // "?"
S_INCREMENT = 56, // "++"
S_DECREMENT = 57, // "--"
S_LSHIFT = 58, // "<<"
S_RSHIFT = 59, // ">>"
S_OR = 60, // "||"
S_AND = 61, // "&&"
S_EQUALITY = 62, // "=="
S_INEQUALITY = 63, // "!="
S_LESS_EQUAL = 64, // "<="
S_GREATER_EQUAL = 65, // ">="
S_LESS = 66, // "<"
S_GREATER = 67, // ">"
S_NOT = 68, // "!"
S_COMPLEMENT = 69, // "~"
S_ASSIGN = 70, // "="
S_ASSIGN_ADD = 71, // "+="
S_ASSIGN_SUB = 72, // "-="
S_ASSIGN_MUL = 73, // "*="
S_ASSIGN_DIV = 74, // "/="
S_ASSIGN_MOD = 75, // "%="
S_ASSIGN_BW_OR = 76, // "|="
S_ASSIGN_BW_AND = 77, // "&="
S_ASSIGN_BW_EXOR = 78, // "^="
S_ASSIGN_RSHIFT = 79, // ">>="
S_ASSIGN_LSHIFT = 80, // "<<="
S_BITWISE_OR = 81, // "|"
S_BITWISE_AND = 82, // "&"
S_BITWISE_EXOR = 83, // "^"
S_ADD = 84, // "+"
S_SUB = 85, // "-"
S_MUL = 86, // "*"
S_DIV = 87, // "/"
S_MOD = 88, // "%"
S_FIELD = 89, // "field"
S_PATH = 90, // "path"
S_IDENTIFIER = 91, // "identifier"
S_STRING = 92, // "string literal"
S_ISTRING = 93, // "localized string"
S_COLOR = 94, // "color"
S_FLOAT = 95, // "float"
S_INTEGER = 96, // "integer"
S_ADD_ARRAY = 97, // ADD_ARRAY
S_THEN = 98, // THEN
S_TERN = 99, // TERN
S_NEG = 100, // NEG
S_ANIMREF = 101, // ANIMREF
S_PREINC = 102, // PREINC
S_PREDEC = 103, // PREDEC
S_POSTINC = 104, // POSTINC
S_POSTDEC = 105, // POSTDEC
S_YYACCEPT = 106, // $accept
S_root = 107, // root
S_program = 108, // program
S_inline = 109, // inline
S_include = 110, // include
S_declaration = 111, // declaration
S_decl_usingtree = 112, // decl_usingtree
S_decl_constant = 113, // decl_constant
S_decl_thread = 114, // decl_thread
S_stmt = 115, // stmt
S_stmt_dev = 116, // stmt_dev
S_stmt_block = 117, // stmt_block
S_stmt_list = 118, // stmt_list
S_stmt_expr = 119, // stmt_expr
S_stmt_call = 120, // stmt_call
S_stmt_assign = 121, // stmt_assign
S_stmt_endon = 122, // stmt_endon
S_stmt_notify = 123, // stmt_notify
S_stmt_wait = 124, // stmt_wait
S_stmt_waittill = 125, // stmt_waittill
S_stmt_waittillmatch = 126, // stmt_waittillmatch
S_stmt_waittillframeend = 127, // stmt_waittillframeend
S_stmt_waitframe = 128, // stmt_waitframe
S_stmt_if = 129, // stmt_if
S_stmt_ifelse = 130, // stmt_ifelse
S_stmt_while = 131, // stmt_while
S_stmt_dowhile = 132, // stmt_dowhile
S_stmt_for = 133, // stmt_for
S_stmt_foreach = 134, // stmt_foreach
S_stmt_switch = 135, // stmt_switch
S_stmt_case = 136, // stmt_case
S_stmt_default = 137, // stmt_default
S_stmt_break = 138, // stmt_break
S_stmt_continue = 139, // stmt_continue
S_stmt_return = 140, // stmt_return
S_stmt_breakpoint = 141, // stmt_breakpoint
S_stmt_prof_begin = 142, // stmt_prof_begin
S_stmt_prof_end = 143, // stmt_prof_end
S_expr = 144, // expr
S_expr_or_empty = 145, // expr_or_empty
S_expr_assign = 146, // expr_assign
S_expr_increment = 147, // expr_increment
S_expr_decrement = 148, // expr_decrement
S_expr_ternary = 149, // expr_ternary
S_expr_binary = 150, // expr_binary
S_expr_primitive = 151, // expr_primitive
S_expr_complement = 152, // expr_complement
S_expr_not = 153, // expr_not
S_expr_call = 154, // expr_call
S_expr_method = 155, // expr_method
S_expr_function = 156, // expr_function
S_expr_pointer = 157, // expr_pointer
S_expr_add_array = 158, // expr_add_array
S_expr_parameters = 159, // expr_parameters
S_expr_arguments = 160, // expr_arguments
S_expr_arguments_no_empty = 161, // expr_arguments_no_empty
S_expr_reference = 162, // expr_reference
S_expr_array = 163, // expr_array
S_expr_field = 164, // expr_field
S_expr_size = 165, // expr_size
S_expr_paren = 166, // expr_paren
S_expr_object = 167, // expr_object
S_expr_thisthread = 168, // expr_thisthread
S_expr_empty_array = 169, // expr_empty_array
S_expr_undefined = 170, // expr_undefined
S_expr_game = 171, // expr_game
S_expr_self = 172, // expr_self
S_expr_anim = 173, // expr_anim
S_expr_level = 174, // expr_level
S_expr_animation = 175, // expr_animation
S_expr_animtree = 176, // expr_animtree
S_expr_identifier = 177, // expr_identifier
S_expr_path = 178, // expr_path
S_expr_istring = 179, // expr_istring
S_expr_string = 180, // expr_string
S_expr_color = 181, // expr_color
S_expr_vector = 182, // expr_vector
S_expr_float = 183, // expr_float
S_expr_integer = 184, // expr_integer
S_expr_false = 185, // expr_false
S_expr_true = 186 // expr_true
S_HSDEFINE = 3, // "#define"
S_HSUNDEF = 4, // "#undef"
S_HSIFDEF = 5, // "#ifdef"
S_HSIFNDEF = 6, // "#ifndef"
S_HSIF = 7, // "#if"
S_HSELIF = 8, // "#elif"
S_HSELSE = 9, // "#else"
S_HSENDIF = 10, // "#endif"
S_DEVBEGIN = 11, // "/#"
S_DEVEND = 12, // "#/"
S_INLINE = 13, // "#inline"
S_INCLUDE = 14, // "#include"
S_USINGTREE = 15, // "#using_animtree"
S_ANIMTREE = 16, // "#animtree"
S_ENDON = 17, // "endon"
S_NOTIFY = 18, // "notify"
S_WAIT = 19, // "wait"
S_WAITTILL = 20, // "waittill"
S_WAITTILLMATCH = 21, // "waittillmatch"
S_WAITTILLFRAMEEND = 22, // "waittillframeend"
S_WAITFRAME = 23, // "waitframe"
S_IF = 24, // "if"
S_ELSE = 25, // "else"
S_DO = 26, // "do"
S_WHILE = 27, // "while"
S_FOR = 28, // "for"
S_FOREACH = 29, // "foreach"
S_IN = 30, // "in"
S_SWITCH = 31, // "switch"
S_CASE = 32, // "case"
S_DEFAULT = 33, // "default"
S_BREAK = 34, // "break"
S_CONTINUE = 35, // "continue"
S_RETURN = 36, // "return"
S_BREAKPOINT = 37, // "breakpoint"
S_PROFBEGIN = 38, // "prof_begin"
S_PROFEND = 39, // "prof_end"
S_THREAD = 40, // "thread"
S_CHILDTHREAD = 41, // "childthread"
S_THISTHREAD = 42, // "thisthread"
S_CALL = 43, // "call"
S_TRUE = 44, // "true"
S_FALSE = 45, // "false"
S_UNDEFINED = 46, // "undefined"
S_SIZE = 47, // ".size"
S_GAME = 48, // "game"
S_SELF = 49, // "self"
S_ANIM = 50, // "anim"
S_LEVEL = 51, // "level"
S_LPAREN = 52, // "("
S_RPAREN = 53, // ")"
S_LBRACE = 54, // "{"
S_RBRACE = 55, // "}"
S_LBRACKET = 56, // "["
S_RBRACKET = 57, // "]"
S_COMMA = 58, // ","
S_DOT = 59, // "."
S_DOUBLECOLON = 60, // "::"
S_COLON = 61, // ":"
S_SEMICOLON = 62, // ";"
S_QMARK = 63, // "?"
S_INCREMENT = 64, // "++"
S_DECREMENT = 65, // "--"
S_LSHIFT = 66, // "<<"
S_RSHIFT = 67, // ">>"
S_OR = 68, // "||"
S_AND = 69, // "&&"
S_EQUALITY = 70, // "=="
S_INEQUALITY = 71, // "!="
S_LESS_EQUAL = 72, // "<="
S_GREATER_EQUAL = 73, // ">="
S_LESS = 74, // "<"
S_GREATER = 75, // ">"
S_NOT = 76, // "!"
S_COMPLEMENT = 77, // "~"
S_ASSIGN = 78, // "="
S_ASSIGN_ADD = 79, // "+="
S_ASSIGN_SUB = 80, // "-="
S_ASSIGN_MUL = 81, // "*="
S_ASSIGN_DIV = 82, // "/="
S_ASSIGN_MOD = 83, // "%="
S_ASSIGN_BW_OR = 84, // "|="
S_ASSIGN_BW_AND = 85, // "&="
S_ASSIGN_BW_EXOR = 86, // "^="
S_ASSIGN_RSHIFT = 87, // ">>="
S_ASSIGN_LSHIFT = 88, // "<<="
S_BITWISE_OR = 89, // "|"
S_BITWISE_AND = 90, // "&"
S_BITWISE_EXOR = 91, // "^"
S_ADD = 92, // "+"
S_SUB = 93, // "-"
S_MUL = 94, // "*"
S_DIV = 95, // "/"
S_MOD = 96, // "%"
S_FIELD = 97, // "field"
S_PATH = 98, // "path"
S_IDENTIFIER = 99, // "identifier"
S_STRING = 100, // "string literal"
S_ISTRING = 101, // "localized string"
S_COLOR = 102, // "color"
S_FLOAT = 103, // "float"
S_INTEGER = 104, // "integer"
S_ADD_ARRAY = 105, // ADD_ARRAY
S_THEN = 106, // THEN
S_TERN = 107, // TERN
S_NEG = 108, // NEG
S_ANIMREF = 109, // ANIMREF
S_PREINC = 110, // PREINC
S_PREDEC = 111, // PREDEC
S_POSTINC = 112, // POSTINC
S_POSTDEC = 113, // POSTDEC
S_YYACCEPT = 114, // $accept
S_root = 115, // root
S_program = 116, // program
S_inline = 117, // inline
S_include = 118, // include
S_declaration = 119, // declaration
S_decl_usingtree = 120, // decl_usingtree
S_decl_constant = 121, // decl_constant
S_decl_thread = 122, // decl_thread
S_stmt = 123, // stmt
S_stmt_dev = 124, // stmt_dev
S_stmt_block = 125, // stmt_block
S_stmt_list = 126, // stmt_list
S_stmt_expr = 127, // stmt_expr
S_stmt_call = 128, // stmt_call
S_stmt_assign = 129, // stmt_assign
S_stmt_endon = 130, // stmt_endon
S_stmt_notify = 131, // stmt_notify
S_stmt_wait = 132, // stmt_wait
S_stmt_waittill = 133, // stmt_waittill
S_stmt_waittillmatch = 134, // stmt_waittillmatch
S_stmt_waittillframeend = 135, // stmt_waittillframeend
S_stmt_waitframe = 136, // stmt_waitframe
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
};
};
@ -2779,6 +2795,126 @@ switch (yykind)
return symbol_type (token::S1UNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSDEFINE (location_type l)
{
return symbol_type (token::HSDEFINE, std::move (l));
}
#else
static
symbol_type
make_HSDEFINE (const location_type& l)
{
return symbol_type (token::HSDEFINE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSUNDEF (location_type l)
{
return symbol_type (token::HSUNDEF, std::move (l));
}
#else
static
symbol_type
make_HSUNDEF (const location_type& l)
{
return symbol_type (token::HSUNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFDEF (location_type l)
{
return symbol_type (token::HSIFDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFDEF (const location_type& l)
{
return symbol_type (token::HSIFDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFNDEF (location_type l)
{
return symbol_type (token::HSIFNDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFNDEF (const location_type& l)
{
return symbol_type (token::HSIFNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIF (location_type l)
{
return symbol_type (token::HSIF, std::move (l));
}
#else
static
symbol_type
make_HSIF (const location_type& l)
{
return symbol_type (token::HSIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELIF (location_type l)
{
return symbol_type (token::HSELIF, std::move (l));
}
#else
static
symbol_type
make_HSELIF (const location_type& l)
{
return symbol_type (token::HSELIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELSE (location_type l)
{
return symbol_type (token::HSELSE, std::move (l));
}
#else
static
symbol_type
make_HSELSE (const location_type& l)
{
return symbol_type (token::HSELSE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSENDIF (location_type l)
{
return symbol_type (token::HSENDIF, std::move (l));
}
#else
static
symbol_type
make_HSENDIF (const location_type& l)
{
return symbol_type (token::HSENDIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -5362,7 +5498,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::s1
#line 5366 "parser.hpp"
#line 5502 "parser.hpp"

View File

@ -16,58 +16,6 @@ xsk::gsc::s2::parser::symbol_type S2lex(xsk::gsc::s2::lexer& lexer)
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() : length(0)
{
data = static_cast<char*>(std::malloc(max_buf_size));
@ -130,7 +78,7 @@ void reader::advance()
}
}
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(xsk::gsc::location(&name)),
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(location(&name)),
mode_(build::dev), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
{
reader_.init(data, size);
@ -141,7 +89,7 @@ void lexer::push_header(const std::string& file)
try
{
if (header_top_++ >= 10)
throw xsk::gsc::error("maximum gsh depth exceeded '10'");
throw comp_error(loc_, "maximum gsh depth exceeded '10'");
auto data = resolver::file_data(file + ".gsh");
@ -152,7 +100,7 @@ void lexer::push_header(const std::string& file)
}
catch (const std::exception& e)
{
throw xsk::gsc::error("parsing header file '" + file + "': " + e.what());
throw error("parsing header file '" + file + "': " + e.what());
}
}
@ -165,7 +113,7 @@ void lexer::pop_header()
readers_.pop();
}
void lexer::restrict_header(const xsk::gsc::location& loc)
void lexer::ban_header(const location& loc)
{
if (header_top_ > 0)
{
@ -173,7 +121,7 @@ void lexer::restrict_header(const xsk::gsc::location& loc)
}
}
auto lexer::lex() -> xsk::gsc::s2::parser::symbol_type
auto lexer::lex() -> parser::symbol_type
{
buffer_.length = 0;
state_ = state::start;
@ -194,7 +142,7 @@ auto lexer::lex() -> xsk::gsc::s2::parser::symbol_type
if (header_top_ > 0)
pop_header();
else
return s2::parser::make_S2EOF(loc_);
return parser::make_S2EOF(loc_);
}
reader_.advance();
@ -212,22 +160,22 @@ auto lexer::lex() -> xsk::gsc::s2::parser::symbol_type
continue;
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
return s2::parser::make_DIV(loc_);
return parser::make_DIV(loc_);
reader_.advance();
if (last == '=')
return s2::parser::make_ASSIGN_DIV(loc_);
return parser::make_ASSIGN_DIV(loc_);
if (last == '#')
{
if (indev_)
throw comp_error(loc_, "cannot recurse devblock ('/#')");
if (mode_ == xsk::gsc::build::dev)
if (mode_ == build::dev)
{
indev_ = true;
return s2::parser::make_DEVBEGIN(loc_);
return parser::make_DEVBEGIN(loc_);
}
else
{
@ -291,7 +239,7 @@ auto lexer::lex() -> xsk::gsc::s2::parser::symbol_type
indev_ = false;
reader_.advance();
return s2::parser::make_DEVEND(loc_);
return parser::make_DEVEND(loc_);
}
buffer_.push(last);
@ -304,12 +252,12 @@ auto lexer::lex() -> xsk::gsc::s2::parser::symbol_type
goto lex_name;
case '*':
if (curr != '/' && curr != '=')
return s2::parser::make_MUL(loc_);
return parser::make_MUL(loc_);
reader_.advance();
if (last == '=')
return s2::parser::make_ASSIGN_MUL(loc_);
return parser::make_ASSIGN_MUL(loc_);
throw comp_error(loc_, "unmatched multiline comment end ('*/')");
case '"':
@ -324,127 +272,127 @@ auto lexer::lex() -> xsk::gsc::s2::parser::symbol_type
state_ = state::field;
goto lex_name_or_number;
case '(':
return s2::parser::make_LPAREN(loc_);
return parser::make_LPAREN(loc_);
case ')':
return s2::parser::make_RPAREN(loc_);
return parser::make_RPAREN(loc_);
case '{':
return s2::parser::make_LBRACE(loc_);
return parser::make_LBRACE(loc_);
case '}':
return s2::parser::make_RBRACE(loc_);
return parser::make_RBRACE(loc_);
case '[':
return s2::parser::make_LBRACKET(loc_);
return parser::make_LBRACKET(loc_);
case ']':
return s2::parser::make_RBRACKET(loc_);
return parser::make_RBRACKET(loc_);
case ',':
return s2::parser::make_COMMA(loc_);
return parser::make_COMMA(loc_);
case ';':
return s2::parser::make_SEMICOLON(loc_);
return parser::make_SEMICOLON(loc_);
case ':':
if (curr != ':')
return s2::parser::make_COLON(loc_);
return parser::make_COLON(loc_);
reader_.advance();
return s2::parser::make_DOUBLECOLON(loc_);
return parser::make_DOUBLECOLON(loc_);
case '?':
return s2::parser::make_QMARK(loc_);
return parser::make_QMARK(loc_);
case '=':
if (curr != '=')
return s2::parser::make_ASSIGN(loc_);
return parser::make_ASSIGN(loc_);
reader_.advance();
return s2::parser::make_EQUALITY(loc_);
return parser::make_EQUALITY(loc_);
case '+':
if (curr != '+' && curr != '=')
return s2::parser::make_ADD(loc_);
return parser::make_ADD(loc_);
reader_.advance();
if (last == '+')
return s2::parser::make_INCREMENT(loc_);
return parser::make_INCREMENT(loc_);
return s2::parser::make_ASSIGN_ADD(loc_);
return parser::make_ASSIGN_ADD(loc_);
case '-':
if (curr != '-' && curr != '=')
return s2::parser::make_SUB(loc_);
return parser::make_SUB(loc_);
reader_.advance();
if (last == '-')
return s2::parser::make_DECREMENT(loc_);
return parser::make_DECREMENT(loc_);
return s2::parser::make_ASSIGN_SUB(loc_);
return parser::make_ASSIGN_SUB(loc_);
case '%':
if (curr != '=')
return s2::parser::make_MOD(loc_);
return parser::make_MOD(loc_);
reader_.advance();
return s2::parser::make_ASSIGN_MOD(loc_);
return parser::make_ASSIGN_MOD(loc_);
case '|':
if (curr != '|' && curr != '=')
return s2::parser::make_BITWISE_OR(loc_);
return parser::make_BITWISE_OR(loc_);
reader_.advance();
if (last == '|')
return s2::parser::make_OR(loc_);
return parser::make_OR(loc_);
return s2::parser::make_ASSIGN_BW_OR(loc_);
return parser::make_ASSIGN_BW_OR(loc_);
case '&':
if (curr != '&' && curr != '=' && curr != '"' && curr != '\'')
return s2::parser::make_BITWISE_AND(loc_);
return parser::make_BITWISE_AND(loc_);
reader_.advance();
if (last == '&')
return s2::parser::make_AND(loc_);
return parser::make_AND(loc_);
if (last == '=')
return s2::parser::make_ASSIGN_BW_AND(loc_);
return parser::make_ASSIGN_BW_AND(loc_);
state_ = state::localize;
goto lex_string;
case '^':
if (curr != '=')
return s2::parser::make_BITWISE_EXOR(loc_);
return parser::make_BITWISE_EXOR(loc_);
reader_.advance();
return s2::parser::make_ASSIGN_BW_EXOR(loc_);
return parser::make_ASSIGN_BW_EXOR(loc_);
case '!':
if (curr != '=')
return s2::parser::make_NOT(loc_);
return parser::make_NOT(loc_);
reader_.advance();
return s2::parser::make_INEQUALITY(loc_);
return parser::make_INEQUALITY(loc_);
case '~':
return s2::parser::make_COMPLEMENT(loc_);
return parser::make_COMPLEMENT(loc_);
case '<':
if (curr != '<' && curr != '=')
return s2::parser::make_LESS(loc_);
return parser::make_LESS(loc_);
reader_.advance();
if (last == '=')
return s2::parser::make_LESS_EQUAL(loc_);
return parser::make_LESS_EQUAL(loc_);
if (curr != '=')
return s2::parser::make_LSHIFT(loc_);
return parser::make_LSHIFT(loc_);
reader_.advance();
return s2::parser::make_ASSIGN_LSHIFT(loc_);
return parser::make_ASSIGN_LSHIFT(loc_);
case '>':
if (curr != '>' && curr != '=')
return s2::parser::make_GREATER(loc_);
return parser::make_GREATER(loc_);
reader_.advance();
if (last == '=')
return s2::parser::make_GREATER_EQUAL(loc_);
return parser::make_GREATER_EQUAL(loc_);
if (curr != '=')
return s2::parser::make_RSHIFT(loc_);
return parser::make_RSHIFT(loc_);
reader_.advance();
return s2::parser::make_ASSIGN_RSHIFT(loc_);
return parser::make_ASSIGN_RSHIFT(loc_);
default:
lex_name_or_number:
if (last >= '0' && last <= '9')
@ -497,9 +445,9 @@ lex_string:
}
if (state_ == state::localize)
return s2::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return s2::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
lex_name:
buffer_.push(last);
@ -534,44 +482,55 @@ lex_name:
if (std::string_view(buffer_.data, buffer_.length) == "size")
{
return s2::parser::make_SIZE(loc_);
return parser::make_SIZE(loc_);
}
return s2::parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
}
else if (state_ == state::preprocessor)
{
if (path)
throw comp_error(loc_, "invalid preprocessor directive");
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
auto token = parser::token::S2UNDEF;
if (key != keyword::KW_INVALID)
return keyword_token(key);
if (buffer_.length < 16)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
// TODO: call preprocessor(key);
if(itr != keyword_map.end())
{
if (itr->second > parser::token::HSENDIF)
return parser::symbol_type(itr->second, loc_);
token = itr->second;
}
}
// TODO: call preprocessor(token);
throw comp_error(loc_, "unknown preprocessor directive");
state_ = state::start;
continue;
}
else
{
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
if (buffer_.length < 17)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
if (key != keyword::KW_INVALID)
return keyword_token(key);
if(itr != keyword_map.end())
return parser::symbol_type(itr->second, loc_);
}
if (path)
{
if (buffer_.data[buffer_.length - 1] == '/')
throw comp_error(loc_, "invalid path end '\\'");
//return s2::parser::make_PATH(xsk::gsc::s2::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return s2::parser::make_PATH(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_PATH(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
//return s2::parser::make_IDENTIFIER(xsk::gsc::s2::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return s2::parser::make_IDENTIFIER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_IDENTIFIER(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
lex_number:
@ -622,9 +581,9 @@ lex_number:
throw comp_error(loc_, "invalid number literal");
if (state_ == state::field || dot || flt)
return s2::parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return s2::parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
}
else if (curr == 'o')
{
@ -656,7 +615,7 @@ lex_number:
if (last == '\'' || buffer_.length <= 0)
throw comp_error(loc_, "invalid octal literal");
return s2::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
}
else if (curr == 'b')
{
@ -690,7 +649,7 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid binary literal");
return s2::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
}
else if (curr == 'x')
{
@ -724,179 +683,60 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid hexadecimal literal");
return s2::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
}
// cant get here!
}
}
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;
}
return keyword::KW_INVALID;
}
std::unordered_map<std::string_view, keyword> lexer::keywords
const std::unordered_map<std::string_view, parser::token::token_kind_type> lexer::keyword_map
{{
/* { "#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 },
{ "#define", parser::token::HSDEFINE },
{ "#undef", parser::token::HSUNDEF },
{ "#ifdef", parser::token::HSIFDEF },
{ "#ifndef", parser::token::HSIFNDEF },
{ "#if", parser::token::HSIF },
{ "#elif", parser::token::HSELIF },
{ "#else", parser::token::HSELSE },
{ "#endif", parser::token::HSENDIF },
{ "#inline", parser::token::INLINE },
{ "#include", parser::token::INCLUDE },
{ "#using_animtree", parser::token::USINGTREE },
{ "#animtree", parser::token::ANIMTREE },
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
{ "waitframe", parser::token::WAITFRAME },
{ "if", parser::token::IF },
{ "else", parser::token::ELSE },
{ "do", parser::token::DO },
{ "while", parser::token::WHILE },
{ "for", parser::token::FOR },
{ "foreach", parser::token::FOREACH },
{ "in", parser::token::IN },
{ "switch", parser::token::SWITCH },
{ "case", parser::token::CASE },
{ "default", parser::token::DEFAULT },
{ "break", parser::token::BREAK },
{ "continue", parser::token::CONTINUE },
{ "return", parser::token::RETURN },
{ "breakpoint", parser::token::BREAKPOINT },
{ "prof_begin", parser::token::PROFBEGIN },
{ "prof_end", parser::token::PROFEND },
{ "thread", parser::token::THREAD },
{ "childthread", parser::token::CHILDTHREAD },
{ "thisthread", parser::token::THISTHREAD },
{ "call", parser::token::CALL },
{ "true", parser::token::TRUE },
{ "false", parser::token::FALSE },
{ "undefined", parser::token::UNDEFINED },
{ "game", parser::token::GAME },
{ "self", parser::token::SELF },
{ "anim", parser::token::ANIM },
{ "level", parser::token::LEVEL },
}};
} // namespace xsk::gsc::s2

View File

@ -10,8 +10,6 @@
namespace xsk::gsc::s2
{
enum class keyword;
constexpr size_t max_buf_size = 0x2000;
struct buffer
@ -53,26 +51,22 @@ class lexer
reader reader_;
buffer buffer_;
location loc_;
build mode_;
std::stack<location> locs_;
std::stack<reader> readers_;
std::uint32_t header_top_;
state state_;
build mode_;
bool indev_;
public:
lexer(const std::string& name, const char* data, size_t size);
auto lex() -> xsk::gsc::s2::parser::symbol_type;
auto lex() -> parser::symbol_type;
void push_header(const std::string& file);
void pop_header();
void restrict_header(const xsk::gsc::location& loc);
void ban_header(const location& loc);
private:
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<std::string_view, keyword> keywords;
static const std::unordered_map<std::string_view, parser::token::token_kind_type> keyword_map;
};
} // namespace xsk::gsc::s2

File diff suppressed because it is too large Load Diff

View File

@ -677,109 +677,117 @@ namespace xsk { namespace gsc { namespace s2 {
S2EOF = 0, // "end of file"
S2error = 1, // error
S2UNDEF = 2, // "invalid token"
DEVBEGIN = 3, // "/#"
DEVEND = 4, // "#/"
INLINE = 5, // "#inline"
INCLUDE = 6, // "#include"
USINGTREE = 7, // "#using_animtree"
ANIMTREE = 8, // "#animtree"
ENDON = 9, // "endon"
NOTIFY = 10, // "notify"
WAIT = 11, // "wait"
WAITTILL = 12, // "waittill"
WAITTILLMATCH = 13, // "waittillmatch"
WAITTILLFRAMEEND = 14, // "waittillframeend"
WAITFRAME = 15, // "waitframe"
IF = 16, // "if"
ELSE = 17, // "else"
DO = 18, // "do"
WHILE = 19, // "while"
FOR = 20, // "for"
FOREACH = 21, // "foreach"
IN = 22, // "in"
SWITCH = 23, // "switch"
CASE = 24, // "case"
DEFAULT = 25, // "default"
BREAK = 26, // "break"
CONTINUE = 27, // "continue"
RETURN = 28, // "return"
BREAKPOINT = 29, // "breakpoint"
PROFBEGIN = 30, // "prof_begin"
PROFEND = 31, // "prof_end"
THREAD = 32, // "thread"
CHILDTHREAD = 33, // "childthread"
THISTHREAD = 34, // "thisthread"
CALL = 35, // "call"
TRUE = 36, // "true"
FALSE = 37, // "false"
UNDEFINED = 38, // "undefined"
SIZE = 39, // ".size"
GAME = 40, // "game"
SELF = 41, // "self"
ANIM = 42, // "anim"
LEVEL = 43, // "level"
LPAREN = 44, // "("
RPAREN = 45, // ")"
LBRACE = 46, // "{"
RBRACE = 47, // "}"
LBRACKET = 48, // "["
RBRACKET = 49, // "]"
COMMA = 50, // ","
DOT = 51, // "."
DOUBLECOLON = 52, // "::"
COLON = 53, // ":"
SEMICOLON = 54, // ";"
QMARK = 55, // "?"
INCREMENT = 56, // "++"
DECREMENT = 57, // "--"
LSHIFT = 58, // "<<"
RSHIFT = 59, // ">>"
OR = 60, // "||"
AND = 61, // "&&"
EQUALITY = 62, // "=="
INEQUALITY = 63, // "!="
LESS_EQUAL = 64, // "<="
GREATER_EQUAL = 65, // ">="
LESS = 66, // "<"
GREATER = 67, // ">"
NOT = 68, // "!"
COMPLEMENT = 69, // "~"
ASSIGN = 70, // "="
ASSIGN_ADD = 71, // "+="
ASSIGN_SUB = 72, // "-="
ASSIGN_MUL = 73, // "*="
ASSIGN_DIV = 74, // "/="
ASSIGN_MOD = 75, // "%="
ASSIGN_BW_OR = 76, // "|="
ASSIGN_BW_AND = 77, // "&="
ASSIGN_BW_EXOR = 78, // "^="
ASSIGN_RSHIFT = 79, // ">>="
ASSIGN_LSHIFT = 80, // "<<="
BITWISE_OR = 81, // "|"
BITWISE_AND = 82, // "&"
BITWISE_EXOR = 83, // "^"
ADD = 84, // "+"
SUB = 85, // "-"
MUL = 86, // "*"
DIV = 87, // "/"
MOD = 88, // "%"
FIELD = 89, // "field"
PATH = 90, // "path"
IDENTIFIER = 91, // "identifier"
STRING = 92, // "string literal"
ISTRING = 93, // "localized string"
COLOR = 94, // "color"
FLOAT = 95, // "float"
INTEGER = 96, // "integer"
ADD_ARRAY = 97, // ADD_ARRAY
THEN = 98, // THEN
TERN = 99, // TERN
NEG = 100, // NEG
ANIMREF = 101, // ANIMREF
PREINC = 102, // PREINC
PREDEC = 103, // PREDEC
POSTINC = 104, // POSTINC
POSTDEC = 105 // POSTDEC
HSDEFINE = 3, // "#define"
HSUNDEF = 4, // "#undef"
HSIFDEF = 5, // "#ifdef"
HSIFNDEF = 6, // "#ifndef"
HSIF = 7, // "#if"
HSELIF = 8, // "#elif"
HSELSE = 9, // "#else"
HSENDIF = 10, // "#endif"
DEVBEGIN = 11, // "/#"
DEVEND = 12, // "#/"
INLINE = 13, // "#inline"
INCLUDE = 14, // "#include"
USINGTREE = 15, // "#using_animtree"
ANIMTREE = 16, // "#animtree"
ENDON = 17, // "endon"
NOTIFY = 18, // "notify"
WAIT = 19, // "wait"
WAITTILL = 20, // "waittill"
WAITTILLMATCH = 21, // "waittillmatch"
WAITTILLFRAMEEND = 22, // "waittillframeend"
WAITFRAME = 23, // "waitframe"
IF = 24, // "if"
ELSE = 25, // "else"
DO = 26, // "do"
WHILE = 27, // "while"
FOR = 28, // "for"
FOREACH = 29, // "foreach"
IN = 30, // "in"
SWITCH = 31, // "switch"
CASE = 32, // "case"
DEFAULT = 33, // "default"
BREAK = 34, // "break"
CONTINUE = 35, // "continue"
RETURN = 36, // "return"
BREAKPOINT = 37, // "breakpoint"
PROFBEGIN = 38, // "prof_begin"
PROFEND = 39, // "prof_end"
THREAD = 40, // "thread"
CHILDTHREAD = 41, // "childthread"
THISTHREAD = 42, // "thisthread"
CALL = 43, // "call"
TRUE = 44, // "true"
FALSE = 45, // "false"
UNDEFINED = 46, // "undefined"
SIZE = 47, // ".size"
GAME = 48, // "game"
SELF = 49, // "self"
ANIM = 50, // "anim"
LEVEL = 51, // "level"
LPAREN = 52, // "("
RPAREN = 53, // ")"
LBRACE = 54, // "{"
RBRACE = 55, // "}"
LBRACKET = 56, // "["
RBRACKET = 57, // "]"
COMMA = 58, // ","
DOT = 59, // "."
DOUBLECOLON = 60, // "::"
COLON = 61, // ":"
SEMICOLON = 62, // ";"
QMARK = 63, // "?"
INCREMENT = 64, // "++"
DECREMENT = 65, // "--"
LSHIFT = 66, // "<<"
RSHIFT = 67, // ">>"
OR = 68, // "||"
AND = 69, // "&&"
EQUALITY = 70, // "=="
INEQUALITY = 71, // "!="
LESS_EQUAL = 72, // "<="
GREATER_EQUAL = 73, // ">="
LESS = 74, // "<"
GREATER = 75, // ">"
NOT = 76, // "!"
COMPLEMENT = 77, // "~"
ASSIGN = 78, // "="
ASSIGN_ADD = 79, // "+="
ASSIGN_SUB = 80, // "-="
ASSIGN_MUL = 81, // "*="
ASSIGN_DIV = 82, // "/="
ASSIGN_MOD = 83, // "%="
ASSIGN_BW_OR = 84, // "|="
ASSIGN_BW_AND = 85, // "&="
ASSIGN_BW_EXOR = 86, // "^="
ASSIGN_RSHIFT = 87, // ">>="
ASSIGN_LSHIFT = 88, // "<<="
BITWISE_OR = 89, // "|"
BITWISE_AND = 90, // "&"
BITWISE_EXOR = 91, // "^"
ADD = 92, // "+"
SUB = 93, // "-"
MUL = 94, // "*"
DIV = 95, // "/"
MOD = 96, // "%"
FIELD = 97, // "field"
PATH = 98, // "path"
IDENTIFIER = 99, // "identifier"
STRING = 100, // "string literal"
ISTRING = 101, // "localized string"
COLOR = 102, // "color"
FLOAT = 103, // "float"
INTEGER = 104, // "integer"
ADD_ARRAY = 105, // ADD_ARRAY
THEN = 106, // THEN
TERN = 107, // TERN
NEG = 108, // NEG
ANIMREF = 109, // ANIMREF
PREINC = 110, // PREINC
PREDEC = 111, // PREDEC
POSTINC = 112, // POSTINC
POSTDEC = 113 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -796,195 +804,203 @@ namespace xsk { namespace gsc { namespace s2 {
{
enum symbol_kind_type
{
YYNTOKENS = 106, ///< Number of tokens.
YYNTOKENS = 114, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_DEVBEGIN = 3, // "/#"
S_DEVEND = 4, // "#/"
S_INLINE = 5, // "#inline"
S_INCLUDE = 6, // "#include"
S_USINGTREE = 7, // "#using_animtree"
S_ANIMTREE = 8, // "#animtree"
S_ENDON = 9, // "endon"
S_NOTIFY = 10, // "notify"
S_WAIT = 11, // "wait"
S_WAITTILL = 12, // "waittill"
S_WAITTILLMATCH = 13, // "waittillmatch"
S_WAITTILLFRAMEEND = 14, // "waittillframeend"
S_WAITFRAME = 15, // "waitframe"
S_IF = 16, // "if"
S_ELSE = 17, // "else"
S_DO = 18, // "do"
S_WHILE = 19, // "while"
S_FOR = 20, // "for"
S_FOREACH = 21, // "foreach"
S_IN = 22, // "in"
S_SWITCH = 23, // "switch"
S_CASE = 24, // "case"
S_DEFAULT = 25, // "default"
S_BREAK = 26, // "break"
S_CONTINUE = 27, // "continue"
S_RETURN = 28, // "return"
S_BREAKPOINT = 29, // "breakpoint"
S_PROFBEGIN = 30, // "prof_begin"
S_PROFEND = 31, // "prof_end"
S_THREAD = 32, // "thread"
S_CHILDTHREAD = 33, // "childthread"
S_THISTHREAD = 34, // "thisthread"
S_CALL = 35, // "call"
S_TRUE = 36, // "true"
S_FALSE = 37, // "false"
S_UNDEFINED = 38, // "undefined"
S_SIZE = 39, // ".size"
S_GAME = 40, // "game"
S_SELF = 41, // "self"
S_ANIM = 42, // "anim"
S_LEVEL = 43, // "level"
S_LPAREN = 44, // "("
S_RPAREN = 45, // ")"
S_LBRACE = 46, // "{"
S_RBRACE = 47, // "}"
S_LBRACKET = 48, // "["
S_RBRACKET = 49, // "]"
S_COMMA = 50, // ","
S_DOT = 51, // "."
S_DOUBLECOLON = 52, // "::"
S_COLON = 53, // ":"
S_SEMICOLON = 54, // ";"
S_QMARK = 55, // "?"
S_INCREMENT = 56, // "++"
S_DECREMENT = 57, // "--"
S_LSHIFT = 58, // "<<"
S_RSHIFT = 59, // ">>"
S_OR = 60, // "||"
S_AND = 61, // "&&"
S_EQUALITY = 62, // "=="
S_INEQUALITY = 63, // "!="
S_LESS_EQUAL = 64, // "<="
S_GREATER_EQUAL = 65, // ">="
S_LESS = 66, // "<"
S_GREATER = 67, // ">"
S_NOT = 68, // "!"
S_COMPLEMENT = 69, // "~"
S_ASSIGN = 70, // "="
S_ASSIGN_ADD = 71, // "+="
S_ASSIGN_SUB = 72, // "-="
S_ASSIGN_MUL = 73, // "*="
S_ASSIGN_DIV = 74, // "/="
S_ASSIGN_MOD = 75, // "%="
S_ASSIGN_BW_OR = 76, // "|="
S_ASSIGN_BW_AND = 77, // "&="
S_ASSIGN_BW_EXOR = 78, // "^="
S_ASSIGN_RSHIFT = 79, // ">>="
S_ASSIGN_LSHIFT = 80, // "<<="
S_BITWISE_OR = 81, // "|"
S_BITWISE_AND = 82, // "&"
S_BITWISE_EXOR = 83, // "^"
S_ADD = 84, // "+"
S_SUB = 85, // "-"
S_MUL = 86, // "*"
S_DIV = 87, // "/"
S_MOD = 88, // "%"
S_FIELD = 89, // "field"
S_PATH = 90, // "path"
S_IDENTIFIER = 91, // "identifier"
S_STRING = 92, // "string literal"
S_ISTRING = 93, // "localized string"
S_COLOR = 94, // "color"
S_FLOAT = 95, // "float"
S_INTEGER = 96, // "integer"
S_ADD_ARRAY = 97, // ADD_ARRAY
S_THEN = 98, // THEN
S_TERN = 99, // TERN
S_NEG = 100, // NEG
S_ANIMREF = 101, // ANIMREF
S_PREINC = 102, // PREINC
S_PREDEC = 103, // PREDEC
S_POSTINC = 104, // POSTINC
S_POSTDEC = 105, // POSTDEC
S_YYACCEPT = 106, // $accept
S_root = 107, // root
S_program = 108, // program
S_inline = 109, // inline
S_include = 110, // include
S_declaration = 111, // declaration
S_decl_usingtree = 112, // decl_usingtree
S_decl_constant = 113, // decl_constant
S_decl_thread = 114, // decl_thread
S_stmt = 115, // stmt
S_stmt_dev = 116, // stmt_dev
S_stmt_block = 117, // stmt_block
S_stmt_list = 118, // stmt_list
S_stmt_expr = 119, // stmt_expr
S_stmt_call = 120, // stmt_call
S_stmt_assign = 121, // stmt_assign
S_stmt_endon = 122, // stmt_endon
S_stmt_notify = 123, // stmt_notify
S_stmt_wait = 124, // stmt_wait
S_stmt_waittill = 125, // stmt_waittill
S_stmt_waittillmatch = 126, // stmt_waittillmatch
S_stmt_waittillframeend = 127, // stmt_waittillframeend
S_stmt_waitframe = 128, // stmt_waitframe
S_stmt_if = 129, // stmt_if
S_stmt_ifelse = 130, // stmt_ifelse
S_stmt_while = 131, // stmt_while
S_stmt_dowhile = 132, // stmt_dowhile
S_stmt_for = 133, // stmt_for
S_stmt_foreach = 134, // stmt_foreach
S_stmt_switch = 135, // stmt_switch
S_stmt_case = 136, // stmt_case
S_stmt_default = 137, // stmt_default
S_stmt_break = 138, // stmt_break
S_stmt_continue = 139, // stmt_continue
S_stmt_return = 140, // stmt_return
S_stmt_breakpoint = 141, // stmt_breakpoint
S_stmt_prof_begin = 142, // stmt_prof_begin
S_stmt_prof_end = 143, // stmt_prof_end
S_expr = 144, // expr
S_expr_or_empty = 145, // expr_or_empty
S_expr_assign = 146, // expr_assign
S_expr_increment = 147, // expr_increment
S_expr_decrement = 148, // expr_decrement
S_expr_ternary = 149, // expr_ternary
S_expr_binary = 150, // expr_binary
S_expr_primitive = 151, // expr_primitive
S_expr_complement = 152, // expr_complement
S_expr_not = 153, // expr_not
S_expr_call = 154, // expr_call
S_expr_method = 155, // expr_method
S_expr_function = 156, // expr_function
S_expr_pointer = 157, // expr_pointer
S_expr_add_array = 158, // expr_add_array
S_expr_parameters = 159, // expr_parameters
S_expr_arguments = 160, // expr_arguments
S_expr_arguments_no_empty = 161, // expr_arguments_no_empty
S_expr_reference = 162, // expr_reference
S_expr_array = 163, // expr_array
S_expr_field = 164, // expr_field
S_expr_size = 165, // expr_size
S_expr_paren = 166, // expr_paren
S_expr_object = 167, // expr_object
S_expr_thisthread = 168, // expr_thisthread
S_expr_empty_array = 169, // expr_empty_array
S_expr_undefined = 170, // expr_undefined
S_expr_game = 171, // expr_game
S_expr_self = 172, // expr_self
S_expr_anim = 173, // expr_anim
S_expr_level = 174, // expr_level
S_expr_animation = 175, // expr_animation
S_expr_animtree = 176, // expr_animtree
S_expr_identifier = 177, // expr_identifier
S_expr_path = 178, // expr_path
S_expr_istring = 179, // expr_istring
S_expr_string = 180, // expr_string
S_expr_color = 181, // expr_color
S_expr_vector = 182, // expr_vector
S_expr_float = 183, // expr_float
S_expr_integer = 184, // expr_integer
S_expr_false = 185, // expr_false
S_expr_true = 186 // expr_true
S_HSDEFINE = 3, // "#define"
S_HSUNDEF = 4, // "#undef"
S_HSIFDEF = 5, // "#ifdef"
S_HSIFNDEF = 6, // "#ifndef"
S_HSIF = 7, // "#if"
S_HSELIF = 8, // "#elif"
S_HSELSE = 9, // "#else"
S_HSENDIF = 10, // "#endif"
S_DEVBEGIN = 11, // "/#"
S_DEVEND = 12, // "#/"
S_INLINE = 13, // "#inline"
S_INCLUDE = 14, // "#include"
S_USINGTREE = 15, // "#using_animtree"
S_ANIMTREE = 16, // "#animtree"
S_ENDON = 17, // "endon"
S_NOTIFY = 18, // "notify"
S_WAIT = 19, // "wait"
S_WAITTILL = 20, // "waittill"
S_WAITTILLMATCH = 21, // "waittillmatch"
S_WAITTILLFRAMEEND = 22, // "waittillframeend"
S_WAITFRAME = 23, // "waitframe"
S_IF = 24, // "if"
S_ELSE = 25, // "else"
S_DO = 26, // "do"
S_WHILE = 27, // "while"
S_FOR = 28, // "for"
S_FOREACH = 29, // "foreach"
S_IN = 30, // "in"
S_SWITCH = 31, // "switch"
S_CASE = 32, // "case"
S_DEFAULT = 33, // "default"
S_BREAK = 34, // "break"
S_CONTINUE = 35, // "continue"
S_RETURN = 36, // "return"
S_BREAKPOINT = 37, // "breakpoint"
S_PROFBEGIN = 38, // "prof_begin"
S_PROFEND = 39, // "prof_end"
S_THREAD = 40, // "thread"
S_CHILDTHREAD = 41, // "childthread"
S_THISTHREAD = 42, // "thisthread"
S_CALL = 43, // "call"
S_TRUE = 44, // "true"
S_FALSE = 45, // "false"
S_UNDEFINED = 46, // "undefined"
S_SIZE = 47, // ".size"
S_GAME = 48, // "game"
S_SELF = 49, // "self"
S_ANIM = 50, // "anim"
S_LEVEL = 51, // "level"
S_LPAREN = 52, // "("
S_RPAREN = 53, // ")"
S_LBRACE = 54, // "{"
S_RBRACE = 55, // "}"
S_LBRACKET = 56, // "["
S_RBRACKET = 57, // "]"
S_COMMA = 58, // ","
S_DOT = 59, // "."
S_DOUBLECOLON = 60, // "::"
S_COLON = 61, // ":"
S_SEMICOLON = 62, // ";"
S_QMARK = 63, // "?"
S_INCREMENT = 64, // "++"
S_DECREMENT = 65, // "--"
S_LSHIFT = 66, // "<<"
S_RSHIFT = 67, // ">>"
S_OR = 68, // "||"
S_AND = 69, // "&&"
S_EQUALITY = 70, // "=="
S_INEQUALITY = 71, // "!="
S_LESS_EQUAL = 72, // "<="
S_GREATER_EQUAL = 73, // ">="
S_LESS = 74, // "<"
S_GREATER = 75, // ">"
S_NOT = 76, // "!"
S_COMPLEMENT = 77, // "~"
S_ASSIGN = 78, // "="
S_ASSIGN_ADD = 79, // "+="
S_ASSIGN_SUB = 80, // "-="
S_ASSIGN_MUL = 81, // "*="
S_ASSIGN_DIV = 82, // "/="
S_ASSIGN_MOD = 83, // "%="
S_ASSIGN_BW_OR = 84, // "|="
S_ASSIGN_BW_AND = 85, // "&="
S_ASSIGN_BW_EXOR = 86, // "^="
S_ASSIGN_RSHIFT = 87, // ">>="
S_ASSIGN_LSHIFT = 88, // "<<="
S_BITWISE_OR = 89, // "|"
S_BITWISE_AND = 90, // "&"
S_BITWISE_EXOR = 91, // "^"
S_ADD = 92, // "+"
S_SUB = 93, // "-"
S_MUL = 94, // "*"
S_DIV = 95, // "/"
S_MOD = 96, // "%"
S_FIELD = 97, // "field"
S_PATH = 98, // "path"
S_IDENTIFIER = 99, // "identifier"
S_STRING = 100, // "string literal"
S_ISTRING = 101, // "localized string"
S_COLOR = 102, // "color"
S_FLOAT = 103, // "float"
S_INTEGER = 104, // "integer"
S_ADD_ARRAY = 105, // ADD_ARRAY
S_THEN = 106, // THEN
S_TERN = 107, // TERN
S_NEG = 108, // NEG
S_ANIMREF = 109, // ANIMREF
S_PREINC = 110, // PREINC
S_PREDEC = 111, // PREDEC
S_POSTINC = 112, // POSTINC
S_POSTDEC = 113, // POSTDEC
S_YYACCEPT = 114, // $accept
S_root = 115, // root
S_program = 116, // program
S_inline = 117, // inline
S_include = 118, // include
S_declaration = 119, // declaration
S_decl_usingtree = 120, // decl_usingtree
S_decl_constant = 121, // decl_constant
S_decl_thread = 122, // decl_thread
S_stmt = 123, // stmt
S_stmt_dev = 124, // stmt_dev
S_stmt_block = 125, // stmt_block
S_stmt_list = 126, // stmt_list
S_stmt_expr = 127, // stmt_expr
S_stmt_call = 128, // stmt_call
S_stmt_assign = 129, // stmt_assign
S_stmt_endon = 130, // stmt_endon
S_stmt_notify = 131, // stmt_notify
S_stmt_wait = 132, // stmt_wait
S_stmt_waittill = 133, // stmt_waittill
S_stmt_waittillmatch = 134, // stmt_waittillmatch
S_stmt_waittillframeend = 135, // stmt_waittillframeend
S_stmt_waitframe = 136, // stmt_waitframe
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
};
};
@ -2779,6 +2795,126 @@ switch (yykind)
return symbol_type (token::S2UNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSDEFINE (location_type l)
{
return symbol_type (token::HSDEFINE, std::move (l));
}
#else
static
symbol_type
make_HSDEFINE (const location_type& l)
{
return symbol_type (token::HSDEFINE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSUNDEF (location_type l)
{
return symbol_type (token::HSUNDEF, std::move (l));
}
#else
static
symbol_type
make_HSUNDEF (const location_type& l)
{
return symbol_type (token::HSUNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFDEF (location_type l)
{
return symbol_type (token::HSIFDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFDEF (const location_type& l)
{
return symbol_type (token::HSIFDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFNDEF (location_type l)
{
return symbol_type (token::HSIFNDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFNDEF (const location_type& l)
{
return symbol_type (token::HSIFNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIF (location_type l)
{
return symbol_type (token::HSIF, std::move (l));
}
#else
static
symbol_type
make_HSIF (const location_type& l)
{
return symbol_type (token::HSIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELIF (location_type l)
{
return symbol_type (token::HSELIF, std::move (l));
}
#else
static
symbol_type
make_HSELIF (const location_type& l)
{
return symbol_type (token::HSELIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELSE (location_type l)
{
return symbol_type (token::HSELSE, std::move (l));
}
#else
static
symbol_type
make_HSELSE (const location_type& l)
{
return symbol_type (token::HSELSE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSENDIF (location_type l)
{
return symbol_type (token::HSENDIF, std::move (l));
}
#else
static
symbol_type
make_HSENDIF (const location_type& l)
{
return symbol_type (token::HSENDIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -5362,7 +5498,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::s2
#line 5366 "parser.hpp"
#line 5502 "parser.hpp"

View File

@ -16,60 +16,6 @@ xsk::gsc::s4::parser::symbol_type S4lex(xsk::gsc::s4::lexer& lexer)
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() : length(0)
{
data = static_cast<char*>(std::malloc(max_buf_size));
@ -132,7 +78,7 @@ void reader::advance()
}
}
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(xsk::gsc::location(&name)),
lexer::lexer(const std::string& name, const char* data, size_t size) : indev_(false), loc_(location(&name)),
mode_(build::dev), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
{
reader_.init(data, size);
@ -143,7 +89,7 @@ void lexer::push_header(const std::string& file)
try
{
if (header_top_++ >= 10)
throw xsk::gsc::error("maximum gsh depth exceeded '10'");
throw comp_error(loc_, "maximum gsh depth exceeded '10'");
auto data = resolver::file_data(file + ".gsh");
@ -154,7 +100,7 @@ void lexer::push_header(const std::string& file)
}
catch (const std::exception& e)
{
throw xsk::gsc::error("parsing header file '" + file + "': " + e.what());
throw error("parsing header file '" + file + "': " + e.what());
}
}
@ -167,7 +113,7 @@ void lexer::pop_header()
readers_.pop();
}
void lexer::restrict_header(const xsk::gsc::location& loc)
void lexer::ban_header(const location& loc)
{
if (header_top_ > 0)
{
@ -175,7 +121,7 @@ void lexer::restrict_header(const xsk::gsc::location& loc)
}
}
auto lexer::lex() -> xsk::gsc::s4::parser::symbol_type
auto lexer::lex() -> parser::symbol_type
{
buffer_.length = 0;
state_ = state::start;
@ -196,7 +142,7 @@ auto lexer::lex() -> xsk::gsc::s4::parser::symbol_type
if (header_top_ > 0)
pop_header();
else
return s4::parser::make_S4EOF(loc_);
return parser::make_S4EOF(loc_);
}
reader_.advance();
@ -214,22 +160,22 @@ auto lexer::lex() -> xsk::gsc::s4::parser::symbol_type
continue;
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
return s4::parser::make_DIV(loc_);
return parser::make_DIV(loc_);
reader_.advance();
if (last == '=')
return s4::parser::make_ASSIGN_DIV(loc_);
return parser::make_ASSIGN_DIV(loc_);
if (last == '#')
{
if (indev_)
throw comp_error(loc_, "cannot recurse devblock ('/#')");
if (mode_ == xsk::gsc::build::dev)
if (mode_ == build::dev)
{
indev_ = true;
return s4::parser::make_DEVBEGIN(loc_);
return parser::make_DEVBEGIN(loc_);
}
else
{
@ -293,7 +239,7 @@ auto lexer::lex() -> xsk::gsc::s4::parser::symbol_type
indev_ = false;
reader_.advance();
return s4::parser::make_DEVEND(loc_);
return parser::make_DEVEND(loc_);
}
buffer_.push(last);
@ -306,12 +252,12 @@ auto lexer::lex() -> xsk::gsc::s4::parser::symbol_type
goto lex_name;
case '*':
if (curr != '/' && curr != '=')
return s4::parser::make_MUL(loc_);
return parser::make_MUL(loc_);
reader_.advance();
if (last == '=')
return s4::parser::make_ASSIGN_MUL(loc_);
return parser::make_ASSIGN_MUL(loc_);
throw comp_error(loc_, "unmatched multiline comment end ('*/')");
case '"':
@ -326,127 +272,127 @@ auto lexer::lex() -> xsk::gsc::s4::parser::symbol_type
state_ = state::field;
goto lex_name_or_number;
case '(':
return s4::parser::make_LPAREN(loc_);
return parser::make_LPAREN(loc_);
case ')':
return s4::parser::make_RPAREN(loc_);
return parser::make_RPAREN(loc_);
case '{':
return s4::parser::make_LBRACE(loc_);
return parser::make_LBRACE(loc_);
case '}':
return s4::parser::make_RBRACE(loc_);
return parser::make_RBRACE(loc_);
case '[':
return s4::parser::make_LBRACKET(loc_);
return parser::make_LBRACKET(loc_);
case ']':
return s4::parser::make_RBRACKET(loc_);
return parser::make_RBRACKET(loc_);
case ',':
return s4::parser::make_COMMA(loc_);
return parser::make_COMMA(loc_);
case ';':
return s4::parser::make_SEMICOLON(loc_);
return parser::make_SEMICOLON(loc_);
case ':':
if (curr != ':')
return s4::parser::make_COLON(loc_);
return parser::make_COLON(loc_);
reader_.advance();
return s4::parser::make_DOUBLECOLON(loc_);
return parser::make_DOUBLECOLON(loc_);
case '?':
return s4::parser::make_QMARK(loc_);
return parser::make_QMARK(loc_);
case '=':
if (curr != '=')
return s4::parser::make_ASSIGN(loc_);
return parser::make_ASSIGN(loc_);
reader_.advance();
return s4::parser::make_EQUALITY(loc_);
return parser::make_EQUALITY(loc_);
case '+':
if (curr != '+' && curr != '=')
return s4::parser::make_ADD(loc_);
return parser::make_ADD(loc_);
reader_.advance();
if (last == '+')
return s4::parser::make_INCREMENT(loc_);
return parser::make_INCREMENT(loc_);
return s4::parser::make_ASSIGN_ADD(loc_);
return parser::make_ASSIGN_ADD(loc_);
case '-':
if (curr != '-' && curr != '=')
return s4::parser::make_SUB(loc_);
return parser::make_SUB(loc_);
reader_.advance();
if (last == '-')
return s4::parser::make_DECREMENT(loc_);
return parser::make_DECREMENT(loc_);
return s4::parser::make_ASSIGN_SUB(loc_);
return parser::make_ASSIGN_SUB(loc_);
case '%':
if (curr != '=')
return s4::parser::make_MOD(loc_);
return parser::make_MOD(loc_);
reader_.advance();
return s4::parser::make_ASSIGN_MOD(loc_);
return parser::make_ASSIGN_MOD(loc_);
case '|':
if (curr != '|' && curr != '=')
return s4::parser::make_BITWISE_OR(loc_);
return parser::make_BITWISE_OR(loc_);
reader_.advance();
if (last == '|')
return s4::parser::make_OR(loc_);
return parser::make_OR(loc_);
return s4::parser::make_ASSIGN_BW_OR(loc_);
return parser::make_ASSIGN_BW_OR(loc_);
case '&':
if (curr != '&' && curr != '=' && curr != '"' && curr != '\'')
return s4::parser::make_BITWISE_AND(loc_);
return parser::make_BITWISE_AND(loc_);
reader_.advance();
if (last == '&')
return s4::parser::make_AND(loc_);
return parser::make_AND(loc_);
if (last == '=')
return s4::parser::make_ASSIGN_BW_AND(loc_);
return parser::make_ASSIGN_BW_AND(loc_);
state_ = state::localize;
goto lex_string;
case '^':
if (curr != '=')
return s4::parser::make_BITWISE_EXOR(loc_);
return parser::make_BITWISE_EXOR(loc_);
reader_.advance();
return s4::parser::make_ASSIGN_BW_EXOR(loc_);
return parser::make_ASSIGN_BW_EXOR(loc_);
case '!':
if (curr != '=')
return s4::parser::make_NOT(loc_);
return parser::make_NOT(loc_);
reader_.advance();
return s4::parser::make_INEQUALITY(loc_);
return parser::make_INEQUALITY(loc_);
case '~':
return s4::parser::make_COMPLEMENT(loc_);
return parser::make_COMPLEMENT(loc_);
case '<':
if (curr != '<' && curr != '=')
return s4::parser::make_LESS(loc_);
return parser::make_LESS(loc_);
reader_.advance();
if (last == '=')
return s4::parser::make_LESS_EQUAL(loc_);
return parser::make_LESS_EQUAL(loc_);
if (curr != '=')
return s4::parser::make_LSHIFT(loc_);
return parser::make_LSHIFT(loc_);
reader_.advance();
return s4::parser::make_ASSIGN_LSHIFT(loc_);
return parser::make_ASSIGN_LSHIFT(loc_);
case '>':
if (curr != '>' && curr != '=')
return s4::parser::make_GREATER(loc_);
return parser::make_GREATER(loc_);
reader_.advance();
if (last == '=')
return s4::parser::make_GREATER_EQUAL(loc_);
return parser::make_GREATER_EQUAL(loc_);
if (curr != '=')
return s4::parser::make_RSHIFT(loc_);
return parser::make_RSHIFT(loc_);
reader_.advance();
return s4::parser::make_ASSIGN_RSHIFT(loc_);
return parser::make_ASSIGN_RSHIFT(loc_);
default:
lex_name_or_number:
if (last >= '0' && last <= '9')
@ -499,9 +445,9 @@ lex_string:
}
if (state_ == state::localize)
return s4::parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_ISTRING(std::string(buffer_.data, buffer_.length), loc_);
return s4::parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_STRING(std::string(buffer_.data, buffer_.length), loc_);
lex_name:
buffer_.push(last);
@ -536,22 +482,32 @@ lex_name:
if (std::string_view(buffer_.data, buffer_.length) == "size")
{
return s4::parser::make_SIZE(loc_);
return parser::make_SIZE(loc_);
}
return s4::parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FIELD(std::string(buffer_.data, buffer_.length), loc_);
}
else if (state_ == state::preprocessor)
{
if (path)
throw comp_error(loc_, "invalid preprocessor directive");
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
auto token = parser::token::S4UNDEF;
if (key != keyword::KW_INVALID)
return keyword_token(key);
if (buffer_.length < 16)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
// TODO: call preprocessor(key);
if(itr != keyword_map.end())
{
if (itr->second > parser::token::HSENDIF)
return parser::symbol_type(itr->second, loc_);
token = itr->second;
}
}
// TODO: call preprocessor(token);
throw comp_error(loc_, "unknown preprocessor directive");
state_ = state::start;
continue;
@ -569,22 +525,23 @@ lex_name:
}
}
auto key = get_keyword(std::string_view(buffer_.data, buffer_.length));
if (buffer_.length < 17)
{
const auto& itr = keyword_map.find(std::string_view(buffer_.data, buffer_.length));
if (key != keyword::KW_INVALID)
return keyword_token(key);
if(itr != keyword_map.end())
return parser::symbol_type(itr->second, loc_);
}
if (path)
{
if (buffer_.data[buffer_.length - 1] == '/')
throw comp_error(loc_, "invalid path end '\\'");
//return s4::parser::make_PATH(xsk::gsc::s4::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return s4::parser::make_PATH(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_PATH(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
//return s4::parser::make_IDENTIFIER(xsk::gsc::s4::resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
return s4::parser::make_IDENTIFIER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_IDENTIFIER(resolver::make_token(std::string_view(buffer_.data, buffer_.length)), loc_);
}
lex_number:
@ -635,9 +592,9 @@ lex_number:
throw comp_error(loc_, "invalid number literal");
if (state_ == state::field || dot || flt)
return s4::parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_FLOAT(std::string(buffer_.data, buffer_.length), loc_);
return s4::parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
return parser::make_INTEGER(std::string(buffer_.data, buffer_.length), loc_);
}
else if (curr == 'o')
{
@ -669,7 +626,7 @@ lex_number:
if (last == '\'' || buffer_.length <= 0)
throw comp_error(loc_, "invalid octal literal");
return s4::parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::oct_to_dec(buffer_.data), loc_);
}
else if (curr == 'b')
{
@ -703,7 +660,7 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid binary literal");
return s4::parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::bin_to_dec(buffer_.data), loc_);
}
else if (curr == 'x')
{
@ -737,185 +694,62 @@ lex_number:
if (last == '\'' || buffer_.length < 3)
throw comp_error(loc_, "invalid hexadecimal literal");
return s4::parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
return parser::make_INTEGER(xsk::utils::string::hex_to_dec(buffer_.data), loc_);
}
// cant get here!
}
}
auto lexer::keyword_token(keyword k) -> xsk::gsc::s4::parser::symbol_type
{
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!");
}
}
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;
}
return keyword::KW_INVALID;
}
std::unordered_map<std::string_view, keyword> lexer::keywords
const std::unordered_map<std::string_view, parser::token::token_kind_type> lexer::keyword_map
{{
/* { "#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 },
{ "#define", parser::token::HSDEFINE },
{ "#undef", parser::token::HSUNDEF },
{ "#ifdef", parser::token::HSIFDEF },
{ "#ifndef", parser::token::HSIFNDEF },
{ "#if", parser::token::HSIF },
{ "#elif", parser::token::HSELIF },
{ "#else", parser::token::HSELSE },
{ "#endif", parser::token::HSENDIF },
{ "#inline", parser::token::INLINE },
{ "#include", parser::token::INCLUDE },
{ "#using_animtree", parser::token::USINGTREE },
{ "#animtree", parser::token::ANIMTREE },
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
{ "waitframe", parser::token::WAITFRAME },
{ "if", parser::token::IF },
{ "else", parser::token::ELSE },
{ "do", parser::token::DO },
{ "while", parser::token::WHILE },
{ "for", parser::token::FOR },
{ "foreach", parser::token::FOREACH },
{ "in", parser::token::IN },
{ "switch", parser::token::SWITCH },
{ "case", parser::token::CASE },
{ "default", parser::token::DEFAULT },
{ "break", parser::token::BREAK },
{ "continue", parser::token::CONTINUE },
{ "return", parser::token::RETURN },
{ "breakpoint", parser::token::BREAKPOINT },
{ "prof_begin", parser::token::PROFBEGIN },
{ "prof_end", parser::token::PROFEND },
{ "thread", parser::token::THREAD },
{ "childthread", parser::token::CHILDTHREAD },
{ "thisthread", parser::token::THISTHREAD },
{ "call", parser::token::CALL },
{ "true", parser::token::TRUE },
{ "false", parser::token::FALSE },
{ "undefined", parser::token::UNDEFINED },
{ "game", parser::token::GAME },
{ "self", parser::token::SELF },
{ "anim", parser::token::ANIM },
{ "level", parser::token::LEVEL },
{ "isdefined", parser::token::ISDEFINED },
{ "istrue", parser::token::ISTRUE },
}};
} // namespace xsk::gsc::s4

View File

@ -10,8 +10,6 @@
namespace xsk::gsc::s4
{
enum class keyword;
constexpr size_t max_buf_size = 0x2000;
struct buffer
@ -53,26 +51,22 @@ class lexer
reader reader_;
buffer buffer_;
location loc_;
build mode_;
std::stack<location> locs_;
std::stack<reader> readers_;
std::uint32_t header_top_;
state state_;
build mode_;
bool indev_;
public:
lexer(const std::string& name, const char* data, size_t size);
auto lex() -> xsk::gsc::s4::parser::symbol_type;
auto lex() -> parser::symbol_type;
void push_header(const std::string& file);
void pop_header();
void restrict_header(const xsk::gsc::location& loc);
void ban_header(const location& loc);
private:
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<std::string_view, keyword> keywords;
static const std::unordered_map<std::string_view, parser::token::token_kind_type> keyword_map;
};
} // namespace xsk::gsc::s4

File diff suppressed because it is too large Load Diff

View File

@ -683,111 +683,119 @@ namespace xsk { namespace gsc { namespace s4 {
S4EOF = 0, // "end of file"
S4error = 1, // error
S4UNDEF = 2, // "invalid token"
DEVBEGIN = 3, // "/#"
DEVEND = 4, // "#/"
INLINE = 5, // "#inline"
INCLUDE = 6, // "#include"
USINGTREE = 7, // "#using_animtree"
ANIMTREE = 8, // "#animtree"
ENDON = 9, // "endon"
NOTIFY = 10, // "notify"
WAIT = 11, // "wait"
WAITTILL = 12, // "waittill"
WAITTILLMATCH = 13, // "waittillmatch"
WAITTILLFRAMEEND = 14, // "waittillframeend"
WAITFRAME = 15, // "waitframe"
IF = 16, // "if"
ELSE = 17, // "else"
DO = 18, // "do"
WHILE = 19, // "while"
FOR = 20, // "for"
FOREACH = 21, // "foreach"
IN = 22, // "in"
SWITCH = 23, // "switch"
CASE = 24, // "case"
DEFAULT = 25, // "default"
BREAK = 26, // "break"
CONTINUE = 27, // "continue"
RETURN = 28, // "return"
BREAKPOINT = 29, // "breakpoint"
PROFBEGIN = 30, // "prof_begin"
PROFEND = 31, // "prof_end"
THREAD = 32, // "thread"
CHILDTHREAD = 33, // "childthread"
THISTHREAD = 34, // "thisthread"
CALL = 35, // "call"
TRUE = 36, // "true"
FALSE = 37, // "false"
UNDEFINED = 38, // "undefined"
SIZE = 39, // ".size"
GAME = 40, // "game"
SELF = 41, // "self"
ANIM = 42, // "anim"
LEVEL = 43, // "level"
ISDEFINED = 44, // "isdefined"
ISTRUE = 45, // "istrue"
LPAREN = 46, // "("
RPAREN = 47, // ")"
LBRACE = 48, // "{"
RBRACE = 49, // "}"
LBRACKET = 50, // "["
RBRACKET = 51, // "]"
COMMA = 52, // ","
DOT = 53, // "."
DOUBLECOLON = 54, // "::"
COLON = 55, // ":"
SEMICOLON = 56, // ";"
QMARK = 57, // "?"
INCREMENT = 58, // "++"
DECREMENT = 59, // "--"
LSHIFT = 60, // "<<"
RSHIFT = 61, // ">>"
OR = 62, // "||"
AND = 63, // "&&"
EQUALITY = 64, // "=="
INEQUALITY = 65, // "!="
LESS_EQUAL = 66, // "<="
GREATER_EQUAL = 67, // ">="
LESS = 68, // "<"
GREATER = 69, // ">"
NOT = 70, // "!"
COMPLEMENT = 71, // "~"
ASSIGN = 72, // "="
ASSIGN_ADD = 73, // "+="
ASSIGN_SUB = 74, // "-="
ASSIGN_MUL = 75, // "*="
ASSIGN_DIV = 76, // "/="
ASSIGN_MOD = 77, // "%="
ASSIGN_BW_OR = 78, // "|="
ASSIGN_BW_AND = 79, // "&="
ASSIGN_BW_EXOR = 80, // "^="
ASSIGN_RSHIFT = 81, // ">>="
ASSIGN_LSHIFT = 82, // "<<="
BITWISE_OR = 83, // "|"
BITWISE_AND = 84, // "&"
BITWISE_EXOR = 85, // "^"
ADD = 86, // "+"
SUB = 87, // "-"
MUL = 88, // "*"
DIV = 89, // "/"
MOD = 90, // "%"
FIELD = 91, // "field"
PATH = 92, // "path"
IDENTIFIER = 93, // "identifier"
STRING = 94, // "string literal"
ISTRING = 95, // "localized string"
COLOR = 96, // "color"
FLOAT = 97, // "float"
INTEGER = 98, // "integer"
ADD_ARRAY = 99, // ADD_ARRAY
THEN = 100, // THEN
TERN = 101, // TERN
NEG = 102, // NEG
ANIMREF = 103, // ANIMREF
PREINC = 104, // PREINC
PREDEC = 105, // PREDEC
POSTINC = 106, // POSTINC
POSTDEC = 107 // POSTDEC
HSDEFINE = 3, // "#define"
HSUNDEF = 4, // "#undef"
HSIFDEF = 5, // "#ifdef"
HSIFNDEF = 6, // "#ifndef"
HSIF = 7, // "#if"
HSELIF = 8, // "#elif"
HSELSE = 9, // "#else"
HSENDIF = 10, // "#endif"
DEVBEGIN = 11, // "/#"
DEVEND = 12, // "#/"
INLINE = 13, // "#inline"
INCLUDE = 14, // "#include"
USINGTREE = 15, // "#using_animtree"
ANIMTREE = 16, // "#animtree"
ENDON = 17, // "endon"
NOTIFY = 18, // "notify"
WAIT = 19, // "wait"
WAITTILL = 20, // "waittill"
WAITTILLMATCH = 21, // "waittillmatch"
WAITTILLFRAMEEND = 22, // "waittillframeend"
WAITFRAME = 23, // "waitframe"
IF = 24, // "if"
ELSE = 25, // "else"
DO = 26, // "do"
WHILE = 27, // "while"
FOR = 28, // "for"
FOREACH = 29, // "foreach"
IN = 30, // "in"
SWITCH = 31, // "switch"
CASE = 32, // "case"
DEFAULT = 33, // "default"
BREAK = 34, // "break"
CONTINUE = 35, // "continue"
RETURN = 36, // "return"
BREAKPOINT = 37, // "breakpoint"
PROFBEGIN = 38, // "prof_begin"
PROFEND = 39, // "prof_end"
THREAD = 40, // "thread"
CHILDTHREAD = 41, // "childthread"
THISTHREAD = 42, // "thisthread"
CALL = 43, // "call"
TRUE = 44, // "true"
FALSE = 45, // "false"
UNDEFINED = 46, // "undefined"
SIZE = 47, // ".size"
GAME = 48, // "game"
SELF = 49, // "self"
ANIM = 50, // "anim"
LEVEL = 51, // "level"
ISDEFINED = 52, // "isdefined"
ISTRUE = 53, // "istrue"
LPAREN = 54, // "("
RPAREN = 55, // ")"
LBRACE = 56, // "{"
RBRACE = 57, // "}"
LBRACKET = 58, // "["
RBRACKET = 59, // "]"
COMMA = 60, // ","
DOT = 61, // "."
DOUBLECOLON = 62, // "::"
COLON = 63, // ":"
SEMICOLON = 64, // ";"
QMARK = 65, // "?"
INCREMENT = 66, // "++"
DECREMENT = 67, // "--"
LSHIFT = 68, // "<<"
RSHIFT = 69, // ">>"
OR = 70, // "||"
AND = 71, // "&&"
EQUALITY = 72, // "=="
INEQUALITY = 73, // "!="
LESS_EQUAL = 74, // "<="
GREATER_EQUAL = 75, // ">="
LESS = 76, // "<"
GREATER = 77, // ">"
NOT = 78, // "!"
COMPLEMENT = 79, // "~"
ASSIGN = 80, // "="
ASSIGN_ADD = 81, // "+="
ASSIGN_SUB = 82, // "-="
ASSIGN_MUL = 83, // "*="
ASSIGN_DIV = 84, // "/="
ASSIGN_MOD = 85, // "%="
ASSIGN_BW_OR = 86, // "|="
ASSIGN_BW_AND = 87, // "&="
ASSIGN_BW_EXOR = 88, // "^="
ASSIGN_RSHIFT = 89, // ">>="
ASSIGN_LSHIFT = 90, // "<<="
BITWISE_OR = 91, // "|"
BITWISE_AND = 92, // "&"
BITWISE_EXOR = 93, // "^"
ADD = 94, // "+"
SUB = 95, // "-"
MUL = 96, // "*"
DIV = 97, // "/"
MOD = 98, // "%"
FIELD = 99, // "field"
PATH = 100, // "path"
IDENTIFIER = 101, // "identifier"
STRING = 102, // "string literal"
ISTRING = 103, // "localized string"
COLOR = 104, // "color"
FLOAT = 105, // "float"
INTEGER = 106, // "integer"
ADD_ARRAY = 107, // ADD_ARRAY
THEN = 108, // THEN
TERN = 109, // TERN
NEG = 110, // NEG
ANIMREF = 111, // ANIMREF
PREINC = 112, // PREINC
PREDEC = 113, // PREDEC
POSTINC = 114, // POSTINC
POSTDEC = 115 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -804,199 +812,207 @@ namespace xsk { namespace gsc { namespace s4 {
{
enum symbol_kind_type
{
YYNTOKENS = 108, ///< Number of tokens.
YYNTOKENS = 116, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_DEVBEGIN = 3, // "/#"
S_DEVEND = 4, // "#/"
S_INLINE = 5, // "#inline"
S_INCLUDE = 6, // "#include"
S_USINGTREE = 7, // "#using_animtree"
S_ANIMTREE = 8, // "#animtree"
S_ENDON = 9, // "endon"
S_NOTIFY = 10, // "notify"
S_WAIT = 11, // "wait"
S_WAITTILL = 12, // "waittill"
S_WAITTILLMATCH = 13, // "waittillmatch"
S_WAITTILLFRAMEEND = 14, // "waittillframeend"
S_WAITFRAME = 15, // "waitframe"
S_IF = 16, // "if"
S_ELSE = 17, // "else"
S_DO = 18, // "do"
S_WHILE = 19, // "while"
S_FOR = 20, // "for"
S_FOREACH = 21, // "foreach"
S_IN = 22, // "in"
S_SWITCH = 23, // "switch"
S_CASE = 24, // "case"
S_DEFAULT = 25, // "default"
S_BREAK = 26, // "break"
S_CONTINUE = 27, // "continue"
S_RETURN = 28, // "return"
S_BREAKPOINT = 29, // "breakpoint"
S_PROFBEGIN = 30, // "prof_begin"
S_PROFEND = 31, // "prof_end"
S_THREAD = 32, // "thread"
S_CHILDTHREAD = 33, // "childthread"
S_THISTHREAD = 34, // "thisthread"
S_CALL = 35, // "call"
S_TRUE = 36, // "true"
S_FALSE = 37, // "false"
S_UNDEFINED = 38, // "undefined"
S_SIZE = 39, // ".size"
S_GAME = 40, // "game"
S_SELF = 41, // "self"
S_ANIM = 42, // "anim"
S_LEVEL = 43, // "level"
S_ISDEFINED = 44, // "isdefined"
S_ISTRUE = 45, // "istrue"
S_LPAREN = 46, // "("
S_RPAREN = 47, // ")"
S_LBRACE = 48, // "{"
S_RBRACE = 49, // "}"
S_LBRACKET = 50, // "["
S_RBRACKET = 51, // "]"
S_COMMA = 52, // ","
S_DOT = 53, // "."
S_DOUBLECOLON = 54, // "::"
S_COLON = 55, // ":"
S_SEMICOLON = 56, // ";"
S_QMARK = 57, // "?"
S_INCREMENT = 58, // "++"
S_DECREMENT = 59, // "--"
S_LSHIFT = 60, // "<<"
S_RSHIFT = 61, // ">>"
S_OR = 62, // "||"
S_AND = 63, // "&&"
S_EQUALITY = 64, // "=="
S_INEQUALITY = 65, // "!="
S_LESS_EQUAL = 66, // "<="
S_GREATER_EQUAL = 67, // ">="
S_LESS = 68, // "<"
S_GREATER = 69, // ">"
S_NOT = 70, // "!"
S_COMPLEMENT = 71, // "~"
S_ASSIGN = 72, // "="
S_ASSIGN_ADD = 73, // "+="
S_ASSIGN_SUB = 74, // "-="
S_ASSIGN_MUL = 75, // "*="
S_ASSIGN_DIV = 76, // "/="
S_ASSIGN_MOD = 77, // "%="
S_ASSIGN_BW_OR = 78, // "|="
S_ASSIGN_BW_AND = 79, // "&="
S_ASSIGN_BW_EXOR = 80, // "^="
S_ASSIGN_RSHIFT = 81, // ">>="
S_ASSIGN_LSHIFT = 82, // "<<="
S_BITWISE_OR = 83, // "|"
S_BITWISE_AND = 84, // "&"
S_BITWISE_EXOR = 85, // "^"
S_ADD = 86, // "+"
S_SUB = 87, // "-"
S_MUL = 88, // "*"
S_DIV = 89, // "/"
S_MOD = 90, // "%"
S_FIELD = 91, // "field"
S_PATH = 92, // "path"
S_IDENTIFIER = 93, // "identifier"
S_STRING = 94, // "string literal"
S_ISTRING = 95, // "localized string"
S_COLOR = 96, // "color"
S_FLOAT = 97, // "float"
S_INTEGER = 98, // "integer"
S_ADD_ARRAY = 99, // ADD_ARRAY
S_THEN = 100, // THEN
S_TERN = 101, // TERN
S_NEG = 102, // NEG
S_ANIMREF = 103, // ANIMREF
S_PREINC = 104, // PREINC
S_PREDEC = 105, // PREDEC
S_POSTINC = 106, // POSTINC
S_POSTDEC = 107, // POSTDEC
S_YYACCEPT = 108, // $accept
S_root = 109, // root
S_program = 110, // program
S_inline = 111, // inline
S_include = 112, // include
S_declaration = 113, // declaration
S_decl_usingtree = 114, // decl_usingtree
S_decl_constant = 115, // decl_constant
S_decl_thread = 116, // decl_thread
S_stmt = 117, // stmt
S_stmt_dev = 118, // stmt_dev
S_stmt_block = 119, // stmt_block
S_stmt_list = 120, // stmt_list
S_stmt_expr = 121, // stmt_expr
S_stmt_call = 122, // stmt_call
S_stmt_assign = 123, // stmt_assign
S_stmt_endon = 124, // stmt_endon
S_stmt_notify = 125, // stmt_notify
S_stmt_wait = 126, // stmt_wait
S_stmt_waittill = 127, // stmt_waittill
S_stmt_waittillmatch = 128, // stmt_waittillmatch
S_stmt_waittillframeend = 129, // stmt_waittillframeend
S_stmt_waitframe = 130, // stmt_waitframe
S_stmt_if = 131, // stmt_if
S_stmt_ifelse = 132, // stmt_ifelse
S_stmt_while = 133, // stmt_while
S_stmt_dowhile = 134, // stmt_dowhile
S_stmt_for = 135, // stmt_for
S_stmt_foreach = 136, // stmt_foreach
S_stmt_switch = 137, // stmt_switch
S_stmt_case = 138, // stmt_case
S_stmt_default = 139, // stmt_default
S_stmt_break = 140, // stmt_break
S_stmt_continue = 141, // stmt_continue
S_stmt_return = 142, // stmt_return
S_stmt_breakpoint = 143, // stmt_breakpoint
S_stmt_prof_begin = 144, // stmt_prof_begin
S_stmt_prof_end = 145, // stmt_prof_end
S_expr = 146, // expr
S_expr_or_empty = 147, // expr_or_empty
S_expr_assign = 148, // expr_assign
S_expr_increment = 149, // expr_increment
S_expr_decrement = 150, // expr_decrement
S_expr_ternary = 151, // expr_ternary
S_expr_binary = 152, // expr_binary
S_expr_primitive = 153, // expr_primitive
S_expr_complement = 154, // expr_complement
S_expr_not = 155, // expr_not
S_expr_call = 156, // expr_call
S_expr_method = 157, // expr_method
S_expr_function = 158, // expr_function
S_expr_pointer = 159, // expr_pointer
S_expr_add_array = 160, // expr_add_array
S_expr_parameters = 161, // expr_parameters
S_expr_arguments = 162, // expr_arguments
S_expr_arguments_no_empty = 163, // expr_arguments_no_empty
S_expr_isdefined = 164, // expr_isdefined
S_expr_istrue = 165, // expr_istrue
S_expr_reference = 166, // expr_reference
S_expr_array = 167, // expr_array
S_expr_field = 168, // expr_field
S_expr_size = 169, // expr_size
S_expr_paren = 170, // expr_paren
S_expr_object = 171, // expr_object
S_expr_thisthread = 172, // expr_thisthread
S_expr_empty_array = 173, // expr_empty_array
S_expr_undefined = 174, // expr_undefined
S_expr_game = 175, // expr_game
S_expr_self = 176, // expr_self
S_expr_anim = 177, // expr_anim
S_expr_level = 178, // expr_level
S_expr_animation = 179, // expr_animation
S_expr_animtree = 180, // expr_animtree
S_expr_identifier = 181, // expr_identifier
S_expr_path = 182, // expr_path
S_expr_istring = 183, // expr_istring
S_expr_string = 184, // expr_string
S_expr_color = 185, // expr_color
S_expr_vector = 186, // expr_vector
S_expr_float = 187, // expr_float
S_expr_integer = 188, // expr_integer
S_expr_false = 189, // expr_false
S_expr_true = 190 // expr_true
S_HSDEFINE = 3, // "#define"
S_HSUNDEF = 4, // "#undef"
S_HSIFDEF = 5, // "#ifdef"
S_HSIFNDEF = 6, // "#ifndef"
S_HSIF = 7, // "#if"
S_HSELIF = 8, // "#elif"
S_HSELSE = 9, // "#else"
S_HSENDIF = 10, // "#endif"
S_DEVBEGIN = 11, // "/#"
S_DEVEND = 12, // "#/"
S_INLINE = 13, // "#inline"
S_INCLUDE = 14, // "#include"
S_USINGTREE = 15, // "#using_animtree"
S_ANIMTREE = 16, // "#animtree"
S_ENDON = 17, // "endon"
S_NOTIFY = 18, // "notify"
S_WAIT = 19, // "wait"
S_WAITTILL = 20, // "waittill"
S_WAITTILLMATCH = 21, // "waittillmatch"
S_WAITTILLFRAMEEND = 22, // "waittillframeend"
S_WAITFRAME = 23, // "waitframe"
S_IF = 24, // "if"
S_ELSE = 25, // "else"
S_DO = 26, // "do"
S_WHILE = 27, // "while"
S_FOR = 28, // "for"
S_FOREACH = 29, // "foreach"
S_IN = 30, // "in"
S_SWITCH = 31, // "switch"
S_CASE = 32, // "case"
S_DEFAULT = 33, // "default"
S_BREAK = 34, // "break"
S_CONTINUE = 35, // "continue"
S_RETURN = 36, // "return"
S_BREAKPOINT = 37, // "breakpoint"
S_PROFBEGIN = 38, // "prof_begin"
S_PROFEND = 39, // "prof_end"
S_THREAD = 40, // "thread"
S_CHILDTHREAD = 41, // "childthread"
S_THISTHREAD = 42, // "thisthread"
S_CALL = 43, // "call"
S_TRUE = 44, // "true"
S_FALSE = 45, // "false"
S_UNDEFINED = 46, // "undefined"
S_SIZE = 47, // ".size"
S_GAME = 48, // "game"
S_SELF = 49, // "self"
S_ANIM = 50, // "anim"
S_LEVEL = 51, // "level"
S_ISDEFINED = 52, // "isdefined"
S_ISTRUE = 53, // "istrue"
S_LPAREN = 54, // "("
S_RPAREN = 55, // ")"
S_LBRACE = 56, // "{"
S_RBRACE = 57, // "}"
S_LBRACKET = 58, // "["
S_RBRACKET = 59, // "]"
S_COMMA = 60, // ","
S_DOT = 61, // "."
S_DOUBLECOLON = 62, // "::"
S_COLON = 63, // ":"
S_SEMICOLON = 64, // ";"
S_QMARK = 65, // "?"
S_INCREMENT = 66, // "++"
S_DECREMENT = 67, // "--"
S_LSHIFT = 68, // "<<"
S_RSHIFT = 69, // ">>"
S_OR = 70, // "||"
S_AND = 71, // "&&"
S_EQUALITY = 72, // "=="
S_INEQUALITY = 73, // "!="
S_LESS_EQUAL = 74, // "<="
S_GREATER_EQUAL = 75, // ">="
S_LESS = 76, // "<"
S_GREATER = 77, // ">"
S_NOT = 78, // "!"
S_COMPLEMENT = 79, // "~"
S_ASSIGN = 80, // "="
S_ASSIGN_ADD = 81, // "+="
S_ASSIGN_SUB = 82, // "-="
S_ASSIGN_MUL = 83, // "*="
S_ASSIGN_DIV = 84, // "/="
S_ASSIGN_MOD = 85, // "%="
S_ASSIGN_BW_OR = 86, // "|="
S_ASSIGN_BW_AND = 87, // "&="
S_ASSIGN_BW_EXOR = 88, // "^="
S_ASSIGN_RSHIFT = 89, // ">>="
S_ASSIGN_LSHIFT = 90, // "<<="
S_BITWISE_OR = 91, // "|"
S_BITWISE_AND = 92, // "&"
S_BITWISE_EXOR = 93, // "^"
S_ADD = 94, // "+"
S_SUB = 95, // "-"
S_MUL = 96, // "*"
S_DIV = 97, // "/"
S_MOD = 98, // "%"
S_FIELD = 99, // "field"
S_PATH = 100, // "path"
S_IDENTIFIER = 101, // "identifier"
S_STRING = 102, // "string literal"
S_ISTRING = 103, // "localized string"
S_COLOR = 104, // "color"
S_FLOAT = 105, // "float"
S_INTEGER = 106, // "integer"
S_ADD_ARRAY = 107, // ADD_ARRAY
S_THEN = 108, // THEN
S_TERN = 109, // TERN
S_NEG = 110, // NEG
S_ANIMREF = 111, // ANIMREF
S_PREINC = 112, // PREINC
S_PREDEC = 113, // PREDEC
S_POSTINC = 114, // POSTINC
S_POSTDEC = 115, // POSTDEC
S_YYACCEPT = 116, // $accept
S_root = 117, // root
S_program = 118, // program
S_inline = 119, // inline
S_include = 120, // include
S_declaration = 121, // declaration
S_decl_usingtree = 122, // decl_usingtree
S_decl_constant = 123, // decl_constant
S_decl_thread = 124, // decl_thread
S_stmt = 125, // stmt
S_stmt_dev = 126, // stmt_dev
S_stmt_block = 127, // stmt_block
S_stmt_list = 128, // stmt_list
S_stmt_expr = 129, // stmt_expr
S_stmt_call = 130, // stmt_call
S_stmt_assign = 131, // stmt_assign
S_stmt_endon = 132, // stmt_endon
S_stmt_notify = 133, // stmt_notify
S_stmt_wait = 134, // stmt_wait
S_stmt_waittill = 135, // stmt_waittill
S_stmt_waittillmatch = 136, // stmt_waittillmatch
S_stmt_waittillframeend = 137, // stmt_waittillframeend
S_stmt_waitframe = 138, // stmt_waitframe
S_stmt_if = 139, // stmt_if
S_stmt_ifelse = 140, // stmt_ifelse
S_stmt_while = 141, // stmt_while
S_stmt_dowhile = 142, // stmt_dowhile
S_stmt_for = 143, // stmt_for
S_stmt_foreach = 144, // stmt_foreach
S_stmt_switch = 145, // stmt_switch
S_stmt_case = 146, // stmt_case
S_stmt_default = 147, // stmt_default
S_stmt_break = 148, // stmt_break
S_stmt_continue = 149, // stmt_continue
S_stmt_return = 150, // stmt_return
S_stmt_breakpoint = 151, // stmt_breakpoint
S_stmt_prof_begin = 152, // stmt_prof_begin
S_stmt_prof_end = 153, // stmt_prof_end
S_expr = 154, // expr
S_expr_or_empty = 155, // expr_or_empty
S_expr_assign = 156, // expr_assign
S_expr_increment = 157, // expr_increment
S_expr_decrement = 158, // expr_decrement
S_expr_ternary = 159, // expr_ternary
S_expr_binary = 160, // expr_binary
S_expr_primitive = 161, // expr_primitive
S_expr_complement = 162, // expr_complement
S_expr_not = 163, // expr_not
S_expr_call = 164, // expr_call
S_expr_method = 165, // expr_method
S_expr_function = 166, // expr_function
S_expr_pointer = 167, // expr_pointer
S_expr_add_array = 168, // expr_add_array
S_expr_parameters = 169, // expr_parameters
S_expr_arguments = 170, // expr_arguments
S_expr_arguments_no_empty = 171, // expr_arguments_no_empty
S_expr_isdefined = 172, // expr_isdefined
S_expr_istrue = 173, // expr_istrue
S_expr_reference = 174, // expr_reference
S_expr_array = 175, // expr_array
S_expr_field = 176, // expr_field
S_expr_size = 177, // expr_size
S_expr_paren = 178, // expr_paren
S_expr_object = 179, // expr_object
S_expr_thisthread = 180, // expr_thisthread
S_expr_empty_array = 181, // expr_empty_array
S_expr_undefined = 182, // expr_undefined
S_expr_game = 183, // expr_game
S_expr_self = 184, // expr_self
S_expr_anim = 185, // expr_anim
S_expr_level = 186, // expr_level
S_expr_animation = 187, // expr_animation
S_expr_animtree = 188, // expr_animtree
S_expr_identifier = 189, // expr_identifier
S_expr_path = 190, // expr_path
S_expr_istring = 191, // expr_istring
S_expr_string = 192, // expr_string
S_expr_color = 193, // expr_color
S_expr_vector = 194, // expr_vector
S_expr_float = 195, // expr_float
S_expr_integer = 196, // expr_integer
S_expr_false = 197, // expr_false
S_expr_true = 198 // expr_true
};
};
@ -2835,6 +2851,126 @@ switch (yykind)
return symbol_type (token::S4UNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSDEFINE (location_type l)
{
return symbol_type (token::HSDEFINE, std::move (l));
}
#else
static
symbol_type
make_HSDEFINE (const location_type& l)
{
return symbol_type (token::HSDEFINE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSUNDEF (location_type l)
{
return symbol_type (token::HSUNDEF, std::move (l));
}
#else
static
symbol_type
make_HSUNDEF (const location_type& l)
{
return symbol_type (token::HSUNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFDEF (location_type l)
{
return symbol_type (token::HSIFDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFDEF (const location_type& l)
{
return symbol_type (token::HSIFDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIFNDEF (location_type l)
{
return symbol_type (token::HSIFNDEF, std::move (l));
}
#else
static
symbol_type
make_HSIFNDEF (const location_type& l)
{
return symbol_type (token::HSIFNDEF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSIF (location_type l)
{
return symbol_type (token::HSIF, std::move (l));
}
#else
static
symbol_type
make_HSIF (const location_type& l)
{
return symbol_type (token::HSIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELIF (location_type l)
{
return symbol_type (token::HSELIF, std::move (l));
}
#else
static
symbol_type
make_HSELIF (const location_type& l)
{
return symbol_type (token::HSELIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSELSE (location_type l)
{
return symbol_type (token::HSELSE, std::move (l));
}
#else
static
symbol_type
make_HSELSE (const location_type& l)
{
return symbol_type (token::HSELSE, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_HSENDIF (location_type l)
{
return symbol_type (token::HSENDIF, std::move (l));
}
#else
static
symbol_type
make_HSENDIF (const location_type& l)
{
return symbol_type (token::HSENDIF, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -5464,7 +5600,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::s4
#line 5468 "parser.hpp"
#line 5604 "parser.hpp"