implement ternary operator

This commit is contained in:
xensik 2021-07-23 21:59:49 +02:00
parent 9e4cadcc9b
commit 5a453c6799
77 changed files with 12345 additions and 11000 deletions

View File

@ -103,6 +103,7 @@ RGX_DEFAULT (.|\n)
\:\: { return h1::parser::make_DOUBLECOLON(loc); }
\: { return h1::parser::make_COLON(loc); }
\; { return h1::parser::make_SEMICOLON(loc); }
\? { return h1::parser::make_QMARK(loc); }
\+\+ { return h1::parser::make_INCREMENT(loc); }
\-\- { return h1::parser::make_DECREMENT(loc); }
\<\<\= { return h1::parser::make_ASSIGN_LSHIFT(loc); }

View File

@ -93,6 +93,7 @@ xsk::gsc::h1::parser::symbol_type H1lex(yyscan_t yyscanner, xsk::gsc::location&
%token DOUBLECOLON "::"
%token COLON ":"
%token SEMICOLON ";"
%token QMARK "?"
%token INCREMENT "++"
%token DECREMENT "--"
%token LSHIFT "<<"
@ -171,6 +172,7 @@ xsk::gsc::h1::parser::symbol_type H1lex(yyscan_t yyscanner, xsk::gsc::location&
%type <expr_assign_ptr> expr_assign
%type <expr_ptr> expr
%type <expr_ptr> expr_compare
%type <expr_ptr> expr_ternary
%type <expr_ptr> expr_binary
%type <expr_ptr> expr_primitive
%type <expr_call_ptr> expr_call
@ -214,6 +216,8 @@ xsk::gsc::h1::parser::symbol_type H1lex(yyscan_t yyscanner, xsk::gsc::location&
%nonassoc ELSE
%nonassoc INCREMENT DECREMENT
%precedence TERN
%right QMARK
%left OR
%left AND
%left BITWISE_OR
@ -470,6 +474,7 @@ for_expr
expr
: expr_compare { $$ = std::move($1); }
| expr_ternary { $$ = std::move($1); }
| expr_binary { $$ = std::move($1); }
| expr_primitive { $$ = std::move($1); }
;
@ -503,6 +508,10 @@ expr_compare
| expr GREATER expr { $$.as_node = std::make_unique<node_expr_greater>(@$, std::move($1), std::move($3)); }
;
expr_ternary
: expr QMARK expr COLON expr %prec TERN { $$.as_node = std::make_unique<node_expr_ternary>(@$, std::move($1), std::move($3), std::move($5)); }
;
expr_binary
: expr BITWISE_OR expr { $$.as_node = std::make_unique<node_expr_bitwise_or>(@$, std::move($1), std::move($3)); }
| expr BITWISE_AND expr { $$.as_node = std::make_unique<node_expr_bitwise_and>(@$, std::move($1), std::move($3)); }

View File

@ -103,6 +103,7 @@ RGX_DEFAULT (.|\n)
\:\: { return h2::parser::make_DOUBLECOLON(loc); }
\: { return h2::parser::make_COLON(loc); }
\; { return h2::parser::make_SEMICOLON(loc); }
\? { return h2::parser::make_QMARK(loc); }
\+\+ { return h2::parser::make_INCREMENT(loc); }
\-\- { return h2::parser::make_DECREMENT(loc); }
\<\<\= { return h2::parser::make_ASSIGN_LSHIFT(loc); }

View File

@ -93,6 +93,7 @@ xsk::gsc::h2::parser::symbol_type H2lex(yyscan_t yyscanner, xsk::gsc::location&
%token DOUBLECOLON "::"
%token COLON ":"
%token SEMICOLON ";"
%token QMARK "?"
%token INCREMENT "++"
%token DECREMENT "--"
%token LSHIFT "<<"
@ -171,6 +172,7 @@ xsk::gsc::h2::parser::symbol_type H2lex(yyscan_t yyscanner, xsk::gsc::location&
%type <expr_assign_ptr> expr_assign
%type <expr_ptr> expr
%type <expr_ptr> expr_compare
%type <expr_ptr> expr_ternary
%type <expr_ptr> expr_binary
%type <expr_ptr> expr_primitive
%type <expr_call_ptr> expr_call
@ -214,6 +216,8 @@ xsk::gsc::h2::parser::symbol_type H2lex(yyscan_t yyscanner, xsk::gsc::location&
%nonassoc ELSE
%nonassoc INCREMENT DECREMENT
%precedence TERN
%right QMARK
%left OR
%left AND
%left BITWISE_OR
@ -470,6 +474,7 @@ for_expr
expr
: expr_compare { $$ = std::move($1); }
| expr_ternary { $$ = std::move($1); }
| expr_binary { $$ = std::move($1); }
| expr_primitive { $$ = std::move($1); }
;
@ -503,6 +508,10 @@ expr_compare
| expr GREATER expr { $$.as_node = std::make_unique<node_expr_greater>(@$, std::move($1), std::move($3)); }
;
expr_ternary
: expr QMARK expr COLON expr %prec TERN { $$.as_node = std::make_unique<node_expr_ternary>(@$, std::move($1), std::move($3), std::move($5)); }
;
expr_binary
: expr BITWISE_OR expr { $$.as_node = std::make_unique<node_expr_bitwise_or>(@$, std::move($1), std::move($3)); }
| expr BITWISE_AND expr { $$.as_node = std::make_unique<node_expr_bitwise_and>(@$, std::move($1), std::move($3)); }

View File

@ -102,6 +102,7 @@ RGX_DEFAULT (.|\n)
\:\: { return iw5::parser::make_DOUBLECOLON(loc); }
\: { return iw5::parser::make_COLON(loc); }
\; { return iw5::parser::make_SEMICOLON(loc); }
\? { return iw5::parser::make_QMARK(loc); }
\+\+ { return iw5::parser::make_INCREMENT(loc); }
\-\- { return iw5::parser::make_DECREMENT(loc); }
\<\<\= { return iw5::parser::make_ASSIGN_LSHIFT(loc); }

View File

@ -92,6 +92,7 @@ xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location
%token DOUBLECOLON "::"
%token COLON ":"
%token SEMICOLON ";"
%token QMARK "?"
%token INCREMENT "++"
%token DECREMENT "--"
%token LSHIFT "<<"
@ -169,6 +170,7 @@ xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location
%type <expr_assign_ptr> expr_assign
%type <expr_ptr> expr
%type <expr_ptr> expr_compare
%type <expr_ptr> expr_ternary
%type <expr_ptr> expr_binary
%type <expr_ptr> expr_primitive
%type <expr_call_ptr> expr_call
@ -212,6 +214,8 @@ xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location
%nonassoc ELSE
%nonassoc INCREMENT DECREMENT
%precedence TERN
%right QMARK
%left OR
%left AND
%left BITWISE_OR
@ -460,6 +464,7 @@ for_expr
expr
: expr_compare { $$ = std::move($1); }
| expr_ternary { $$ = std::move($1); }
| expr_binary { $$ = std::move($1); }
| expr_primitive { $$ = std::move($1); }
;
@ -493,6 +498,10 @@ expr_compare
| expr GREATER expr { $$.as_node = std::make_unique<node_expr_greater>(@$, std::move($1), std::move($3)); }
;
expr_ternary
: expr QMARK expr COLON expr %prec TERN { $$.as_node = std::make_unique<node_expr_ternary>(@$, std::move($1), std::move($3), std::move($5)); }
;
expr_binary
: expr BITWISE_OR expr { $$.as_node = std::make_unique<node_expr_bitwise_or>(@$, std::move($1), std::move($3)); }
| expr BITWISE_AND expr { $$.as_node = std::make_unique<node_expr_bitwise_and>(@$, std::move($1), std::move($3)); }

View File

@ -102,6 +102,7 @@ RGX_DEFAULT (.|\n)
\:\: { return iw6::parser::make_DOUBLECOLON(loc); }
\: { return iw6::parser::make_COLON(loc); }
\; { return iw6::parser::make_SEMICOLON(loc); }
\? { return iw6::parser::make_QMARK(loc); }
\+\+ { return iw6::parser::make_INCREMENT(loc); }
\-\- { return iw6::parser::make_DECREMENT(loc); }
\<\<\= { return iw6::parser::make_ASSIGN_LSHIFT(loc); }

View File

@ -92,6 +92,7 @@ xsk::gsc::iw6::parser::symbol_type IW6lex(yyscan_t yyscanner, xsk::gsc::location
%token DOUBLECOLON "::"
%token COLON ":"
%token SEMICOLON ";"
%token QMARK "?"
%token INCREMENT "++"
%token DECREMENT "--"
%token LSHIFT "<<"
@ -169,6 +170,7 @@ xsk::gsc::iw6::parser::symbol_type IW6lex(yyscan_t yyscanner, xsk::gsc::location
%type <expr_assign_ptr> expr_assign
%type <expr_ptr> expr
%type <expr_ptr> expr_compare
%type <expr_ptr> expr_ternary
%type <expr_ptr> expr_binary
%type <expr_ptr> expr_primitive
%type <expr_call_ptr> expr_call
@ -212,6 +214,8 @@ xsk::gsc::iw6::parser::symbol_type IW6lex(yyscan_t yyscanner, xsk::gsc::location
%nonassoc ELSE
%nonassoc INCREMENT DECREMENT
%precedence TERN
%right QMARK
%left OR
%left AND
%left BITWISE_OR
@ -460,6 +464,7 @@ for_expr
expr
: expr_compare { $$ = std::move($1); }
| expr_ternary { $$ = std::move($1); }
| expr_binary { $$ = std::move($1); }
| expr_primitive { $$ = std::move($1); }
;
@ -493,6 +498,10 @@ expr_compare
| expr GREATER expr { $$.as_node = std::make_unique<node_expr_greater>(@$, std::move($1), std::move($3)); }
;
expr_ternary
: expr QMARK expr COLON expr %prec TERN { $$.as_node = std::make_unique<node_expr_ternary>(@$, std::move($1), std::move($3), std::move($5)); }
;
expr_binary
: expr BITWISE_OR expr { $$.as_node = std::make_unique<node_expr_bitwise_or>(@$, std::move($1), std::move($3)); }
| expr BITWISE_AND expr { $$.as_node = std::make_unique<node_expr_bitwise_and>(@$, std::move($1), std::move($3)); }

View File

@ -102,6 +102,7 @@ RGX_DEFAULT (.|\n)
\:\: { return iw7::parser::make_DOUBLECOLON(loc); }
\: { return iw7::parser::make_COLON(loc); }
\; { return iw7::parser::make_SEMICOLON(loc); }
\? { return iw7::parser::make_QMARK(loc); }
\+\+ { return iw7::parser::make_INCREMENT(loc); }
\-\- { return iw7::parser::make_DECREMENT(loc); }
\<\<\= { return iw7::parser::make_ASSIGN_LSHIFT(loc); }

View File

@ -92,6 +92,7 @@ xsk::gsc::iw7::parser::symbol_type IW7lex(yyscan_t yyscanner, xsk::gsc::location
%token DOUBLECOLON "::"
%token COLON ":"
%token SEMICOLON ";"
%token QMARK "?"
%token INCREMENT "++"
%token DECREMENT "--"
%token LSHIFT "<<"
@ -169,6 +170,7 @@ xsk::gsc::iw7::parser::symbol_type IW7lex(yyscan_t yyscanner, xsk::gsc::location
%type <expr_assign_ptr> expr_assign
%type <expr_ptr> expr
%type <expr_ptr> expr_compare
%type <expr_ptr> expr_ternary
%type <expr_ptr> expr_binary
%type <expr_ptr> expr_primitive
%type <expr_call_ptr> expr_call
@ -212,6 +214,8 @@ xsk::gsc::iw7::parser::symbol_type IW7lex(yyscan_t yyscanner, xsk::gsc::location
%nonassoc ELSE
%nonassoc INCREMENT DECREMENT
%precedence TERN
%right QMARK
%left OR
%left AND
%left BITWISE_OR
@ -460,6 +464,7 @@ for_expr
expr
: expr_compare { $$ = std::move($1); }
| expr_ternary { $$ = std::move($1); }
| expr_binary { $$ = std::move($1); }
| expr_primitive { $$ = std::move($1); }
;
@ -493,6 +498,10 @@ expr_compare
| expr GREATER expr { $$.as_node = std::make_unique<node_expr_greater>(@$, std::move($1), std::move($3)); }
;
expr_ternary
: expr QMARK expr COLON expr %prec TERN { $$.as_node = std::make_unique<node_expr_ternary>(@$, std::move($1), std::move($3), std::move($5)); }
;
expr_binary
: expr BITWISE_OR expr { $$.as_node = std::make_unique<node_expr_bitwise_or>(@$, std::move($1), std::move($3)); }
| expr BITWISE_AND expr { $$.as_node = std::make_unique<node_expr_bitwise_and>(@$, std::move($1), std::move($3)); }

View File

@ -103,6 +103,7 @@ RGX_DEFAULT (.|\n)
\:\: { return s1::parser::make_DOUBLECOLON(loc); }
\: { return s1::parser::make_COLON(loc); }
\; { return s1::parser::make_SEMICOLON(loc); }
\? { return s1::parser::make_QMARK(loc); }
\+\+ { return s1::parser::make_INCREMENT(loc); }
\-\- { return s1::parser::make_DECREMENT(loc); }
\<\<\= { return s1::parser::make_ASSIGN_LSHIFT(loc); }

View File

@ -93,6 +93,7 @@ xsk::gsc::s1::parser::symbol_type S1lex(yyscan_t yyscanner, xsk::gsc::location&
%token DOUBLECOLON "::"
%token COLON ":"
%token SEMICOLON ";"
%token QMARK "?"
%token INCREMENT "++"
%token DECREMENT "--"
%token LSHIFT "<<"
@ -171,6 +172,7 @@ xsk::gsc::s1::parser::symbol_type S1lex(yyscan_t yyscanner, xsk::gsc::location&
%type <expr_assign_ptr> expr_assign
%type <expr_ptr> expr
%type <expr_ptr> expr_compare
%type <expr_ptr> expr_ternary
%type <expr_ptr> expr_binary
%type <expr_ptr> expr_primitive
%type <expr_call_ptr> expr_call
@ -214,6 +216,8 @@ xsk::gsc::s1::parser::symbol_type S1lex(yyscan_t yyscanner, xsk::gsc::location&
%nonassoc ELSE
%nonassoc INCREMENT DECREMENT
%precedence TERN
%right QMARK
%left OR
%left AND
%left BITWISE_OR
@ -470,6 +474,7 @@ for_expr
expr
: expr_compare { $$ = std::move($1); }
| expr_ternary { $$ = std::move($1); }
| expr_binary { $$ = std::move($1); }
| expr_primitive { $$ = std::move($1); }
;
@ -503,6 +508,10 @@ expr_compare
| expr GREATER expr { $$.as_node = std::make_unique<node_expr_greater>(@$, std::move($1), std::move($3)); }
;
expr_ternary
: expr QMARK expr COLON expr %prec TERN { $$.as_node = std::make_unique<node_expr_ternary>(@$, std::move($1), std::move($3), std::move($5)); }
;
expr_binary
: expr BITWISE_OR expr { $$.as_node = std::make_unique<node_expr_bitwise_or>(@$, std::move($1), std::move($3)); }
| expr BITWISE_AND expr { $$.as_node = std::make_unique<node_expr_bitwise_and>(@$, std::move($1), std::move($3)); }

View File

@ -103,6 +103,7 @@ RGX_DEFAULT (.|\n)
\:\: { return s2::parser::make_DOUBLECOLON(loc); }
\: { return s2::parser::make_COLON(loc); }
\; { return s2::parser::make_SEMICOLON(loc); }
\? { return s2::parser::make_QMARK(loc); }
\+\+ { return s2::parser::make_INCREMENT(loc); }
\-\- { return s2::parser::make_DECREMENT(loc); }
\<\<\= { return s2::parser::make_ASSIGN_LSHIFT(loc); }

View File

@ -93,6 +93,7 @@ xsk::gsc::s2::parser::symbol_type S2lex(yyscan_t yyscanner, xsk::gsc::location&
%token DOUBLECOLON "::"
%token COLON ":"
%token SEMICOLON ";"
%token QMARK "?"
%token INCREMENT "++"
%token DECREMENT "--"
%token LSHIFT "<<"
@ -171,6 +172,7 @@ xsk::gsc::s2::parser::symbol_type S2lex(yyscan_t yyscanner, xsk::gsc::location&
%type <expr_assign_ptr> expr_assign
%type <expr_ptr> expr
%type <expr_ptr> expr_compare
%type <expr_ptr> expr_ternary
%type <expr_ptr> expr_binary
%type <expr_ptr> expr_primitive
%type <expr_call_ptr> expr_call
@ -214,6 +216,8 @@ xsk::gsc::s2::parser::symbol_type S2lex(yyscan_t yyscanner, xsk::gsc::location&
%nonassoc ELSE
%nonassoc INCREMENT DECREMENT
%precedence TERN
%right QMARK
%left OR
%left AND
%left BITWISE_OR
@ -470,6 +474,7 @@ for_expr
expr
: expr_compare { $$ = std::move($1); }
| expr_ternary { $$ = std::move($1); }
| expr_binary { $$ = std::move($1); }
| expr_primitive { $$ = std::move($1); }
;
@ -503,6 +508,10 @@ expr_compare
| expr GREATER expr { $$.as_node = std::make_unique<node_expr_greater>(@$, std::move($1), std::move($3)); }
;
expr_ternary
: expr QMARK expr COLON expr %prec TERN { $$.as_node = std::make_unique<node_expr_ternary>(@$, std::move($1), std::move($3), std::move($5)); }
;
expr_binary
: expr BITWISE_OR expr { $$.as_node = std::make_unique<node_expr_bitwise_or>(@$, std::move($1), std::move($3)); }
| expr BITWISE_AND expr { $$.as_node = std::make_unique<node_expr_bitwise_and>(@$, std::move($1), std::move($3)); }

View File

@ -115,7 +115,6 @@ void assembler::assemble(const std::string& file, std::vector<gsc::function_ptr>
functions_ = std::move(functions);
script_->write<std::uint8_t>(static_cast<std::uint8_t>(opcode::OP_End));
stack_->write<std::uint32_t>(0x69773630);
for (const auto& func : functions_)
{

View File

@ -409,7 +409,7 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -465,7 +465,7 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -540,7 +540,7 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -752,6 +752,7 @@ void compiler::emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
{
switch(expr.as_node->type)
{
case gsc::node_t::expr_ternary: emit_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: emit_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: emit_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: emit_expr_binary(ctx, expr.as_binary); break;
@ -849,6 +850,30 @@ void compiler::emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_ass
}
}
void compiler::emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
auto else_loc = create_label();
auto end_loc = create_label();
if(expr->cond.as_node->type == gsc::node_t::expr_not)
{
emit_expr(ctx, expr->cond.as_not->rvalue);
emit_opcode(ctx, opcode::OP_JumpOnTrue, else_loc);
}
else
{
emit_expr(ctx, expr->cond);
emit_opcode(ctx, opcode::OP_JumpOnFalse, else_loc);
}
emit_expr(ctx, expr->lvalue);
emit_opcode(ctx, opcode::OP_jump, end_loc);
insert_label(else_loc);
emit_expr(ctx, expr->rvalue);
insert_label(end_loc);
}
void compiler::emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
emit_expr(ctx, expr->lvalue);

View File

@ -68,6 +68,7 @@ private:
void emit_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr);
void emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
void emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void emit_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void emit_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -96,6 +96,14 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
decompile_expr();
}
}
for(auto& entry : tern_labels_)
{
if(entry == itr->second)
{
decompile_ternary();
}
}
}
switch (opcode(inst->opcode))
@ -1833,6 +1841,7 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
{
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1916,6 +1925,29 @@ void decompiler::decompile_expr()
}
}
void decompiler::decompile_ternary()
{
auto rvalue = std::move(stack_.top());
stack_.pop();
auto lvalue = std::move(stack_.top());
stack_.pop();
func_->block->stmts.pop_back();
auto stmt = std::move(func_->block->stmts.back());
func_->block->stmts.pop_back();
if(stmt.as_node->type == node_t::asm_jump_cond)
{
auto loc = stmt.as_cond->loc;
auto e = std::make_unique<gsc::node_expr_ternary>(loc, std::move(stmt.as_cond->expr), std::move(lvalue), std::move(rvalue));
stack_.push(std::move(e));
}
else
{
throw gsc::decomp_error("TRIED TO DECOMPILE INVALID TERNARY EXPR!");
}
}
void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
{
this->decompile_search_infinite(block);
@ -3006,6 +3038,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
case gsc::node_t::expr_assign_bitwise_or: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_and: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_exor: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_ternary: process_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: process_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: process_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: process_expr_binary(ctx, expr.as_binary); break;
@ -3106,6 +3139,13 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assi
}
}
void decompiler::process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
process_expr(ctx, expr->cond);
process_expr(ctx, expr->lvalue);
process_expr(ctx, expr->rvalue);
}
void decompiler::process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
process_expr(ctx, expr->lvalue);

View File

@ -16,6 +16,7 @@ class decompiler : public gsc::decompiler
gsc::thread_ptr func_;
std::unordered_map<std::uint32_t, std::string> labels_;
std::vector<std::string> expr_labels_;
std::vector<std::string> tern_labels_;
std::stack<gsc::node_ptr> stack_;
std::vector<gsc::context> blocks_;
@ -27,6 +28,7 @@ private:
void decompile_function(const gsc::function_ptr& func);
void decompile_statements(const gsc::function_ptr& func);
void decompile_expr();
void decompile_ternary();
void decompile_block(const gsc::stmt_list_ptr& block);
void decompile_search_infinite(const gsc::stmt_list_ptr& block);
void decompile_search_loop(const gsc::stmt_list_ptr& block);
@ -68,6 +70,7 @@ private:
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
void process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -553,8 +553,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 100
#define YY_END_OF_BUFFER 101
#define YY_NUM_RULES 101
#define YY_END_OF_BUFFER 102
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -562,42 +562,42 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[305] =
static const flex_int16_t yy_accept[306] =
{ 0,
0, 0, 0, 0, 0, 0, 101, 99, 1, 2,
88, 99, 99, 87, 91, 99, 49, 50, 85, 83,
55, 84, 56, 86, 98, 58, 59, 72, 82, 73,
94, 53, 54, 92, 94, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
51, 90, 52, 89, 5, 6, 5, 9, 10, 9,
69, 0, 96, 0, 0, 0, 0, 78, 0, 67,
0, 80, 0, 0, 76, 60, 74, 61, 75, 97,
0, 8, 4, 3, 77, 97, 98, 0, 0, 57,
64, 70, 68, 71, 65, 94, 81, 94, 94, 94,
0, 0, 0, 0, 0, 0, 102, 100, 1, 2,
89, 100, 100, 88, 92, 100, 49, 50, 86, 84,
55, 85, 56, 87, 99, 58, 59, 73, 83, 74,
60, 95, 53, 54, 93, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 51, 91, 52, 90, 5, 6, 5, 9, 10,
9, 70, 0, 97, 0, 0, 0, 0, 79, 0,
68, 0, 81, 0, 0, 77, 61, 75, 62, 76,
98, 0, 8, 4, 3, 78, 98, 99, 0, 0,
57, 65, 71, 69, 72, 66, 95, 82, 95, 95,
94, 94, 94, 94, 94, 94, 94, 94, 25, 30,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 79, 66, 7, 11, 0, 96, 0, 0, 0,
0, 0, 95, 0, 0, 0, 0, 96, 0, 97,
0, 3, 97, 97, 93, 62, 63, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 28, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 0, 0, 0, 0, 95, 0, 0, 95, 0,
0, 47, 94, 40, 32, 94, 94, 94, 26, 94,
94, 94, 45, 94, 94, 94, 94, 46, 94, 94,
95, 95, 95, 95, 95, 95, 95, 95, 95, 25,
30, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 80, 67, 7, 11, 0, 97, 0, 0,
0, 0, 0, 96, 0, 0, 0, 0, 97, 0,
98, 0, 3, 98, 98, 94, 63, 64, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 28, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 0, 0, 0, 0, 96, 0, 0, 96,
0, 0, 47, 95, 40, 32, 95, 95, 95, 26,
95, 95, 95, 45, 95, 95, 95, 95, 46, 95,
94, 41, 94, 20, 94, 0, 0, 0, 44, 34,
94, 94, 94, 18, 42, 94, 48, 94, 94, 94,
94, 94, 94, 94, 94, 94, 27, 0, 0, 0,
94, 94, 94, 94, 94, 19, 94, 94, 36, 31,
94, 37, 94, 94, 94, 0, 0, 0, 94, 94,
94, 33, 29, 94, 94, 94, 94, 94, 94, 0,
15, 0, 94, 94, 35, 94, 14, 94, 94, 94,
21, 17, 0, 94, 94, 94, 94, 43, 24, 94,
94, 0, 12, 94, 13, 39, 94, 94, 0, 38,
94, 94, 0, 94, 94, 0, 94, 22, 0, 94,
95, 95, 41, 95, 20, 95, 0, 0, 0, 44,
34, 95, 95, 95, 18, 42, 95, 48, 95, 95,
95, 95, 95, 95, 95, 95, 95, 27, 0, 0,
0, 95, 95, 95, 95, 95, 19, 95, 95, 36,
31, 95, 37, 95, 95, 95, 0, 0, 0, 95,
95, 95, 33, 29, 95, 95, 95, 95, 95, 95,
0, 15, 0, 95, 95, 35, 95, 14, 95, 95,
95, 21, 17, 0, 95, 95, 95, 95, 43, 24,
95, 95, 0, 12, 95, 13, 39, 95, 95, 0,
38, 95, 95, 0, 95, 95, 0, 95, 22, 0,
16, 94, 23, 0
95, 16, 95, 23, 0
} ;
static const YY_CHAR yy_ec[256] =
@ -608,14 +608,14 @@ static const YY_CHAR yy_ec[256] =
1, 2, 4, 5, 6, 1, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 19, 20, 21,
22, 23, 1, 1, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 26, 27, 28, 29, 1, 30, 31, 32, 33,
22, 23, 24, 1, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 27, 28, 29, 30, 1, 31, 32, 33, 34,
34, 35, 36, 37, 38, 24, 39, 40, 41, 42,
43, 44, 24, 45, 46, 47, 48, 49, 50, 24,
51, 52, 53, 54, 55, 56, 1, 1, 1, 1,
35, 36, 37, 38, 39, 25, 40, 41, 42, 43,
44, 45, 25, 46, 47, 48, 49, 50, 51, 25,
52, 53, 54, 55, 56, 57, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -632,240 +632,240 @@ static const YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
static const YY_CHAR yy_meta[57] =
static const YY_CHAR yy_meta[58] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 4, 1, 1,
1, 1, 1, 4, 1, 5, 1, 1, 4, 4,
1, 1, 1, 1, 4, 1, 5, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1
4, 4, 4, 1, 1, 1, 1
} ;
static const flex_int16_t yy_base[319] =
static const flex_int16_t yy_base[320] =
{ 0,
0, 0, 54, 55, 56, 57, 574, 575, 575, 575,
551, 56, 35, 550, 63, 55, 575, 575, 549, 56,
575, 55, 56, 74, 71, 551, 575, 54, 547, 70,
542, 575, 575, 545, 53, 58, 64, 72, 73, 74,
79, 84, 82, 85, 86, 88, 95, 97, 94, 107,
575, 96, 575, 575, 575, 575, 549, 575, 575, 548,
575, 120, 575, 127, 522, 521, 516, 575, 122, 575,
115, 575, 126, 140, 575, 575, 575, 575, 575, 120,
523, 575, 575, 0, 575, 121, 141, 135, 0, 575,
538, 575, 575, 575, 537, 532, 575, 132, 128, 134,
0, 0, 55, 56, 57, 58, 575, 576, 576, 576,
552, 57, 34, 551, 66, 60, 576, 576, 550, 57,
576, 63, 48, 74, 74, 552, 576, 55, 548, 59,
576, 542, 576, 576, 546, 62, 66, 71, 72, 67,
73, 87, 70, 76, 89, 92, 93, 94, 96, 97,
99, 576, 100, 576, 576, 576, 576, 550, 576, 576,
549, 576, 120, 576, 136, 522, 521, 516, 576, 122,
576, 123, 576, 126, 143, 576, 576, 576, 576, 576,
118, 523, 576, 576, 0, 576, 125, 140, 132, 0,
576, 539, 576, 576, 576, 538, 532, 576, 130, 133,
137, 139, 138, 142, 114, 143, 145, 146, 531, 530,
150, 151, 152, 153, 156, 159, 163, 158, 160, 165,
166, 575, 575, 575, 575, 189, 197, 202, 517, 522,
515, 204, 575, 207, 205, 208, 209, 210, 213, 575,
500, 0, 202, 575, 525, 575, 575, 199, 212, 187,
195, 206, 198, 217, 215, 218, 222, 224, 225, 226,
227, 228, 229, 231, 236, 230, 238, 241, 244, 243,
245, 509, 509, 506, 268, 269, 276, 271, 273, 283,
513, 520, 261, 519, 518, 258, 263, 262, 517, 270,
272, 277, 516, 278, 279, 282, 287, 515, 289, 290,
124, 135, 137, 139, 145, 149, 146, 150, 151, 531,
530, 152, 155, 154, 157, 158, 161, 162, 163, 170,
167, 168, 576, 576, 576, 576, 186, 204, 211, 517,
522, 515, 205, 576, 212, 202, 215, 210, 213, 217,
576, 500, 0, 205, 576, 525, 576, 576, 194, 203,
206, 200, 216, 198, 218, 221, 223, 224, 225, 226,
227, 231, 228, 232, 236, 238, 241, 239, 242, 248,
246, 249, 509, 509, 506, 273, 274, 277, 275, 276,
284, 513, 520, 104, 519, 518, 262, 268, 264, 517,
265, 270, 279, 516, 271, 282, 287, 288, 515, 289,
293, 514, 291, 294, 296, 492, 490, 501, 575, 298,
299, 301, 305, 510, 509, 302, 508, 307, 313, 309,
312, 322, 324, 314, 310, 327, 507, 487, 498, 501,
328, 330, 334, 336, 335, 503, 340, 337, 502, 501,
342, 500, 338, 343, 344, 491, 490, 493, 350, 349,
351, 496, 495, 355, 360, 363, 364, 366, 369, 486,
575, 477, 370, 374, 492, 373, 491, 375, 377, 380,
378, 575, 478, 376, 390, 389, 391, 489, 488, 392,
395, 472, 486, 396, 472, 424, 400, 401, 402, 421,
402, 406, 397, 407, 408, 406, 410, 352, 259, 409,
272, 292, 514, 294, 297, 300, 492, 490, 501, 576,
298, 299, 301, 305, 510, 509, 304, 508, 302, 321,
309, 311, 312, 324, 328, 313, 330, 507, 487, 498,
501, 333, 334, 314, 335, 337, 503, 338, 339, 502,
501, 341, 500, 343, 347, 344, 491, 490, 493, 349,
352, 354, 496, 495, 353, 357, 365, 366, 367, 369,
486, 576, 477, 368, 370, 492, 375, 491, 372, 379,
377, 380, 576, 478, 381, 388, 390, 391, 489, 488,
393, 396, 472, 473, 394, 425, 424, 399, 397, 402,
422, 404, 405, 398, 407, 409, 405, 408, 315, 193,
575, 413, 200, 575, 451, 456, 461, 466, 469, 471,
476, 481, 486, 491, 496, 84, 501, 506
410, 576, 414, 159, 576, 453, 458, 463, 468, 471,
473, 478, 483, 488, 493, 498, 68, 503, 508
} ;
static const flex_int16_t yy_def[319] =
static const flex_int16_t yy_def[320] =
{ 0,
304, 1, 305, 305, 306, 306, 304, 304, 304, 304,
304, 307, 304, 304, 304, 308, 304, 304, 304, 304,
304, 304, 304, 304, 309, 304, 304, 304, 304, 304,
310, 304, 304, 304, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 307, 304, 311, 304, 304, 304, 304, 312, 304,
313, 304, 308, 314, 304, 304, 304, 304, 304, 304,
304, 304, 304, 315, 304, 304, 309, 309, 316, 304,
304, 304, 304, 304, 304, 310, 304, 310, 310, 310,
305, 1, 306, 306, 307, 307, 305, 305, 305, 305,
305, 308, 305, 305, 305, 309, 305, 305, 305, 305,
305, 305, 305, 305, 310, 305, 305, 305, 305, 305,
305, 311, 305, 305, 305, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 308, 305, 312, 305, 305, 305, 305, 313,
305, 314, 305, 309, 315, 305, 305, 305, 305, 305,
305, 305, 305, 305, 316, 305, 305, 310, 310, 317,
305, 305, 305, 305, 305, 305, 311, 305, 311, 311,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 304, 304, 307, 307, 311, 304, 304,
304, 312, 304, 317, 313, 318, 308, 308, 314, 304,
304, 315, 304, 304, 316, 304, 304, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 304, 312, 312, 317, 313, 313, 318,
304, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 305, 305, 308, 308, 312, 305,
305, 305, 313, 305, 318, 314, 319, 309, 309, 315,
305, 305, 316, 305, 305, 317, 305, 305, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 305, 313, 313, 318, 314, 314,
319, 305, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
310, 310, 310, 310, 310, 304, 304, 304, 304, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 304, 304, 304,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 304, 304, 304, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 304,
304, 304, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 310, 310, 310, 310, 310, 310, 310,
310, 304, 310, 310, 310, 310, 310, 310, 304, 310,
310, 310, 304, 310, 310, 304, 310, 310, 304, 310,
311, 311, 311, 311, 311, 311, 305, 305, 305, 305,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 305, 305,
305, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 305, 305, 305, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
305, 305, 305, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 311, 311, 311, 311, 311, 311,
311, 311, 305, 311, 311, 311, 311, 311, 311, 305,
311, 311, 311, 305, 311, 311, 305, 311, 311, 305,
304, 310, 310, 0, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304
311, 305, 311, 311, 0, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305
} ;
static const flex_int16_t yy_nxt[632] =
static const flex_int16_t yy_nxt[634] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 8, 33, 34, 31, 35,
36, 37, 38, 39, 40, 41, 31, 42, 31, 43,
31, 44, 31, 45, 46, 47, 48, 49, 31, 50,
31, 31, 51, 52, 53, 54, 56, 56, 59, 59,
63, 60, 60, 63, 65, 57, 57, 69, 76, 78,
70, 71, 66, 80, 91, 92, 79, 77, 89, 82,
74, 64, 67, 89, 72, 83, 86, 145, 87, 89,
84, 94, 95, 100, 98, 85, 89, 89, 89, 89,
28, 29, 30, 31, 32, 33, 8, 34, 35, 32,
36, 37, 38, 39, 40, 41, 42, 32, 43, 32,
44, 32, 45, 32, 46, 47, 48, 49, 50, 32,
51, 32, 32, 52, 53, 54, 55, 57, 57, 60,
60, 64, 61, 61, 66, 81, 58, 58, 64, 77,
70, 146, 67, 71, 72, 92, 93, 79, 78, 83,
95, 96, 68, 65, 80, 84, 75, 73, 90, 87,
85, 88, 90, 90, 82, 86, 90, 90, 90, 90,
101, 81, 99, 106, 89, 103, 102, 89, 108, 89,
89, 89, 104, 89, 105, 111, 107, 122, 109, 89,
89, 114, 89, 133, 63, 110, 133, 112, 115, 62,
113, 127, 89, 117, 63, 119, 120, 80, 143, 89,
136, 118, 73, 121, 116, 64, 156, 134, 138, 123,
304, 74, 128, 89, 140, 144, 86, 89, 87, 89,
89, 149, 89, 89, 89, 139, 89, 89, 89, 148,
89, 89, 154, 150, 152, 89, 89, 89, 89, 151,
153, 89, 157, 89, 89, 89, 159, 155, 89, 158,
89, 89, 169, 63, 162, 164, 165, 161, 160, 163,
90, 101, 90, 107, 99, 110, 104, 105, 102, 106,
112, 100, 111, 90, 103, 90, 108, 109, 90, 90,
90, 123, 90, 90, 64, 90, 134, 115, 116, 121,
90, 134, 113, 118, 64, 81, 122, 114, 63, 120,
128, 119, 144, 211, 117, 74, 65, 305, 135, 137,
90, 139, 75, 141, 124, 87, 90, 88, 90, 90,
145, 90, 129, 90, 151, 90, 90, 150, 149, 140,
152, 90, 90, 153, 155, 90, 90, 90, 90, 154,
90, 90, 157, 90, 90, 90, 158, 90, 90, 90,
64, 156, 160, 90, 90, 159, 90, 163, 165, 166,
166, 63, 170, 171, 62, 168, 127, 167, 133, 132,
135, 176, 89, 133, 64, 73, 179, 63, 63, 143,
89, 138, 64, 89, 89, 89, 184, 128, 185, 134,
136, 89, 177, 180, 74, 74, 144, 89, 139, 182,
89, 183, 89, 89, 187, 186, 188, 89, 189, 89,
89, 89, 89, 89, 89, 89, 89, 192, 193, 194,
190, 89, 196, 89, 195, 198, 89, 191, 89, 89,
89, 201, 133, 133, 202, 200, 197, 203, 132, 133,
176, 133, 199, 89, 205, 135, 89, 89, 89, 204,
211, 179, 301, 134, 134, 89, 136, 89, 136, 210,
167, 161, 162, 170, 164, 171, 172, 168, 64, 134,
134, 169, 65, 63, 133, 128, 177, 136, 64, 74,
90, 64, 144, 180, 90, 139, 90, 302, 137, 90,
65, 135, 90, 184, 186, 183, 75, 129, 178, 75,
145, 181, 90, 140, 90, 188, 185, 90, 189, 90,
90, 90, 90, 90, 90, 190, 187, 90, 90, 193,
194, 195, 90, 197, 90, 90, 191, 90, 90, 196,
192, 199, 90, 202, 90, 90, 203, 134, 134, 133,
198, 177, 204, 134, 134, 200, 136, 201, 90, 206,
90, 90, 180, 205, 90, 212, 90, 90, 90, 135,
212, 177, 89, 89, 89, 215, 216, 89, 180, 213,
219, 214, 89, 218, 89, 89, 89, 217, 89, 89,
221, 89, 223, 89, 89, 224, 89, 89, 225, 227,
89, 220, 89, 235, 89, 89, 222, 89, 89, 89,
226, 231, 233, 237, 234, 232, 238, 89, 240, 89,
239, 243, 89, 89, 244, 89, 242, 236, 241, 89,
89, 89, 89, 89, 245, 89, 250, 89, 89, 89,
249, 253, 258, 254, 89, 89, 89, 89, 255, 257,
89, 251, 252, 259, 265, 89, 256, 263, 89, 89,
266, 89, 267, 264, 89, 89, 268, 269, 89, 89,
135, 137, 137, 178, 216, 90, 213, 215, 90, 217,
181, 218, 214, 90, 90, 90, 220, 219, 90, 223,
90, 222, 224, 90, 90, 90, 90, 90, 90, 225,
90, 90, 226, 221, 228, 90, 236, 90, 90, 90,
90, 90, 232, 234, 227, 235, 233, 90, 241, 242,
90, 240, 238, 237, 90, 239, 90, 243, 245, 90,
90, 90, 252, 90, 90, 90, 244, 90, 246, 90,
90, 251, 255, 90, 254, 90, 250, 259, 90, 90,
90, 256, 253, 90, 260, 258, 257, 264, 266, 267,
268, 90, 90, 90, 90, 90, 90, 265, 90, 269,
89, 89, 89, 89, 277, 89, 270, 275, 271, 278,
276, 274, 280, 279, 89, 89, 89, 89, 281, 284,
89, 89, 283, 286, 288, 89, 89, 89, 290, 291,
285, 89, 89, 89, 89, 89, 287, 295, 89, 299,
297, 296, 294, 300, 298, 303, 89, 292, 293, 89,
302, 55, 55, 55, 55, 55, 58, 58, 58, 58,
58, 62, 62, 62, 62, 62, 73, 73, 73, 73,
73, 88, 88, 88, 96, 96, 126, 126, 126, 126,
126, 132, 132, 132, 132, 132, 135, 135, 135, 135,
135, 137, 137, 137, 137, 137, 142, 89, 142, 142,
270, 90, 278, 90, 276, 90, 90, 90, 271, 272,
275, 280, 279, 277, 90, 281, 90, 90, 285, 90,
90, 282, 90, 90, 287, 90, 289, 291, 284, 292,
90, 90, 286, 90, 90, 90, 90, 296, 288, 300,
90, 298, 301, 297, 293, 295, 299, 304, 90, 294,
90, 90, 303, 56, 56, 56, 56, 56, 59, 59,
59, 59, 59, 63, 63, 63, 63, 63, 74, 74,
74, 74, 74, 89, 89, 89, 97, 97, 127, 127,
127, 127, 127, 133, 133, 133, 133, 133, 136, 136,
136, 136, 136, 138, 138, 138, 138, 138, 143, 90,
142, 175, 175, 175, 175, 175, 178, 178, 178, 178,
178, 89, 289, 89, 89, 282, 89, 89, 273, 272,
89, 89, 262, 261, 260, 89, 89, 89, 89, 248,
247, 246, 89, 89, 89, 89, 230, 229, 228, 89,
89, 89, 89, 89, 89, 89, 209, 208, 207, 206,
89, 181, 174, 173, 172, 89, 89, 89, 147, 146,
141, 131, 130, 129, 125, 124, 97, 89, 93, 90,
75, 68, 61, 304, 7, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
143, 143, 143, 176, 176, 176, 176, 176, 179, 179,
179, 179, 179, 290, 90, 90, 283, 90, 90, 274,
273, 90, 90, 263, 262, 261, 90, 90, 90, 90,
249, 248, 247, 90, 90, 90, 90, 231, 230, 229,
90, 90, 90, 90, 90, 90, 90, 210, 209, 208,
207, 90, 182, 175, 174, 173, 90, 90, 90, 148,
147, 142, 132, 131, 130, 126, 125, 98, 90, 94,
91, 76, 69, 62, 305, 7, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305
} ;
static const flex_int16_t yy_chk[632] =
static const flex_int16_t yy_chk[634] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 4, 5, 6,
12, 5, 6, 16, 13, 3, 4, 15, 20, 22,
15, 15, 13, 23, 28, 28, 22, 20, 35, 24,
16, 12, 13, 36, 15, 24, 25, 316, 25, 37,
24, 30, 30, 37, 35, 24, 25, 38, 39, 40,
1, 1, 1, 1, 1, 1, 1, 3, 4, 5,
6, 12, 5, 6, 13, 23, 3, 4, 16, 20,
15, 317, 13, 15, 15, 28, 28, 22, 20, 24,
30, 30, 13, 12, 22, 24, 16, 15, 36, 25,
24, 25, 37, 40, 23, 24, 43, 38, 39, 41,
37, 23, 36, 40, 41, 38, 37, 43, 41, 42,
44, 45, 39, 46, 39, 43, 40, 52, 42, 49,
47, 46, 48, 71, 62, 42, 69, 44, 47, 64,
45, 64, 50, 48, 73, 49, 50, 80, 86, 105,
71, 48, 74, 50, 47, 62, 105, 69, 74, 52,
88, 73, 64, 99, 80, 86, 87, 98, 87, 100,
88, 99, 101, 103, 102, 74, 87, 104, 106, 98,
107, 108, 103, 100, 101, 111, 112, 113, 114, 100,
102, 115, 106, 118, 116, 119, 108, 104, 117, 107,
120, 121, 119, 126, 113, 115, 116, 112, 111, 114,
25, 38, 44, 41, 36, 43, 39, 40, 38, 40,
44, 37, 43, 42, 38, 45, 41, 42, 46, 47,
48, 53, 49, 50, 63, 51, 70, 47, 48, 51,
184, 72, 45, 49, 74, 81, 51, 46, 65, 50,
65, 49, 87, 184, 48, 75, 63, 89, 70, 72,
101, 75, 74, 81, 53, 88, 99, 88, 89, 100,
87, 102, 65, 103, 101, 104, 88, 100, 99, 75,
101, 105, 107, 102, 104, 106, 108, 109, 112, 103,
114, 113, 106, 115, 116, 304, 107, 117, 118, 119,
127, 105, 109, 121, 122, 108, 120, 114, 116, 117,
117, 127, 120, 121, 128, 118, 128, 117, 132, 134,
136, 134, 150, 135, 126, 139, 136, 137, 138, 143,
151, 139, 127, 153, 148, 303, 150, 128, 151, 132,
135, 152, 134, 136, 137, 138, 143, 149, 139, 148,
155, 149, 154, 156, 153, 152, 154, 157, 155, 158,
159, 160, 161, 162, 163, 166, 164, 158, 159, 160,
156, 165, 162, 167, 161, 164, 168, 157, 170, 169,
171, 167, 175, 176, 168, 166, 163, 169, 177, 178,
177, 179, 165, 186, 171, 180, 183, 188, 187, 170,
186, 180, 299, 175, 176, 190, 178, 191, 179, 183,
118, 112, 113, 120, 115, 121, 122, 118, 128, 133,
136, 119, 127, 129, 135, 129, 135, 137, 138, 140,
149, 139, 144, 137, 154, 140, 152, 300, 136, 150,
128, 133, 151, 150, 152, 149, 138, 129, 135, 139,
144, 137, 153, 140, 155, 154, 151, 156, 155, 157,
158, 159, 160, 161, 163, 156, 153, 162, 164, 159,
160, 161, 165, 163, 166, 168, 157, 167, 169, 162,
158, 165, 171, 168, 170, 172, 169, 176, 177, 178,
164, 178, 170, 179, 180, 166, 181, 167, 187, 172,
189, 191, 181, 171, 188, 187, 192, 195, 201, 176,
187, 177, 192, 194, 195, 191, 192, 196, 180, 188,
196, 190, 197, 195, 199, 200, 203, 194, 201, 204,
199, 205, 201, 210, 211, 203, 212, 216, 204, 205,
213, 197, 218, 216, 220, 225, 200, 221, 219, 224,
204, 210, 212, 219, 213, 211, 219, 222, 221, 223,
220, 224, 226, 231, 225, 232, 223, 218, 222, 233,
235, 234, 238, 243, 226, 237, 232, 241, 244, 245,
231, 235, 244, 237, 250, 249, 251, 298, 238, 243,
254, 233, 234, 245, 251, 255, 241, 249, 256, 257,
254, 258, 255, 250, 259, 263, 256, 257, 266, 264,
177, 179, 180, 178, 192, 193, 188, 191, 196, 193,
181, 195, 189, 197, 198, 200, 197, 196, 202, 201,
204, 200, 202, 205, 211, 212, 206, 213, 219, 204,
217, 214, 205, 198, 206, 221, 217, 222, 223, 226,
234, 299, 211, 213, 205, 214, 212, 220, 222, 223,
224, 221, 220, 219, 225, 220, 227, 224, 226, 232,
233, 235, 234, 236, 238, 239, 225, 242, 227, 244,
246, 233, 238, 245, 236, 250, 232, 245, 251, 255,
252, 239, 235, 256, 246, 244, 242, 250, 252, 255,
256, 257, 258, 259, 264, 260, 265, 251, 269, 257,
268, 274, 269, 271, 268, 270, 258, 264, 259, 269,
266, 263, 271, 270, 276, 275, 277, 280, 271, 275,
281, 284, 274, 277, 281, 287, 288, 291, 284, 287,
276, 292, 294, 295, 300, 297, 280, 292, 302, 296,
294, 293, 291, 297, 295, 302, 290, 288, 289, 286,
300, 305, 305, 305, 305, 305, 306, 306, 306, 306,
306, 307, 307, 307, 307, 307, 308, 308, 308, 308,
308, 309, 309, 309, 310, 310, 311, 311, 311, 311,
311, 312, 312, 312, 312, 312, 313, 313, 313, 313,
313, 314, 314, 314, 314, 314, 315, 285, 315, 315,
258, 267, 269, 271, 265, 270, 272, 275, 259, 260,
264, 271, 270, 267, 276, 272, 277, 278, 276, 281,
285, 272, 282, 289, 278, 288, 282, 285, 275, 288,
292, 293, 277, 295, 298, 296, 301, 293, 281, 297,
303, 295, 298, 294, 289, 292, 296, 303, 291, 290,
287, 286, 301, 306, 306, 306, 306, 306, 307, 307,
307, 307, 307, 308, 308, 308, 308, 308, 309, 309,
309, 309, 309, 310, 310, 310, 311, 311, 312, 312,
312, 312, 312, 313, 313, 313, 313, 313, 314, 314,
314, 314, 314, 315, 315, 315, 315, 315, 316, 284,
315, 317, 317, 317, 317, 317, 318, 318, 318, 318,
318, 283, 282, 279, 278, 273, 267, 265, 262, 260,
253, 252, 248, 247, 246, 242, 240, 239, 236, 230,
229, 228, 227, 217, 215, 214, 208, 207, 206, 202,
198, 193, 189, 185, 184, 182, 181, 174, 173, 172,
145, 141, 131, 130, 129, 110, 109, 96, 95, 91,
81, 67, 66, 65, 60, 57, 34, 31, 29, 26,
19, 14, 11, 7, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
316, 316, 316, 318, 318, 318, 318, 318, 319, 319,
319, 319, 319, 283, 280, 279, 274, 268, 266, 263,
261, 254, 253, 249, 248, 247, 243, 241, 240, 237,
231, 230, 229, 228, 218, 216, 215, 209, 208, 207,
203, 199, 194, 190, 186, 185, 183, 182, 175, 174,
173, 146, 142, 132, 131, 130, 111, 110, 97, 96,
92, 82, 68, 67, 66, 61, 58, 35, 32, 29,
26, 19, 14, 11, 7, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305
} ;
/* The intent behind this definition is that it'll catch
@ -1183,13 +1183,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_current_state != 304 );
while ( yy_current_state != 305 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1510,218 +1510,223 @@ YY_RULE_SETUP
case 60:
YY_RULE_SETUP
#line 107 "lexer.lpp"
{ return h1::parser::make_INCREMENT(loc); }
{ return h1::parser::make_QMARK(loc); }
YY_BREAK
case 61:
YY_RULE_SETUP
#line 108 "lexer.lpp"
{ return h1::parser::make_DECREMENT(loc); }
{ return h1::parser::make_INCREMENT(loc); }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 109 "lexer.lpp"
{ return h1::parser::make_ASSIGN_LSHIFT(loc); }
{ return h1::parser::make_DECREMENT(loc); }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 110 "lexer.lpp"
{ return h1::parser::make_ASSIGN_RSHIFT(loc); }
{ return h1::parser::make_ASSIGN_LSHIFT(loc); }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 111 "lexer.lpp"
{ return h1::parser::make_LSHIFT(loc); }
{ return h1::parser::make_ASSIGN_RSHIFT(loc); }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 112 "lexer.lpp"
{ return h1::parser::make_RSHIFT(loc); }
{ return h1::parser::make_LSHIFT(loc); }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 113 "lexer.lpp"
{ return h1::parser::make_OR(loc); }
{ return h1::parser::make_RSHIFT(loc); }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 114 "lexer.lpp"
{ return h1::parser::make_AND(loc); }
{ return h1::parser::make_OR(loc); }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 115 "lexer.lpp"
{ return h1::parser::make_EQUALITY(loc); }
{ return h1::parser::make_AND(loc); }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 116 "lexer.lpp"
{ return h1::parser::make_INEQUALITY(loc); }
{ return h1::parser::make_EQUALITY(loc); }
YY_BREAK
case 70:
YY_RULE_SETUP
#line 117 "lexer.lpp"
{ return h1::parser::make_LESS_EQUAL(loc); }
{ return h1::parser::make_INEQUALITY(loc); }
YY_BREAK
case 71:
YY_RULE_SETUP
#line 118 "lexer.lpp"
{ return h1::parser::make_GREATER_EQUAL(loc); }
{ return h1::parser::make_LESS_EQUAL(loc); }
YY_BREAK
case 72:
YY_RULE_SETUP
#line 119 "lexer.lpp"
{ return h1::parser::make_LESS(loc); }
{ return h1::parser::make_GREATER_EQUAL(loc); }
YY_BREAK
case 73:
YY_RULE_SETUP
#line 120 "lexer.lpp"
{ return h1::parser::make_GREATER(loc); }
{ return h1::parser::make_LESS(loc); }
YY_BREAK
case 74:
YY_RULE_SETUP
#line 121 "lexer.lpp"
{ return h1::parser::make_ASSIGN_ADD(loc); }
{ return h1::parser::make_GREATER(loc); }
YY_BREAK
case 75:
YY_RULE_SETUP
#line 122 "lexer.lpp"
{ return h1::parser::make_ASSIGN_SUB(loc); }
{ return h1::parser::make_ASSIGN_ADD(loc); }
YY_BREAK
case 76:
YY_RULE_SETUP
#line 123 "lexer.lpp"
{ return h1::parser::make_ASSIGN_MULT(loc); }
{ return h1::parser::make_ASSIGN_SUB(loc); }
YY_BREAK
case 77:
YY_RULE_SETUP
#line 124 "lexer.lpp"
{ return h1::parser::make_ASSIGN_DIV(loc); }
{ return h1::parser::make_ASSIGN_MULT(loc); }
YY_BREAK
case 78:
YY_RULE_SETUP
#line 125 "lexer.lpp"
{ return h1::parser::make_ASSIGN_MOD(loc); }
{ return h1::parser::make_ASSIGN_DIV(loc); }
YY_BREAK
case 79:
YY_RULE_SETUP
#line 126 "lexer.lpp"
{ return h1::parser::make_ASSIGN_BITWISE_OR(loc); }
{ return h1::parser::make_ASSIGN_MOD(loc); }
YY_BREAK
case 80:
YY_RULE_SETUP
#line 127 "lexer.lpp"
{ return h1::parser::make_ASSIGN_BITWISE_AND(loc); }
{ return h1::parser::make_ASSIGN_BITWISE_OR(loc); }
YY_BREAK
case 81:
YY_RULE_SETUP
#line 128 "lexer.lpp"
{ return h1::parser::make_ASSIGN_BITWISE_EXOR(loc); }
{ return h1::parser::make_ASSIGN_BITWISE_AND(loc); }
YY_BREAK
case 82:
YY_RULE_SETUP
#line 129 "lexer.lpp"
{ return h1::parser::make_ASSIGN(loc); }
{ return h1::parser::make_ASSIGN_BITWISE_EXOR(loc); }
YY_BREAK
case 83:
YY_RULE_SETUP
#line 130 "lexer.lpp"
{ return h1::parser::make_ADD(loc); }
{ return h1::parser::make_ASSIGN(loc); }
YY_BREAK
case 84:
YY_RULE_SETUP
#line 131 "lexer.lpp"
{ return h1::parser::make_SUB(loc); }
{ return h1::parser::make_ADD(loc); }
YY_BREAK
case 85:
YY_RULE_SETUP
#line 132 "lexer.lpp"
{ return h1::parser::make_MULT(loc); }
{ return h1::parser::make_SUB(loc); }
YY_BREAK
case 86:
YY_RULE_SETUP
#line 133 "lexer.lpp"
{ return h1::parser::make_DIV(loc); }
{ return h1::parser::make_MULT(loc); }
YY_BREAK
case 87:
YY_RULE_SETUP
#line 134 "lexer.lpp"
{ return h1::parser::make_MOD(loc); }
{ return h1::parser::make_DIV(loc); }
YY_BREAK
case 88:
YY_RULE_SETUP
#line 135 "lexer.lpp"
{ return h1::parser::make_NOT(loc); }
{ return h1::parser::make_MOD(loc); }
YY_BREAK
case 89:
YY_RULE_SETUP
#line 136 "lexer.lpp"
{ return h1::parser::make_COMPLEMENT(loc); }
{ return h1::parser::make_NOT(loc); }
YY_BREAK
case 90:
YY_RULE_SETUP
#line 137 "lexer.lpp"
{ return h1::parser::make_BITWISE_OR(loc); }
{ return h1::parser::make_COMPLEMENT(loc); }
YY_BREAK
case 91:
YY_RULE_SETUP
#line 138 "lexer.lpp"
{ return h1::parser::make_BITWISE_AND(loc); }
{ return h1::parser::make_BITWISE_OR(loc); }
YY_BREAK
case 92:
YY_RULE_SETUP
#line 139 "lexer.lpp"
{ return h1::parser::make_BITWISE_EXOR(loc); }
{ return h1::parser::make_BITWISE_AND(loc); }
YY_BREAK
case 93:
YY_RULE_SETUP
#line 140 "lexer.lpp"
{ return h1::parser::make_FILE(utils::string::fordslash(yytext), loc); }
{ return h1::parser::make_BITWISE_EXOR(loc); }
YY_BREAK
case 94:
YY_RULE_SETUP
#line 141 "lexer.lpp"
{ return h1::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
{ return h1::parser::make_FILE(utils::string::fordslash(yytext), loc); }
YY_BREAK
case 95:
/* rule 95 can match eol */
YY_RULE_SETUP
#line 142 "lexer.lpp"
{ return h1::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
{ return h1::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 143 "lexer.lpp"
{ return h1::parser::make_STRING(std::string(yytext), loc); }
{ return h1::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
YY_BREAK
case 97:
/* rule 97 can match eol */
YY_RULE_SETUP
#line 144 "lexer.lpp"
{ return h1::parser::make_FLOAT(std::string(yytext), loc); }
{ return h1::parser::make_STRING(std::string(yytext), loc); }
YY_BREAK
case 98:
YY_RULE_SETUP
#line 145 "lexer.lpp"
{ return h1::parser::make_FLOAT(std::string(yytext), loc); }
YY_BREAK
case 99:
YY_RULE_SETUP
#line 146 "lexer.lpp"
{ return h1::parser::make_INTEGER(std::string(yytext), loc); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT_BLOCK_STATE):
case YY_STATE_EOF(DEVELOPER_BLOCK_STATE):
#line 146 "lexer.lpp"
#line 147 "lexer.lpp"
{ return h1::parser::make_H1EOF(loc); }
YY_BREAK
case 99:
/* rule 99 can match eol */
case 100:
/* rule 100 can match eol */
YY_RULE_SETUP
#line 147 "lexer.lpp"
#line 148 "lexer.lpp"
{ throw h1::parser::syntax_error(loc, "bad token: \'" + std::string(yytext) + "\'"); }
YY_BREAK
case 100:
case 101:
YY_RULE_SETUP
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"
ECHO;
YY_BREAK
#line 1724 "lexer.cpp"
#line 1729 "lexer.cpp"
case YY_END_OF_BUFFER:
{
@ -2019,7 +2024,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@ -2048,11 +2053,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 304);
yy_is_jam = (yy_current_state == 305);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@ -2851,6 +2856,6 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"

View File

@ -700,7 +700,7 @@ extern int yylex (yyscan_t yyscanner);
#undef yyTABLES_NAME
#endif
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"
#line 706 "lexer.hpp"

File diff suppressed because it is too large Load Diff

View File

@ -446,6 +446,7 @@ namespace xsk { namespace gsc { namespace h1 {
// for_expr
// expr
// expr_compare
// expr_ternary
// expr_binary
// expr_primitive
char dummy11[sizeof (expr_ptr)];
@ -700,53 +701,55 @@ namespace xsk { namespace gsc { namespace h1 {
DOUBLECOLON = 48, // "::"
COLON = 49, // ":"
SEMICOLON = 50, // ";"
INCREMENT = 51, // "++"
DECREMENT = 52, // "--"
LSHIFT = 53, // "<<"
RSHIFT = 54, // ">>"
OR = 55, // "||"
AND = 56, // "&&"
EQUALITY = 57, // "=="
INEQUALITY = 58, // "!="
LESS_EQUAL = 59, // "<="
GREATER_EQUAL = 60, // ">="
LESS = 61, // "<"
GREATER = 62, // ">"
NOT = 63, // "!"
COMPLEMENT = 64, // "~"
ASSIGN = 65, // "="
ASSIGN_ADD = 66, // "+="
ASSIGN_SUB = 67, // "-="
ASSIGN_MULT = 68, // "*="
ASSIGN_DIV = 69, // "/="
ASSIGN_MOD = 70, // "%="
ASSIGN_BITWISE_OR = 71, // "|="
ASSIGN_BITWISE_AND = 72, // "&="
ASSIGN_BITWISE_EXOR = 73, // "^="
ASSIGN_RSHIFT = 74, // ">>="
ASSIGN_LSHIFT = 75, // "<<="
BITWISE_OR = 76, // "|"
BITWISE_AND = 77, // "&"
BITWISE_EXOR = 78, // "^"
ADD = 79, // "+"
SUB = 80, // "-"
MULT = 81, // "*"
DIV = 82, // "/"
MOD = 83, // "%"
FILE = 84, // "file path"
NAME = 85, // "identifier"
STRING = 86, // "string literal"
ISTRING = 87, // "localized string"
FLOAT = 88, // "float"
INTEGER = 89, // "int"
ADD_ARRAY = 90, // ADD_ARRAY
THEN = 91, // THEN
NEG = 92, // NEG
ANIMREF = 93, // ANIMREF
PREINC = 94, // PREINC
PREDEC = 95, // PREDEC
POSTINC = 96, // POSTINC
POSTDEC = 97 // POSTDEC
QMARK = 51, // "?"
INCREMENT = 52, // "++"
DECREMENT = 53, // "--"
LSHIFT = 54, // "<<"
RSHIFT = 55, // ">>"
OR = 56, // "||"
AND = 57, // "&&"
EQUALITY = 58, // "=="
INEQUALITY = 59, // "!="
LESS_EQUAL = 60, // "<="
GREATER_EQUAL = 61, // ">="
LESS = 62, // "<"
GREATER = 63, // ">"
NOT = 64, // "!"
COMPLEMENT = 65, // "~"
ASSIGN = 66, // "="
ASSIGN_ADD = 67, // "+="
ASSIGN_SUB = 68, // "-="
ASSIGN_MULT = 69, // "*="
ASSIGN_DIV = 70, // "/="
ASSIGN_MOD = 71, // "%="
ASSIGN_BITWISE_OR = 72, // "|="
ASSIGN_BITWISE_AND = 73, // "&="
ASSIGN_BITWISE_EXOR = 74, // "^="
ASSIGN_RSHIFT = 75, // ">>="
ASSIGN_LSHIFT = 76, // "<<="
BITWISE_OR = 77, // "|"
BITWISE_AND = 78, // "&"
BITWISE_EXOR = 79, // "^"
ADD = 80, // "+"
SUB = 81, // "-"
MULT = 82, // "*"
DIV = 83, // "/"
MOD = 84, // "%"
FILE = 85, // "file path"
NAME = 86, // "identifier"
STRING = 87, // "string literal"
ISTRING = 88, // "localized string"
FLOAT = 89, // "float"
INTEGER = 90, // "int"
ADD_ARRAY = 91, // ADD_ARRAY
THEN = 92, // THEN
TERN = 93, // TERN
NEG = 94, // NEG
ANIMREF = 95, // ANIMREF
PREINC = 96, // PREINC
PREDEC = 97, // PREDEC
POSTINC = 98, // POSTINC
POSTDEC = 99 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -763,7 +766,7 @@ namespace xsk { namespace gsc { namespace h1 {
{
enum symbol_kind_type
{
YYNTOKENS = 98, ///< Number of tokens.
YYNTOKENS = 100, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
@ -816,129 +819,132 @@ namespace xsk { namespace gsc { namespace h1 {
S_DOUBLECOLON = 48, // "::"
S_COLON = 49, // ":"
S_SEMICOLON = 50, // ";"
S_INCREMENT = 51, // "++"
S_DECREMENT = 52, // "--"
S_LSHIFT = 53, // "<<"
S_RSHIFT = 54, // ">>"
S_OR = 55, // "||"
S_AND = 56, // "&&"
S_EQUALITY = 57, // "=="
S_INEQUALITY = 58, // "!="
S_LESS_EQUAL = 59, // "<="
S_GREATER_EQUAL = 60, // ">="
S_LESS = 61, // "<"
S_GREATER = 62, // ">"
S_NOT = 63, // "!"
S_COMPLEMENT = 64, // "~"
S_ASSIGN = 65, // "="
S_ASSIGN_ADD = 66, // "+="
S_ASSIGN_SUB = 67, // "-="
S_ASSIGN_MULT = 68, // "*="
S_ASSIGN_DIV = 69, // "/="
S_ASSIGN_MOD = 70, // "%="
S_ASSIGN_BITWISE_OR = 71, // "|="
S_ASSIGN_BITWISE_AND = 72, // "&="
S_ASSIGN_BITWISE_EXOR = 73, // "^="
S_ASSIGN_RSHIFT = 74, // ">>="
S_ASSIGN_LSHIFT = 75, // "<<="
S_BITWISE_OR = 76, // "|"
S_BITWISE_AND = 77, // "&"
S_BITWISE_EXOR = 78, // "^"
S_ADD = 79, // "+"
S_SUB = 80, // "-"
S_MULT = 81, // "*"
S_DIV = 82, // "/"
S_MOD = 83, // "%"
S_FILE = 84, // "file path"
S_NAME = 85, // "identifier"
S_STRING = 86, // "string literal"
S_ISTRING = 87, // "localized string"
S_FLOAT = 88, // "float"
S_INTEGER = 89, // "int"
S_ADD_ARRAY = 90, // ADD_ARRAY
S_THEN = 91, // THEN
S_NEG = 92, // NEG
S_ANIMREF = 93, // ANIMREF
S_PREINC = 94, // PREINC
S_PREDEC = 95, // PREDEC
S_POSTINC = 96, // POSTINC
S_POSTDEC = 97, // POSTDEC
S_YYACCEPT = 98, // $accept
S_root = 99, // root
S_program = 100, // program
S_include = 101, // include
S_define = 102, // define
S_usingtree = 103, // usingtree
S_constant = 104, // constant
S_thread = 105, // thread
S_parameters = 106, // parameters
S_stmt = 107, // stmt
S_stmt_block = 108, // stmt_block
S_stmt_list = 109, // stmt_list
S_stmt_call = 110, // stmt_call
S_stmt_assign = 111, // stmt_assign
S_stmt_endon = 112, // stmt_endon
S_stmt_notify = 113, // stmt_notify
S_stmt_wait = 114, // stmt_wait
S_stmt_waittill = 115, // stmt_waittill
S_stmt_waittillmatch = 116, // stmt_waittillmatch
S_stmt_waittillframeend = 117, // stmt_waittillframeend
S_stmt_waitframe = 118, // stmt_waitframe
S_stmt_if = 119, // stmt_if
S_stmt_ifelse = 120, // stmt_ifelse
S_stmt_while = 121, // stmt_while
S_stmt_for = 122, // stmt_for
S_stmt_foreach = 123, // stmt_foreach
S_stmt_switch = 124, // stmt_switch
S_stmt_case = 125, // stmt_case
S_stmt_default = 126, // stmt_default
S_stmt_break = 127, // stmt_break
S_stmt_continue = 128, // stmt_continue
S_stmt_return = 129, // stmt_return
S_stmt_breakpoint = 130, // stmt_breakpoint
S_stmt_prof_begin = 131, // stmt_prof_begin
S_stmt_prof_end = 132, // stmt_prof_end
S_for_stmt = 133, // for_stmt
S_for_expr = 134, // for_expr
S_expr = 135, // expr
S_expr_assign = 136, // expr_assign
S_expr_compare = 137, // expr_compare
S_expr_binary = 138, // expr_binary
S_expr_primitive = 139, // expr_primitive
S_expr_call = 140, // expr_call
S_expr_call_thread = 141, // expr_call_thread
S_expr_call_childthread = 142, // expr_call_childthread
S_expr_call_function = 143, // expr_call_function
S_expr_call_pointer = 144, // expr_call_pointer
S_expr_arguments = 145, // expr_arguments
S_expr_arguments_filled = 146, // expr_arguments_filled
S_expr_arguments_empty = 147, // expr_arguments_empty
S_expr_function = 148, // expr_function
S_expr_add_array = 149, // expr_add_array
S_expr_array = 150, // expr_array
S_expr_field = 151, // expr_field
S_expr_size = 152, // expr_size
S_object = 153, // object
S_thisthread = 154, // thisthread
S_empty_array = 155, // empty_array
S_undefined = 156, // undefined
S_game = 157, // game
S_self = 158, // self
S_anim = 159, // anim
S_level = 160, // level
S_animation = 161, // animation
S_animtree = 162, // animtree
S_name = 163, // name
S_file = 164, // file
S_istring = 165, // istring
S_string = 166, // string
S_vector = 167, // vector
S_neg_float = 168, // neg_float
S_neg_integer = 169, // neg_integer
S_float = 170, // float
S_integer = 171, // integer
S_false = 172, // false
S_true = 173 // true
S_QMARK = 51, // "?"
S_INCREMENT = 52, // "++"
S_DECREMENT = 53, // "--"
S_LSHIFT = 54, // "<<"
S_RSHIFT = 55, // ">>"
S_OR = 56, // "||"
S_AND = 57, // "&&"
S_EQUALITY = 58, // "=="
S_INEQUALITY = 59, // "!="
S_LESS_EQUAL = 60, // "<="
S_GREATER_EQUAL = 61, // ">="
S_LESS = 62, // "<"
S_GREATER = 63, // ">"
S_NOT = 64, // "!"
S_COMPLEMENT = 65, // "~"
S_ASSIGN = 66, // "="
S_ASSIGN_ADD = 67, // "+="
S_ASSIGN_SUB = 68, // "-="
S_ASSIGN_MULT = 69, // "*="
S_ASSIGN_DIV = 70, // "/="
S_ASSIGN_MOD = 71, // "%="
S_ASSIGN_BITWISE_OR = 72, // "|="
S_ASSIGN_BITWISE_AND = 73, // "&="
S_ASSIGN_BITWISE_EXOR = 74, // "^="
S_ASSIGN_RSHIFT = 75, // ">>="
S_ASSIGN_LSHIFT = 76, // "<<="
S_BITWISE_OR = 77, // "|"
S_BITWISE_AND = 78, // "&"
S_BITWISE_EXOR = 79, // "^"
S_ADD = 80, // "+"
S_SUB = 81, // "-"
S_MULT = 82, // "*"
S_DIV = 83, // "/"
S_MOD = 84, // "%"
S_FILE = 85, // "file path"
S_NAME = 86, // "identifier"
S_STRING = 87, // "string literal"
S_ISTRING = 88, // "localized string"
S_FLOAT = 89, // "float"
S_INTEGER = 90, // "int"
S_ADD_ARRAY = 91, // ADD_ARRAY
S_THEN = 92, // THEN
S_TERN = 93, // TERN
S_NEG = 94, // NEG
S_ANIMREF = 95, // ANIMREF
S_PREINC = 96, // PREINC
S_PREDEC = 97, // PREDEC
S_POSTINC = 98, // POSTINC
S_POSTDEC = 99, // POSTDEC
S_YYACCEPT = 100, // $accept
S_root = 101, // root
S_program = 102, // program
S_include = 103, // include
S_define = 104, // define
S_usingtree = 105, // usingtree
S_constant = 106, // constant
S_thread = 107, // thread
S_parameters = 108, // parameters
S_stmt = 109, // stmt
S_stmt_block = 110, // stmt_block
S_stmt_list = 111, // stmt_list
S_stmt_call = 112, // stmt_call
S_stmt_assign = 113, // stmt_assign
S_stmt_endon = 114, // stmt_endon
S_stmt_notify = 115, // stmt_notify
S_stmt_wait = 116, // stmt_wait
S_stmt_waittill = 117, // stmt_waittill
S_stmt_waittillmatch = 118, // stmt_waittillmatch
S_stmt_waittillframeend = 119, // stmt_waittillframeend
S_stmt_waitframe = 120, // stmt_waitframe
S_stmt_if = 121, // stmt_if
S_stmt_ifelse = 122, // stmt_ifelse
S_stmt_while = 123, // stmt_while
S_stmt_for = 124, // stmt_for
S_stmt_foreach = 125, // stmt_foreach
S_stmt_switch = 126, // stmt_switch
S_stmt_case = 127, // stmt_case
S_stmt_default = 128, // stmt_default
S_stmt_break = 129, // stmt_break
S_stmt_continue = 130, // stmt_continue
S_stmt_return = 131, // stmt_return
S_stmt_breakpoint = 132, // stmt_breakpoint
S_stmt_prof_begin = 133, // stmt_prof_begin
S_stmt_prof_end = 134, // stmt_prof_end
S_for_stmt = 135, // for_stmt
S_for_expr = 136, // for_expr
S_expr = 137, // expr
S_expr_assign = 138, // expr_assign
S_expr_compare = 139, // expr_compare
S_expr_ternary = 140, // expr_ternary
S_expr_binary = 141, // expr_binary
S_expr_primitive = 142, // expr_primitive
S_expr_call = 143, // expr_call
S_expr_call_thread = 144, // expr_call_thread
S_expr_call_childthread = 145, // expr_call_childthread
S_expr_call_function = 146, // expr_call_function
S_expr_call_pointer = 147, // expr_call_pointer
S_expr_arguments = 148, // expr_arguments
S_expr_arguments_filled = 149, // expr_arguments_filled
S_expr_arguments_empty = 150, // expr_arguments_empty
S_expr_function = 151, // expr_function
S_expr_add_array = 152, // expr_add_array
S_expr_array = 153, // expr_array
S_expr_field = 154, // expr_field
S_expr_size = 155, // expr_size
S_object = 156, // object
S_thisthread = 157, // thisthread
S_empty_array = 158, // empty_array
S_undefined = 159, // undefined
S_game = 160, // game
S_self = 161, // self
S_anim = 162, // anim
S_level = 163, // level
S_animation = 164, // animation
S_animtree = 165, // animtree
S_name = 166, // name
S_file = 167, // file
S_istring = 168, // istring
S_string = 169, // string
S_vector = 170, // vector
S_neg_float = 171, // neg_float
S_neg_integer = 172, // neg_integer
S_float = 173, // float
S_integer = 174, // integer
S_false = 175, // false
S_true = 176 // true
};
};
@ -1023,6 +1029,7 @@ namespace xsk { namespace gsc { namespace h1 {
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (std::move (that.value));
@ -2117,6 +2124,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.template destroy< expr_ptr > ();
@ -3241,6 +3249,21 @@ switch (yykind)
return symbol_type (token::SEMICOLON, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_QMARK (location_type l)
{
return symbol_type (token::QMARK, std::move (l));
}
#else
static
symbol_type
make_QMARK (const location_type& l)
{
return symbol_type (token::QMARK, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -3856,6 +3879,21 @@ switch (yykind)
return symbol_type (token::THEN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_TERN (location_type l)
{
return symbol_type (token::TERN, std::move (l));
}
#else
static
symbol_type
make_TERN (const location_type& l)
{
return symbol_type (token::TERN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4290,8 +4328,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 1646, ///< Last index in yytable_.
yynnts_ = 76, ///< Number of nonterminal symbols.
yylast_ = 1842, ///< Last index in yytable_.
yynnts_ = 77, ///< Number of nonterminal symbols.
yyfinal_ = 15 ///< Termination state number.
};
@ -4367,6 +4405,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.copy< expr_ptr > (YY_MOVE (that.value));
@ -4647,6 +4686,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (YY_MOVE (s.value));
@ -4913,7 +4953,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::h1
#line 4917 "parser.hpp"
#line 4957 "parser.hpp"

View File

@ -115,7 +115,6 @@ void assembler::assemble(const std::string& file, std::vector<gsc::function_ptr>
functions_ = std::move(functions);
script_->write<std::uint8_t>(static_cast<std::uint8_t>(opcode::OP_End));
stack_->write<std::uint32_t>(0x69773630);
for (const auto& func : functions_)
{

View File

@ -409,7 +409,7 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -465,7 +465,7 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -540,7 +540,7 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -752,6 +752,7 @@ void compiler::emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
{
switch(expr.as_node->type)
{
case gsc::node_t::expr_ternary: emit_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: emit_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: emit_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: emit_expr_binary(ctx, expr.as_binary); break;
@ -849,6 +850,30 @@ void compiler::emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_ass
}
}
void compiler::emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
auto else_loc = create_label();
auto end_loc = create_label();
if(expr->cond.as_node->type == gsc::node_t::expr_not)
{
emit_expr(ctx, expr->cond.as_not->rvalue);
emit_opcode(ctx, opcode::OP_JumpOnTrue, else_loc);
}
else
{
emit_expr(ctx, expr->cond);
emit_opcode(ctx, opcode::OP_JumpOnFalse, else_loc);
}
emit_expr(ctx, expr->lvalue);
emit_opcode(ctx, opcode::OP_jump, end_loc);
insert_label(else_loc);
emit_expr(ctx, expr->rvalue);
insert_label(end_loc);
}
void compiler::emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
emit_expr(ctx, expr->lvalue);

View File

@ -68,6 +68,7 @@ private:
void emit_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr);
void emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
void emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void emit_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void emit_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -96,6 +96,14 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
decompile_expr();
}
}
for(auto& entry : tern_labels_)
{
if(entry == itr->second)
{
decompile_ternary();
}
}
}
switch (opcode(inst->opcode))
@ -1833,6 +1841,7 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
{
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1916,6 +1925,29 @@ void decompiler::decompile_expr()
}
}
void decompiler::decompile_ternary()
{
auto rvalue = std::move(stack_.top());
stack_.pop();
auto lvalue = std::move(stack_.top());
stack_.pop();
func_->block->stmts.pop_back();
auto stmt = std::move(func_->block->stmts.back());
func_->block->stmts.pop_back();
if(stmt.as_node->type == node_t::asm_jump_cond)
{
auto loc = stmt.as_cond->loc;
auto e = std::make_unique<gsc::node_expr_ternary>(loc, std::move(stmt.as_cond->expr), std::move(lvalue), std::move(rvalue));
stack_.push(std::move(e));
}
else
{
throw gsc::decomp_error("TRIED TO DECOMPILE INVALID TERNARY EXPR!");
}
}
void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
{
this->decompile_search_infinite(block);
@ -3006,6 +3038,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
case gsc::node_t::expr_assign_bitwise_or: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_and: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_exor: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_ternary: process_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: process_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: process_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: process_expr_binary(ctx, expr.as_binary); break;
@ -3106,6 +3139,13 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assi
}
}
void decompiler::process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
process_expr(ctx, expr->cond);
process_expr(ctx, expr->lvalue);
process_expr(ctx, expr->rvalue);
}
void decompiler::process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
process_expr(ctx, expr->lvalue);

View File

@ -16,6 +16,7 @@ class decompiler : public gsc::decompiler
gsc::thread_ptr func_;
std::unordered_map<std::uint32_t, std::string> labels_;
std::vector<std::string> expr_labels_;
std::vector<std::string> tern_labels_;
std::stack<gsc::node_ptr> stack_;
std::vector<gsc::context> blocks_;
@ -27,6 +28,7 @@ private:
void decompile_function(const gsc::function_ptr& func);
void decompile_statements(const gsc::function_ptr& func);
void decompile_expr();
void decompile_ternary();
void decompile_block(const gsc::stmt_list_ptr& block);
void decompile_search_infinite(const gsc::stmt_list_ptr& block);
void decompile_search_loop(const gsc::stmt_list_ptr& block);
@ -68,6 +70,7 @@ private:
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
void process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -553,8 +553,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 100
#define YY_END_OF_BUFFER 101
#define YY_NUM_RULES 101
#define YY_END_OF_BUFFER 102
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -562,42 +562,42 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[305] =
static const flex_int16_t yy_accept[306] =
{ 0,
0, 0, 0, 0, 0, 0, 101, 99, 1, 2,
88, 99, 99, 87, 91, 99, 49, 50, 85, 83,
55, 84, 56, 86, 98, 58, 59, 72, 82, 73,
94, 53, 54, 92, 94, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
51, 90, 52, 89, 5, 6, 5, 9, 10, 9,
69, 0, 96, 0, 0, 0, 0, 78, 0, 67,
0, 80, 0, 0, 76, 60, 74, 61, 75, 97,
0, 8, 4, 3, 77, 97, 98, 0, 0, 57,
64, 70, 68, 71, 65, 94, 81, 94, 94, 94,
0, 0, 0, 0, 0, 0, 102, 100, 1, 2,
89, 100, 100, 88, 92, 100, 49, 50, 86, 84,
55, 85, 56, 87, 99, 58, 59, 73, 83, 74,
60, 95, 53, 54, 93, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 51, 91, 52, 90, 5, 6, 5, 9, 10,
9, 70, 0, 97, 0, 0, 0, 0, 79, 0,
68, 0, 81, 0, 0, 77, 61, 75, 62, 76,
98, 0, 8, 4, 3, 78, 98, 99, 0, 0,
57, 65, 71, 69, 72, 66, 95, 82, 95, 95,
94, 94, 94, 94, 94, 94, 94, 94, 25, 30,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 79, 66, 7, 11, 0, 96, 0, 0, 0,
0, 0, 95, 0, 0, 0, 0, 96, 0, 97,
0, 3, 97, 97, 93, 62, 63, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 28, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 0, 0, 0, 0, 95, 0, 0, 95, 0,
0, 47, 94, 40, 32, 94, 94, 94, 26, 94,
94, 94, 45, 94, 94, 94, 94, 46, 94, 94,
95, 95, 95, 95, 95, 95, 95, 95, 95, 25,
30, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 80, 67, 7, 11, 0, 97, 0, 0,
0, 0, 0, 96, 0, 0, 0, 0, 97, 0,
98, 0, 3, 98, 98, 94, 63, 64, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 28, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 0, 0, 0, 0, 96, 0, 0, 96,
0, 0, 47, 95, 40, 32, 95, 95, 95, 26,
95, 95, 95, 45, 95, 95, 95, 95, 46, 95,
94, 41, 94, 20, 94, 0, 0, 0, 44, 34,
94, 94, 94, 18, 42, 94, 48, 94, 94, 94,
94, 94, 94, 94, 94, 94, 27, 0, 0, 0,
94, 94, 94, 94, 94, 19, 94, 94, 36, 31,
94, 37, 94, 94, 94, 0, 0, 0, 94, 94,
94, 33, 29, 94, 94, 94, 94, 94, 94, 0,
15, 0, 94, 94, 35, 94, 14, 94, 94, 94,
21, 17, 0, 94, 94, 94, 94, 43, 24, 94,
94, 0, 12, 94, 13, 39, 94, 94, 0, 38,
94, 94, 0, 94, 94, 0, 94, 22, 0, 94,
95, 95, 41, 95, 20, 95, 0, 0, 0, 44,
34, 95, 95, 95, 18, 42, 95, 48, 95, 95,
95, 95, 95, 95, 95, 95, 95, 27, 0, 0,
0, 95, 95, 95, 95, 95, 19, 95, 95, 36,
31, 95, 37, 95, 95, 95, 0, 0, 0, 95,
95, 95, 33, 29, 95, 95, 95, 95, 95, 95,
0, 15, 0, 95, 95, 35, 95, 14, 95, 95,
95, 21, 17, 0, 95, 95, 95, 95, 43, 24,
95, 95, 0, 12, 95, 13, 39, 95, 95, 0,
38, 95, 95, 0, 95, 95, 0, 95, 22, 0,
16, 94, 23, 0
95, 16, 95, 23, 0
} ;
static const YY_CHAR yy_ec[256] =
@ -608,14 +608,14 @@ static const YY_CHAR yy_ec[256] =
1, 2, 4, 5, 6, 1, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 19, 20, 21,
22, 23, 1, 1, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 26, 27, 28, 29, 1, 30, 31, 32, 33,
22, 23, 24, 1, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 27, 28, 29, 30, 1, 31, 32, 33, 34,
34, 35, 36, 37, 38, 24, 39, 40, 41, 42,
43, 44, 24, 45, 46, 47, 48, 49, 50, 24,
51, 52, 53, 54, 55, 56, 1, 1, 1, 1,
35, 36, 37, 38, 39, 25, 40, 41, 42, 43,
44, 45, 25, 46, 47, 48, 49, 50, 51, 25,
52, 53, 54, 55, 56, 57, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -632,240 +632,240 @@ static const YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
static const YY_CHAR yy_meta[57] =
static const YY_CHAR yy_meta[58] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 4, 1, 1,
1, 1, 1, 4, 1, 5, 1, 1, 4, 4,
1, 1, 1, 1, 4, 1, 5, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1
4, 4, 4, 1, 1, 1, 1
} ;
static const flex_int16_t yy_base[319] =
static const flex_int16_t yy_base[320] =
{ 0,
0, 0, 54, 55, 56, 57, 574, 575, 575, 575,
551, 56, 35, 550, 63, 55, 575, 575, 549, 56,
575, 55, 56, 74, 71, 551, 575, 54, 547, 70,
542, 575, 575, 545, 53, 58, 64, 72, 73, 74,
79, 84, 82, 85, 86, 88, 95, 97, 94, 107,
575, 96, 575, 575, 575, 575, 549, 575, 575, 548,
575, 120, 575, 127, 522, 521, 516, 575, 122, 575,
115, 575, 126, 140, 575, 575, 575, 575, 575, 120,
523, 575, 575, 0, 575, 121, 141, 135, 0, 575,
538, 575, 575, 575, 537, 532, 575, 132, 128, 134,
0, 0, 55, 56, 57, 58, 575, 576, 576, 576,
552, 57, 34, 551, 66, 60, 576, 576, 550, 57,
576, 63, 48, 74, 74, 552, 576, 55, 548, 59,
576, 542, 576, 576, 546, 62, 66, 71, 72, 67,
73, 87, 70, 76, 89, 92, 93, 94, 96, 97,
99, 576, 100, 576, 576, 576, 576, 550, 576, 576,
549, 576, 120, 576, 136, 522, 521, 516, 576, 122,
576, 123, 576, 126, 143, 576, 576, 576, 576, 576,
118, 523, 576, 576, 0, 576, 125, 140, 132, 0,
576, 539, 576, 576, 576, 538, 532, 576, 130, 133,
137, 139, 138, 142, 114, 143, 145, 146, 531, 530,
150, 151, 152, 153, 156, 159, 163, 158, 160, 165,
166, 575, 575, 575, 575, 189, 197, 202, 517, 522,
515, 204, 575, 207, 205, 208, 209, 210, 213, 575,
500, 0, 202, 575, 525, 575, 575, 199, 212, 187,
195, 206, 198, 217, 215, 218, 222, 224, 225, 226,
227, 228, 229, 231, 236, 230, 238, 241, 244, 243,
245, 509, 509, 506, 268, 269, 276, 271, 273, 283,
513, 520, 261, 519, 518, 258, 263, 262, 517, 270,
272, 277, 516, 278, 279, 282, 287, 515, 289, 290,
124, 135, 137, 139, 145, 149, 146, 150, 151, 531,
530, 152, 155, 154, 157, 158, 161, 162, 163, 170,
167, 168, 576, 576, 576, 576, 186, 204, 211, 517,
522, 515, 205, 576, 212, 202, 215, 210, 213, 217,
576, 500, 0, 205, 576, 525, 576, 576, 194, 203,
206, 200, 216, 198, 218, 221, 223, 224, 225, 226,
227, 231, 228, 232, 236, 238, 241, 239, 242, 248,
246, 249, 509, 509, 506, 273, 274, 277, 275, 276,
284, 513, 520, 104, 519, 518, 262, 268, 264, 517,
265, 270, 279, 516, 271, 282, 287, 288, 515, 289,
293, 514, 291, 294, 296, 492, 490, 501, 575, 298,
299, 301, 305, 510, 509, 302, 508, 307, 313, 309,
312, 322, 324, 314, 310, 327, 507, 487, 498, 501,
328, 330, 334, 336, 335, 503, 340, 337, 502, 501,
342, 500, 338, 343, 344, 491, 490, 493, 350, 349,
351, 496, 495, 355, 360, 363, 364, 366, 369, 486,
575, 477, 370, 374, 492, 373, 491, 375, 377, 380,
378, 575, 478, 376, 390, 389, 391, 489, 488, 392,
395, 472, 486, 396, 472, 424, 400, 401, 402, 421,
402, 406, 397, 407, 408, 406, 410, 352, 259, 409,
272, 292, 514, 294, 297, 300, 492, 490, 501, 576,
298, 299, 301, 305, 510, 509, 304, 508, 302, 321,
309, 311, 312, 324, 328, 313, 330, 507, 487, 498,
501, 333, 334, 314, 335, 337, 503, 338, 339, 502,
501, 341, 500, 343, 347, 344, 491, 490, 493, 349,
352, 354, 496, 495, 353, 357, 365, 366, 367, 369,
486, 576, 477, 368, 370, 492, 375, 491, 372, 379,
377, 380, 576, 478, 381, 388, 390, 391, 489, 488,
393, 396, 472, 473, 394, 425, 424, 399, 397, 402,
422, 404, 405, 398, 407, 409, 405, 408, 315, 193,
575, 413, 200, 575, 451, 456, 461, 466, 469, 471,
476, 481, 486, 491, 496, 84, 501, 506
410, 576, 414, 159, 576, 453, 458, 463, 468, 471,
473, 478, 483, 488, 493, 498, 68, 503, 508
} ;
static const flex_int16_t yy_def[319] =
static const flex_int16_t yy_def[320] =
{ 0,
304, 1, 305, 305, 306, 306, 304, 304, 304, 304,
304, 307, 304, 304, 304, 308, 304, 304, 304, 304,
304, 304, 304, 304, 309, 304, 304, 304, 304, 304,
310, 304, 304, 304, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 307, 304, 311, 304, 304, 304, 304, 312, 304,
313, 304, 308, 314, 304, 304, 304, 304, 304, 304,
304, 304, 304, 315, 304, 304, 309, 309, 316, 304,
304, 304, 304, 304, 304, 310, 304, 310, 310, 310,
305, 1, 306, 306, 307, 307, 305, 305, 305, 305,
305, 308, 305, 305, 305, 309, 305, 305, 305, 305,
305, 305, 305, 305, 310, 305, 305, 305, 305, 305,
305, 311, 305, 305, 305, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 308, 305, 312, 305, 305, 305, 305, 313,
305, 314, 305, 309, 315, 305, 305, 305, 305, 305,
305, 305, 305, 305, 316, 305, 305, 310, 310, 317,
305, 305, 305, 305, 305, 305, 311, 305, 311, 311,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 304, 304, 307, 307, 311, 304, 304,
304, 312, 304, 317, 313, 318, 308, 308, 314, 304,
304, 315, 304, 304, 316, 304, 304, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 304, 312, 312, 317, 313, 313, 318,
304, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 305, 305, 308, 308, 312, 305,
305, 305, 313, 305, 318, 314, 319, 309, 309, 315,
305, 305, 316, 305, 305, 317, 305, 305, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 305, 313, 313, 318, 314, 314,
319, 305, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
310, 310, 310, 310, 310, 304, 304, 304, 304, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 304, 304, 304,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 304, 304, 304, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 304,
304, 304, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 310, 310, 310, 310, 310, 310, 310,
310, 304, 310, 310, 310, 310, 310, 310, 304, 310,
310, 310, 304, 310, 310, 304, 310, 310, 304, 310,
311, 311, 311, 311, 311, 311, 305, 305, 305, 305,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 305, 305,
305, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 305, 305, 305, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
305, 305, 305, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 311, 311, 311, 311, 311, 311,
311, 311, 305, 311, 311, 311, 311, 311, 311, 305,
311, 311, 311, 305, 311, 311, 305, 311, 311, 305,
304, 310, 310, 0, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304
311, 305, 311, 311, 0, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305
} ;
static const flex_int16_t yy_nxt[632] =
static const flex_int16_t yy_nxt[634] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 8, 33, 34, 31, 35,
36, 37, 38, 39, 40, 41, 31, 42, 31, 43,
31, 44, 31, 45, 46, 47, 48, 49, 31, 50,
31, 31, 51, 52, 53, 54, 56, 56, 59, 59,
63, 60, 60, 63, 65, 57, 57, 69, 76, 78,
70, 71, 66, 80, 91, 92, 79, 77, 89, 82,
74, 64, 67, 89, 72, 83, 86, 145, 87, 89,
84, 94, 95, 100, 98, 85, 89, 89, 89, 89,
28, 29, 30, 31, 32, 33, 8, 34, 35, 32,
36, 37, 38, 39, 40, 41, 42, 32, 43, 32,
44, 32, 45, 32, 46, 47, 48, 49, 50, 32,
51, 32, 32, 52, 53, 54, 55, 57, 57, 60,
60, 64, 61, 61, 66, 81, 58, 58, 64, 77,
70, 146, 67, 71, 72, 92, 93, 79, 78, 83,
95, 96, 68, 65, 80, 84, 75, 73, 90, 87,
85, 88, 90, 90, 82, 86, 90, 90, 90, 90,
101, 81, 99, 106, 89, 103, 102, 89, 108, 89,
89, 89, 104, 89, 105, 111, 107, 122, 109, 89,
89, 114, 89, 133, 63, 110, 133, 112, 115, 62,
113, 127, 89, 117, 63, 119, 120, 80, 143, 89,
136, 118, 73, 121, 116, 64, 156, 134, 138, 123,
304, 74, 128, 89, 140, 144, 86, 89, 87, 89,
89, 149, 89, 89, 89, 139, 89, 89, 89, 148,
89, 89, 154, 150, 152, 89, 89, 89, 89, 151,
153, 89, 157, 89, 89, 89, 159, 155, 89, 158,
89, 89, 169, 63, 162, 164, 165, 161, 160, 163,
90, 101, 90, 107, 99, 110, 104, 105, 102, 106,
112, 100, 111, 90, 103, 90, 108, 109, 90, 90,
90, 123, 90, 90, 64, 90, 134, 115, 116, 121,
90, 134, 113, 118, 64, 81, 122, 114, 63, 120,
128, 119, 144, 211, 117, 74, 65, 305, 135, 137,
90, 139, 75, 141, 124, 87, 90, 88, 90, 90,
145, 90, 129, 90, 151, 90, 90, 150, 149, 140,
152, 90, 90, 153, 155, 90, 90, 90, 90, 154,
90, 90, 157, 90, 90, 90, 158, 90, 90, 90,
64, 156, 160, 90, 90, 159, 90, 163, 165, 166,
166, 63, 170, 171, 62, 168, 127, 167, 133, 132,
135, 176, 89, 133, 64, 73, 179, 63, 63, 143,
89, 138, 64, 89, 89, 89, 184, 128, 185, 134,
136, 89, 177, 180, 74, 74, 144, 89, 139, 182,
89, 183, 89, 89, 187, 186, 188, 89, 189, 89,
89, 89, 89, 89, 89, 89, 89, 192, 193, 194,
190, 89, 196, 89, 195, 198, 89, 191, 89, 89,
89, 201, 133, 133, 202, 200, 197, 203, 132, 133,
176, 133, 199, 89, 205, 135, 89, 89, 89, 204,
211, 179, 301, 134, 134, 89, 136, 89, 136, 210,
167, 161, 162, 170, 164, 171, 172, 168, 64, 134,
134, 169, 65, 63, 133, 128, 177, 136, 64, 74,
90, 64, 144, 180, 90, 139, 90, 302, 137, 90,
65, 135, 90, 184, 186, 183, 75, 129, 178, 75,
145, 181, 90, 140, 90, 188, 185, 90, 189, 90,
90, 90, 90, 90, 90, 190, 187, 90, 90, 193,
194, 195, 90, 197, 90, 90, 191, 90, 90, 196,
192, 199, 90, 202, 90, 90, 203, 134, 134, 133,
198, 177, 204, 134, 134, 200, 136, 201, 90, 206,
90, 90, 180, 205, 90, 212, 90, 90, 90, 135,
212, 177, 89, 89, 89, 215, 216, 89, 180, 213,
219, 214, 89, 218, 89, 89, 89, 217, 89, 89,
221, 89, 223, 89, 89, 224, 89, 89, 225, 227,
89, 220, 89, 235, 89, 89, 222, 89, 89, 89,
226, 231, 233, 237, 234, 232, 238, 89, 240, 89,
239, 243, 89, 89, 244, 89, 242, 236, 241, 89,
89, 89, 89, 89, 245, 89, 250, 89, 89, 89,
249, 253, 258, 254, 89, 89, 89, 89, 255, 257,
89, 251, 252, 259, 265, 89, 256, 263, 89, 89,
266, 89, 267, 264, 89, 89, 268, 269, 89, 89,
135, 137, 137, 178, 216, 90, 213, 215, 90, 217,
181, 218, 214, 90, 90, 90, 220, 219, 90, 223,
90, 222, 224, 90, 90, 90, 90, 90, 90, 225,
90, 90, 226, 221, 228, 90, 236, 90, 90, 90,
90, 90, 232, 234, 227, 235, 233, 90, 241, 242,
90, 240, 238, 237, 90, 239, 90, 243, 245, 90,
90, 90, 252, 90, 90, 90, 244, 90, 246, 90,
90, 251, 255, 90, 254, 90, 250, 259, 90, 90,
90, 256, 253, 90, 260, 258, 257, 264, 266, 267,
268, 90, 90, 90, 90, 90, 90, 265, 90, 269,
89, 89, 89, 89, 277, 89, 270, 275, 271, 278,
276, 274, 280, 279, 89, 89, 89, 89, 281, 284,
89, 89, 283, 286, 288, 89, 89, 89, 290, 291,
285, 89, 89, 89, 89, 89, 287, 295, 89, 299,
297, 296, 294, 300, 298, 303, 89, 292, 293, 89,
302, 55, 55, 55, 55, 55, 58, 58, 58, 58,
58, 62, 62, 62, 62, 62, 73, 73, 73, 73,
73, 88, 88, 88, 96, 96, 126, 126, 126, 126,
126, 132, 132, 132, 132, 132, 135, 135, 135, 135,
135, 137, 137, 137, 137, 137, 142, 89, 142, 142,
270, 90, 278, 90, 276, 90, 90, 90, 271, 272,
275, 280, 279, 277, 90, 281, 90, 90, 285, 90,
90, 282, 90, 90, 287, 90, 289, 291, 284, 292,
90, 90, 286, 90, 90, 90, 90, 296, 288, 300,
90, 298, 301, 297, 293, 295, 299, 304, 90, 294,
90, 90, 303, 56, 56, 56, 56, 56, 59, 59,
59, 59, 59, 63, 63, 63, 63, 63, 74, 74,
74, 74, 74, 89, 89, 89, 97, 97, 127, 127,
127, 127, 127, 133, 133, 133, 133, 133, 136, 136,
136, 136, 136, 138, 138, 138, 138, 138, 143, 90,
142, 175, 175, 175, 175, 175, 178, 178, 178, 178,
178, 89, 289, 89, 89, 282, 89, 89, 273, 272,
89, 89, 262, 261, 260, 89, 89, 89, 89, 248,
247, 246, 89, 89, 89, 89, 230, 229, 228, 89,
89, 89, 89, 89, 89, 89, 209, 208, 207, 206,
89, 181, 174, 173, 172, 89, 89, 89, 147, 146,
141, 131, 130, 129, 125, 124, 97, 89, 93, 90,
75, 68, 61, 304, 7, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
143, 143, 143, 176, 176, 176, 176, 176, 179, 179,
179, 179, 179, 290, 90, 90, 283, 90, 90, 274,
273, 90, 90, 263, 262, 261, 90, 90, 90, 90,
249, 248, 247, 90, 90, 90, 90, 231, 230, 229,
90, 90, 90, 90, 90, 90, 90, 210, 209, 208,
207, 90, 182, 175, 174, 173, 90, 90, 90, 148,
147, 142, 132, 131, 130, 126, 125, 98, 90, 94,
91, 76, 69, 62, 305, 7, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305
} ;
static const flex_int16_t yy_chk[632] =
static const flex_int16_t yy_chk[634] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 4, 5, 6,
12, 5, 6, 16, 13, 3, 4, 15, 20, 22,
15, 15, 13, 23, 28, 28, 22, 20, 35, 24,
16, 12, 13, 36, 15, 24, 25, 316, 25, 37,
24, 30, 30, 37, 35, 24, 25, 38, 39, 40,
1, 1, 1, 1, 1, 1, 1, 3, 4, 5,
6, 12, 5, 6, 13, 23, 3, 4, 16, 20,
15, 317, 13, 15, 15, 28, 28, 22, 20, 24,
30, 30, 13, 12, 22, 24, 16, 15, 36, 25,
24, 25, 37, 40, 23, 24, 43, 38, 39, 41,
37, 23, 36, 40, 41, 38, 37, 43, 41, 42,
44, 45, 39, 46, 39, 43, 40, 52, 42, 49,
47, 46, 48, 71, 62, 42, 69, 44, 47, 64,
45, 64, 50, 48, 73, 49, 50, 80, 86, 105,
71, 48, 74, 50, 47, 62, 105, 69, 74, 52,
88, 73, 64, 99, 80, 86, 87, 98, 87, 100,
88, 99, 101, 103, 102, 74, 87, 104, 106, 98,
107, 108, 103, 100, 101, 111, 112, 113, 114, 100,
102, 115, 106, 118, 116, 119, 108, 104, 117, 107,
120, 121, 119, 126, 113, 115, 116, 112, 111, 114,
25, 38, 44, 41, 36, 43, 39, 40, 38, 40,
44, 37, 43, 42, 38, 45, 41, 42, 46, 47,
48, 53, 49, 50, 63, 51, 70, 47, 48, 51,
184, 72, 45, 49, 74, 81, 51, 46, 65, 50,
65, 49, 87, 184, 48, 75, 63, 89, 70, 72,
101, 75, 74, 81, 53, 88, 99, 88, 89, 100,
87, 102, 65, 103, 101, 104, 88, 100, 99, 75,
101, 105, 107, 102, 104, 106, 108, 109, 112, 103,
114, 113, 106, 115, 116, 304, 107, 117, 118, 119,
127, 105, 109, 121, 122, 108, 120, 114, 116, 117,
117, 127, 120, 121, 128, 118, 128, 117, 132, 134,
136, 134, 150, 135, 126, 139, 136, 137, 138, 143,
151, 139, 127, 153, 148, 303, 150, 128, 151, 132,
135, 152, 134, 136, 137, 138, 143, 149, 139, 148,
155, 149, 154, 156, 153, 152, 154, 157, 155, 158,
159, 160, 161, 162, 163, 166, 164, 158, 159, 160,
156, 165, 162, 167, 161, 164, 168, 157, 170, 169,
171, 167, 175, 176, 168, 166, 163, 169, 177, 178,
177, 179, 165, 186, 171, 180, 183, 188, 187, 170,
186, 180, 299, 175, 176, 190, 178, 191, 179, 183,
118, 112, 113, 120, 115, 121, 122, 118, 128, 133,
136, 119, 127, 129, 135, 129, 135, 137, 138, 140,
149, 139, 144, 137, 154, 140, 152, 300, 136, 150,
128, 133, 151, 150, 152, 149, 138, 129, 135, 139,
144, 137, 153, 140, 155, 154, 151, 156, 155, 157,
158, 159, 160, 161, 163, 156, 153, 162, 164, 159,
160, 161, 165, 163, 166, 168, 157, 167, 169, 162,
158, 165, 171, 168, 170, 172, 169, 176, 177, 178,
164, 178, 170, 179, 180, 166, 181, 167, 187, 172,
189, 191, 181, 171, 188, 187, 192, 195, 201, 176,
187, 177, 192, 194, 195, 191, 192, 196, 180, 188,
196, 190, 197, 195, 199, 200, 203, 194, 201, 204,
199, 205, 201, 210, 211, 203, 212, 216, 204, 205,
213, 197, 218, 216, 220, 225, 200, 221, 219, 224,
204, 210, 212, 219, 213, 211, 219, 222, 221, 223,
220, 224, 226, 231, 225, 232, 223, 218, 222, 233,
235, 234, 238, 243, 226, 237, 232, 241, 244, 245,
231, 235, 244, 237, 250, 249, 251, 298, 238, 243,
254, 233, 234, 245, 251, 255, 241, 249, 256, 257,
254, 258, 255, 250, 259, 263, 256, 257, 266, 264,
177, 179, 180, 178, 192, 193, 188, 191, 196, 193,
181, 195, 189, 197, 198, 200, 197, 196, 202, 201,
204, 200, 202, 205, 211, 212, 206, 213, 219, 204,
217, 214, 205, 198, 206, 221, 217, 222, 223, 226,
234, 299, 211, 213, 205, 214, 212, 220, 222, 223,
224, 221, 220, 219, 225, 220, 227, 224, 226, 232,
233, 235, 234, 236, 238, 239, 225, 242, 227, 244,
246, 233, 238, 245, 236, 250, 232, 245, 251, 255,
252, 239, 235, 256, 246, 244, 242, 250, 252, 255,
256, 257, 258, 259, 264, 260, 265, 251, 269, 257,
268, 274, 269, 271, 268, 270, 258, 264, 259, 269,
266, 263, 271, 270, 276, 275, 277, 280, 271, 275,
281, 284, 274, 277, 281, 287, 288, 291, 284, 287,
276, 292, 294, 295, 300, 297, 280, 292, 302, 296,
294, 293, 291, 297, 295, 302, 290, 288, 289, 286,
300, 305, 305, 305, 305, 305, 306, 306, 306, 306,
306, 307, 307, 307, 307, 307, 308, 308, 308, 308,
308, 309, 309, 309, 310, 310, 311, 311, 311, 311,
311, 312, 312, 312, 312, 312, 313, 313, 313, 313,
313, 314, 314, 314, 314, 314, 315, 285, 315, 315,
258, 267, 269, 271, 265, 270, 272, 275, 259, 260,
264, 271, 270, 267, 276, 272, 277, 278, 276, 281,
285, 272, 282, 289, 278, 288, 282, 285, 275, 288,
292, 293, 277, 295, 298, 296, 301, 293, 281, 297,
303, 295, 298, 294, 289, 292, 296, 303, 291, 290,
287, 286, 301, 306, 306, 306, 306, 306, 307, 307,
307, 307, 307, 308, 308, 308, 308, 308, 309, 309,
309, 309, 309, 310, 310, 310, 311, 311, 312, 312,
312, 312, 312, 313, 313, 313, 313, 313, 314, 314,
314, 314, 314, 315, 315, 315, 315, 315, 316, 284,
315, 317, 317, 317, 317, 317, 318, 318, 318, 318,
318, 283, 282, 279, 278, 273, 267, 265, 262, 260,
253, 252, 248, 247, 246, 242, 240, 239, 236, 230,
229, 228, 227, 217, 215, 214, 208, 207, 206, 202,
198, 193, 189, 185, 184, 182, 181, 174, 173, 172,
145, 141, 131, 130, 129, 110, 109, 96, 95, 91,
81, 67, 66, 65, 60, 57, 34, 31, 29, 26,
19, 14, 11, 7, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
316, 316, 316, 318, 318, 318, 318, 318, 319, 319,
319, 319, 319, 283, 280, 279, 274, 268, 266, 263,
261, 254, 253, 249, 248, 247, 243, 241, 240, 237,
231, 230, 229, 228, 218, 216, 215, 209, 208, 207,
203, 199, 194, 190, 186, 185, 183, 182, 175, 174,
173, 146, 142, 132, 131, 130, 111, 110, 97, 96,
92, 82, 68, 67, 66, 61, 58, 35, 32, 29,
26, 19, 14, 11, 7, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305
} ;
/* The intent behind this definition is that it'll catch
@ -1183,13 +1183,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_current_state != 304 );
while ( yy_current_state != 305 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1510,218 +1510,223 @@ YY_RULE_SETUP
case 60:
YY_RULE_SETUP
#line 107 "lexer.lpp"
{ return h2::parser::make_INCREMENT(loc); }
{ return h2::parser::make_QMARK(loc); }
YY_BREAK
case 61:
YY_RULE_SETUP
#line 108 "lexer.lpp"
{ return h2::parser::make_DECREMENT(loc); }
{ return h2::parser::make_INCREMENT(loc); }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 109 "lexer.lpp"
{ return h2::parser::make_ASSIGN_LSHIFT(loc); }
{ return h2::parser::make_DECREMENT(loc); }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 110 "lexer.lpp"
{ return h2::parser::make_ASSIGN_RSHIFT(loc); }
{ return h2::parser::make_ASSIGN_LSHIFT(loc); }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 111 "lexer.lpp"
{ return h2::parser::make_LSHIFT(loc); }
{ return h2::parser::make_ASSIGN_RSHIFT(loc); }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 112 "lexer.lpp"
{ return h2::parser::make_RSHIFT(loc); }
{ return h2::parser::make_LSHIFT(loc); }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 113 "lexer.lpp"
{ return h2::parser::make_OR(loc); }
{ return h2::parser::make_RSHIFT(loc); }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 114 "lexer.lpp"
{ return h2::parser::make_AND(loc); }
{ return h2::parser::make_OR(loc); }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 115 "lexer.lpp"
{ return h2::parser::make_EQUALITY(loc); }
{ return h2::parser::make_AND(loc); }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 116 "lexer.lpp"
{ return h2::parser::make_INEQUALITY(loc); }
{ return h2::parser::make_EQUALITY(loc); }
YY_BREAK
case 70:
YY_RULE_SETUP
#line 117 "lexer.lpp"
{ return h2::parser::make_LESS_EQUAL(loc); }
{ return h2::parser::make_INEQUALITY(loc); }
YY_BREAK
case 71:
YY_RULE_SETUP
#line 118 "lexer.lpp"
{ return h2::parser::make_GREATER_EQUAL(loc); }
{ return h2::parser::make_LESS_EQUAL(loc); }
YY_BREAK
case 72:
YY_RULE_SETUP
#line 119 "lexer.lpp"
{ return h2::parser::make_LESS(loc); }
{ return h2::parser::make_GREATER_EQUAL(loc); }
YY_BREAK
case 73:
YY_RULE_SETUP
#line 120 "lexer.lpp"
{ return h2::parser::make_GREATER(loc); }
{ return h2::parser::make_LESS(loc); }
YY_BREAK
case 74:
YY_RULE_SETUP
#line 121 "lexer.lpp"
{ return h2::parser::make_ASSIGN_ADD(loc); }
{ return h2::parser::make_GREATER(loc); }
YY_BREAK
case 75:
YY_RULE_SETUP
#line 122 "lexer.lpp"
{ return h2::parser::make_ASSIGN_SUB(loc); }
{ return h2::parser::make_ASSIGN_ADD(loc); }
YY_BREAK
case 76:
YY_RULE_SETUP
#line 123 "lexer.lpp"
{ return h2::parser::make_ASSIGN_MULT(loc); }
{ return h2::parser::make_ASSIGN_SUB(loc); }
YY_BREAK
case 77:
YY_RULE_SETUP
#line 124 "lexer.lpp"
{ return h2::parser::make_ASSIGN_DIV(loc); }
{ return h2::parser::make_ASSIGN_MULT(loc); }
YY_BREAK
case 78:
YY_RULE_SETUP
#line 125 "lexer.lpp"
{ return h2::parser::make_ASSIGN_MOD(loc); }
{ return h2::parser::make_ASSIGN_DIV(loc); }
YY_BREAK
case 79:
YY_RULE_SETUP
#line 126 "lexer.lpp"
{ return h2::parser::make_ASSIGN_BITWISE_OR(loc); }
{ return h2::parser::make_ASSIGN_MOD(loc); }
YY_BREAK
case 80:
YY_RULE_SETUP
#line 127 "lexer.lpp"
{ return h2::parser::make_ASSIGN_BITWISE_AND(loc); }
{ return h2::parser::make_ASSIGN_BITWISE_OR(loc); }
YY_BREAK
case 81:
YY_RULE_SETUP
#line 128 "lexer.lpp"
{ return h2::parser::make_ASSIGN_BITWISE_EXOR(loc); }
{ return h2::parser::make_ASSIGN_BITWISE_AND(loc); }
YY_BREAK
case 82:
YY_RULE_SETUP
#line 129 "lexer.lpp"
{ return h2::parser::make_ASSIGN(loc); }
{ return h2::parser::make_ASSIGN_BITWISE_EXOR(loc); }
YY_BREAK
case 83:
YY_RULE_SETUP
#line 130 "lexer.lpp"
{ return h2::parser::make_ADD(loc); }
{ return h2::parser::make_ASSIGN(loc); }
YY_BREAK
case 84:
YY_RULE_SETUP
#line 131 "lexer.lpp"
{ return h2::parser::make_SUB(loc); }
{ return h2::parser::make_ADD(loc); }
YY_BREAK
case 85:
YY_RULE_SETUP
#line 132 "lexer.lpp"
{ return h2::parser::make_MULT(loc); }
{ return h2::parser::make_SUB(loc); }
YY_BREAK
case 86:
YY_RULE_SETUP
#line 133 "lexer.lpp"
{ return h2::parser::make_DIV(loc); }
{ return h2::parser::make_MULT(loc); }
YY_BREAK
case 87:
YY_RULE_SETUP
#line 134 "lexer.lpp"
{ return h2::parser::make_MOD(loc); }
{ return h2::parser::make_DIV(loc); }
YY_BREAK
case 88:
YY_RULE_SETUP
#line 135 "lexer.lpp"
{ return h2::parser::make_NOT(loc); }
{ return h2::parser::make_MOD(loc); }
YY_BREAK
case 89:
YY_RULE_SETUP
#line 136 "lexer.lpp"
{ return h2::parser::make_COMPLEMENT(loc); }
{ return h2::parser::make_NOT(loc); }
YY_BREAK
case 90:
YY_RULE_SETUP
#line 137 "lexer.lpp"
{ return h2::parser::make_BITWISE_OR(loc); }
{ return h2::parser::make_COMPLEMENT(loc); }
YY_BREAK
case 91:
YY_RULE_SETUP
#line 138 "lexer.lpp"
{ return h2::parser::make_BITWISE_AND(loc); }
{ return h2::parser::make_BITWISE_OR(loc); }
YY_BREAK
case 92:
YY_RULE_SETUP
#line 139 "lexer.lpp"
{ return h2::parser::make_BITWISE_EXOR(loc); }
{ return h2::parser::make_BITWISE_AND(loc); }
YY_BREAK
case 93:
YY_RULE_SETUP
#line 140 "lexer.lpp"
{ return h2::parser::make_FILE(utils::string::fordslash(yytext), loc); }
{ return h2::parser::make_BITWISE_EXOR(loc); }
YY_BREAK
case 94:
YY_RULE_SETUP
#line 141 "lexer.lpp"
{ return h2::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
{ return h2::parser::make_FILE(utils::string::fordslash(yytext), loc); }
YY_BREAK
case 95:
/* rule 95 can match eol */
YY_RULE_SETUP
#line 142 "lexer.lpp"
{ return h2::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
{ return h2::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 143 "lexer.lpp"
{ return h2::parser::make_STRING(std::string(yytext), loc); }
{ return h2::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
YY_BREAK
case 97:
/* rule 97 can match eol */
YY_RULE_SETUP
#line 144 "lexer.lpp"
{ return h2::parser::make_FLOAT(std::string(yytext), loc); }
{ return h2::parser::make_STRING(std::string(yytext), loc); }
YY_BREAK
case 98:
YY_RULE_SETUP
#line 145 "lexer.lpp"
{ return h2::parser::make_FLOAT(std::string(yytext), loc); }
YY_BREAK
case 99:
YY_RULE_SETUP
#line 146 "lexer.lpp"
{ return h2::parser::make_INTEGER(std::string(yytext), loc); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT_BLOCK_STATE):
case YY_STATE_EOF(DEVELOPER_BLOCK_STATE):
#line 146 "lexer.lpp"
#line 147 "lexer.lpp"
{ return h2::parser::make_H2EOF(loc); }
YY_BREAK
case 99:
/* rule 99 can match eol */
case 100:
/* rule 100 can match eol */
YY_RULE_SETUP
#line 147 "lexer.lpp"
#line 148 "lexer.lpp"
{ throw h2::parser::syntax_error(loc, "bad token: \'" + std::string(yytext) + "\'"); }
YY_BREAK
case 100:
case 101:
YY_RULE_SETUP
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"
ECHO;
YY_BREAK
#line 1724 "lexer.cpp"
#line 1729 "lexer.cpp"
case YY_END_OF_BUFFER:
{
@ -2019,7 +2024,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@ -2048,11 +2053,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 304);
yy_is_jam = (yy_current_state == 305);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@ -2851,6 +2856,6 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"

View File

@ -700,7 +700,7 @@ extern int yylex (yyscan_t yyscanner);
#undef yyTABLES_NAME
#endif
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"
#line 706 "lexer.hpp"

File diff suppressed because it is too large Load Diff

View File

@ -446,6 +446,7 @@ namespace xsk { namespace gsc { namespace h2 {
// for_expr
// expr
// expr_compare
// expr_ternary
// expr_binary
// expr_primitive
char dummy11[sizeof (expr_ptr)];
@ -700,53 +701,55 @@ namespace xsk { namespace gsc { namespace h2 {
DOUBLECOLON = 48, // "::"
COLON = 49, // ":"
SEMICOLON = 50, // ";"
INCREMENT = 51, // "++"
DECREMENT = 52, // "--"
LSHIFT = 53, // "<<"
RSHIFT = 54, // ">>"
OR = 55, // "||"
AND = 56, // "&&"
EQUALITY = 57, // "=="
INEQUALITY = 58, // "!="
LESS_EQUAL = 59, // "<="
GREATER_EQUAL = 60, // ">="
LESS = 61, // "<"
GREATER = 62, // ">"
NOT = 63, // "!"
COMPLEMENT = 64, // "~"
ASSIGN = 65, // "="
ASSIGN_ADD = 66, // "+="
ASSIGN_SUB = 67, // "-="
ASSIGN_MULT = 68, // "*="
ASSIGN_DIV = 69, // "/="
ASSIGN_MOD = 70, // "%="
ASSIGN_BITWISE_OR = 71, // "|="
ASSIGN_BITWISE_AND = 72, // "&="
ASSIGN_BITWISE_EXOR = 73, // "^="
ASSIGN_RSHIFT = 74, // ">>="
ASSIGN_LSHIFT = 75, // "<<="
BITWISE_OR = 76, // "|"
BITWISE_AND = 77, // "&"
BITWISE_EXOR = 78, // "^"
ADD = 79, // "+"
SUB = 80, // "-"
MULT = 81, // "*"
DIV = 82, // "/"
MOD = 83, // "%"
FILE = 84, // "file path"
NAME = 85, // "identifier"
STRING = 86, // "string literal"
ISTRING = 87, // "localized string"
FLOAT = 88, // "float"
INTEGER = 89, // "int"
ADD_ARRAY = 90, // ADD_ARRAY
THEN = 91, // THEN
NEG = 92, // NEG
ANIMREF = 93, // ANIMREF
PREINC = 94, // PREINC
PREDEC = 95, // PREDEC
POSTINC = 96, // POSTINC
POSTDEC = 97 // POSTDEC
QMARK = 51, // "?"
INCREMENT = 52, // "++"
DECREMENT = 53, // "--"
LSHIFT = 54, // "<<"
RSHIFT = 55, // ">>"
OR = 56, // "||"
AND = 57, // "&&"
EQUALITY = 58, // "=="
INEQUALITY = 59, // "!="
LESS_EQUAL = 60, // "<="
GREATER_EQUAL = 61, // ">="
LESS = 62, // "<"
GREATER = 63, // ">"
NOT = 64, // "!"
COMPLEMENT = 65, // "~"
ASSIGN = 66, // "="
ASSIGN_ADD = 67, // "+="
ASSIGN_SUB = 68, // "-="
ASSIGN_MULT = 69, // "*="
ASSIGN_DIV = 70, // "/="
ASSIGN_MOD = 71, // "%="
ASSIGN_BITWISE_OR = 72, // "|="
ASSIGN_BITWISE_AND = 73, // "&="
ASSIGN_BITWISE_EXOR = 74, // "^="
ASSIGN_RSHIFT = 75, // ">>="
ASSIGN_LSHIFT = 76, // "<<="
BITWISE_OR = 77, // "|"
BITWISE_AND = 78, // "&"
BITWISE_EXOR = 79, // "^"
ADD = 80, // "+"
SUB = 81, // "-"
MULT = 82, // "*"
DIV = 83, // "/"
MOD = 84, // "%"
FILE = 85, // "file path"
NAME = 86, // "identifier"
STRING = 87, // "string literal"
ISTRING = 88, // "localized string"
FLOAT = 89, // "float"
INTEGER = 90, // "int"
ADD_ARRAY = 91, // ADD_ARRAY
THEN = 92, // THEN
TERN = 93, // TERN
NEG = 94, // NEG
ANIMREF = 95, // ANIMREF
PREINC = 96, // PREINC
PREDEC = 97, // PREDEC
POSTINC = 98, // POSTINC
POSTDEC = 99 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -763,7 +766,7 @@ namespace xsk { namespace gsc { namespace h2 {
{
enum symbol_kind_type
{
YYNTOKENS = 98, ///< Number of tokens.
YYNTOKENS = 100, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
@ -816,129 +819,132 @@ namespace xsk { namespace gsc { namespace h2 {
S_DOUBLECOLON = 48, // "::"
S_COLON = 49, // ":"
S_SEMICOLON = 50, // ";"
S_INCREMENT = 51, // "++"
S_DECREMENT = 52, // "--"
S_LSHIFT = 53, // "<<"
S_RSHIFT = 54, // ">>"
S_OR = 55, // "||"
S_AND = 56, // "&&"
S_EQUALITY = 57, // "=="
S_INEQUALITY = 58, // "!="
S_LESS_EQUAL = 59, // "<="
S_GREATER_EQUAL = 60, // ">="
S_LESS = 61, // "<"
S_GREATER = 62, // ">"
S_NOT = 63, // "!"
S_COMPLEMENT = 64, // "~"
S_ASSIGN = 65, // "="
S_ASSIGN_ADD = 66, // "+="
S_ASSIGN_SUB = 67, // "-="
S_ASSIGN_MULT = 68, // "*="
S_ASSIGN_DIV = 69, // "/="
S_ASSIGN_MOD = 70, // "%="
S_ASSIGN_BITWISE_OR = 71, // "|="
S_ASSIGN_BITWISE_AND = 72, // "&="
S_ASSIGN_BITWISE_EXOR = 73, // "^="
S_ASSIGN_RSHIFT = 74, // ">>="
S_ASSIGN_LSHIFT = 75, // "<<="
S_BITWISE_OR = 76, // "|"
S_BITWISE_AND = 77, // "&"
S_BITWISE_EXOR = 78, // "^"
S_ADD = 79, // "+"
S_SUB = 80, // "-"
S_MULT = 81, // "*"
S_DIV = 82, // "/"
S_MOD = 83, // "%"
S_FILE = 84, // "file path"
S_NAME = 85, // "identifier"
S_STRING = 86, // "string literal"
S_ISTRING = 87, // "localized string"
S_FLOAT = 88, // "float"
S_INTEGER = 89, // "int"
S_ADD_ARRAY = 90, // ADD_ARRAY
S_THEN = 91, // THEN
S_NEG = 92, // NEG
S_ANIMREF = 93, // ANIMREF
S_PREINC = 94, // PREINC
S_PREDEC = 95, // PREDEC
S_POSTINC = 96, // POSTINC
S_POSTDEC = 97, // POSTDEC
S_YYACCEPT = 98, // $accept
S_root = 99, // root
S_program = 100, // program
S_include = 101, // include
S_define = 102, // define
S_usingtree = 103, // usingtree
S_constant = 104, // constant
S_thread = 105, // thread
S_parameters = 106, // parameters
S_stmt = 107, // stmt
S_stmt_block = 108, // stmt_block
S_stmt_list = 109, // stmt_list
S_stmt_call = 110, // stmt_call
S_stmt_assign = 111, // stmt_assign
S_stmt_endon = 112, // stmt_endon
S_stmt_notify = 113, // stmt_notify
S_stmt_wait = 114, // stmt_wait
S_stmt_waittill = 115, // stmt_waittill
S_stmt_waittillmatch = 116, // stmt_waittillmatch
S_stmt_waittillframeend = 117, // stmt_waittillframeend
S_stmt_waitframe = 118, // stmt_waitframe
S_stmt_if = 119, // stmt_if
S_stmt_ifelse = 120, // stmt_ifelse
S_stmt_while = 121, // stmt_while
S_stmt_for = 122, // stmt_for
S_stmt_foreach = 123, // stmt_foreach
S_stmt_switch = 124, // stmt_switch
S_stmt_case = 125, // stmt_case
S_stmt_default = 126, // stmt_default
S_stmt_break = 127, // stmt_break
S_stmt_continue = 128, // stmt_continue
S_stmt_return = 129, // stmt_return
S_stmt_breakpoint = 130, // stmt_breakpoint
S_stmt_prof_begin = 131, // stmt_prof_begin
S_stmt_prof_end = 132, // stmt_prof_end
S_for_stmt = 133, // for_stmt
S_for_expr = 134, // for_expr
S_expr = 135, // expr
S_expr_assign = 136, // expr_assign
S_expr_compare = 137, // expr_compare
S_expr_binary = 138, // expr_binary
S_expr_primitive = 139, // expr_primitive
S_expr_call = 140, // expr_call
S_expr_call_thread = 141, // expr_call_thread
S_expr_call_childthread = 142, // expr_call_childthread
S_expr_call_function = 143, // expr_call_function
S_expr_call_pointer = 144, // expr_call_pointer
S_expr_arguments = 145, // expr_arguments
S_expr_arguments_filled = 146, // expr_arguments_filled
S_expr_arguments_empty = 147, // expr_arguments_empty
S_expr_function = 148, // expr_function
S_expr_add_array = 149, // expr_add_array
S_expr_array = 150, // expr_array
S_expr_field = 151, // expr_field
S_expr_size = 152, // expr_size
S_object = 153, // object
S_thisthread = 154, // thisthread
S_empty_array = 155, // empty_array
S_undefined = 156, // undefined
S_game = 157, // game
S_self = 158, // self
S_anim = 159, // anim
S_level = 160, // level
S_animation = 161, // animation
S_animtree = 162, // animtree
S_name = 163, // name
S_file = 164, // file
S_istring = 165, // istring
S_string = 166, // string
S_vector = 167, // vector
S_neg_float = 168, // neg_float
S_neg_integer = 169, // neg_integer
S_float = 170, // float
S_integer = 171, // integer
S_false = 172, // false
S_true = 173 // true
S_QMARK = 51, // "?"
S_INCREMENT = 52, // "++"
S_DECREMENT = 53, // "--"
S_LSHIFT = 54, // "<<"
S_RSHIFT = 55, // ">>"
S_OR = 56, // "||"
S_AND = 57, // "&&"
S_EQUALITY = 58, // "=="
S_INEQUALITY = 59, // "!="
S_LESS_EQUAL = 60, // "<="
S_GREATER_EQUAL = 61, // ">="
S_LESS = 62, // "<"
S_GREATER = 63, // ">"
S_NOT = 64, // "!"
S_COMPLEMENT = 65, // "~"
S_ASSIGN = 66, // "="
S_ASSIGN_ADD = 67, // "+="
S_ASSIGN_SUB = 68, // "-="
S_ASSIGN_MULT = 69, // "*="
S_ASSIGN_DIV = 70, // "/="
S_ASSIGN_MOD = 71, // "%="
S_ASSIGN_BITWISE_OR = 72, // "|="
S_ASSIGN_BITWISE_AND = 73, // "&="
S_ASSIGN_BITWISE_EXOR = 74, // "^="
S_ASSIGN_RSHIFT = 75, // ">>="
S_ASSIGN_LSHIFT = 76, // "<<="
S_BITWISE_OR = 77, // "|"
S_BITWISE_AND = 78, // "&"
S_BITWISE_EXOR = 79, // "^"
S_ADD = 80, // "+"
S_SUB = 81, // "-"
S_MULT = 82, // "*"
S_DIV = 83, // "/"
S_MOD = 84, // "%"
S_FILE = 85, // "file path"
S_NAME = 86, // "identifier"
S_STRING = 87, // "string literal"
S_ISTRING = 88, // "localized string"
S_FLOAT = 89, // "float"
S_INTEGER = 90, // "int"
S_ADD_ARRAY = 91, // ADD_ARRAY
S_THEN = 92, // THEN
S_TERN = 93, // TERN
S_NEG = 94, // NEG
S_ANIMREF = 95, // ANIMREF
S_PREINC = 96, // PREINC
S_PREDEC = 97, // PREDEC
S_POSTINC = 98, // POSTINC
S_POSTDEC = 99, // POSTDEC
S_YYACCEPT = 100, // $accept
S_root = 101, // root
S_program = 102, // program
S_include = 103, // include
S_define = 104, // define
S_usingtree = 105, // usingtree
S_constant = 106, // constant
S_thread = 107, // thread
S_parameters = 108, // parameters
S_stmt = 109, // stmt
S_stmt_block = 110, // stmt_block
S_stmt_list = 111, // stmt_list
S_stmt_call = 112, // stmt_call
S_stmt_assign = 113, // stmt_assign
S_stmt_endon = 114, // stmt_endon
S_stmt_notify = 115, // stmt_notify
S_stmt_wait = 116, // stmt_wait
S_stmt_waittill = 117, // stmt_waittill
S_stmt_waittillmatch = 118, // stmt_waittillmatch
S_stmt_waittillframeend = 119, // stmt_waittillframeend
S_stmt_waitframe = 120, // stmt_waitframe
S_stmt_if = 121, // stmt_if
S_stmt_ifelse = 122, // stmt_ifelse
S_stmt_while = 123, // stmt_while
S_stmt_for = 124, // stmt_for
S_stmt_foreach = 125, // stmt_foreach
S_stmt_switch = 126, // stmt_switch
S_stmt_case = 127, // stmt_case
S_stmt_default = 128, // stmt_default
S_stmt_break = 129, // stmt_break
S_stmt_continue = 130, // stmt_continue
S_stmt_return = 131, // stmt_return
S_stmt_breakpoint = 132, // stmt_breakpoint
S_stmt_prof_begin = 133, // stmt_prof_begin
S_stmt_prof_end = 134, // stmt_prof_end
S_for_stmt = 135, // for_stmt
S_for_expr = 136, // for_expr
S_expr = 137, // expr
S_expr_assign = 138, // expr_assign
S_expr_compare = 139, // expr_compare
S_expr_ternary = 140, // expr_ternary
S_expr_binary = 141, // expr_binary
S_expr_primitive = 142, // expr_primitive
S_expr_call = 143, // expr_call
S_expr_call_thread = 144, // expr_call_thread
S_expr_call_childthread = 145, // expr_call_childthread
S_expr_call_function = 146, // expr_call_function
S_expr_call_pointer = 147, // expr_call_pointer
S_expr_arguments = 148, // expr_arguments
S_expr_arguments_filled = 149, // expr_arguments_filled
S_expr_arguments_empty = 150, // expr_arguments_empty
S_expr_function = 151, // expr_function
S_expr_add_array = 152, // expr_add_array
S_expr_array = 153, // expr_array
S_expr_field = 154, // expr_field
S_expr_size = 155, // expr_size
S_object = 156, // object
S_thisthread = 157, // thisthread
S_empty_array = 158, // empty_array
S_undefined = 159, // undefined
S_game = 160, // game
S_self = 161, // self
S_anim = 162, // anim
S_level = 163, // level
S_animation = 164, // animation
S_animtree = 165, // animtree
S_name = 166, // name
S_file = 167, // file
S_istring = 168, // istring
S_string = 169, // string
S_vector = 170, // vector
S_neg_float = 171, // neg_float
S_neg_integer = 172, // neg_integer
S_float = 173, // float
S_integer = 174, // integer
S_false = 175, // false
S_true = 176 // true
};
};
@ -1023,6 +1029,7 @@ namespace xsk { namespace gsc { namespace h2 {
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (std::move (that.value));
@ -2117,6 +2124,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.template destroy< expr_ptr > ();
@ -3241,6 +3249,21 @@ switch (yykind)
return symbol_type (token::SEMICOLON, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_QMARK (location_type l)
{
return symbol_type (token::QMARK, std::move (l));
}
#else
static
symbol_type
make_QMARK (const location_type& l)
{
return symbol_type (token::QMARK, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -3856,6 +3879,21 @@ switch (yykind)
return symbol_type (token::THEN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_TERN (location_type l)
{
return symbol_type (token::TERN, std::move (l));
}
#else
static
symbol_type
make_TERN (const location_type& l)
{
return symbol_type (token::TERN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4290,8 +4328,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 1646, ///< Last index in yytable_.
yynnts_ = 76, ///< Number of nonterminal symbols.
yylast_ = 1842, ///< Last index in yytable_.
yynnts_ = 77, ///< Number of nonterminal symbols.
yyfinal_ = 15 ///< Termination state number.
};
@ -4367,6 +4405,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.copy< expr_ptr > (YY_MOVE (that.value));
@ -4647,6 +4686,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (YY_MOVE (s.value));
@ -4913,7 +4953,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::h2
#line 4917 "parser.hpp"
#line 4957 "parser.hpp"

View File

@ -403,7 +403,7 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -459,7 +459,7 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -534,7 +534,7 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -746,6 +746,7 @@ void compiler::emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
{
switch(expr.as_node->type)
{
case gsc::node_t::expr_ternary: emit_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: emit_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: emit_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: emit_expr_binary(ctx, expr.as_binary); break;
@ -843,6 +844,30 @@ void compiler::emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_ass
}
}
void compiler::emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
auto else_loc = create_label();
auto end_loc = create_label();
if(expr->cond.as_node->type == gsc::node_t::expr_not)
{
emit_expr(ctx, expr->cond.as_not->rvalue);
emit_opcode(ctx, opcode::OP_JumpOnTrue, else_loc);
}
else
{
emit_expr(ctx, expr->cond);
emit_opcode(ctx, opcode::OP_JumpOnFalse, else_loc);
}
emit_expr(ctx, expr->lvalue);
emit_opcode(ctx, opcode::OP_jump, end_loc);
insert_label(else_loc);
emit_expr(ctx, expr->rvalue);
insert_label(end_loc);
}
void compiler::emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
emit_expr(ctx, expr->lvalue);

View File

@ -67,6 +67,7 @@ private:
void emit_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr);
void emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
void emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void emit_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void emit_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -96,6 +96,14 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
decompile_expr();
}
}
for(auto& entry : tern_labels_)
{
if(entry == itr->second)
{
decompile_ternary();
}
}
}
switch (opcode(inst->opcode))
@ -1827,6 +1835,7 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
{
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1910,6 +1919,29 @@ void decompiler::decompile_expr()
}
}
void decompiler::decompile_ternary()
{
auto rvalue = std::move(stack_.top());
stack_.pop();
auto lvalue = std::move(stack_.top());
stack_.pop();
func_->block->stmts.pop_back();
auto stmt = std::move(func_->block->stmts.back());
func_->block->stmts.pop_back();
if(stmt.as_node->type == node_t::asm_jump_cond)
{
auto loc = stmt.as_cond->loc;
auto e = std::make_unique<gsc::node_expr_ternary>(loc, std::move(stmt.as_cond->expr), std::move(lvalue), std::move(rvalue));
stack_.push(std::move(e));
}
else
{
throw gsc::decomp_error("TRIED TO DECOMPILE INVALID TERNARY EXPR!");
}
}
void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
{
this->decompile_search_infinite(block);
@ -3000,6 +3032,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
case gsc::node_t::expr_assign_bitwise_or: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_and: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_exor: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_ternary: process_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: process_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: process_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: process_expr_binary(ctx, expr.as_binary); break;
@ -3100,6 +3133,13 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assi
}
}
void decompiler::process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
process_expr(ctx, expr->cond);
process_expr(ctx, expr->lvalue);
process_expr(ctx, expr->rvalue);
}
void decompiler::process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
process_expr(ctx, expr->lvalue);

View File

@ -16,6 +16,7 @@ class decompiler : public gsc::decompiler
gsc::thread_ptr func_;
std::unordered_map<std::uint32_t, std::string> labels_;
std::vector<std::string> expr_labels_;
std::vector<std::string> tern_labels_;
std::stack<gsc::node_ptr> stack_;
std::vector<gsc::context> blocks_;
@ -27,6 +28,7 @@ private:
void decompile_function(const gsc::function_ptr& func);
void decompile_statements(const gsc::function_ptr& func);
void decompile_expr();
void decompile_ternary();
void decompile_block(const gsc::stmt_list_ptr& block);
void decompile_search_infinite(const gsc::stmt_list_ptr& block);
void decompile_search_loop(const gsc::stmt_list_ptr& block);
@ -68,6 +70,7 @@ private:
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
void process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -553,8 +553,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 99
#define YY_END_OF_BUFFER 100
#define YY_NUM_RULES 100
#define YY_END_OF_BUFFER 101
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -562,40 +562,40 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[300] =
static const flex_int16_t yy_accept[301] =
{ 0,
0, 0, 0, 0, 0, 0, 100, 98, 1, 2,
87, 98, 98, 86, 90, 98, 48, 49, 84, 82,
54, 83, 55, 85, 97, 57, 58, 71, 81, 72,
93, 52, 53, 91, 93, 93, 93, 93, 93, 93,
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
50, 89, 51, 88, 5, 6, 5, 9, 10, 9,
68, 0, 95, 0, 0, 0, 0, 77, 0, 66,
0, 79, 0, 0, 75, 59, 73, 60, 74, 96,
0, 8, 4, 3, 76, 96, 97, 0, 0, 56,
63, 69, 67, 70, 64, 93, 80, 93, 93, 93,
0, 0, 0, 0, 0, 0, 101, 99, 1, 2,
88, 99, 99, 87, 91, 99, 48, 49, 85, 83,
54, 84, 55, 86, 98, 57, 58, 72, 82, 73,
59, 94, 52, 53, 92, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 50, 90, 51, 89, 5, 6, 5, 9, 10,
9, 69, 0, 96, 0, 0, 0, 0, 78, 0,
67, 0, 80, 0, 0, 76, 60, 74, 61, 75,
97, 0, 8, 4, 3, 77, 97, 98, 0, 0,
56, 64, 70, 68, 71, 65, 94, 81, 94, 94,
93, 93, 93, 93, 93, 93, 93, 93, 24, 29,
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
93, 78, 65, 7, 11, 0, 95, 0, 0, 0,
0, 0, 94, 0, 0, 0, 0, 95, 0, 96,
0, 3, 96, 96, 92, 61, 62, 93, 93, 93,
93, 93, 93, 93, 93, 93, 93, 27, 93, 93,
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
93, 0, 0, 0, 0, 94, 0, 0, 94, 0,
0, 46, 93, 39, 31, 93, 93, 93, 25, 93,
93, 93, 44, 93, 93, 93, 93, 45, 93, 93,
94, 94, 94, 94, 94, 94, 94, 94, 94, 24,
29, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 79, 66, 7, 11, 0, 96, 0, 0,
0, 0, 0, 95, 0, 0, 0, 0, 96, 0,
97, 0, 3, 97, 97, 93, 62, 63, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 27, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 0, 0, 0, 0, 95, 0, 0, 95,
0, 0, 46, 94, 39, 31, 94, 94, 94, 25,
94, 94, 94, 44, 94, 94, 94, 94, 45, 94,
93, 40, 93, 20, 93, 0, 0, 0, 43, 33,
93, 93, 93, 18, 41, 93, 47, 93, 93, 93,
93, 93, 93, 93, 93, 26, 0, 0, 0, 93,
93, 93, 93, 93, 19, 93, 93, 35, 30, 93,
36, 93, 93, 0, 0, 0, 93, 93, 93, 32,
28, 93, 93, 93, 93, 93, 0, 15, 0, 93,
93, 34, 93, 14, 93, 93, 21, 17, 0, 93,
93, 93, 93, 42, 93, 93, 0, 12, 93, 13,
38, 93, 93, 0, 37, 93, 93, 0, 93, 93,
0, 93, 22, 0, 93, 16, 93, 23, 0
94, 94, 40, 94, 20, 94, 0, 0, 0, 43,
33, 94, 94, 94, 18, 41, 94, 47, 94, 94,
94, 94, 94, 94, 94, 94, 26, 0, 0, 0,
94, 94, 94, 94, 94, 19, 94, 94, 35, 30,
94, 36, 94, 94, 0, 0, 0, 94, 94, 94,
32, 28, 94, 94, 94, 94, 94, 0, 15, 0,
94, 94, 34, 94, 14, 94, 94, 21, 17, 0,
94, 94, 94, 94, 42, 94, 94, 0, 12, 94,
13, 38, 94, 94, 0, 37, 94, 94, 0, 94,
94, 0, 94, 22, 0, 94, 16, 94, 23, 0
} ;
@ -607,14 +607,14 @@ static const YY_CHAR yy_ec[256] =
1, 2, 4, 5, 6, 1, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 19, 20, 21,
22, 23, 1, 1, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 26, 27, 28, 29, 1, 30, 31, 32, 33,
22, 23, 24, 1, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 27, 28, 29, 30, 1, 31, 32, 33, 34,
34, 35, 36, 37, 38, 24, 39, 40, 41, 42,
43, 44, 24, 45, 46, 47, 48, 49, 50, 24,
51, 52, 53, 54, 55, 56, 1, 1, 1, 1,
35, 36, 37, 38, 39, 25, 40, 41, 42, 43,
44, 45, 25, 46, 47, 48, 49, 50, 51, 25,
52, 53, 54, 55, 56, 57, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -631,238 +631,238 @@ static const YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
static const YY_CHAR yy_meta[57] =
static const YY_CHAR yy_meta[58] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 4, 1, 1,
1, 1, 1, 4, 1, 5, 1, 1, 4, 4,
1, 1, 1, 1, 4, 1, 5, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1
4, 4, 4, 1, 1, 1, 1
} ;
static const flex_int16_t yy_base[314] =
static const flex_int16_t yy_base[315] =
{ 0,
0, 0, 54, 55, 56, 57, 564, 565, 565, 565,
541, 56, 35, 540, 63, 55, 565, 565, 539, 56,
565, 55, 56, 74, 71, 541, 565, 54, 537, 70,
532, 565, 565, 535, 53, 58, 64, 72, 73, 74,
79, 84, 82, 85, 86, 88, 95, 97, 94, 107,
565, 96, 565, 565, 565, 565, 539, 565, 565, 538,
565, 120, 565, 127, 512, 511, 506, 565, 122, 565,
115, 565, 126, 140, 565, 565, 565, 565, 565, 120,
513, 565, 565, 0, 565, 121, 141, 135, 0, 565,
528, 565, 565, 565, 527, 522, 565, 132, 128, 134,
0, 0, 55, 56, 57, 58, 565, 566, 566, 566,
542, 57, 34, 541, 66, 60, 566, 566, 540, 57,
566, 63, 48, 74, 74, 542, 566, 55, 538, 59,
566, 532, 566, 566, 536, 62, 66, 71, 72, 67,
73, 87, 70, 76, 89, 92, 93, 94, 96, 97,
99, 566, 100, 566, 566, 566, 566, 540, 566, 566,
539, 566, 120, 566, 136, 512, 511, 506, 566, 122,
566, 123, 566, 126, 143, 566, 566, 566, 566, 566,
118, 513, 566, 566, 0, 566, 125, 140, 132, 0,
566, 529, 566, 566, 566, 528, 522, 566, 130, 133,
137, 139, 138, 142, 114, 143, 145, 146, 521, 520,
150, 151, 152, 153, 156, 159, 163, 158, 160, 165,
166, 565, 565, 565, 565, 189, 197, 202, 507, 512,
505, 204, 565, 207, 205, 208, 209, 210, 213, 565,
490, 0, 202, 565, 515, 565, 565, 199, 212, 187,
195, 206, 198, 217, 215, 218, 222, 224, 225, 226,
227, 228, 229, 231, 236, 230, 238, 241, 244, 243,
245, 499, 499, 496, 268, 269, 276, 271, 273, 283,
503, 510, 261, 509, 508, 258, 263, 262, 507, 270,
272, 277, 506, 278, 279, 282, 287, 505, 289, 290,
124, 135, 137, 139, 145, 149, 146, 150, 151, 521,
520, 152, 155, 154, 157, 158, 161, 162, 163, 170,
167, 168, 566, 566, 566, 566, 186, 204, 211, 507,
512, 505, 205, 566, 212, 202, 215, 210, 213, 217,
566, 490, 0, 205, 566, 515, 566, 566, 194, 203,
206, 200, 216, 198, 218, 221, 223, 224, 225, 226,
227, 231, 228, 232, 236, 238, 241, 239, 242, 248,
246, 249, 499, 499, 496, 273, 274, 277, 275, 276,
284, 503, 510, 104, 509, 508, 262, 268, 264, 507,
265, 270, 279, 506, 271, 282, 287, 288, 505, 289,
293, 504, 291, 294, 296, 482, 480, 491, 565, 298,
299, 301, 305, 500, 499, 302, 498, 303, 313, 307,
314, 322, 324, 326, 327, 497, 477, 488, 491, 312,
330, 310, 334, 335, 493, 336, 337, 492, 491, 340,
490, 342, 343, 481, 480, 483, 348, 345, 354, 486,
485, 351, 349, 363, 365, 352, 476, 565, 467, 367,
368, 482, 369, 481, 370, 372, 375, 565, 468, 377,
378, 380, 385, 466, 386, 387, 403, 417, 388, 416,
414, 389, 394, 389, 408, 397, 400, 331, 399, 402,
339, 401, 309, 259, 403, 565, 404, 200, 565, 445,
272, 292, 504, 294, 297, 298, 482, 480, 491, 566,
299, 300, 304, 301, 500, 499, 302, 498, 305, 311,
309, 312, 313, 322, 314, 327, 497, 477, 488, 491,
328, 331, 310, 333, 335, 493, 336, 334, 492, 491,
337, 490, 341, 338, 481, 480, 483, 343, 340, 353,
486, 485, 348, 360, 362, 363, 351, 476, 566, 467,
364, 366, 482, 369, 481, 368, 375, 376, 566, 455,
373, 379, 377, 388, 419, 378, 386, 403, 417, 389,
416, 414, 398, 384, 392, 412, 392, 400, 368, 401,
399, 341, 403, 347, 193, 404, 566, 408, 159, 566,
450, 455, 460, 463, 465, 470, 475, 480, 485, 490,
84, 495, 500
447, 452, 457, 462, 465, 467, 472, 477, 482, 487,
492, 68, 497, 502
} ;
static const flex_int16_t yy_def[314] =
static const flex_int16_t yy_def[315] =
{ 0,
299, 1, 300, 300, 301, 301, 299, 299, 299, 299,
299, 302, 299, 299, 299, 303, 299, 299, 299, 299,
299, 299, 299, 299, 304, 299, 299, 299, 299, 299,
305, 299, 299, 299, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 302, 299, 306, 299, 299, 299, 299, 307, 299,
308, 299, 303, 309, 299, 299, 299, 299, 299, 299,
299, 299, 299, 310, 299, 299, 304, 304, 311, 299,
299, 299, 299, 299, 299, 305, 299, 305, 305, 305,
300, 1, 301, 301, 302, 302, 300, 300, 300, 300,
300, 303, 300, 300, 300, 304, 300, 300, 300, 300,
300, 300, 300, 300, 305, 300, 300, 300, 300, 300,
300, 306, 300, 300, 300, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 303, 300, 307, 300, 300, 300, 300, 308,
300, 309, 300, 304, 310, 300, 300, 300, 300, 300,
300, 300, 300, 300, 311, 300, 300, 305, 305, 312,
300, 300, 300, 300, 300, 300, 306, 300, 306, 306,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 299, 299, 299, 299, 302, 302, 306, 299, 299,
299, 307, 299, 312, 308, 313, 303, 303, 309, 299,
299, 310, 299, 299, 311, 299, 299, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 299, 299, 299, 307, 307, 312, 308, 308, 313,
299, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 300, 300, 300, 300, 303, 303, 307, 300,
300, 300, 308, 300, 313, 309, 314, 304, 304, 310,
300, 300, 311, 300, 300, 312, 300, 300, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 300, 300, 300, 308, 308, 313, 309, 309,
314, 300, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
305, 305, 305, 305, 305, 299, 299, 299, 299, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 299, 299, 299, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 299, 299, 299, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 299, 299, 299, 305,
305, 305, 305, 305, 305, 305, 305, 299, 299, 305,
305, 305, 305, 305, 305, 305, 299, 305, 305, 305,
305, 305, 305, 299, 305, 305, 305, 299, 305, 305,
299, 305, 305, 299, 305, 299, 305, 305, 0, 299,
306, 306, 306, 306, 306, 306, 300, 300, 300, 300,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 300, 300, 300,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 300, 300, 300, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 300, 300, 300,
306, 306, 306, 306, 306, 306, 306, 306, 300, 300,
306, 306, 306, 306, 306, 306, 306, 300, 306, 306,
306, 306, 306, 306, 300, 306, 306, 306, 300, 306,
306, 300, 306, 306, 300, 306, 300, 306, 306, 0,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300
} ;
static const flex_int16_t yy_nxt[622] =
static const flex_int16_t yy_nxt[624] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 8, 33, 34, 31, 35,
36, 37, 38, 39, 40, 41, 31, 42, 31, 43,
31, 44, 31, 45, 46, 47, 48, 49, 31, 50,
31, 31, 51, 52, 53, 54, 56, 56, 59, 59,
63, 60, 60, 63, 65, 57, 57, 69, 76, 78,
70, 71, 66, 80, 91, 92, 79, 77, 89, 82,
74, 64, 67, 89, 72, 83, 86, 145, 87, 89,
84, 94, 95, 100, 98, 85, 89, 89, 89, 89,
28, 29, 30, 31, 32, 33, 8, 34, 35, 32,
36, 37, 38, 39, 40, 41, 42, 32, 43, 32,
44, 32, 45, 32, 46, 47, 48, 49, 50, 32,
51, 32, 32, 52, 53, 54, 55, 57, 57, 60,
60, 64, 61, 61, 66, 81, 58, 58, 64, 77,
70, 146, 67, 71, 72, 92, 93, 79, 78, 83,
95, 96, 68, 65, 80, 84, 75, 73, 90, 87,
85, 88, 90, 90, 82, 86, 90, 90, 90, 90,
101, 81, 99, 106, 89, 103, 102, 89, 108, 89,
89, 89, 104, 89, 105, 111, 107, 122, 109, 89,
89, 114, 89, 133, 63, 110, 133, 112, 115, 62,
113, 127, 89, 117, 63, 119, 120, 80, 143, 89,
136, 118, 73, 121, 116, 64, 156, 134, 138, 123,
299, 74, 128, 89, 140, 144, 86, 89, 87, 89,
89, 149, 89, 89, 89, 139, 89, 89, 89, 148,
89, 89, 154, 150, 152, 89, 89, 89, 89, 151,
153, 89, 157, 89, 89, 89, 159, 155, 89, 158,
89, 89, 169, 63, 162, 164, 165, 161, 160, 163,
90, 101, 90, 107, 99, 110, 104, 105, 102, 106,
112, 100, 111, 90, 103, 90, 108, 109, 90, 90,
90, 123, 90, 90, 64, 90, 134, 115, 116, 121,
90, 134, 113, 118, 64, 81, 122, 114, 63, 120,
128, 119, 144, 211, 117, 74, 65, 300, 135, 137,
90, 139, 75, 141, 124, 87, 90, 88, 90, 90,
145, 90, 129, 90, 151, 90, 90, 150, 149, 140,
152, 90, 90, 153, 155, 90, 90, 90, 90, 154,
90, 90, 157, 90, 90, 90, 158, 90, 90, 90,
64, 156, 160, 90, 90, 159, 90, 163, 165, 166,
166, 63, 170, 171, 62, 168, 127, 167, 133, 132,
135, 176, 89, 133, 64, 73, 179, 63, 63, 143,
89, 138, 64, 89, 89, 89, 184, 128, 185, 134,
136, 89, 177, 180, 74, 74, 144, 89, 139, 182,
89, 183, 89, 89, 187, 186, 188, 89, 189, 89,
89, 89, 89, 89, 89, 89, 89, 192, 193, 194,
190, 89, 196, 89, 195, 198, 89, 191, 89, 89,
89, 201, 133, 133, 202, 200, 197, 203, 132, 133,
176, 133, 199, 89, 205, 135, 89, 89, 89, 204,
211, 179, 296, 134, 134, 89, 136, 89, 136, 210,
167, 161, 162, 170, 164, 171, 172, 168, 64, 134,
134, 169, 65, 63, 133, 128, 177, 136, 64, 74,
90, 64, 144, 180, 90, 139, 90, 297, 137, 90,
65, 135, 90, 184, 186, 183, 75, 129, 178, 75,
145, 181, 90, 140, 90, 188, 185, 90, 189, 90,
90, 90, 90, 90, 90, 190, 187, 90, 90, 193,
194, 195, 90, 197, 90, 90, 191, 90, 90, 196,
192, 199, 90, 202, 90, 90, 203, 134, 134, 133,
198, 177, 204, 134, 134, 200, 136, 201, 90, 206,
90, 90, 180, 205, 90, 212, 90, 90, 90, 135,
212, 177, 89, 89, 89, 215, 216, 89, 180, 213,
219, 214, 89, 218, 89, 89, 89, 217, 89, 89,
221, 89, 223, 89, 89, 224, 89, 89, 89, 226,
89, 220, 89, 234, 89, 89, 222, 89, 89, 89,
225, 230, 232, 236, 233, 231, 237, 89, 238, 89,
239, 89, 89, 235, 247, 89, 241, 249, 240, 89,
89, 89, 89, 242, 243, 89, 248, 89, 89, 252,
89, 251, 294, 89, 89, 291, 89, 89, 253, 89,
250, 264, 256, 255, 254, 260, 263, 262, 89, 261,
89, 267, 89, 89, 89, 89, 265, 89, 266, 273,
135, 137, 137, 178, 216, 90, 213, 215, 90, 217,
181, 218, 214, 90, 90, 90, 220, 219, 90, 223,
90, 222, 224, 90, 90, 90, 90, 90, 90, 225,
90, 90, 227, 221, 235, 90, 90, 90, 90, 90,
90, 234, 237, 231, 226, 238, 233, 232, 90, 240,
241, 239, 243, 90, 90, 242, 236, 90, 250, 90,
90, 90, 90, 90, 90, 244, 90, 90, 249, 90,
253, 248, 252, 90, 90, 295, 254, 90, 257, 90,
251, 261, 255, 256, 264, 262, 90, 263, 90, 90,
90, 268, 90, 265, 90, 90, 266, 267, 274, 90,
89, 271, 89, 89, 274, 89, 272, 279, 270, 275,
89, 89, 89, 89, 89, 276, 283, 281, 286, 89,
285, 280, 89, 278, 89, 89, 89, 89, 89, 89,
282, 290, 292, 89, 295, 288, 298, 289, 293, 89,
287, 89, 89, 284, 297, 55, 55, 55, 55, 55,
58, 58, 58, 58, 58, 62, 62, 62, 62, 62,
73, 73, 73, 73, 73, 88, 88, 88, 96, 96,
126, 126, 126, 126, 126, 132, 132, 132, 132, 132,
135, 135, 135, 135, 135, 137, 137, 137, 137, 137,
142, 89, 142, 142, 142, 175, 175, 175, 175, 175,
272, 90, 90, 90, 90, 90, 271, 273, 275, 280,
90, 276, 90, 292, 90, 90, 284, 277, 90, 281,
279, 282, 286, 283, 90, 90, 90, 90, 287, 90,
90, 288, 291, 290, 90, 293, 294, 296, 90, 289,
90, 299, 90, 90, 285, 90, 298, 56, 56, 56,
56, 56, 59, 59, 59, 59, 59, 63, 63, 63,
63, 63, 74, 74, 74, 74, 74, 89, 89, 89,
97, 97, 127, 127, 127, 127, 127, 133, 133, 133,
133, 133, 136, 136, 136, 136, 136, 138, 138, 138,
138, 138, 143, 278, 143, 143, 143, 176, 176, 176,
178, 178, 178, 178, 178, 277, 89, 89, 269, 268,
89, 89, 259, 258, 257, 89, 89, 89, 89, 246,
245, 244, 89, 89, 89, 89, 229, 228, 227, 89,
89, 89, 89, 89, 89, 89, 209, 208, 207, 206,
89, 181, 174, 173, 172, 89, 89, 89, 147, 146,
141, 131, 130, 129, 125, 124, 97, 89, 93, 90,
75, 68, 61, 299, 7, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
176, 176, 179, 179, 179, 179, 179, 90, 90, 270,
269, 90, 90, 260, 259, 258, 90, 90, 90, 90,
247, 246, 245, 90, 90, 90, 90, 230, 229, 228,
90, 90, 90, 90, 90, 90, 90, 210, 209, 208,
207, 90, 182, 175, 174, 173, 90, 90, 90, 148,
147, 142, 132, 131, 130, 126, 125, 98, 90, 94,
91, 76, 69, 62, 300, 7, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300
} ;
static const flex_int16_t yy_chk[622] =
static const flex_int16_t yy_chk[624] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 4, 5, 6,
12, 5, 6, 16, 13, 3, 4, 15, 20, 22,
15, 15, 13, 23, 28, 28, 22, 20, 35, 24,
16, 12, 13, 36, 15, 24, 25, 311, 25, 37,
24, 30, 30, 37, 35, 24, 25, 38, 39, 40,
1, 1, 1, 1, 1, 1, 1, 3, 4, 5,
6, 12, 5, 6, 13, 23, 3, 4, 16, 20,
15, 312, 13, 15, 15, 28, 28, 22, 20, 24,
30, 30, 13, 12, 22, 24, 16, 15, 36, 25,
24, 25, 37, 40, 23, 24, 43, 38, 39, 41,
37, 23, 36, 40, 41, 38, 37, 43, 41, 42,
44, 45, 39, 46, 39, 43, 40, 52, 42, 49,
47, 46, 48, 71, 62, 42, 69, 44, 47, 64,
45, 64, 50, 48, 73, 49, 50, 80, 86, 105,
71, 48, 74, 50, 47, 62, 105, 69, 74, 52,
88, 73, 64, 99, 80, 86, 87, 98, 87, 100,
88, 99, 101, 103, 102, 74, 87, 104, 106, 98,
107, 108, 103, 100, 101, 111, 112, 113, 114, 100,
102, 115, 106, 118, 116, 119, 108, 104, 117, 107,
120, 121, 119, 126, 113, 115, 116, 112, 111, 114,
25, 38, 44, 41, 36, 43, 39, 40, 38, 40,
44, 37, 43, 42, 38, 45, 41, 42, 46, 47,
48, 53, 49, 50, 63, 51, 70, 47, 48, 51,
184, 72, 45, 49, 74, 81, 51, 46, 65, 50,
65, 49, 87, 184, 48, 75, 63, 89, 70, 72,
101, 75, 74, 81, 53, 88, 99, 88, 89, 100,
87, 102, 65, 103, 101, 104, 88, 100, 99, 75,
101, 105, 107, 102, 104, 106, 108, 109, 112, 103,
114, 113, 106, 115, 116, 299, 107, 117, 118, 119,
127, 105, 109, 121, 122, 108, 120, 114, 116, 117,
117, 127, 120, 121, 128, 118, 128, 117, 132, 134,
136, 134, 150, 135, 126, 139, 136, 137, 138, 143,
151, 139, 127, 153, 148, 298, 150, 128, 151, 132,
135, 152, 134, 136, 137, 138, 143, 149, 139, 148,
155, 149, 154, 156, 153, 152, 154, 157, 155, 158,
159, 160, 161, 162, 163, 166, 164, 158, 159, 160,
156, 165, 162, 167, 161, 164, 168, 157, 170, 169,
171, 167, 175, 176, 168, 166, 163, 169, 177, 178,
177, 179, 165, 186, 171, 180, 183, 188, 187, 170,
186, 180, 294, 175, 176, 190, 178, 191, 179, 183,
118, 112, 113, 120, 115, 121, 122, 118, 128, 133,
136, 119, 127, 129, 135, 129, 135, 137, 138, 140,
149, 139, 144, 137, 154, 140, 152, 295, 136, 150,
128, 133, 151, 150, 152, 149, 138, 129, 135, 139,
144, 137, 153, 140, 155, 154, 151, 156, 155, 157,
158, 159, 160, 161, 163, 156, 153, 162, 164, 159,
160, 161, 165, 163, 166, 168, 157, 167, 169, 162,
158, 165, 171, 168, 170, 172, 169, 176, 177, 178,
164, 178, 170, 179, 180, 166, 181, 167, 187, 172,
189, 191, 181, 171, 188, 187, 192, 195, 201, 176,
187, 177, 192, 194, 195, 191, 192, 196, 180, 188,
196, 190, 197, 195, 199, 200, 203, 194, 201, 204,
199, 205, 201, 210, 211, 203, 212, 216, 218, 205,
213, 197, 220, 216, 293, 232, 200, 230, 219, 221,
204, 210, 212, 219, 213, 211, 219, 222, 220, 223,
221, 224, 225, 218, 230, 231, 223, 232, 222, 233,
234, 236, 237, 224, 225, 240, 231, 242, 243, 236,
248, 234, 291, 247, 253, 288, 252, 256, 237, 249,
233, 253, 243, 242, 240, 247, 252, 249, 254, 248,
255, 256, 260, 261, 263, 265, 254, 266, 255, 265,
177, 179, 180, 178, 192, 193, 188, 191, 196, 193,
181, 195, 189, 197, 198, 200, 197, 196, 202, 201,
204, 200, 202, 205, 206, 211, 212, 214, 217, 204,
213, 219, 206, 198, 217, 221, 233, 220, 222, 223,
225, 214, 220, 211, 205, 220, 213, 212, 224, 222,
223, 221, 225, 226, 231, 224, 219, 232, 233, 234,
238, 235, 237, 241, 244, 226, 249, 243, 232, 248,
237, 231, 235, 294, 253, 292, 238, 257, 244, 250,
234, 248, 241, 243, 253, 249, 254, 250, 255, 256,
261, 257, 262, 254, 266, 264, 255, 256, 266, 271,
267, 261, 270, 271, 266, 272, 263, 271, 260, 267,
273, 275, 276, 279, 282, 267, 276, 273, 282, 283,
279, 272, 286, 270, 289, 287, 292, 290, 295, 297,
275, 287, 289, 285, 292, 284, 297, 286, 290, 281,
283, 280, 278, 277, 295, 300, 300, 300, 300, 300,
301, 301, 301, 301, 301, 302, 302, 302, 302, 302,
303, 303, 303, 303, 303, 304, 304, 304, 305, 305,
306, 306, 306, 306, 306, 307, 307, 307, 307, 307,
308, 308, 308, 308, 308, 309, 309, 309, 309, 309,
310, 274, 310, 310, 310, 312, 312, 312, 312, 312,
262, 267, 268, 273, 276, 272, 261, 264, 267, 272,
284, 268, 277, 289, 274, 280, 277, 268, 287, 273,
271, 274, 280, 276, 283, 291, 288, 290, 283, 293,
296, 284, 288, 287, 298, 290, 291, 293, 286, 285,
282, 298, 281, 279, 278, 275, 296, 301, 301, 301,
301, 301, 302, 302, 302, 302, 302, 303, 303, 303,
303, 303, 304, 304, 304, 304, 304, 305, 305, 305,
306, 306, 307, 307, 307, 307, 307, 308, 308, 308,
308, 308, 309, 309, 309, 309, 309, 310, 310, 310,
310, 310, 311, 270, 311, 311, 311, 313, 313, 313,
313, 313, 313, 313, 313, 269, 264, 262, 259, 257,
251, 250, 246, 245, 244, 241, 239, 238, 235, 229,
228, 227, 226, 217, 215, 214, 208, 207, 206, 202,
198, 193, 189, 185, 184, 182, 181, 174, 173, 172,
145, 141, 131, 130, 129, 110, 109, 96, 95, 91,
81, 67, 66, 65, 60, 57, 34, 31, 29, 26,
19, 14, 11, 7, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
313, 313, 314, 314, 314, 314, 314, 265, 263, 260,
258, 252, 251, 247, 246, 245, 242, 240, 239, 236,
230, 229, 228, 227, 218, 216, 215, 209, 208, 207,
203, 199, 194, 190, 186, 185, 183, 182, 175, 174,
173, 146, 142, 132, 131, 130, 111, 110, 97, 96,
92, 82, 68, 67, 66, 61, 58, 35, 32, 29,
26, 19, 14, 11, 7, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300
} ;
/* The intent behind this definition is that it'll catch
@ -1180,13 +1180,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 300 )
if ( yy_current_state >= 301 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_current_state != 299 );
while ( yy_current_state != 300 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1502,218 +1502,223 @@ YY_RULE_SETUP
case 59:
YY_RULE_SETUP
#line 106 "lexer.lpp"
{ return iw5::parser::make_INCREMENT(loc); }
{ return iw5::parser::make_QMARK(loc); }
YY_BREAK
case 60:
YY_RULE_SETUP
#line 107 "lexer.lpp"
{ return iw5::parser::make_DECREMENT(loc); }
{ return iw5::parser::make_INCREMENT(loc); }
YY_BREAK
case 61:
YY_RULE_SETUP
#line 108 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_LSHIFT(loc); }
{ return iw5::parser::make_DECREMENT(loc); }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 109 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_RSHIFT(loc); }
{ return iw5::parser::make_ASSIGN_LSHIFT(loc); }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 110 "lexer.lpp"
{ return iw5::parser::make_LSHIFT(loc); }
{ return iw5::parser::make_ASSIGN_RSHIFT(loc); }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 111 "lexer.lpp"
{ return iw5::parser::make_RSHIFT(loc); }
{ return iw5::parser::make_LSHIFT(loc); }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 112 "lexer.lpp"
{ return iw5::parser::make_OR(loc); }
{ return iw5::parser::make_RSHIFT(loc); }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 113 "lexer.lpp"
{ return iw5::parser::make_AND(loc); }
{ return iw5::parser::make_OR(loc); }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 114 "lexer.lpp"
{ return iw5::parser::make_EQUALITY(loc); }
{ return iw5::parser::make_AND(loc); }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 115 "lexer.lpp"
{ return iw5::parser::make_INEQUALITY(loc); }
{ return iw5::parser::make_EQUALITY(loc); }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 116 "lexer.lpp"
{ return iw5::parser::make_LESS_EQUAL(loc); }
{ return iw5::parser::make_INEQUALITY(loc); }
YY_BREAK
case 70:
YY_RULE_SETUP
#line 117 "lexer.lpp"
{ return iw5::parser::make_GREATER_EQUAL(loc); }
{ return iw5::parser::make_LESS_EQUAL(loc); }
YY_BREAK
case 71:
YY_RULE_SETUP
#line 118 "lexer.lpp"
{ return iw5::parser::make_LESS(loc); }
{ return iw5::parser::make_GREATER_EQUAL(loc); }
YY_BREAK
case 72:
YY_RULE_SETUP
#line 119 "lexer.lpp"
{ return iw5::parser::make_GREATER(loc); }
{ return iw5::parser::make_LESS(loc); }
YY_BREAK
case 73:
YY_RULE_SETUP
#line 120 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_ADD(loc); }
{ return iw5::parser::make_GREATER(loc); }
YY_BREAK
case 74:
YY_RULE_SETUP
#line 121 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_SUB(loc); }
{ return iw5::parser::make_ASSIGN_ADD(loc); }
YY_BREAK
case 75:
YY_RULE_SETUP
#line 122 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_MULT(loc); }
{ return iw5::parser::make_ASSIGN_SUB(loc); }
YY_BREAK
case 76:
YY_RULE_SETUP
#line 123 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_DIV(loc); }
{ return iw5::parser::make_ASSIGN_MULT(loc); }
YY_BREAK
case 77:
YY_RULE_SETUP
#line 124 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_MOD(loc); }
{ return iw5::parser::make_ASSIGN_DIV(loc); }
YY_BREAK
case 78:
YY_RULE_SETUP
#line 125 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_BITWISE_OR(loc); }
{ return iw5::parser::make_ASSIGN_MOD(loc); }
YY_BREAK
case 79:
YY_RULE_SETUP
#line 126 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_BITWISE_AND(loc); }
{ return iw5::parser::make_ASSIGN_BITWISE_OR(loc); }
YY_BREAK
case 80:
YY_RULE_SETUP
#line 127 "lexer.lpp"
{ return iw5::parser::make_ASSIGN_BITWISE_EXOR(loc); }
{ return iw5::parser::make_ASSIGN_BITWISE_AND(loc); }
YY_BREAK
case 81:
YY_RULE_SETUP
#line 128 "lexer.lpp"
{ return iw5::parser::make_ASSIGN(loc); }
{ return iw5::parser::make_ASSIGN_BITWISE_EXOR(loc); }
YY_BREAK
case 82:
YY_RULE_SETUP
#line 129 "lexer.lpp"
{ return iw5::parser::make_ADD(loc); }
{ return iw5::parser::make_ASSIGN(loc); }
YY_BREAK
case 83:
YY_RULE_SETUP
#line 130 "lexer.lpp"
{ return iw5::parser::make_SUB(loc); }
{ return iw5::parser::make_ADD(loc); }
YY_BREAK
case 84:
YY_RULE_SETUP
#line 131 "lexer.lpp"
{ return iw5::parser::make_MULT(loc); }
{ return iw5::parser::make_SUB(loc); }
YY_BREAK
case 85:
YY_RULE_SETUP
#line 132 "lexer.lpp"
{ return iw5::parser::make_DIV(loc); }
{ return iw5::parser::make_MULT(loc); }
YY_BREAK
case 86:
YY_RULE_SETUP
#line 133 "lexer.lpp"
{ return iw5::parser::make_MOD(loc); }
{ return iw5::parser::make_DIV(loc); }
YY_BREAK
case 87:
YY_RULE_SETUP
#line 134 "lexer.lpp"
{ return iw5::parser::make_NOT(loc); }
{ return iw5::parser::make_MOD(loc); }
YY_BREAK
case 88:
YY_RULE_SETUP
#line 135 "lexer.lpp"
{ return iw5::parser::make_COMPLEMENT(loc); }
{ return iw5::parser::make_NOT(loc); }
YY_BREAK
case 89:
YY_RULE_SETUP
#line 136 "lexer.lpp"
{ return iw5::parser::make_BITWISE_OR(loc); }
{ return iw5::parser::make_COMPLEMENT(loc); }
YY_BREAK
case 90:
YY_RULE_SETUP
#line 137 "lexer.lpp"
{ return iw5::parser::make_BITWISE_AND(loc); }
{ return iw5::parser::make_BITWISE_OR(loc); }
YY_BREAK
case 91:
YY_RULE_SETUP
#line 138 "lexer.lpp"
{ return iw5::parser::make_BITWISE_EXOR(loc); }
{ return iw5::parser::make_BITWISE_AND(loc); }
YY_BREAK
case 92:
YY_RULE_SETUP
#line 139 "lexer.lpp"
{ return iw5::parser::make_FILE(utils::string::fordslash(yytext), loc); }
{ return iw5::parser::make_BITWISE_EXOR(loc); }
YY_BREAK
case 93:
YY_RULE_SETUP
#line 140 "lexer.lpp"
{ return iw5::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
{ return iw5::parser::make_FILE(utils::string::fordslash(yytext), loc); }
YY_BREAK
case 94:
/* rule 94 can match eol */
YY_RULE_SETUP
#line 141 "lexer.lpp"
{ return iw5::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
{ return iw5::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
YY_BREAK
case 95:
/* rule 95 can match eol */
YY_RULE_SETUP
#line 142 "lexer.lpp"
{ return iw5::parser::make_STRING(std::string(yytext), loc); }
{ return iw5::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 143 "lexer.lpp"
{ return iw5::parser::make_FLOAT(std::string(yytext), loc); }
{ return iw5::parser::make_STRING(std::string(yytext), loc); }
YY_BREAK
case 97:
YY_RULE_SETUP
#line 144 "lexer.lpp"
{ return iw5::parser::make_FLOAT(std::string(yytext), loc); }
YY_BREAK
case 98:
YY_RULE_SETUP
#line 145 "lexer.lpp"
{ return iw5::parser::make_INTEGER(std::string(yytext), loc); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT_BLOCK_STATE):
case YY_STATE_EOF(DEVELOPER_BLOCK_STATE):
#line 145 "lexer.lpp"
#line 146 "lexer.lpp"
{ return iw5::parser::make_IW5EOF(loc); }
YY_BREAK
case 98:
/* rule 98 can match eol */
case 99:
/* rule 99 can match eol */
YY_RULE_SETUP
#line 146 "lexer.lpp"
#line 147 "lexer.lpp"
{ throw iw5::parser::syntax_error(loc, "bad token: '" + std::string(yytext) + "'"); }
YY_BREAK
case 99:
case 100:
YY_RULE_SETUP
#line 148 "lexer.lpp"
#line 149 "lexer.lpp"
ECHO;
YY_BREAK
#line 1716 "lexer.cpp"
#line 1721 "lexer.cpp"
case YY_END_OF_BUFFER:
{
@ -2011,7 +2016,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 300 )
if ( yy_current_state >= 301 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@ -2040,11 +2045,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 300 )
if ( yy_current_state >= 301 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 299);
yy_is_jam = (yy_current_state == 300);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@ -2843,6 +2848,6 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 148 "lexer.lpp"
#line 149 "lexer.lpp"

View File

@ -700,7 +700,7 @@ extern int yylex (yyscan_t yyscanner);
#undef yyTABLES_NAME
#endif
#line 148 "lexer.lpp"
#line 149 "lexer.lpp"
#line 706 "lexer.hpp"

File diff suppressed because it is too large Load Diff

View File

@ -446,6 +446,7 @@ namespace xsk { namespace gsc { namespace iw5 {
// for_expr
// expr
// expr_compare
// expr_ternary
// expr_binary
// expr_primitive
char dummy11[sizeof (expr_ptr)];
@ -696,53 +697,55 @@ namespace xsk { namespace gsc { namespace iw5 {
DOUBLECOLON = 47, // "::"
COLON = 48, // ":"
SEMICOLON = 49, // ";"
INCREMENT = 50, // "++"
DECREMENT = 51, // "--"
LSHIFT = 52, // "<<"
RSHIFT = 53, // ">>"
OR = 54, // "||"
AND = 55, // "&&"
EQUALITY = 56, // "=="
INEQUALITY = 57, // "!="
LESS_EQUAL = 58, // "<="
GREATER_EQUAL = 59, // ">="
LESS = 60, // "<"
GREATER = 61, // ">"
NOT = 62, // "!"
COMPLEMENT = 63, // "~"
ASSIGN = 64, // "="
ASSIGN_ADD = 65, // "+="
ASSIGN_SUB = 66, // "-="
ASSIGN_MULT = 67, // "*="
ASSIGN_DIV = 68, // "/="
ASSIGN_MOD = 69, // "%="
ASSIGN_BITWISE_OR = 70, // "|="
ASSIGN_BITWISE_AND = 71, // "&="
ASSIGN_BITWISE_EXOR = 72, // "^="
ASSIGN_RSHIFT = 73, // ">>="
ASSIGN_LSHIFT = 74, // "<<="
BITWISE_OR = 75, // "|"
BITWISE_AND = 76, // "&"
BITWISE_EXOR = 77, // "^"
ADD = 78, // "+"
SUB = 79, // "-"
MULT = 80, // "*"
DIV = 81, // "/"
MOD = 82, // "%"
FILE = 83, // "file path"
NAME = 84, // "identifier"
STRING = 85, // "string literal"
ISTRING = 86, // "localized string"
FLOAT = 87, // "float"
INTEGER = 88, // "int"
ADD_ARRAY = 89, // ADD_ARRAY
THEN = 90, // THEN
NEG = 91, // NEG
ANIMREF = 92, // ANIMREF
PREINC = 93, // PREINC
PREDEC = 94, // PREDEC
POSTINC = 95, // POSTINC
POSTDEC = 96 // POSTDEC
QMARK = 50, // "?"
INCREMENT = 51, // "++"
DECREMENT = 52, // "--"
LSHIFT = 53, // "<<"
RSHIFT = 54, // ">>"
OR = 55, // "||"
AND = 56, // "&&"
EQUALITY = 57, // "=="
INEQUALITY = 58, // "!="
LESS_EQUAL = 59, // "<="
GREATER_EQUAL = 60, // ">="
LESS = 61, // "<"
GREATER = 62, // ">"
NOT = 63, // "!"
COMPLEMENT = 64, // "~"
ASSIGN = 65, // "="
ASSIGN_ADD = 66, // "+="
ASSIGN_SUB = 67, // "-="
ASSIGN_MULT = 68, // "*="
ASSIGN_DIV = 69, // "/="
ASSIGN_MOD = 70, // "%="
ASSIGN_BITWISE_OR = 71, // "|="
ASSIGN_BITWISE_AND = 72, // "&="
ASSIGN_BITWISE_EXOR = 73, // "^="
ASSIGN_RSHIFT = 74, // ">>="
ASSIGN_LSHIFT = 75, // "<<="
BITWISE_OR = 76, // "|"
BITWISE_AND = 77, // "&"
BITWISE_EXOR = 78, // "^"
ADD = 79, // "+"
SUB = 80, // "-"
MULT = 81, // "*"
DIV = 82, // "/"
MOD = 83, // "%"
FILE = 84, // "file path"
NAME = 85, // "identifier"
STRING = 86, // "string literal"
ISTRING = 87, // "localized string"
FLOAT = 88, // "float"
INTEGER = 89, // "int"
ADD_ARRAY = 90, // ADD_ARRAY
THEN = 91, // THEN
TERN = 92, // TERN
NEG = 93, // NEG
ANIMREF = 94, // ANIMREF
PREINC = 95, // PREINC
PREDEC = 96, // PREDEC
POSTINC = 97, // POSTINC
POSTDEC = 98 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -759,7 +762,7 @@ namespace xsk { namespace gsc { namespace iw5 {
{
enum symbol_kind_type
{
YYNTOKENS = 97, ///< Number of tokens.
YYNTOKENS = 99, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
@ -811,128 +814,131 @@ namespace xsk { namespace gsc { namespace iw5 {
S_DOUBLECOLON = 47, // "::"
S_COLON = 48, // ":"
S_SEMICOLON = 49, // ";"
S_INCREMENT = 50, // "++"
S_DECREMENT = 51, // "--"
S_LSHIFT = 52, // "<<"
S_RSHIFT = 53, // ">>"
S_OR = 54, // "||"
S_AND = 55, // "&&"
S_EQUALITY = 56, // "=="
S_INEQUALITY = 57, // "!="
S_LESS_EQUAL = 58, // "<="
S_GREATER_EQUAL = 59, // ">="
S_LESS = 60, // "<"
S_GREATER = 61, // ">"
S_NOT = 62, // "!"
S_COMPLEMENT = 63, // "~"
S_ASSIGN = 64, // "="
S_ASSIGN_ADD = 65, // "+="
S_ASSIGN_SUB = 66, // "-="
S_ASSIGN_MULT = 67, // "*="
S_ASSIGN_DIV = 68, // "/="
S_ASSIGN_MOD = 69, // "%="
S_ASSIGN_BITWISE_OR = 70, // "|="
S_ASSIGN_BITWISE_AND = 71, // "&="
S_ASSIGN_BITWISE_EXOR = 72, // "^="
S_ASSIGN_RSHIFT = 73, // ">>="
S_ASSIGN_LSHIFT = 74, // "<<="
S_BITWISE_OR = 75, // "|"
S_BITWISE_AND = 76, // "&"
S_BITWISE_EXOR = 77, // "^"
S_ADD = 78, // "+"
S_SUB = 79, // "-"
S_MULT = 80, // "*"
S_DIV = 81, // "/"
S_MOD = 82, // "%"
S_FILE = 83, // "file path"
S_NAME = 84, // "identifier"
S_STRING = 85, // "string literal"
S_ISTRING = 86, // "localized string"
S_FLOAT = 87, // "float"
S_INTEGER = 88, // "int"
S_ADD_ARRAY = 89, // ADD_ARRAY
S_THEN = 90, // THEN
S_NEG = 91, // NEG
S_ANIMREF = 92, // ANIMREF
S_PREINC = 93, // PREINC
S_PREDEC = 94, // PREDEC
S_POSTINC = 95, // POSTINC
S_POSTDEC = 96, // POSTDEC
S_YYACCEPT = 97, // $accept
S_root = 98, // root
S_program = 99, // program
S_include = 100, // include
S_define = 101, // define
S_usingtree = 102, // usingtree
S_constant = 103, // constant
S_thread = 104, // thread
S_parameters = 105, // parameters
S_stmt = 106, // stmt
S_stmt_block = 107, // stmt_block
S_stmt_list = 108, // stmt_list
S_stmt_call = 109, // stmt_call
S_stmt_assign = 110, // stmt_assign
S_stmt_endon = 111, // stmt_endon
S_stmt_notify = 112, // stmt_notify
S_stmt_wait = 113, // stmt_wait
S_stmt_waittill = 114, // stmt_waittill
S_stmt_waittillmatch = 115, // stmt_waittillmatch
S_stmt_waittillframeend = 116, // stmt_waittillframeend
S_stmt_if = 117, // stmt_if
S_stmt_ifelse = 118, // stmt_ifelse
S_stmt_while = 119, // stmt_while
S_stmt_for = 120, // stmt_for
S_stmt_foreach = 121, // stmt_foreach
S_stmt_switch = 122, // stmt_switch
S_stmt_case = 123, // stmt_case
S_stmt_default = 124, // stmt_default
S_stmt_break = 125, // stmt_break
S_stmt_continue = 126, // stmt_continue
S_stmt_return = 127, // stmt_return
S_stmt_breakpoint = 128, // stmt_breakpoint
S_stmt_prof_begin = 129, // stmt_prof_begin
S_stmt_prof_end = 130, // stmt_prof_end
S_for_stmt = 131, // for_stmt
S_for_expr = 132, // for_expr
S_expr = 133, // expr
S_expr_assign = 134, // expr_assign
S_expr_compare = 135, // expr_compare
S_expr_binary = 136, // expr_binary
S_expr_primitive = 137, // expr_primitive
S_expr_call = 138, // expr_call
S_expr_call_thread = 139, // expr_call_thread
S_expr_call_childthread = 140, // expr_call_childthread
S_expr_call_function = 141, // expr_call_function
S_expr_call_pointer = 142, // expr_call_pointer
S_expr_arguments = 143, // expr_arguments
S_expr_arguments_filled = 144, // expr_arguments_filled
S_expr_arguments_empty = 145, // expr_arguments_empty
S_expr_function = 146, // expr_function
S_expr_add_array = 147, // expr_add_array
S_expr_array = 148, // expr_array
S_expr_field = 149, // expr_field
S_expr_size = 150, // expr_size
S_object = 151, // object
S_thisthread = 152, // thisthread
S_empty_array = 153, // empty_array
S_undefined = 154, // undefined
S_game = 155, // game
S_self = 156, // self
S_anim = 157, // anim
S_level = 158, // level
S_animation = 159, // animation
S_animtree = 160, // animtree
S_name = 161, // name
S_file = 162, // file
S_istring = 163, // istring
S_string = 164, // string
S_vector = 165, // vector
S_neg_float = 166, // neg_float
S_neg_integer = 167, // neg_integer
S_float = 168, // float
S_integer = 169, // integer
S_false = 170, // false
S_true = 171 // true
S_QMARK = 50, // "?"
S_INCREMENT = 51, // "++"
S_DECREMENT = 52, // "--"
S_LSHIFT = 53, // "<<"
S_RSHIFT = 54, // ">>"
S_OR = 55, // "||"
S_AND = 56, // "&&"
S_EQUALITY = 57, // "=="
S_INEQUALITY = 58, // "!="
S_LESS_EQUAL = 59, // "<="
S_GREATER_EQUAL = 60, // ">="
S_LESS = 61, // "<"
S_GREATER = 62, // ">"
S_NOT = 63, // "!"
S_COMPLEMENT = 64, // "~"
S_ASSIGN = 65, // "="
S_ASSIGN_ADD = 66, // "+="
S_ASSIGN_SUB = 67, // "-="
S_ASSIGN_MULT = 68, // "*="
S_ASSIGN_DIV = 69, // "/="
S_ASSIGN_MOD = 70, // "%="
S_ASSIGN_BITWISE_OR = 71, // "|="
S_ASSIGN_BITWISE_AND = 72, // "&="
S_ASSIGN_BITWISE_EXOR = 73, // "^="
S_ASSIGN_RSHIFT = 74, // ">>="
S_ASSIGN_LSHIFT = 75, // "<<="
S_BITWISE_OR = 76, // "|"
S_BITWISE_AND = 77, // "&"
S_BITWISE_EXOR = 78, // "^"
S_ADD = 79, // "+"
S_SUB = 80, // "-"
S_MULT = 81, // "*"
S_DIV = 82, // "/"
S_MOD = 83, // "%"
S_FILE = 84, // "file path"
S_NAME = 85, // "identifier"
S_STRING = 86, // "string literal"
S_ISTRING = 87, // "localized string"
S_FLOAT = 88, // "float"
S_INTEGER = 89, // "int"
S_ADD_ARRAY = 90, // ADD_ARRAY
S_THEN = 91, // THEN
S_TERN = 92, // TERN
S_NEG = 93, // NEG
S_ANIMREF = 94, // ANIMREF
S_PREINC = 95, // PREINC
S_PREDEC = 96, // PREDEC
S_POSTINC = 97, // POSTINC
S_POSTDEC = 98, // POSTDEC
S_YYACCEPT = 99, // $accept
S_root = 100, // root
S_program = 101, // program
S_include = 102, // include
S_define = 103, // define
S_usingtree = 104, // usingtree
S_constant = 105, // constant
S_thread = 106, // thread
S_parameters = 107, // parameters
S_stmt = 108, // stmt
S_stmt_block = 109, // stmt_block
S_stmt_list = 110, // stmt_list
S_stmt_call = 111, // stmt_call
S_stmt_assign = 112, // stmt_assign
S_stmt_endon = 113, // stmt_endon
S_stmt_notify = 114, // stmt_notify
S_stmt_wait = 115, // stmt_wait
S_stmt_waittill = 116, // stmt_waittill
S_stmt_waittillmatch = 117, // stmt_waittillmatch
S_stmt_waittillframeend = 118, // stmt_waittillframeend
S_stmt_if = 119, // stmt_if
S_stmt_ifelse = 120, // stmt_ifelse
S_stmt_while = 121, // stmt_while
S_stmt_for = 122, // stmt_for
S_stmt_foreach = 123, // stmt_foreach
S_stmt_switch = 124, // stmt_switch
S_stmt_case = 125, // stmt_case
S_stmt_default = 126, // stmt_default
S_stmt_break = 127, // stmt_break
S_stmt_continue = 128, // stmt_continue
S_stmt_return = 129, // stmt_return
S_stmt_breakpoint = 130, // stmt_breakpoint
S_stmt_prof_begin = 131, // stmt_prof_begin
S_stmt_prof_end = 132, // stmt_prof_end
S_for_stmt = 133, // for_stmt
S_for_expr = 134, // for_expr
S_expr = 135, // expr
S_expr_assign = 136, // expr_assign
S_expr_compare = 137, // expr_compare
S_expr_ternary = 138, // expr_ternary
S_expr_binary = 139, // expr_binary
S_expr_primitive = 140, // expr_primitive
S_expr_call = 141, // expr_call
S_expr_call_thread = 142, // expr_call_thread
S_expr_call_childthread = 143, // expr_call_childthread
S_expr_call_function = 144, // expr_call_function
S_expr_call_pointer = 145, // expr_call_pointer
S_expr_arguments = 146, // expr_arguments
S_expr_arguments_filled = 147, // expr_arguments_filled
S_expr_arguments_empty = 148, // expr_arguments_empty
S_expr_function = 149, // expr_function
S_expr_add_array = 150, // expr_add_array
S_expr_array = 151, // expr_array
S_expr_field = 152, // expr_field
S_expr_size = 153, // expr_size
S_object = 154, // object
S_thisthread = 155, // thisthread
S_empty_array = 156, // empty_array
S_undefined = 157, // undefined
S_game = 158, // game
S_self = 159, // self
S_anim = 160, // anim
S_level = 161, // level
S_animation = 162, // animation
S_animtree = 163, // animtree
S_name = 164, // name
S_file = 165, // file
S_istring = 166, // istring
S_string = 167, // string
S_vector = 168, // vector
S_neg_float = 169, // neg_float
S_neg_integer = 170, // neg_integer
S_float = 171, // float
S_integer = 172, // integer
S_false = 173, // false
S_true = 174 // true
};
};
@ -1017,6 +1023,7 @@ namespace xsk { namespace gsc { namespace iw5 {
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (std::move (that.value));
@ -2093,6 +2100,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.template destroy< expr_ptr > ();
@ -3198,6 +3206,21 @@ switch (yykind)
return symbol_type (token::SEMICOLON, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_QMARK (location_type l)
{
return symbol_type (token::QMARK, std::move (l));
}
#else
static
symbol_type
make_QMARK (const location_type& l)
{
return symbol_type (token::QMARK, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -3813,6 +3836,21 @@ switch (yykind)
return symbol_type (token::THEN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_TERN (location_type l)
{
return symbol_type (token::TERN, std::move (l));
}
#else
static
symbol_type
make_TERN (const location_type& l)
{
return symbol_type (token::TERN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4247,8 +4285,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 1556, ///< Last index in yytable_.
yynnts_ = 75, ///< Number of nonterminal symbols.
yylast_ = 1892, ///< Last index in yytable_.
yynnts_ = 76, ///< Number of nonterminal symbols.
yyfinal_ = 15 ///< Termination state number.
};
@ -4324,6 +4362,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.copy< expr_ptr > (YY_MOVE (that.value));
@ -4600,6 +4639,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (YY_MOVE (s.value));
@ -4862,7 +4902,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw5
#line 4866 "parser.hpp"
#line 4906 "parser.hpp"

View File

@ -115,7 +115,6 @@ void assembler::assemble(const std::string& file, std::vector<gsc::function_ptr>
functions_ = std::move(functions);
script_->write<std::uint8_t>(static_cast<std::uint8_t>(opcode::OP_End));
stack_->write<std::uint32_t>(0x69773630);
for (const auto& func : functions_)
{

View File

@ -403,7 +403,7 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -459,7 +459,7 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -534,7 +534,7 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -746,6 +746,7 @@ void compiler::emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
{
switch(expr.as_node->type)
{
case gsc::node_t::expr_ternary: emit_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: emit_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: emit_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: emit_expr_binary(ctx, expr.as_binary); break;
@ -843,6 +844,30 @@ void compiler::emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_ass
}
}
void compiler::emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
auto else_loc = create_label();
auto end_loc = create_label();
if(expr->cond.as_node->type == gsc::node_t::expr_not)
{
emit_expr(ctx, expr->cond.as_not->rvalue);
emit_opcode(ctx, opcode::OP_JumpOnTrue, else_loc);
}
else
{
emit_expr(ctx, expr->cond);
emit_opcode(ctx, opcode::OP_JumpOnFalse, else_loc);
}
emit_expr(ctx, expr->lvalue);
emit_opcode(ctx, opcode::OP_jump, end_loc);
insert_label(else_loc);
emit_expr(ctx, expr->rvalue);
insert_label(end_loc);
}
void compiler::emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
emit_expr(ctx, expr->lvalue);

View File

@ -67,6 +67,7 @@ private:
void emit_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr);
void emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
void emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void emit_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void emit_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -96,6 +96,14 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
decompile_expr();
}
}
for(auto& entry : tern_labels_)
{
if(entry == itr->second)
{
decompile_ternary();
}
}
}
switch (opcode(inst->opcode))
@ -1827,6 +1835,7 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
{
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1910,6 +1919,29 @@ void decompiler::decompile_expr()
}
}
void decompiler::decompile_ternary()
{
auto rvalue = std::move(stack_.top());
stack_.pop();
auto lvalue = std::move(stack_.top());
stack_.pop();
func_->block->stmts.pop_back();
auto stmt = std::move(func_->block->stmts.back());
func_->block->stmts.pop_back();
if(stmt.as_node->type == node_t::asm_jump_cond)
{
auto loc = stmt.as_cond->loc;
auto e = std::make_unique<gsc::node_expr_ternary>(loc, std::move(stmt.as_cond->expr), std::move(lvalue), std::move(rvalue));
stack_.push(std::move(e));
}
else
{
throw gsc::decomp_error("TRIED TO DECOMPILE INVALID TERNARY EXPR!");
}
}
void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
{
this->decompile_search_infinite(block);
@ -3000,6 +3032,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
case gsc::node_t::expr_assign_bitwise_or: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_and: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_exor: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_ternary: process_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: process_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: process_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: process_expr_binary(ctx, expr.as_binary); break;
@ -3100,6 +3133,13 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assi
}
}
void decompiler::process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
process_expr(ctx, expr->cond);
process_expr(ctx, expr->lvalue);
process_expr(ctx, expr->rvalue);
}
void decompiler::process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
process_expr(ctx, expr->lvalue);

View File

@ -16,6 +16,7 @@ class decompiler : public gsc::decompiler
gsc::thread_ptr func_;
std::unordered_map<std::uint32_t, std::string> labels_;
std::vector<std::string> expr_labels_;
std::vector<std::string> tern_labels_;
std::stack<gsc::node_ptr> stack_;
std::vector<gsc::context> blocks_;
@ -27,6 +28,7 @@ private:
void decompile_function(const gsc::function_ptr& func);
void decompile_statements(const gsc::function_ptr& func);
void decompile_expr();
void decompile_ternary();
void decompile_block(const gsc::stmt_list_ptr& block);
void decompile_search_infinite(const gsc::stmt_list_ptr& block);
void decompile_search_loop(const gsc::stmt_list_ptr& block);
@ -68,6 +70,7 @@ private:
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
void process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -553,8 +553,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 99
#define YY_END_OF_BUFFER 100
#define YY_NUM_RULES 100
#define YY_END_OF_BUFFER 101
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -562,40 +562,40 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[300] =
static const flex_int16_t yy_accept[301] =
{ 0,
0, 0, 0, 0, 0, 0, 100, 98, 1, 2,
87, 98, 98, 86, 90, 98, 48, 49, 84, 82,
54, 83, 55, 85, 97, 57, 58, 71, 81, 72,
93, 52, 53, 91, 93, 93, 93, 93, 93, 93,
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
50, 89, 51, 88, 5, 6, 5, 9, 10, 9,
68, 0, 95, 0, 0, 0, 0, 77, 0, 66,
0, 79, 0, 0, 75, 59, 73, 60, 74, 96,
0, 8, 4, 3, 76, 96, 97, 0, 0, 56,
63, 69, 67, 70, 64, 93, 80, 93, 93, 93,
0, 0, 0, 0, 0, 0, 101, 99, 1, 2,
88, 99, 99, 87, 91, 99, 48, 49, 85, 83,
54, 84, 55, 86, 98, 57, 58, 72, 82, 73,
59, 94, 52, 53, 92, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 50, 90, 51, 89, 5, 6, 5, 9, 10,
9, 69, 0, 96, 0, 0, 0, 0, 78, 0,
67, 0, 80, 0, 0, 76, 60, 74, 61, 75,
97, 0, 8, 4, 3, 77, 97, 98, 0, 0,
56, 64, 70, 68, 71, 65, 94, 81, 94, 94,
93, 93, 93, 93, 93, 93, 93, 93, 24, 29,
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
93, 78, 65, 7, 11, 0, 95, 0, 0, 0,
0, 0, 94, 0, 0, 0, 0, 95, 0, 96,
0, 3, 96, 96, 92, 61, 62, 93, 93, 93,
93, 93, 93, 93, 93, 93, 93, 27, 93, 93,
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
93, 0, 0, 0, 0, 94, 0, 0, 94, 0,
0, 46, 93, 39, 31, 93, 93, 93, 25, 93,
93, 93, 44, 93, 93, 93, 93, 45, 93, 93,
94, 94, 94, 94, 94, 94, 94, 94, 94, 24,
29, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 79, 66, 7, 11, 0, 96, 0, 0,
0, 0, 0, 95, 0, 0, 0, 0, 96, 0,
97, 0, 3, 97, 97, 93, 62, 63, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 27, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 0, 0, 0, 0, 95, 0, 0, 95,
0, 0, 46, 94, 39, 31, 94, 94, 94, 25,
94, 94, 94, 44, 94, 94, 94, 94, 45, 94,
93, 40, 93, 20, 93, 0, 0, 0, 43, 33,
93, 93, 93, 18, 41, 93, 47, 93, 93, 93,
93, 93, 93, 93, 93, 26, 0, 0, 0, 93,
93, 93, 93, 93, 19, 93, 93, 35, 30, 93,
36, 93, 93, 0, 0, 0, 93, 93, 93, 32,
28, 93, 93, 93, 93, 93, 0, 15, 0, 93,
93, 34, 93, 14, 93, 93, 21, 17, 0, 93,
93, 93, 93, 42, 93, 93, 0, 12, 93, 13,
38, 93, 93, 0, 37, 93, 93, 0, 93, 93,
0, 93, 22, 0, 93, 16, 93, 23, 0
94, 94, 40, 94, 20, 94, 0, 0, 0, 43,
33, 94, 94, 94, 18, 41, 94, 47, 94, 94,
94, 94, 94, 94, 94, 94, 26, 0, 0, 0,
94, 94, 94, 94, 94, 19, 94, 94, 35, 30,
94, 36, 94, 94, 0, 0, 0, 94, 94, 94,
32, 28, 94, 94, 94, 94, 94, 0, 15, 0,
94, 94, 34, 94, 14, 94, 94, 21, 17, 0,
94, 94, 94, 94, 42, 94, 94, 0, 12, 94,
13, 38, 94, 94, 0, 37, 94, 94, 0, 94,
94, 0, 94, 22, 0, 94, 16, 94, 23, 0
} ;
@ -607,14 +607,14 @@ static const YY_CHAR yy_ec[256] =
1, 2, 4, 5, 6, 1, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 19, 20, 21,
22, 23, 1, 1, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 26, 27, 28, 29, 1, 30, 31, 32, 33,
22, 23, 24, 1, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 27, 28, 29, 30, 1, 31, 32, 33, 34,
34, 35, 36, 37, 38, 24, 39, 40, 41, 42,
43, 44, 24, 45, 46, 47, 48, 49, 50, 24,
51, 52, 53, 54, 55, 56, 1, 1, 1, 1,
35, 36, 37, 38, 39, 25, 40, 41, 42, 43,
44, 45, 25, 46, 47, 48, 49, 50, 51, 25,
52, 53, 54, 55, 56, 57, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -631,238 +631,238 @@ static const YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
static const YY_CHAR yy_meta[57] =
static const YY_CHAR yy_meta[58] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 4, 1, 1,
1, 1, 1, 4, 1, 5, 1, 1, 4, 4,
1, 1, 1, 1, 4, 1, 5, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1
4, 4, 4, 1, 1, 1, 1
} ;
static const flex_int16_t yy_base[314] =
static const flex_int16_t yy_base[315] =
{ 0,
0, 0, 54, 55, 56, 57, 564, 565, 565, 565,
541, 56, 35, 540, 63, 55, 565, 565, 539, 56,
565, 55, 56, 74, 71, 541, 565, 54, 537, 70,
532, 565, 565, 535, 53, 58, 64, 72, 73, 74,
79, 84, 82, 85, 86, 88, 95, 97, 94, 107,
565, 96, 565, 565, 565, 565, 539, 565, 565, 538,
565, 120, 565, 127, 512, 511, 506, 565, 122, 565,
115, 565, 126, 140, 565, 565, 565, 565, 565, 120,
513, 565, 565, 0, 565, 121, 141, 135, 0, 565,
528, 565, 565, 565, 527, 522, 565, 132, 128, 134,
0, 0, 55, 56, 57, 58, 565, 566, 566, 566,
542, 57, 34, 541, 66, 60, 566, 566, 540, 57,
566, 63, 48, 74, 74, 542, 566, 55, 538, 59,
566, 532, 566, 566, 536, 62, 66, 71, 72, 67,
73, 87, 70, 76, 89, 92, 93, 94, 96, 97,
99, 566, 100, 566, 566, 566, 566, 540, 566, 566,
539, 566, 120, 566, 136, 512, 511, 506, 566, 122,
566, 123, 566, 126, 143, 566, 566, 566, 566, 566,
118, 513, 566, 566, 0, 566, 125, 140, 132, 0,
566, 529, 566, 566, 566, 528, 522, 566, 130, 133,
137, 139, 138, 142, 114, 143, 145, 146, 521, 520,
150, 151, 152, 153, 156, 159, 163, 158, 160, 165,
166, 565, 565, 565, 565, 189, 197, 202, 507, 512,
505, 204, 565, 207, 205, 208, 209, 210, 213, 565,
490, 0, 202, 565, 515, 565, 565, 199, 212, 187,
195, 206, 198, 217, 215, 218, 222, 224, 225, 226,
227, 228, 229, 231, 236, 230, 238, 241, 244, 243,
245, 499, 499, 496, 268, 269, 276, 271, 273, 283,
503, 510, 261, 509, 508, 258, 263, 262, 507, 270,
272, 277, 506, 278, 279, 282, 287, 505, 289, 290,
124, 135, 137, 139, 145, 149, 146, 150, 151, 521,
520, 152, 155, 154, 157, 158, 161, 162, 163, 170,
167, 168, 566, 566, 566, 566, 186, 204, 211, 507,
512, 505, 205, 566, 212, 202, 215, 210, 213, 217,
566, 490, 0, 205, 566, 515, 566, 566, 194, 203,
206, 200, 216, 198, 218, 221, 223, 224, 225, 226,
227, 231, 228, 232, 236, 238, 241, 239, 242, 248,
246, 249, 499, 499, 496, 273, 274, 277, 275, 276,
284, 503, 510, 104, 509, 508, 262, 268, 264, 507,
265, 270, 279, 506, 271, 282, 287, 288, 505, 289,
293, 504, 291, 294, 296, 482, 480, 491, 565, 298,
299, 301, 305, 500, 499, 302, 498, 303, 313, 307,
314, 322, 324, 326, 327, 497, 477, 488, 491, 312,
330, 310, 334, 335, 493, 336, 337, 492, 491, 340,
490, 342, 343, 481, 480, 483, 348, 345, 354, 486,
485, 351, 349, 363, 365, 352, 476, 565, 467, 367,
368, 482, 369, 481, 370, 372, 375, 565, 468, 377,
378, 380, 385, 466, 386, 387, 403, 417, 388, 416,
414, 389, 394, 389, 408, 397, 400, 331, 399, 402,
339, 401, 309, 259, 403, 565, 404, 200, 565, 445,
272, 292, 504, 294, 297, 298, 482, 480, 491, 566,
299, 300, 304, 301, 500, 499, 302, 498, 305, 311,
309, 312, 313, 322, 314, 327, 497, 477, 488, 491,
328, 331, 310, 333, 335, 493, 336, 334, 492, 491,
337, 490, 341, 338, 481, 480, 483, 343, 340, 353,
486, 485, 348, 360, 362, 363, 351, 476, 566, 467,
364, 366, 482, 369, 481, 368, 375, 376, 566, 455,
373, 379, 377, 388, 419, 378, 386, 403, 417, 389,
416, 414, 398, 384, 392, 412, 392, 400, 368, 401,
399, 341, 403, 347, 193, 404, 566, 408, 159, 566,
450, 455, 460, 463, 465, 470, 475, 480, 485, 490,
84, 495, 500
447, 452, 457, 462, 465, 467, 472, 477, 482, 487,
492, 68, 497, 502
} ;
static const flex_int16_t yy_def[314] =
static const flex_int16_t yy_def[315] =
{ 0,
299, 1, 300, 300, 301, 301, 299, 299, 299, 299,
299, 302, 299, 299, 299, 303, 299, 299, 299, 299,
299, 299, 299, 299, 304, 299, 299, 299, 299, 299,
305, 299, 299, 299, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 302, 299, 306, 299, 299, 299, 299, 307, 299,
308, 299, 303, 309, 299, 299, 299, 299, 299, 299,
299, 299, 299, 310, 299, 299, 304, 304, 311, 299,
299, 299, 299, 299, 299, 305, 299, 305, 305, 305,
300, 1, 301, 301, 302, 302, 300, 300, 300, 300,
300, 303, 300, 300, 300, 304, 300, 300, 300, 300,
300, 300, 300, 300, 305, 300, 300, 300, 300, 300,
300, 306, 300, 300, 300, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 303, 300, 307, 300, 300, 300, 300, 308,
300, 309, 300, 304, 310, 300, 300, 300, 300, 300,
300, 300, 300, 300, 311, 300, 300, 305, 305, 312,
300, 300, 300, 300, 300, 300, 306, 300, 306, 306,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 299, 299, 299, 299, 302, 302, 306, 299, 299,
299, 307, 299, 312, 308, 313, 303, 303, 309, 299,
299, 310, 299, 299, 311, 299, 299, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 299, 299, 299, 307, 307, 312, 308, 308, 313,
299, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 300, 300, 300, 300, 303, 303, 307, 300,
300, 300, 308, 300, 313, 309, 314, 304, 304, 310,
300, 300, 311, 300, 300, 312, 300, 300, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 300, 300, 300, 308, 308, 313, 309, 309,
314, 300, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
305, 305, 305, 305, 305, 299, 299, 299, 299, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 299, 299, 299, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 299, 299, 299, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 299, 299, 299, 305,
305, 305, 305, 305, 305, 305, 305, 299, 299, 305,
305, 305, 305, 305, 305, 305, 299, 305, 305, 305,
305, 305, 305, 299, 305, 305, 305, 299, 305, 305,
299, 305, 305, 299, 305, 299, 305, 305, 0, 299,
306, 306, 306, 306, 306, 306, 300, 300, 300, 300,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 300, 300, 300,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 300, 300, 300, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 300, 300, 300,
306, 306, 306, 306, 306, 306, 306, 306, 300, 300,
306, 306, 306, 306, 306, 306, 306, 300, 306, 306,
306, 306, 306, 306, 300, 306, 306, 306, 300, 306,
306, 300, 306, 306, 300, 306, 300, 306, 306, 0,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300
} ;
static const flex_int16_t yy_nxt[622] =
static const flex_int16_t yy_nxt[624] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 8, 33, 34, 31, 35,
36, 37, 38, 39, 40, 41, 31, 42, 31, 43,
31, 44, 31, 45, 46, 47, 48, 49, 31, 50,
31, 31, 51, 52, 53, 54, 56, 56, 59, 59,
63, 60, 60, 63, 65, 57, 57, 69, 76, 78,
70, 71, 66, 80, 91, 92, 79, 77, 89, 82,
74, 64, 67, 89, 72, 83, 86, 145, 87, 89,
84, 94, 95, 100, 98, 85, 89, 89, 89, 89,
28, 29, 30, 31, 32, 33, 8, 34, 35, 32,
36, 37, 38, 39, 40, 41, 42, 32, 43, 32,
44, 32, 45, 32, 46, 47, 48, 49, 50, 32,
51, 32, 32, 52, 53, 54, 55, 57, 57, 60,
60, 64, 61, 61, 66, 81, 58, 58, 64, 77,
70, 146, 67, 71, 72, 92, 93, 79, 78, 83,
95, 96, 68, 65, 80, 84, 75, 73, 90, 87,
85, 88, 90, 90, 82, 86, 90, 90, 90, 90,
101, 81, 99, 106, 89, 103, 102, 89, 108, 89,
89, 89, 104, 89, 105, 111, 107, 122, 109, 89,
89, 114, 89, 133, 63, 110, 133, 112, 115, 62,
113, 127, 89, 117, 63, 119, 120, 80, 143, 89,
136, 118, 73, 121, 116, 64, 156, 134, 138, 123,
299, 74, 128, 89, 140, 144, 86, 89, 87, 89,
89, 149, 89, 89, 89, 139, 89, 89, 89, 148,
89, 89, 154, 150, 152, 89, 89, 89, 89, 151,
153, 89, 157, 89, 89, 89, 159, 155, 89, 158,
89, 89, 169, 63, 162, 164, 165, 161, 160, 163,
90, 101, 90, 107, 99, 110, 104, 105, 102, 106,
112, 100, 111, 90, 103, 90, 108, 109, 90, 90,
90, 123, 90, 90, 64, 90, 134, 115, 116, 121,
90, 134, 113, 118, 64, 81, 122, 114, 63, 120,
128, 119, 144, 211, 117, 74, 65, 300, 135, 137,
90, 139, 75, 141, 124, 87, 90, 88, 90, 90,
145, 90, 129, 90, 151, 90, 90, 150, 149, 140,
152, 90, 90, 153, 155, 90, 90, 90, 90, 154,
90, 90, 157, 90, 90, 90, 158, 90, 90, 90,
64, 156, 160, 90, 90, 159, 90, 163, 165, 166,
166, 63, 170, 171, 62, 168, 127, 167, 133, 132,
135, 176, 89, 133, 64, 73, 179, 63, 63, 143,
89, 138, 64, 89, 89, 89, 184, 128, 185, 134,
136, 89, 177, 180, 74, 74, 144, 89, 139, 182,
89, 183, 89, 89, 187, 186, 188, 89, 189, 89,
89, 89, 89, 89, 89, 89, 89, 192, 193, 194,
190, 89, 196, 89, 195, 198, 89, 191, 89, 89,
89, 201, 133, 133, 202, 200, 197, 203, 132, 133,
176, 133, 199, 89, 205, 135, 89, 89, 89, 204,
211, 179, 296, 134, 134, 89, 136, 89, 136, 210,
167, 161, 162, 170, 164, 171, 172, 168, 64, 134,
134, 169, 65, 63, 133, 128, 177, 136, 64, 74,
90, 64, 144, 180, 90, 139, 90, 297, 137, 90,
65, 135, 90, 184, 186, 183, 75, 129, 178, 75,
145, 181, 90, 140, 90, 188, 185, 90, 189, 90,
90, 90, 90, 90, 90, 190, 187, 90, 90, 193,
194, 195, 90, 197, 90, 90, 191, 90, 90, 196,
192, 199, 90, 202, 90, 90, 203, 134, 134, 133,
198, 177, 204, 134, 134, 200, 136, 201, 90, 206,
90, 90, 180, 205, 90, 212, 90, 90, 90, 135,
212, 177, 89, 89, 89, 215, 216, 89, 180, 213,
219, 214, 89, 218, 89, 89, 89, 217, 89, 89,
221, 89, 223, 89, 89, 224, 89, 89, 89, 226,
89, 220, 89, 234, 89, 89, 222, 89, 89, 89,
225, 230, 232, 236, 233, 231, 237, 89, 238, 89,
239, 89, 89, 235, 247, 89, 241, 249, 240, 89,
89, 89, 89, 242, 243, 89, 248, 89, 89, 252,
89, 251, 294, 89, 89, 291, 89, 89, 253, 89,
250, 264, 256, 255, 254, 260, 263, 262, 89, 261,
89, 267, 89, 89, 89, 89, 265, 89, 266, 273,
135, 137, 137, 178, 216, 90, 213, 215, 90, 217,
181, 218, 214, 90, 90, 90, 220, 219, 90, 223,
90, 222, 224, 90, 90, 90, 90, 90, 90, 225,
90, 90, 227, 221, 235, 90, 90, 90, 90, 90,
90, 234, 237, 231, 226, 238, 233, 232, 90, 240,
241, 239, 243, 90, 90, 242, 236, 90, 250, 90,
90, 90, 90, 90, 90, 244, 90, 90, 249, 90,
253, 248, 252, 90, 90, 295, 254, 90, 257, 90,
251, 261, 255, 256, 264, 262, 90, 263, 90, 90,
90, 268, 90, 265, 90, 90, 266, 267, 274, 90,
89, 271, 89, 89, 274, 89, 272, 279, 270, 275,
89, 89, 89, 89, 89, 276, 283, 281, 286, 89,
285, 280, 89, 278, 89, 89, 89, 89, 89, 89,
282, 290, 292, 89, 295, 288, 298, 289, 293, 89,
287, 89, 89, 284, 297, 55, 55, 55, 55, 55,
58, 58, 58, 58, 58, 62, 62, 62, 62, 62,
73, 73, 73, 73, 73, 88, 88, 88, 96, 96,
126, 126, 126, 126, 126, 132, 132, 132, 132, 132,
135, 135, 135, 135, 135, 137, 137, 137, 137, 137,
142, 89, 142, 142, 142, 175, 175, 175, 175, 175,
272, 90, 90, 90, 90, 90, 271, 273, 275, 280,
90, 276, 90, 292, 90, 90, 284, 277, 90, 281,
279, 282, 286, 283, 90, 90, 90, 90, 287, 90,
90, 288, 291, 290, 90, 293, 294, 296, 90, 289,
90, 299, 90, 90, 285, 90, 298, 56, 56, 56,
56, 56, 59, 59, 59, 59, 59, 63, 63, 63,
63, 63, 74, 74, 74, 74, 74, 89, 89, 89,
97, 97, 127, 127, 127, 127, 127, 133, 133, 133,
133, 133, 136, 136, 136, 136, 136, 138, 138, 138,
138, 138, 143, 278, 143, 143, 143, 176, 176, 176,
178, 178, 178, 178, 178, 277, 89, 89, 269, 268,
89, 89, 259, 258, 257, 89, 89, 89, 89, 246,
245, 244, 89, 89, 89, 89, 229, 228, 227, 89,
89, 89, 89, 89, 89, 89, 209, 208, 207, 206,
89, 181, 174, 173, 172, 89, 89, 89, 147, 146,
141, 131, 130, 129, 125, 124, 97, 89, 93, 90,
75, 68, 61, 299, 7, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
176, 176, 179, 179, 179, 179, 179, 90, 90, 270,
269, 90, 90, 260, 259, 258, 90, 90, 90, 90,
247, 246, 245, 90, 90, 90, 90, 230, 229, 228,
90, 90, 90, 90, 90, 90, 90, 210, 209, 208,
207, 90, 182, 175, 174, 173, 90, 90, 90, 148,
147, 142, 132, 131, 130, 126, 125, 98, 90, 94,
91, 76, 69, 62, 300, 7, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300
} ;
static const flex_int16_t yy_chk[622] =
static const flex_int16_t yy_chk[624] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 4, 5, 6,
12, 5, 6, 16, 13, 3, 4, 15, 20, 22,
15, 15, 13, 23, 28, 28, 22, 20, 35, 24,
16, 12, 13, 36, 15, 24, 25, 311, 25, 37,
24, 30, 30, 37, 35, 24, 25, 38, 39, 40,
1, 1, 1, 1, 1, 1, 1, 3, 4, 5,
6, 12, 5, 6, 13, 23, 3, 4, 16, 20,
15, 312, 13, 15, 15, 28, 28, 22, 20, 24,
30, 30, 13, 12, 22, 24, 16, 15, 36, 25,
24, 25, 37, 40, 23, 24, 43, 38, 39, 41,
37, 23, 36, 40, 41, 38, 37, 43, 41, 42,
44, 45, 39, 46, 39, 43, 40, 52, 42, 49,
47, 46, 48, 71, 62, 42, 69, 44, 47, 64,
45, 64, 50, 48, 73, 49, 50, 80, 86, 105,
71, 48, 74, 50, 47, 62, 105, 69, 74, 52,
88, 73, 64, 99, 80, 86, 87, 98, 87, 100,
88, 99, 101, 103, 102, 74, 87, 104, 106, 98,
107, 108, 103, 100, 101, 111, 112, 113, 114, 100,
102, 115, 106, 118, 116, 119, 108, 104, 117, 107,
120, 121, 119, 126, 113, 115, 116, 112, 111, 114,
25, 38, 44, 41, 36, 43, 39, 40, 38, 40,
44, 37, 43, 42, 38, 45, 41, 42, 46, 47,
48, 53, 49, 50, 63, 51, 70, 47, 48, 51,
184, 72, 45, 49, 74, 81, 51, 46, 65, 50,
65, 49, 87, 184, 48, 75, 63, 89, 70, 72,
101, 75, 74, 81, 53, 88, 99, 88, 89, 100,
87, 102, 65, 103, 101, 104, 88, 100, 99, 75,
101, 105, 107, 102, 104, 106, 108, 109, 112, 103,
114, 113, 106, 115, 116, 299, 107, 117, 118, 119,
127, 105, 109, 121, 122, 108, 120, 114, 116, 117,
117, 127, 120, 121, 128, 118, 128, 117, 132, 134,
136, 134, 150, 135, 126, 139, 136, 137, 138, 143,
151, 139, 127, 153, 148, 298, 150, 128, 151, 132,
135, 152, 134, 136, 137, 138, 143, 149, 139, 148,
155, 149, 154, 156, 153, 152, 154, 157, 155, 158,
159, 160, 161, 162, 163, 166, 164, 158, 159, 160,
156, 165, 162, 167, 161, 164, 168, 157, 170, 169,
171, 167, 175, 176, 168, 166, 163, 169, 177, 178,
177, 179, 165, 186, 171, 180, 183, 188, 187, 170,
186, 180, 294, 175, 176, 190, 178, 191, 179, 183,
118, 112, 113, 120, 115, 121, 122, 118, 128, 133,
136, 119, 127, 129, 135, 129, 135, 137, 138, 140,
149, 139, 144, 137, 154, 140, 152, 295, 136, 150,
128, 133, 151, 150, 152, 149, 138, 129, 135, 139,
144, 137, 153, 140, 155, 154, 151, 156, 155, 157,
158, 159, 160, 161, 163, 156, 153, 162, 164, 159,
160, 161, 165, 163, 166, 168, 157, 167, 169, 162,
158, 165, 171, 168, 170, 172, 169, 176, 177, 178,
164, 178, 170, 179, 180, 166, 181, 167, 187, 172,
189, 191, 181, 171, 188, 187, 192, 195, 201, 176,
187, 177, 192, 194, 195, 191, 192, 196, 180, 188,
196, 190, 197, 195, 199, 200, 203, 194, 201, 204,
199, 205, 201, 210, 211, 203, 212, 216, 218, 205,
213, 197, 220, 216, 293, 232, 200, 230, 219, 221,
204, 210, 212, 219, 213, 211, 219, 222, 220, 223,
221, 224, 225, 218, 230, 231, 223, 232, 222, 233,
234, 236, 237, 224, 225, 240, 231, 242, 243, 236,
248, 234, 291, 247, 253, 288, 252, 256, 237, 249,
233, 253, 243, 242, 240, 247, 252, 249, 254, 248,
255, 256, 260, 261, 263, 265, 254, 266, 255, 265,
177, 179, 180, 178, 192, 193, 188, 191, 196, 193,
181, 195, 189, 197, 198, 200, 197, 196, 202, 201,
204, 200, 202, 205, 206, 211, 212, 214, 217, 204,
213, 219, 206, 198, 217, 221, 233, 220, 222, 223,
225, 214, 220, 211, 205, 220, 213, 212, 224, 222,
223, 221, 225, 226, 231, 224, 219, 232, 233, 234,
238, 235, 237, 241, 244, 226, 249, 243, 232, 248,
237, 231, 235, 294, 253, 292, 238, 257, 244, 250,
234, 248, 241, 243, 253, 249, 254, 250, 255, 256,
261, 257, 262, 254, 266, 264, 255, 256, 266, 271,
267, 261, 270, 271, 266, 272, 263, 271, 260, 267,
273, 275, 276, 279, 282, 267, 276, 273, 282, 283,
279, 272, 286, 270, 289, 287, 292, 290, 295, 297,
275, 287, 289, 285, 292, 284, 297, 286, 290, 281,
283, 280, 278, 277, 295, 300, 300, 300, 300, 300,
301, 301, 301, 301, 301, 302, 302, 302, 302, 302,
303, 303, 303, 303, 303, 304, 304, 304, 305, 305,
306, 306, 306, 306, 306, 307, 307, 307, 307, 307,
308, 308, 308, 308, 308, 309, 309, 309, 309, 309,
310, 274, 310, 310, 310, 312, 312, 312, 312, 312,
262, 267, 268, 273, 276, 272, 261, 264, 267, 272,
284, 268, 277, 289, 274, 280, 277, 268, 287, 273,
271, 274, 280, 276, 283, 291, 288, 290, 283, 293,
296, 284, 288, 287, 298, 290, 291, 293, 286, 285,
282, 298, 281, 279, 278, 275, 296, 301, 301, 301,
301, 301, 302, 302, 302, 302, 302, 303, 303, 303,
303, 303, 304, 304, 304, 304, 304, 305, 305, 305,
306, 306, 307, 307, 307, 307, 307, 308, 308, 308,
308, 308, 309, 309, 309, 309, 309, 310, 310, 310,
310, 310, 311, 270, 311, 311, 311, 313, 313, 313,
313, 313, 313, 313, 313, 269, 264, 262, 259, 257,
251, 250, 246, 245, 244, 241, 239, 238, 235, 229,
228, 227, 226, 217, 215, 214, 208, 207, 206, 202,
198, 193, 189, 185, 184, 182, 181, 174, 173, 172,
145, 141, 131, 130, 129, 110, 109, 96, 95, 91,
81, 67, 66, 65, 60, 57, 34, 31, 29, 26,
19, 14, 11, 7, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
313, 313, 314, 314, 314, 314, 314, 265, 263, 260,
258, 252, 251, 247, 246, 245, 242, 240, 239, 236,
230, 229, 228, 227, 218, 216, 215, 209, 208, 207,
203, 199, 194, 190, 186, 185, 183, 182, 175, 174,
173, 146, 142, 132, 131, 130, 111, 110, 97, 96,
92, 82, 68, 67, 66, 61, 58, 35, 32, 29,
26, 19, 14, 11, 7, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300
} ;
/* The intent behind this definition is that it'll catch
@ -1180,13 +1180,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 300 )
if ( yy_current_state >= 301 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_current_state != 299 );
while ( yy_current_state != 300 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1502,218 +1502,223 @@ YY_RULE_SETUP
case 59:
YY_RULE_SETUP
#line 106 "lexer.lpp"
{ return iw6::parser::make_INCREMENT(loc); }
{ return iw6::parser::make_QMARK(loc); }
YY_BREAK
case 60:
YY_RULE_SETUP
#line 107 "lexer.lpp"
{ return iw6::parser::make_DECREMENT(loc); }
{ return iw6::parser::make_INCREMENT(loc); }
YY_BREAK
case 61:
YY_RULE_SETUP
#line 108 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_LSHIFT(loc); }
{ return iw6::parser::make_DECREMENT(loc); }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 109 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_RSHIFT(loc); }
{ return iw6::parser::make_ASSIGN_LSHIFT(loc); }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 110 "lexer.lpp"
{ return iw6::parser::make_LSHIFT(loc); }
{ return iw6::parser::make_ASSIGN_RSHIFT(loc); }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 111 "lexer.lpp"
{ return iw6::parser::make_RSHIFT(loc); }
{ return iw6::parser::make_LSHIFT(loc); }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 112 "lexer.lpp"
{ return iw6::parser::make_OR(loc); }
{ return iw6::parser::make_RSHIFT(loc); }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 113 "lexer.lpp"
{ return iw6::parser::make_AND(loc); }
{ return iw6::parser::make_OR(loc); }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 114 "lexer.lpp"
{ return iw6::parser::make_EQUALITY(loc); }
{ return iw6::parser::make_AND(loc); }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 115 "lexer.lpp"
{ return iw6::parser::make_INEQUALITY(loc); }
{ return iw6::parser::make_EQUALITY(loc); }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 116 "lexer.lpp"
{ return iw6::parser::make_LESS_EQUAL(loc); }
{ return iw6::parser::make_INEQUALITY(loc); }
YY_BREAK
case 70:
YY_RULE_SETUP
#line 117 "lexer.lpp"
{ return iw6::parser::make_GREATER_EQUAL(loc); }
{ return iw6::parser::make_LESS_EQUAL(loc); }
YY_BREAK
case 71:
YY_RULE_SETUP
#line 118 "lexer.lpp"
{ return iw6::parser::make_LESS(loc); }
{ return iw6::parser::make_GREATER_EQUAL(loc); }
YY_BREAK
case 72:
YY_RULE_SETUP
#line 119 "lexer.lpp"
{ return iw6::parser::make_GREATER(loc); }
{ return iw6::parser::make_LESS(loc); }
YY_BREAK
case 73:
YY_RULE_SETUP
#line 120 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_ADD(loc); }
{ return iw6::parser::make_GREATER(loc); }
YY_BREAK
case 74:
YY_RULE_SETUP
#line 121 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_SUB(loc); }
{ return iw6::parser::make_ASSIGN_ADD(loc); }
YY_BREAK
case 75:
YY_RULE_SETUP
#line 122 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_MULT(loc); }
{ return iw6::parser::make_ASSIGN_SUB(loc); }
YY_BREAK
case 76:
YY_RULE_SETUP
#line 123 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_DIV(loc); }
{ return iw6::parser::make_ASSIGN_MULT(loc); }
YY_BREAK
case 77:
YY_RULE_SETUP
#line 124 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_MOD(loc); }
{ return iw6::parser::make_ASSIGN_DIV(loc); }
YY_BREAK
case 78:
YY_RULE_SETUP
#line 125 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_BITWISE_OR(loc); }
{ return iw6::parser::make_ASSIGN_MOD(loc); }
YY_BREAK
case 79:
YY_RULE_SETUP
#line 126 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_BITWISE_AND(loc); }
{ return iw6::parser::make_ASSIGN_BITWISE_OR(loc); }
YY_BREAK
case 80:
YY_RULE_SETUP
#line 127 "lexer.lpp"
{ return iw6::parser::make_ASSIGN_BITWISE_EXOR(loc); }
{ return iw6::parser::make_ASSIGN_BITWISE_AND(loc); }
YY_BREAK
case 81:
YY_RULE_SETUP
#line 128 "lexer.lpp"
{ return iw6::parser::make_ASSIGN(loc); }
{ return iw6::parser::make_ASSIGN_BITWISE_EXOR(loc); }
YY_BREAK
case 82:
YY_RULE_SETUP
#line 129 "lexer.lpp"
{ return iw6::parser::make_ADD(loc); }
{ return iw6::parser::make_ASSIGN(loc); }
YY_BREAK
case 83:
YY_RULE_SETUP
#line 130 "lexer.lpp"
{ return iw6::parser::make_SUB(loc); }
{ return iw6::parser::make_ADD(loc); }
YY_BREAK
case 84:
YY_RULE_SETUP
#line 131 "lexer.lpp"
{ return iw6::parser::make_MULT(loc); }
{ return iw6::parser::make_SUB(loc); }
YY_BREAK
case 85:
YY_RULE_SETUP
#line 132 "lexer.lpp"
{ return iw6::parser::make_DIV(loc); }
{ return iw6::parser::make_MULT(loc); }
YY_BREAK
case 86:
YY_RULE_SETUP
#line 133 "lexer.lpp"
{ return iw6::parser::make_MOD(loc); }
{ return iw6::parser::make_DIV(loc); }
YY_BREAK
case 87:
YY_RULE_SETUP
#line 134 "lexer.lpp"
{ return iw6::parser::make_NOT(loc); }
{ return iw6::parser::make_MOD(loc); }
YY_BREAK
case 88:
YY_RULE_SETUP
#line 135 "lexer.lpp"
{ return iw6::parser::make_COMPLEMENT(loc); }
{ return iw6::parser::make_NOT(loc); }
YY_BREAK
case 89:
YY_RULE_SETUP
#line 136 "lexer.lpp"
{ return iw6::parser::make_BITWISE_OR(loc); }
{ return iw6::parser::make_COMPLEMENT(loc); }
YY_BREAK
case 90:
YY_RULE_SETUP
#line 137 "lexer.lpp"
{ return iw6::parser::make_BITWISE_AND(loc); }
{ return iw6::parser::make_BITWISE_OR(loc); }
YY_BREAK
case 91:
YY_RULE_SETUP
#line 138 "lexer.lpp"
{ return iw6::parser::make_BITWISE_EXOR(loc); }
{ return iw6::parser::make_BITWISE_AND(loc); }
YY_BREAK
case 92:
YY_RULE_SETUP
#line 139 "lexer.lpp"
{ return iw6::parser::make_FILE(utils::string::fordslash(yytext), loc); }
{ return iw6::parser::make_BITWISE_EXOR(loc); }
YY_BREAK
case 93:
YY_RULE_SETUP
#line 140 "lexer.lpp"
{ return iw6::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
{ return iw6::parser::make_FILE(utils::string::fordslash(yytext), loc); }
YY_BREAK
case 94:
/* rule 94 can match eol */
YY_RULE_SETUP
#line 141 "lexer.lpp"
{ return iw6::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
{ return iw6::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
YY_BREAK
case 95:
/* rule 95 can match eol */
YY_RULE_SETUP
#line 142 "lexer.lpp"
{ return iw6::parser::make_STRING(std::string(yytext), loc); }
{ return iw6::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 143 "lexer.lpp"
{ return iw6::parser::make_FLOAT(std::string(yytext), loc); }
{ return iw6::parser::make_STRING(std::string(yytext), loc); }
YY_BREAK
case 97:
YY_RULE_SETUP
#line 144 "lexer.lpp"
{ return iw6::parser::make_FLOAT(std::string(yytext), loc); }
YY_BREAK
case 98:
YY_RULE_SETUP
#line 145 "lexer.lpp"
{ return iw6::parser::make_INTEGER(std::string(yytext), loc); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT_BLOCK_STATE):
case YY_STATE_EOF(DEVELOPER_BLOCK_STATE):
#line 145 "lexer.lpp"
#line 146 "lexer.lpp"
{ return iw6::parser::make_IW6EOF(loc); }
YY_BREAK
case 98:
/* rule 98 can match eol */
case 99:
/* rule 99 can match eol */
YY_RULE_SETUP
#line 146 "lexer.lpp"
#line 147 "lexer.lpp"
{ throw iw6::parser::syntax_error(loc, "bad token: \'" + std::string(yytext) + "\'"); }
YY_BREAK
case 99:
case 100:
YY_RULE_SETUP
#line 148 "lexer.lpp"
#line 149 "lexer.lpp"
ECHO;
YY_BREAK
#line 1716 "lexer.cpp"
#line 1721 "lexer.cpp"
case YY_END_OF_BUFFER:
{
@ -2011,7 +2016,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 300 )
if ( yy_current_state >= 301 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@ -2040,11 +2045,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 300 )
if ( yy_current_state >= 301 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 299);
yy_is_jam = (yy_current_state == 300);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@ -2843,6 +2848,6 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 148 "lexer.lpp"
#line 149 "lexer.lpp"

View File

@ -700,7 +700,7 @@ extern int yylex (yyscan_t yyscanner);
#undef yyTABLES_NAME
#endif
#line 148 "lexer.lpp"
#line 149 "lexer.lpp"
#line 706 "lexer.hpp"

File diff suppressed because it is too large Load Diff

View File

@ -446,6 +446,7 @@ namespace xsk { namespace gsc { namespace iw6 {
// for_expr
// expr
// expr_compare
// expr_ternary
// expr_binary
// expr_primitive
char dummy11[sizeof (expr_ptr)];
@ -696,53 +697,55 @@ namespace xsk { namespace gsc { namespace iw6 {
DOUBLECOLON = 47, // "::"
COLON = 48, // ":"
SEMICOLON = 49, // ";"
INCREMENT = 50, // "++"
DECREMENT = 51, // "--"
LSHIFT = 52, // "<<"
RSHIFT = 53, // ">>"
OR = 54, // "||"
AND = 55, // "&&"
EQUALITY = 56, // "=="
INEQUALITY = 57, // "!="
LESS_EQUAL = 58, // "<="
GREATER_EQUAL = 59, // ">="
LESS = 60, // "<"
GREATER = 61, // ">"
NOT = 62, // "!"
COMPLEMENT = 63, // "~"
ASSIGN = 64, // "="
ASSIGN_ADD = 65, // "+="
ASSIGN_SUB = 66, // "-="
ASSIGN_MULT = 67, // "*="
ASSIGN_DIV = 68, // "/="
ASSIGN_MOD = 69, // "%="
ASSIGN_BITWISE_OR = 70, // "|="
ASSIGN_BITWISE_AND = 71, // "&="
ASSIGN_BITWISE_EXOR = 72, // "^="
ASSIGN_RSHIFT = 73, // ">>="
ASSIGN_LSHIFT = 74, // "<<="
BITWISE_OR = 75, // "|"
BITWISE_AND = 76, // "&"
BITWISE_EXOR = 77, // "^"
ADD = 78, // "+"
SUB = 79, // "-"
MULT = 80, // "*"
DIV = 81, // "/"
MOD = 82, // "%"
FILE = 83, // "file path"
NAME = 84, // "identifier"
STRING = 85, // "string literal"
ISTRING = 86, // "localized string"
FLOAT = 87, // "float"
INTEGER = 88, // "int"
ADD_ARRAY = 89, // ADD_ARRAY
THEN = 90, // THEN
NEG = 91, // NEG
ANIMREF = 92, // ANIMREF
PREINC = 93, // PREINC
PREDEC = 94, // PREDEC
POSTINC = 95, // POSTINC
POSTDEC = 96 // POSTDEC
QMARK = 50, // "?"
INCREMENT = 51, // "++"
DECREMENT = 52, // "--"
LSHIFT = 53, // "<<"
RSHIFT = 54, // ">>"
OR = 55, // "||"
AND = 56, // "&&"
EQUALITY = 57, // "=="
INEQUALITY = 58, // "!="
LESS_EQUAL = 59, // "<="
GREATER_EQUAL = 60, // ">="
LESS = 61, // "<"
GREATER = 62, // ">"
NOT = 63, // "!"
COMPLEMENT = 64, // "~"
ASSIGN = 65, // "="
ASSIGN_ADD = 66, // "+="
ASSIGN_SUB = 67, // "-="
ASSIGN_MULT = 68, // "*="
ASSIGN_DIV = 69, // "/="
ASSIGN_MOD = 70, // "%="
ASSIGN_BITWISE_OR = 71, // "|="
ASSIGN_BITWISE_AND = 72, // "&="
ASSIGN_BITWISE_EXOR = 73, // "^="
ASSIGN_RSHIFT = 74, // ">>="
ASSIGN_LSHIFT = 75, // "<<="
BITWISE_OR = 76, // "|"
BITWISE_AND = 77, // "&"
BITWISE_EXOR = 78, // "^"
ADD = 79, // "+"
SUB = 80, // "-"
MULT = 81, // "*"
DIV = 82, // "/"
MOD = 83, // "%"
FILE = 84, // "file path"
NAME = 85, // "identifier"
STRING = 86, // "string literal"
ISTRING = 87, // "localized string"
FLOAT = 88, // "float"
INTEGER = 89, // "int"
ADD_ARRAY = 90, // ADD_ARRAY
THEN = 91, // THEN
TERN = 92, // TERN
NEG = 93, // NEG
ANIMREF = 94, // ANIMREF
PREINC = 95, // PREINC
PREDEC = 96, // PREDEC
POSTINC = 97, // POSTINC
POSTDEC = 98 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -759,7 +762,7 @@ namespace xsk { namespace gsc { namespace iw6 {
{
enum symbol_kind_type
{
YYNTOKENS = 97, ///< Number of tokens.
YYNTOKENS = 99, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
@ -811,128 +814,131 @@ namespace xsk { namespace gsc { namespace iw6 {
S_DOUBLECOLON = 47, // "::"
S_COLON = 48, // ":"
S_SEMICOLON = 49, // ";"
S_INCREMENT = 50, // "++"
S_DECREMENT = 51, // "--"
S_LSHIFT = 52, // "<<"
S_RSHIFT = 53, // ">>"
S_OR = 54, // "||"
S_AND = 55, // "&&"
S_EQUALITY = 56, // "=="
S_INEQUALITY = 57, // "!="
S_LESS_EQUAL = 58, // "<="
S_GREATER_EQUAL = 59, // ">="
S_LESS = 60, // "<"
S_GREATER = 61, // ">"
S_NOT = 62, // "!"
S_COMPLEMENT = 63, // "~"
S_ASSIGN = 64, // "="
S_ASSIGN_ADD = 65, // "+="
S_ASSIGN_SUB = 66, // "-="
S_ASSIGN_MULT = 67, // "*="
S_ASSIGN_DIV = 68, // "/="
S_ASSIGN_MOD = 69, // "%="
S_ASSIGN_BITWISE_OR = 70, // "|="
S_ASSIGN_BITWISE_AND = 71, // "&="
S_ASSIGN_BITWISE_EXOR = 72, // "^="
S_ASSIGN_RSHIFT = 73, // ">>="
S_ASSIGN_LSHIFT = 74, // "<<="
S_BITWISE_OR = 75, // "|"
S_BITWISE_AND = 76, // "&"
S_BITWISE_EXOR = 77, // "^"
S_ADD = 78, // "+"
S_SUB = 79, // "-"
S_MULT = 80, // "*"
S_DIV = 81, // "/"
S_MOD = 82, // "%"
S_FILE = 83, // "file path"
S_NAME = 84, // "identifier"
S_STRING = 85, // "string literal"
S_ISTRING = 86, // "localized string"
S_FLOAT = 87, // "float"
S_INTEGER = 88, // "int"
S_ADD_ARRAY = 89, // ADD_ARRAY
S_THEN = 90, // THEN
S_NEG = 91, // NEG
S_ANIMREF = 92, // ANIMREF
S_PREINC = 93, // PREINC
S_PREDEC = 94, // PREDEC
S_POSTINC = 95, // POSTINC
S_POSTDEC = 96, // POSTDEC
S_YYACCEPT = 97, // $accept
S_root = 98, // root
S_program = 99, // program
S_include = 100, // include
S_define = 101, // define
S_usingtree = 102, // usingtree
S_constant = 103, // constant
S_thread = 104, // thread
S_parameters = 105, // parameters
S_stmt = 106, // stmt
S_stmt_block = 107, // stmt_block
S_stmt_list = 108, // stmt_list
S_stmt_call = 109, // stmt_call
S_stmt_assign = 110, // stmt_assign
S_stmt_endon = 111, // stmt_endon
S_stmt_notify = 112, // stmt_notify
S_stmt_wait = 113, // stmt_wait
S_stmt_waittill = 114, // stmt_waittill
S_stmt_waittillmatch = 115, // stmt_waittillmatch
S_stmt_waittillframeend = 116, // stmt_waittillframeend
S_stmt_if = 117, // stmt_if
S_stmt_ifelse = 118, // stmt_ifelse
S_stmt_while = 119, // stmt_while
S_stmt_for = 120, // stmt_for
S_stmt_foreach = 121, // stmt_foreach
S_stmt_switch = 122, // stmt_switch
S_stmt_case = 123, // stmt_case
S_stmt_default = 124, // stmt_default
S_stmt_break = 125, // stmt_break
S_stmt_continue = 126, // stmt_continue
S_stmt_return = 127, // stmt_return
S_stmt_breakpoint = 128, // stmt_breakpoint
S_stmt_prof_begin = 129, // stmt_prof_begin
S_stmt_prof_end = 130, // stmt_prof_end
S_for_stmt = 131, // for_stmt
S_for_expr = 132, // for_expr
S_expr = 133, // expr
S_expr_assign = 134, // expr_assign
S_expr_compare = 135, // expr_compare
S_expr_binary = 136, // expr_binary
S_expr_primitive = 137, // expr_primitive
S_expr_call = 138, // expr_call
S_expr_call_thread = 139, // expr_call_thread
S_expr_call_childthread = 140, // expr_call_childthread
S_expr_call_function = 141, // expr_call_function
S_expr_call_pointer = 142, // expr_call_pointer
S_expr_arguments = 143, // expr_arguments
S_expr_arguments_filled = 144, // expr_arguments_filled
S_expr_arguments_empty = 145, // expr_arguments_empty
S_expr_function = 146, // expr_function
S_expr_add_array = 147, // expr_add_array
S_expr_array = 148, // expr_array
S_expr_field = 149, // expr_field
S_expr_size = 150, // expr_size
S_object = 151, // object
S_thisthread = 152, // thisthread
S_empty_array = 153, // empty_array
S_undefined = 154, // undefined
S_game = 155, // game
S_self = 156, // self
S_anim = 157, // anim
S_level = 158, // level
S_animation = 159, // animation
S_animtree = 160, // animtree
S_name = 161, // name
S_file = 162, // file
S_istring = 163, // istring
S_string = 164, // string
S_vector = 165, // vector
S_neg_float = 166, // neg_float
S_neg_integer = 167, // neg_integer
S_float = 168, // float
S_integer = 169, // integer
S_false = 170, // false
S_true = 171 // true
S_QMARK = 50, // "?"
S_INCREMENT = 51, // "++"
S_DECREMENT = 52, // "--"
S_LSHIFT = 53, // "<<"
S_RSHIFT = 54, // ">>"
S_OR = 55, // "||"
S_AND = 56, // "&&"
S_EQUALITY = 57, // "=="
S_INEQUALITY = 58, // "!="
S_LESS_EQUAL = 59, // "<="
S_GREATER_EQUAL = 60, // ">="
S_LESS = 61, // "<"
S_GREATER = 62, // ">"
S_NOT = 63, // "!"
S_COMPLEMENT = 64, // "~"
S_ASSIGN = 65, // "="
S_ASSIGN_ADD = 66, // "+="
S_ASSIGN_SUB = 67, // "-="
S_ASSIGN_MULT = 68, // "*="
S_ASSIGN_DIV = 69, // "/="
S_ASSIGN_MOD = 70, // "%="
S_ASSIGN_BITWISE_OR = 71, // "|="
S_ASSIGN_BITWISE_AND = 72, // "&="
S_ASSIGN_BITWISE_EXOR = 73, // "^="
S_ASSIGN_RSHIFT = 74, // ">>="
S_ASSIGN_LSHIFT = 75, // "<<="
S_BITWISE_OR = 76, // "|"
S_BITWISE_AND = 77, // "&"
S_BITWISE_EXOR = 78, // "^"
S_ADD = 79, // "+"
S_SUB = 80, // "-"
S_MULT = 81, // "*"
S_DIV = 82, // "/"
S_MOD = 83, // "%"
S_FILE = 84, // "file path"
S_NAME = 85, // "identifier"
S_STRING = 86, // "string literal"
S_ISTRING = 87, // "localized string"
S_FLOAT = 88, // "float"
S_INTEGER = 89, // "int"
S_ADD_ARRAY = 90, // ADD_ARRAY
S_THEN = 91, // THEN
S_TERN = 92, // TERN
S_NEG = 93, // NEG
S_ANIMREF = 94, // ANIMREF
S_PREINC = 95, // PREINC
S_PREDEC = 96, // PREDEC
S_POSTINC = 97, // POSTINC
S_POSTDEC = 98, // POSTDEC
S_YYACCEPT = 99, // $accept
S_root = 100, // root
S_program = 101, // program
S_include = 102, // include
S_define = 103, // define
S_usingtree = 104, // usingtree
S_constant = 105, // constant
S_thread = 106, // thread
S_parameters = 107, // parameters
S_stmt = 108, // stmt
S_stmt_block = 109, // stmt_block
S_stmt_list = 110, // stmt_list
S_stmt_call = 111, // stmt_call
S_stmt_assign = 112, // stmt_assign
S_stmt_endon = 113, // stmt_endon
S_stmt_notify = 114, // stmt_notify
S_stmt_wait = 115, // stmt_wait
S_stmt_waittill = 116, // stmt_waittill
S_stmt_waittillmatch = 117, // stmt_waittillmatch
S_stmt_waittillframeend = 118, // stmt_waittillframeend
S_stmt_if = 119, // stmt_if
S_stmt_ifelse = 120, // stmt_ifelse
S_stmt_while = 121, // stmt_while
S_stmt_for = 122, // stmt_for
S_stmt_foreach = 123, // stmt_foreach
S_stmt_switch = 124, // stmt_switch
S_stmt_case = 125, // stmt_case
S_stmt_default = 126, // stmt_default
S_stmt_break = 127, // stmt_break
S_stmt_continue = 128, // stmt_continue
S_stmt_return = 129, // stmt_return
S_stmt_breakpoint = 130, // stmt_breakpoint
S_stmt_prof_begin = 131, // stmt_prof_begin
S_stmt_prof_end = 132, // stmt_prof_end
S_for_stmt = 133, // for_stmt
S_for_expr = 134, // for_expr
S_expr = 135, // expr
S_expr_assign = 136, // expr_assign
S_expr_compare = 137, // expr_compare
S_expr_ternary = 138, // expr_ternary
S_expr_binary = 139, // expr_binary
S_expr_primitive = 140, // expr_primitive
S_expr_call = 141, // expr_call
S_expr_call_thread = 142, // expr_call_thread
S_expr_call_childthread = 143, // expr_call_childthread
S_expr_call_function = 144, // expr_call_function
S_expr_call_pointer = 145, // expr_call_pointer
S_expr_arguments = 146, // expr_arguments
S_expr_arguments_filled = 147, // expr_arguments_filled
S_expr_arguments_empty = 148, // expr_arguments_empty
S_expr_function = 149, // expr_function
S_expr_add_array = 150, // expr_add_array
S_expr_array = 151, // expr_array
S_expr_field = 152, // expr_field
S_expr_size = 153, // expr_size
S_object = 154, // object
S_thisthread = 155, // thisthread
S_empty_array = 156, // empty_array
S_undefined = 157, // undefined
S_game = 158, // game
S_self = 159, // self
S_anim = 160, // anim
S_level = 161, // level
S_animation = 162, // animation
S_animtree = 163, // animtree
S_name = 164, // name
S_file = 165, // file
S_istring = 166, // istring
S_string = 167, // string
S_vector = 168, // vector
S_neg_float = 169, // neg_float
S_neg_integer = 170, // neg_integer
S_float = 171, // float
S_integer = 172, // integer
S_false = 173, // false
S_true = 174 // true
};
};
@ -1017,6 +1023,7 @@ namespace xsk { namespace gsc { namespace iw6 {
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (std::move (that.value));
@ -2093,6 +2100,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.template destroy< expr_ptr > ();
@ -3198,6 +3206,21 @@ switch (yykind)
return symbol_type (token::SEMICOLON, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_QMARK (location_type l)
{
return symbol_type (token::QMARK, std::move (l));
}
#else
static
symbol_type
make_QMARK (const location_type& l)
{
return symbol_type (token::QMARK, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -3813,6 +3836,21 @@ switch (yykind)
return symbol_type (token::THEN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_TERN (location_type l)
{
return symbol_type (token::TERN, std::move (l));
}
#else
static
symbol_type
make_TERN (const location_type& l)
{
return symbol_type (token::TERN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4247,8 +4285,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 1591, ///< Last index in yytable_.
yynnts_ = 75, ///< Number of nonterminal symbols.
yylast_ = 1836, ///< Last index in yytable_.
yynnts_ = 76, ///< Number of nonterminal symbols.
yyfinal_ = 15 ///< Termination state number.
};
@ -4324,6 +4362,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.copy< expr_ptr > (YY_MOVE (that.value));
@ -4600,6 +4639,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (YY_MOVE (s.value));
@ -4862,7 +4902,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw6
#line 4866 "parser.hpp"
#line 4906 "parser.hpp"

View File

@ -115,7 +115,6 @@ void assembler::assemble(const std::string& file, std::vector<gsc::function_ptr>
functions_ = std::move(functions);
script_->write<std::uint8_t>(static_cast<std::uint8_t>(opcode::OP_End));
stack_->write<std::uint32_t>(0x69773630);
for (const auto& func : functions_)
{

View File

@ -403,7 +403,7 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -459,7 +459,7 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -534,7 +534,7 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -746,6 +746,7 @@ void compiler::emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
{
switch(expr.as_node->type)
{
case gsc::node_t::expr_ternary: emit_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: emit_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: emit_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: emit_expr_binary(ctx, expr.as_binary); break;
@ -843,6 +844,30 @@ void compiler::emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_ass
}
}
void compiler::emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
auto else_loc = create_label();
auto end_loc = create_label();
if(expr->cond.as_node->type == gsc::node_t::expr_not)
{
emit_expr(ctx, expr->cond.as_not->rvalue);
emit_opcode(ctx, opcode::OP_JumpOnTrue, else_loc);
}
else
{
emit_expr(ctx, expr->cond);
emit_opcode(ctx, opcode::OP_JumpOnFalse, else_loc);
}
emit_expr(ctx, expr->lvalue);
emit_opcode(ctx, opcode::OP_jump, end_loc);
insert_label(else_loc);
emit_expr(ctx, expr->rvalue);
insert_label(end_loc);
}
void compiler::emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
emit_expr(ctx, expr->lvalue);

View File

@ -67,6 +67,7 @@ private:
void emit_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr);
void emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
void emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void emit_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void emit_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -96,6 +96,14 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
decompile_expr();
}
}
for(auto& entry : tern_labels_)
{
if(entry == itr->second)
{
decompile_ternary();
}
}
}
switch (opcode(inst->opcode))
@ -1827,6 +1835,7 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
{
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1910,6 +1919,29 @@ void decompiler::decompile_expr()
}
}
void decompiler::decompile_ternary()
{
auto rvalue = std::move(stack_.top());
stack_.pop();
auto lvalue = std::move(stack_.top());
stack_.pop();
func_->block->stmts.pop_back();
auto stmt = std::move(func_->block->stmts.back());
func_->block->stmts.pop_back();
if(stmt.as_node->type == node_t::asm_jump_cond)
{
auto loc = stmt.as_cond->loc;
auto e = std::make_unique<gsc::node_expr_ternary>(loc, std::move(stmt.as_cond->expr), std::move(lvalue), std::move(rvalue));
stack_.push(std::move(e));
}
else
{
throw gsc::decomp_error("TRIED TO DECOMPILE INVALID TERNARY EXPR!");
}
}
void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
{
this->decompile_search_infinite(block);
@ -3000,6 +3032,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
case gsc::node_t::expr_assign_bitwise_or: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_and: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_exor: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_ternary: process_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: process_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: process_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: process_expr_binary(ctx, expr.as_binary); break;
@ -3100,6 +3133,13 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assi
}
}
void decompiler::process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
process_expr(ctx, expr->cond);
process_expr(ctx, expr->lvalue);
process_expr(ctx, expr->rvalue);
}
void decompiler::process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
process_expr(ctx, expr->lvalue);

View File

@ -16,6 +16,7 @@ class decompiler : public gsc::decompiler
gsc::thread_ptr func_;
std::unordered_map<std::uint32_t, std::string> labels_;
std::vector<std::string> expr_labels_;
std::vector<std::string> tern_labels_;
std::stack<gsc::node_ptr> stack_;
std::vector<gsc::context> blocks_;
@ -27,6 +28,7 @@ private:
void decompile_function(const gsc::function_ptr& func);
void decompile_statements(const gsc::function_ptr& func);
void decompile_expr();
void decompile_ternary();
void decompile_block(const gsc::stmt_list_ptr& block);
void decompile_search_infinite(const gsc::stmt_list_ptr& block);
void decompile_search_loop(const gsc::stmt_list_ptr& block);
@ -68,6 +70,7 @@ private:
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
void process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -553,8 +553,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 99
#define YY_END_OF_BUFFER 100
#define YY_NUM_RULES 100
#define YY_END_OF_BUFFER 101
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -562,40 +562,40 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[300] =
static const flex_int16_t yy_accept[301] =
{ 0,
0, 0, 0, 0, 0, 0, 100, 98, 1, 2,
87, 98, 98, 86, 90, 98, 48, 49, 84, 82,
54, 83, 55, 85, 97, 57, 58, 71, 81, 72,
93, 52, 53, 91, 93, 93, 93, 93, 93, 93,
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
50, 89, 51, 88, 5, 6, 5, 9, 10, 9,
68, 0, 95, 0, 0, 0, 0, 77, 0, 66,
0, 79, 0, 0, 75, 59, 73, 60, 74, 96,
0, 8, 4, 3, 76, 96, 97, 0, 0, 56,
63, 69, 67, 70, 64, 93, 80, 93, 93, 93,
0, 0, 0, 0, 0, 0, 101, 99, 1, 2,
88, 99, 99, 87, 91, 99, 48, 49, 85, 83,
54, 84, 55, 86, 98, 57, 58, 72, 82, 73,
59, 94, 52, 53, 92, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 50, 90, 51, 89, 5, 6, 5, 9, 10,
9, 69, 0, 96, 0, 0, 0, 0, 78, 0,
67, 0, 80, 0, 0, 76, 60, 74, 61, 75,
97, 0, 8, 4, 3, 77, 97, 98, 0, 0,
56, 64, 70, 68, 71, 65, 94, 81, 94, 94,
93, 93, 93, 93, 93, 93, 93, 93, 24, 29,
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
93, 78, 65, 7, 11, 0, 95, 0, 0, 0,
0, 0, 94, 0, 0, 0, 0, 95, 0, 96,
0, 3, 96, 96, 92, 61, 62, 93, 93, 93,
93, 93, 93, 93, 93, 93, 93, 27, 93, 93,
93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
93, 0, 0, 0, 0, 94, 0, 0, 94, 0,
0, 46, 93, 39, 31, 93, 93, 93, 25, 93,
93, 93, 44, 93, 93, 93, 93, 45, 93, 93,
94, 94, 94, 94, 94, 94, 94, 94, 94, 24,
29, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 79, 66, 7, 11, 0, 96, 0, 0,
0, 0, 0, 95, 0, 0, 0, 0, 96, 0,
97, 0, 3, 97, 97, 93, 62, 63, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 27, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 0, 0, 0, 0, 95, 0, 0, 95,
0, 0, 46, 94, 39, 31, 94, 94, 94, 25,
94, 94, 94, 44, 94, 94, 94, 94, 45, 94,
93, 40, 93, 20, 93, 0, 0, 0, 43, 33,
93, 93, 93, 18, 41, 93, 47, 93, 93, 93,
93, 93, 93, 93, 93, 26, 0, 0, 0, 93,
93, 93, 93, 93, 19, 93, 93, 35, 30, 93,
36, 93, 93, 0, 0, 0, 93, 93, 93, 32,
28, 93, 93, 93, 93, 93, 0, 15, 0, 93,
93, 34, 93, 14, 93, 93, 21, 17, 0, 93,
93, 93, 93, 42, 93, 93, 0, 12, 93, 13,
38, 93, 93, 0, 37, 93, 93, 0, 93, 93,
0, 93, 22, 0, 93, 16, 93, 23, 0
94, 94, 40, 94, 20, 94, 0, 0, 0, 43,
33, 94, 94, 94, 18, 41, 94, 47, 94, 94,
94, 94, 94, 94, 94, 94, 26, 0, 0, 0,
94, 94, 94, 94, 94, 19, 94, 94, 35, 30,
94, 36, 94, 94, 0, 0, 0, 94, 94, 94,
32, 28, 94, 94, 94, 94, 94, 0, 15, 0,
94, 94, 34, 94, 14, 94, 94, 21, 17, 0,
94, 94, 94, 94, 42, 94, 94, 0, 12, 94,
13, 38, 94, 94, 0, 37, 94, 94, 0, 94,
94, 0, 94, 22, 0, 94, 16, 94, 23, 0
} ;
@ -607,14 +607,14 @@ static const YY_CHAR yy_ec[256] =
1, 2, 4, 5, 6, 1, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 19, 20, 21,
22, 23, 1, 1, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 26, 27, 28, 29, 1, 30, 31, 32, 33,
22, 23, 24, 1, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 27, 28, 29, 30, 1, 31, 32, 33, 34,
34, 35, 36, 37, 38, 24, 39, 40, 41, 42,
43, 44, 24, 45, 46, 47, 48, 49, 50, 24,
51, 52, 53, 54, 55, 56, 1, 1, 1, 1,
35, 36, 37, 38, 39, 25, 40, 41, 42, 43,
44, 45, 25, 46, 47, 48, 49, 50, 51, 25,
52, 53, 54, 55, 56, 57, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -631,238 +631,238 @@ static const YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
static const YY_CHAR yy_meta[57] =
static const YY_CHAR yy_meta[58] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 4, 1, 1,
1, 1, 1, 4, 1, 5, 1, 1, 4, 4,
1, 1, 1, 1, 4, 1, 5, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1
4, 4, 4, 1, 1, 1, 1
} ;
static const flex_int16_t yy_base[314] =
static const flex_int16_t yy_base[315] =
{ 0,
0, 0, 54, 55, 56, 57, 564, 565, 565, 565,
541, 56, 35, 540, 63, 55, 565, 565, 539, 56,
565, 55, 56, 74, 71, 541, 565, 54, 537, 70,
532, 565, 565, 535, 53, 58, 64, 72, 73, 74,
79, 84, 82, 85, 86, 88, 95, 97, 94, 107,
565, 96, 565, 565, 565, 565, 539, 565, 565, 538,
565, 120, 565, 127, 512, 511, 506, 565, 122, 565,
115, 565, 126, 140, 565, 565, 565, 565, 565, 120,
513, 565, 565, 0, 565, 121, 141, 135, 0, 565,
528, 565, 565, 565, 527, 522, 565, 132, 128, 134,
0, 0, 55, 56, 57, 58, 565, 566, 566, 566,
542, 57, 34, 541, 66, 60, 566, 566, 540, 57,
566, 63, 48, 74, 74, 542, 566, 55, 538, 59,
566, 532, 566, 566, 536, 62, 66, 71, 72, 67,
73, 87, 70, 76, 89, 92, 93, 94, 96, 97,
99, 566, 100, 566, 566, 566, 566, 540, 566, 566,
539, 566, 120, 566, 136, 512, 511, 506, 566, 122,
566, 123, 566, 126, 143, 566, 566, 566, 566, 566,
118, 513, 566, 566, 0, 566, 125, 140, 132, 0,
566, 529, 566, 566, 566, 528, 522, 566, 130, 133,
137, 139, 138, 142, 114, 143, 145, 146, 521, 520,
150, 151, 152, 153, 156, 159, 163, 158, 160, 165,
166, 565, 565, 565, 565, 189, 197, 202, 507, 512,
505, 204, 565, 207, 205, 208, 209, 210, 213, 565,
490, 0, 202, 565, 515, 565, 565, 199, 212, 187,
195, 206, 198, 217, 215, 218, 222, 224, 225, 226,
227, 228, 229, 231, 236, 230, 238, 241, 244, 243,
245, 499, 499, 496, 268, 269, 276, 271, 273, 283,
503, 510, 261, 509, 508, 258, 263, 262, 507, 270,
272, 277, 506, 278, 279, 282, 287, 505, 289, 290,
124, 135, 137, 139, 145, 149, 146, 150, 151, 521,
520, 152, 155, 154, 157, 158, 161, 162, 163, 170,
167, 168, 566, 566, 566, 566, 186, 204, 211, 507,
512, 505, 205, 566, 212, 202, 215, 210, 213, 217,
566, 490, 0, 205, 566, 515, 566, 566, 194, 203,
206, 200, 216, 198, 218, 221, 223, 224, 225, 226,
227, 231, 228, 232, 236, 238, 241, 239, 242, 248,
246, 249, 499, 499, 496, 273, 274, 277, 275, 276,
284, 503, 510, 104, 509, 508, 262, 268, 264, 507,
265, 270, 279, 506, 271, 282, 287, 288, 505, 289,
293, 504, 291, 294, 296, 482, 480, 491, 565, 298,
299, 301, 305, 500, 499, 302, 498, 303, 313, 307,
314, 322, 324, 326, 327, 497, 477, 488, 491, 312,
330, 310, 334, 335, 493, 336, 337, 492, 491, 340,
490, 342, 343, 481, 480, 483, 348, 345, 354, 486,
485, 351, 349, 363, 365, 352, 476, 565, 467, 367,
368, 482, 369, 481, 370, 372, 375, 565, 468, 377,
378, 380, 385, 466, 386, 387, 403, 417, 388, 416,
414, 389, 394, 389, 408, 397, 400, 331, 399, 402,
339, 401, 309, 259, 403, 565, 404, 200, 565, 445,
272, 292, 504, 294, 297, 298, 482, 480, 491, 566,
299, 300, 304, 301, 500, 499, 302, 498, 305, 311,
309, 312, 313, 322, 314, 327, 497, 477, 488, 491,
328, 331, 310, 333, 335, 493, 336, 334, 492, 491,
337, 490, 341, 338, 481, 480, 483, 343, 340, 353,
486, 485, 348, 360, 362, 363, 351, 476, 566, 467,
364, 366, 482, 369, 481, 368, 375, 376, 566, 455,
373, 379, 377, 388, 419, 378, 386, 403, 417, 389,
416, 414, 398, 384, 392, 412, 392, 400, 368, 401,
399, 341, 403, 347, 193, 404, 566, 408, 159, 566,
450, 455, 460, 463, 465, 470, 475, 480, 485, 490,
84, 495, 500
447, 452, 457, 462, 465, 467, 472, 477, 482, 487,
492, 68, 497, 502
} ;
static const flex_int16_t yy_def[314] =
static const flex_int16_t yy_def[315] =
{ 0,
299, 1, 300, 300, 301, 301, 299, 299, 299, 299,
299, 302, 299, 299, 299, 303, 299, 299, 299, 299,
299, 299, 299, 299, 304, 299, 299, 299, 299, 299,
305, 299, 299, 299, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 302, 299, 306, 299, 299, 299, 299, 307, 299,
308, 299, 303, 309, 299, 299, 299, 299, 299, 299,
299, 299, 299, 310, 299, 299, 304, 304, 311, 299,
299, 299, 299, 299, 299, 305, 299, 305, 305, 305,
300, 1, 301, 301, 302, 302, 300, 300, 300, 300,
300, 303, 300, 300, 300, 304, 300, 300, 300, 300,
300, 300, 300, 300, 305, 300, 300, 300, 300, 300,
300, 306, 300, 300, 300, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 303, 300, 307, 300, 300, 300, 300, 308,
300, 309, 300, 304, 310, 300, 300, 300, 300, 300,
300, 300, 300, 300, 311, 300, 300, 305, 305, 312,
300, 300, 300, 300, 300, 300, 306, 300, 306, 306,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 299, 299, 299, 299, 302, 302, 306, 299, 299,
299, 307, 299, 312, 308, 313, 303, 303, 309, 299,
299, 310, 299, 299, 311, 299, 299, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 299, 299, 299, 307, 307, 312, 308, 308, 313,
299, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 300, 300, 300, 300, 303, 303, 307, 300,
300, 300, 308, 300, 313, 309, 314, 304, 304, 310,
300, 300, 311, 300, 300, 312, 300, 300, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 300, 300, 300, 308, 308, 313, 309, 309,
314, 300, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
305, 305, 305, 305, 305, 299, 299, 299, 299, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 299, 299, 299, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 299, 299, 299, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 299, 299, 299, 305,
305, 305, 305, 305, 305, 305, 305, 299, 299, 305,
305, 305, 305, 305, 305, 305, 299, 305, 305, 305,
305, 305, 305, 299, 305, 305, 305, 299, 305, 305,
299, 305, 305, 299, 305, 299, 305, 305, 0, 299,
306, 306, 306, 306, 306, 306, 300, 300, 300, 300,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 300, 300, 300,
306, 306, 306, 306, 306, 306, 306, 306, 306, 306,
306, 306, 306, 306, 300, 300, 300, 306, 306, 306,
306, 306, 306, 306, 306, 306, 306, 300, 300, 300,
306, 306, 306, 306, 306, 306, 306, 306, 300, 300,
306, 306, 306, 306, 306, 306, 306, 300, 306, 306,
306, 306, 306, 306, 300, 306, 306, 306, 300, 306,
306, 300, 306, 306, 300, 306, 300, 306, 306, 0,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300
} ;
static const flex_int16_t yy_nxt[622] =
static const flex_int16_t yy_nxt[624] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 8, 33, 34, 31, 35,
36, 37, 38, 39, 40, 41, 31, 42, 31, 43,
31, 44, 31, 45, 46, 47, 48, 49, 31, 50,
31, 31, 51, 52, 53, 54, 56, 56, 59, 59,
63, 60, 60, 63, 65, 57, 57, 69, 76, 78,
70, 71, 66, 80, 91, 92, 79, 77, 89, 82,
74, 64, 67, 89, 72, 83, 86, 145, 87, 89,
84, 94, 95, 100, 98, 85, 89, 89, 89, 89,
28, 29, 30, 31, 32, 33, 8, 34, 35, 32,
36, 37, 38, 39, 40, 41, 42, 32, 43, 32,
44, 32, 45, 32, 46, 47, 48, 49, 50, 32,
51, 32, 32, 52, 53, 54, 55, 57, 57, 60,
60, 64, 61, 61, 66, 81, 58, 58, 64, 77,
70, 146, 67, 71, 72, 92, 93, 79, 78, 83,
95, 96, 68, 65, 80, 84, 75, 73, 90, 87,
85, 88, 90, 90, 82, 86, 90, 90, 90, 90,
101, 81, 99, 106, 89, 103, 102, 89, 108, 89,
89, 89, 104, 89, 105, 111, 107, 122, 109, 89,
89, 114, 89, 133, 63, 110, 133, 112, 115, 62,
113, 127, 89, 117, 63, 119, 120, 80, 143, 89,
136, 118, 73, 121, 116, 64, 156, 134, 138, 123,
299, 74, 128, 89, 140, 144, 86, 89, 87, 89,
89, 149, 89, 89, 89, 139, 89, 89, 89, 148,
89, 89, 154, 150, 152, 89, 89, 89, 89, 151,
153, 89, 157, 89, 89, 89, 159, 155, 89, 158,
89, 89, 169, 63, 162, 164, 165, 161, 160, 163,
90, 101, 90, 107, 99, 110, 104, 105, 102, 106,
112, 100, 111, 90, 103, 90, 108, 109, 90, 90,
90, 123, 90, 90, 64, 90, 134, 115, 116, 121,
90, 134, 113, 118, 64, 81, 122, 114, 63, 120,
128, 119, 144, 211, 117, 74, 65, 300, 135, 137,
90, 139, 75, 141, 124, 87, 90, 88, 90, 90,
145, 90, 129, 90, 151, 90, 90, 150, 149, 140,
152, 90, 90, 153, 155, 90, 90, 90, 90, 154,
90, 90, 157, 90, 90, 90, 158, 90, 90, 90,
64, 156, 160, 90, 90, 159, 90, 163, 165, 166,
166, 63, 170, 171, 62, 168, 127, 167, 133, 132,
135, 176, 89, 133, 64, 73, 179, 63, 63, 143,
89, 138, 64, 89, 89, 89, 184, 128, 185, 134,
136, 89, 177, 180, 74, 74, 144, 89, 139, 182,
89, 183, 89, 89, 187, 186, 188, 89, 189, 89,
89, 89, 89, 89, 89, 89, 89, 192, 193, 194,
190, 89, 196, 89, 195, 198, 89, 191, 89, 89,
89, 201, 133, 133, 202, 200, 197, 203, 132, 133,
176, 133, 199, 89, 205, 135, 89, 89, 89, 204,
211, 179, 296, 134, 134, 89, 136, 89, 136, 210,
167, 161, 162, 170, 164, 171, 172, 168, 64, 134,
134, 169, 65, 63, 133, 128, 177, 136, 64, 74,
90, 64, 144, 180, 90, 139, 90, 297, 137, 90,
65, 135, 90, 184, 186, 183, 75, 129, 178, 75,
145, 181, 90, 140, 90, 188, 185, 90, 189, 90,
90, 90, 90, 90, 90, 190, 187, 90, 90, 193,
194, 195, 90, 197, 90, 90, 191, 90, 90, 196,
192, 199, 90, 202, 90, 90, 203, 134, 134, 133,
198, 177, 204, 134, 134, 200, 136, 201, 90, 206,
90, 90, 180, 205, 90, 212, 90, 90, 90, 135,
212, 177, 89, 89, 89, 215, 216, 89, 180, 213,
219, 214, 89, 218, 89, 89, 89, 217, 89, 89,
221, 89, 223, 89, 89, 224, 89, 89, 89, 226,
89, 220, 89, 234, 89, 89, 222, 89, 89, 89,
225, 230, 232, 236, 233, 231, 237, 89, 238, 89,
239, 89, 89, 235, 247, 89, 241, 249, 240, 89,
89, 89, 89, 242, 243, 89, 248, 89, 89, 252,
89, 251, 294, 89, 89, 291, 89, 89, 253, 89,
250, 264, 256, 255, 254, 260, 263, 262, 89, 261,
89, 267, 89, 89, 89, 89, 265, 89, 266, 273,
135, 137, 137, 178, 216, 90, 213, 215, 90, 217,
181, 218, 214, 90, 90, 90, 220, 219, 90, 223,
90, 222, 224, 90, 90, 90, 90, 90, 90, 225,
90, 90, 227, 221, 235, 90, 90, 90, 90, 90,
90, 234, 237, 231, 226, 238, 233, 232, 90, 240,
241, 239, 243, 90, 90, 242, 236, 90, 250, 90,
90, 90, 90, 90, 90, 244, 90, 90, 249, 90,
253, 248, 252, 90, 90, 295, 254, 90, 257, 90,
251, 261, 255, 256, 264, 262, 90, 263, 90, 90,
90, 268, 90, 265, 90, 90, 266, 267, 274, 90,
89, 271, 89, 89, 274, 89, 272, 279, 270, 275,
89, 89, 89, 89, 89, 276, 283, 281, 286, 89,
285, 280, 89, 278, 89, 89, 89, 89, 89, 89,
282, 290, 292, 89, 295, 288, 298, 289, 293, 89,
287, 89, 89, 284, 297, 55, 55, 55, 55, 55,
58, 58, 58, 58, 58, 62, 62, 62, 62, 62,
73, 73, 73, 73, 73, 88, 88, 88, 96, 96,
126, 126, 126, 126, 126, 132, 132, 132, 132, 132,
135, 135, 135, 135, 135, 137, 137, 137, 137, 137,
142, 89, 142, 142, 142, 175, 175, 175, 175, 175,
272, 90, 90, 90, 90, 90, 271, 273, 275, 280,
90, 276, 90, 292, 90, 90, 284, 277, 90, 281,
279, 282, 286, 283, 90, 90, 90, 90, 287, 90,
90, 288, 291, 290, 90, 293, 294, 296, 90, 289,
90, 299, 90, 90, 285, 90, 298, 56, 56, 56,
56, 56, 59, 59, 59, 59, 59, 63, 63, 63,
63, 63, 74, 74, 74, 74, 74, 89, 89, 89,
97, 97, 127, 127, 127, 127, 127, 133, 133, 133,
133, 133, 136, 136, 136, 136, 136, 138, 138, 138,
138, 138, 143, 278, 143, 143, 143, 176, 176, 176,
178, 178, 178, 178, 178, 277, 89, 89, 269, 268,
89, 89, 259, 258, 257, 89, 89, 89, 89, 246,
245, 244, 89, 89, 89, 89, 229, 228, 227, 89,
89, 89, 89, 89, 89, 89, 209, 208, 207, 206,
89, 181, 174, 173, 172, 89, 89, 89, 147, 146,
141, 131, 130, 129, 125, 124, 97, 89, 93, 90,
75, 68, 61, 299, 7, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
176, 176, 179, 179, 179, 179, 179, 90, 90, 270,
269, 90, 90, 260, 259, 258, 90, 90, 90, 90,
247, 246, 245, 90, 90, 90, 90, 230, 229, 228,
90, 90, 90, 90, 90, 90, 90, 210, 209, 208,
207, 90, 182, 175, 174, 173, 90, 90, 90, 148,
147, 142, 132, 131, 130, 126, 125, 98, 90, 94,
91, 76, 69, 62, 300, 7, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300
} ;
static const flex_int16_t yy_chk[622] =
static const flex_int16_t yy_chk[624] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 4, 5, 6,
12, 5, 6, 16, 13, 3, 4, 15, 20, 22,
15, 15, 13, 23, 28, 28, 22, 20, 35, 24,
16, 12, 13, 36, 15, 24, 25, 311, 25, 37,
24, 30, 30, 37, 35, 24, 25, 38, 39, 40,
1, 1, 1, 1, 1, 1, 1, 3, 4, 5,
6, 12, 5, 6, 13, 23, 3, 4, 16, 20,
15, 312, 13, 15, 15, 28, 28, 22, 20, 24,
30, 30, 13, 12, 22, 24, 16, 15, 36, 25,
24, 25, 37, 40, 23, 24, 43, 38, 39, 41,
37, 23, 36, 40, 41, 38, 37, 43, 41, 42,
44, 45, 39, 46, 39, 43, 40, 52, 42, 49,
47, 46, 48, 71, 62, 42, 69, 44, 47, 64,
45, 64, 50, 48, 73, 49, 50, 80, 86, 105,
71, 48, 74, 50, 47, 62, 105, 69, 74, 52,
88, 73, 64, 99, 80, 86, 87, 98, 87, 100,
88, 99, 101, 103, 102, 74, 87, 104, 106, 98,
107, 108, 103, 100, 101, 111, 112, 113, 114, 100,
102, 115, 106, 118, 116, 119, 108, 104, 117, 107,
120, 121, 119, 126, 113, 115, 116, 112, 111, 114,
25, 38, 44, 41, 36, 43, 39, 40, 38, 40,
44, 37, 43, 42, 38, 45, 41, 42, 46, 47,
48, 53, 49, 50, 63, 51, 70, 47, 48, 51,
184, 72, 45, 49, 74, 81, 51, 46, 65, 50,
65, 49, 87, 184, 48, 75, 63, 89, 70, 72,
101, 75, 74, 81, 53, 88, 99, 88, 89, 100,
87, 102, 65, 103, 101, 104, 88, 100, 99, 75,
101, 105, 107, 102, 104, 106, 108, 109, 112, 103,
114, 113, 106, 115, 116, 299, 107, 117, 118, 119,
127, 105, 109, 121, 122, 108, 120, 114, 116, 117,
117, 127, 120, 121, 128, 118, 128, 117, 132, 134,
136, 134, 150, 135, 126, 139, 136, 137, 138, 143,
151, 139, 127, 153, 148, 298, 150, 128, 151, 132,
135, 152, 134, 136, 137, 138, 143, 149, 139, 148,
155, 149, 154, 156, 153, 152, 154, 157, 155, 158,
159, 160, 161, 162, 163, 166, 164, 158, 159, 160,
156, 165, 162, 167, 161, 164, 168, 157, 170, 169,
171, 167, 175, 176, 168, 166, 163, 169, 177, 178,
177, 179, 165, 186, 171, 180, 183, 188, 187, 170,
186, 180, 294, 175, 176, 190, 178, 191, 179, 183,
118, 112, 113, 120, 115, 121, 122, 118, 128, 133,
136, 119, 127, 129, 135, 129, 135, 137, 138, 140,
149, 139, 144, 137, 154, 140, 152, 295, 136, 150,
128, 133, 151, 150, 152, 149, 138, 129, 135, 139,
144, 137, 153, 140, 155, 154, 151, 156, 155, 157,
158, 159, 160, 161, 163, 156, 153, 162, 164, 159,
160, 161, 165, 163, 166, 168, 157, 167, 169, 162,
158, 165, 171, 168, 170, 172, 169, 176, 177, 178,
164, 178, 170, 179, 180, 166, 181, 167, 187, 172,
189, 191, 181, 171, 188, 187, 192, 195, 201, 176,
187, 177, 192, 194, 195, 191, 192, 196, 180, 188,
196, 190, 197, 195, 199, 200, 203, 194, 201, 204,
199, 205, 201, 210, 211, 203, 212, 216, 218, 205,
213, 197, 220, 216, 293, 232, 200, 230, 219, 221,
204, 210, 212, 219, 213, 211, 219, 222, 220, 223,
221, 224, 225, 218, 230, 231, 223, 232, 222, 233,
234, 236, 237, 224, 225, 240, 231, 242, 243, 236,
248, 234, 291, 247, 253, 288, 252, 256, 237, 249,
233, 253, 243, 242, 240, 247, 252, 249, 254, 248,
255, 256, 260, 261, 263, 265, 254, 266, 255, 265,
177, 179, 180, 178, 192, 193, 188, 191, 196, 193,
181, 195, 189, 197, 198, 200, 197, 196, 202, 201,
204, 200, 202, 205, 206, 211, 212, 214, 217, 204,
213, 219, 206, 198, 217, 221, 233, 220, 222, 223,
225, 214, 220, 211, 205, 220, 213, 212, 224, 222,
223, 221, 225, 226, 231, 224, 219, 232, 233, 234,
238, 235, 237, 241, 244, 226, 249, 243, 232, 248,
237, 231, 235, 294, 253, 292, 238, 257, 244, 250,
234, 248, 241, 243, 253, 249, 254, 250, 255, 256,
261, 257, 262, 254, 266, 264, 255, 256, 266, 271,
267, 261, 270, 271, 266, 272, 263, 271, 260, 267,
273, 275, 276, 279, 282, 267, 276, 273, 282, 283,
279, 272, 286, 270, 289, 287, 292, 290, 295, 297,
275, 287, 289, 285, 292, 284, 297, 286, 290, 281,
283, 280, 278, 277, 295, 300, 300, 300, 300, 300,
301, 301, 301, 301, 301, 302, 302, 302, 302, 302,
303, 303, 303, 303, 303, 304, 304, 304, 305, 305,
306, 306, 306, 306, 306, 307, 307, 307, 307, 307,
308, 308, 308, 308, 308, 309, 309, 309, 309, 309,
310, 274, 310, 310, 310, 312, 312, 312, 312, 312,
262, 267, 268, 273, 276, 272, 261, 264, 267, 272,
284, 268, 277, 289, 274, 280, 277, 268, 287, 273,
271, 274, 280, 276, 283, 291, 288, 290, 283, 293,
296, 284, 288, 287, 298, 290, 291, 293, 286, 285,
282, 298, 281, 279, 278, 275, 296, 301, 301, 301,
301, 301, 302, 302, 302, 302, 302, 303, 303, 303,
303, 303, 304, 304, 304, 304, 304, 305, 305, 305,
306, 306, 307, 307, 307, 307, 307, 308, 308, 308,
308, 308, 309, 309, 309, 309, 309, 310, 310, 310,
310, 310, 311, 270, 311, 311, 311, 313, 313, 313,
313, 313, 313, 313, 313, 269, 264, 262, 259, 257,
251, 250, 246, 245, 244, 241, 239, 238, 235, 229,
228, 227, 226, 217, 215, 214, 208, 207, 206, 202,
198, 193, 189, 185, 184, 182, 181, 174, 173, 172,
145, 141, 131, 130, 129, 110, 109, 96, 95, 91,
81, 67, 66, 65, 60, 57, 34, 31, 29, 26,
19, 14, 11, 7, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
313, 313, 314, 314, 314, 314, 314, 265, 263, 260,
258, 252, 251, 247, 246, 245, 242, 240, 239, 236,
230, 229, 228, 227, 218, 216, 215, 209, 208, 207,
203, 199, 194, 190, 186, 185, 183, 182, 175, 174,
173, 146, 142, 132, 131, 130, 111, 110, 97, 96,
92, 82, 68, 67, 66, 61, 58, 35, 32, 29,
26, 19, 14, 11, 7, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
299
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300
} ;
/* The intent behind this definition is that it'll catch
@ -1180,13 +1180,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 300 )
if ( yy_current_state >= 301 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_current_state != 299 );
while ( yy_current_state != 300 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1502,218 +1502,223 @@ YY_RULE_SETUP
case 59:
YY_RULE_SETUP
#line 106 "lexer.lpp"
{ return iw7::parser::make_INCREMENT(loc); }
{ return iw7::parser::make_QMARK(loc); }
YY_BREAK
case 60:
YY_RULE_SETUP
#line 107 "lexer.lpp"
{ return iw7::parser::make_DECREMENT(loc); }
{ return iw7::parser::make_INCREMENT(loc); }
YY_BREAK
case 61:
YY_RULE_SETUP
#line 108 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_LSHIFT(loc); }
{ return iw7::parser::make_DECREMENT(loc); }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 109 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_RSHIFT(loc); }
{ return iw7::parser::make_ASSIGN_LSHIFT(loc); }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 110 "lexer.lpp"
{ return iw7::parser::make_LSHIFT(loc); }
{ return iw7::parser::make_ASSIGN_RSHIFT(loc); }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 111 "lexer.lpp"
{ return iw7::parser::make_RSHIFT(loc); }
{ return iw7::parser::make_LSHIFT(loc); }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 112 "lexer.lpp"
{ return iw7::parser::make_OR(loc); }
{ return iw7::parser::make_RSHIFT(loc); }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 113 "lexer.lpp"
{ return iw7::parser::make_AND(loc); }
{ return iw7::parser::make_OR(loc); }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 114 "lexer.lpp"
{ return iw7::parser::make_EQUALITY(loc); }
{ return iw7::parser::make_AND(loc); }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 115 "lexer.lpp"
{ return iw7::parser::make_INEQUALITY(loc); }
{ return iw7::parser::make_EQUALITY(loc); }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 116 "lexer.lpp"
{ return iw7::parser::make_LESS_EQUAL(loc); }
{ return iw7::parser::make_INEQUALITY(loc); }
YY_BREAK
case 70:
YY_RULE_SETUP
#line 117 "lexer.lpp"
{ return iw7::parser::make_GREATER_EQUAL(loc); }
{ return iw7::parser::make_LESS_EQUAL(loc); }
YY_BREAK
case 71:
YY_RULE_SETUP
#line 118 "lexer.lpp"
{ return iw7::parser::make_LESS(loc); }
{ return iw7::parser::make_GREATER_EQUAL(loc); }
YY_BREAK
case 72:
YY_RULE_SETUP
#line 119 "lexer.lpp"
{ return iw7::parser::make_GREATER(loc); }
{ return iw7::parser::make_LESS(loc); }
YY_BREAK
case 73:
YY_RULE_SETUP
#line 120 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_ADD(loc); }
{ return iw7::parser::make_GREATER(loc); }
YY_BREAK
case 74:
YY_RULE_SETUP
#line 121 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_SUB(loc); }
{ return iw7::parser::make_ASSIGN_ADD(loc); }
YY_BREAK
case 75:
YY_RULE_SETUP
#line 122 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_MULT(loc); }
{ return iw7::parser::make_ASSIGN_SUB(loc); }
YY_BREAK
case 76:
YY_RULE_SETUP
#line 123 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_DIV(loc); }
{ return iw7::parser::make_ASSIGN_MULT(loc); }
YY_BREAK
case 77:
YY_RULE_SETUP
#line 124 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_MOD(loc); }
{ return iw7::parser::make_ASSIGN_DIV(loc); }
YY_BREAK
case 78:
YY_RULE_SETUP
#line 125 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_BITWISE_OR(loc); }
{ return iw7::parser::make_ASSIGN_MOD(loc); }
YY_BREAK
case 79:
YY_RULE_SETUP
#line 126 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_BITWISE_AND(loc); }
{ return iw7::parser::make_ASSIGN_BITWISE_OR(loc); }
YY_BREAK
case 80:
YY_RULE_SETUP
#line 127 "lexer.lpp"
{ return iw7::parser::make_ASSIGN_BITWISE_EXOR(loc); }
{ return iw7::parser::make_ASSIGN_BITWISE_AND(loc); }
YY_BREAK
case 81:
YY_RULE_SETUP
#line 128 "lexer.lpp"
{ return iw7::parser::make_ASSIGN(loc); }
{ return iw7::parser::make_ASSIGN_BITWISE_EXOR(loc); }
YY_BREAK
case 82:
YY_RULE_SETUP
#line 129 "lexer.lpp"
{ return iw7::parser::make_ADD(loc); }
{ return iw7::parser::make_ASSIGN(loc); }
YY_BREAK
case 83:
YY_RULE_SETUP
#line 130 "lexer.lpp"
{ return iw7::parser::make_SUB(loc); }
{ return iw7::parser::make_ADD(loc); }
YY_BREAK
case 84:
YY_RULE_SETUP
#line 131 "lexer.lpp"
{ return iw7::parser::make_MULT(loc); }
{ return iw7::parser::make_SUB(loc); }
YY_BREAK
case 85:
YY_RULE_SETUP
#line 132 "lexer.lpp"
{ return iw7::parser::make_DIV(loc); }
{ return iw7::parser::make_MULT(loc); }
YY_BREAK
case 86:
YY_RULE_SETUP
#line 133 "lexer.lpp"
{ return iw7::parser::make_MOD(loc); }
{ return iw7::parser::make_DIV(loc); }
YY_BREAK
case 87:
YY_RULE_SETUP
#line 134 "lexer.lpp"
{ return iw7::parser::make_NOT(loc); }
{ return iw7::parser::make_MOD(loc); }
YY_BREAK
case 88:
YY_RULE_SETUP
#line 135 "lexer.lpp"
{ return iw7::parser::make_COMPLEMENT(loc); }
{ return iw7::parser::make_NOT(loc); }
YY_BREAK
case 89:
YY_RULE_SETUP
#line 136 "lexer.lpp"
{ return iw7::parser::make_BITWISE_OR(loc); }
{ return iw7::parser::make_COMPLEMENT(loc); }
YY_BREAK
case 90:
YY_RULE_SETUP
#line 137 "lexer.lpp"
{ return iw7::parser::make_BITWISE_AND(loc); }
{ return iw7::parser::make_BITWISE_OR(loc); }
YY_BREAK
case 91:
YY_RULE_SETUP
#line 138 "lexer.lpp"
{ return iw7::parser::make_BITWISE_EXOR(loc); }
{ return iw7::parser::make_BITWISE_AND(loc); }
YY_BREAK
case 92:
YY_RULE_SETUP
#line 139 "lexer.lpp"
{ return iw7::parser::make_FILE(utils::string::fordslash(yytext), loc); }
{ return iw7::parser::make_BITWISE_EXOR(loc); }
YY_BREAK
case 93:
YY_RULE_SETUP
#line 140 "lexer.lpp"
{ return iw7::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
{ return iw7::parser::make_FILE(utils::string::fordslash(yytext), loc); }
YY_BREAK
case 94:
/* rule 94 can match eol */
YY_RULE_SETUP
#line 141 "lexer.lpp"
{ return iw7::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
{ return iw7::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
YY_BREAK
case 95:
/* rule 95 can match eol */
YY_RULE_SETUP
#line 142 "lexer.lpp"
{ return iw7::parser::make_STRING(std::string(yytext), loc); }
{ return iw7::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 143 "lexer.lpp"
{ return iw7::parser::make_FLOAT(std::string(yytext), loc); }
{ return iw7::parser::make_STRING(std::string(yytext), loc); }
YY_BREAK
case 97:
YY_RULE_SETUP
#line 144 "lexer.lpp"
{ return iw7::parser::make_FLOAT(std::string(yytext), loc); }
YY_BREAK
case 98:
YY_RULE_SETUP
#line 145 "lexer.lpp"
{ return iw7::parser::make_INTEGER(std::string(yytext), loc); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT_BLOCK_STATE):
case YY_STATE_EOF(DEVELOPER_BLOCK_STATE):
#line 145 "lexer.lpp"
#line 146 "lexer.lpp"
{ return iw7::parser::make_IW7EOF(loc); }
YY_BREAK
case 98:
/* rule 98 can match eol */
case 99:
/* rule 99 can match eol */
YY_RULE_SETUP
#line 146 "lexer.lpp"
#line 147 "lexer.lpp"
{ throw iw7::parser::syntax_error(loc, "bad token: \'" + std::string(yytext) + "\'"); }
YY_BREAK
case 99:
case 100:
YY_RULE_SETUP
#line 148 "lexer.lpp"
#line 149 "lexer.lpp"
ECHO;
YY_BREAK
#line 1716 "lexer.cpp"
#line 1721 "lexer.cpp"
case YY_END_OF_BUFFER:
{
@ -2011,7 +2016,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 300 )
if ( yy_current_state >= 301 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@ -2040,11 +2045,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 300 )
if ( yy_current_state >= 301 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 299);
yy_is_jam = (yy_current_state == 300);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@ -2843,6 +2848,6 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 148 "lexer.lpp"
#line 149 "lexer.lpp"

View File

@ -700,7 +700,7 @@ extern int yylex (yyscan_t yyscanner);
#undef yyTABLES_NAME
#endif
#line 148 "lexer.lpp"
#line 149 "lexer.lpp"
#line 706 "lexer.hpp"

File diff suppressed because it is too large Load Diff

View File

@ -446,6 +446,7 @@ namespace xsk { namespace gsc { namespace iw7 {
// for_expr
// expr
// expr_compare
// expr_ternary
// expr_binary
// expr_primitive
char dummy11[sizeof (expr_ptr)];
@ -696,53 +697,55 @@ namespace xsk { namespace gsc { namespace iw7 {
DOUBLECOLON = 47, // "::"
COLON = 48, // ":"
SEMICOLON = 49, // ";"
INCREMENT = 50, // "++"
DECREMENT = 51, // "--"
LSHIFT = 52, // "<<"
RSHIFT = 53, // ">>"
OR = 54, // "||"
AND = 55, // "&&"
EQUALITY = 56, // "=="
INEQUALITY = 57, // "!="
LESS_EQUAL = 58, // "<="
GREATER_EQUAL = 59, // ">="
LESS = 60, // "<"
GREATER = 61, // ">"
NOT = 62, // "!"
COMPLEMENT = 63, // "~"
ASSIGN = 64, // "="
ASSIGN_ADD = 65, // "+="
ASSIGN_SUB = 66, // "-="
ASSIGN_MULT = 67, // "*="
ASSIGN_DIV = 68, // "/="
ASSIGN_MOD = 69, // "%="
ASSIGN_BITWISE_OR = 70, // "|="
ASSIGN_BITWISE_AND = 71, // "&="
ASSIGN_BITWISE_EXOR = 72, // "^="
ASSIGN_RSHIFT = 73, // ">>="
ASSIGN_LSHIFT = 74, // "<<="
BITWISE_OR = 75, // "|"
BITWISE_AND = 76, // "&"
BITWISE_EXOR = 77, // "^"
ADD = 78, // "+"
SUB = 79, // "-"
MULT = 80, // "*"
DIV = 81, // "/"
MOD = 82, // "%"
FILE = 83, // "file path"
NAME = 84, // "identifier"
STRING = 85, // "string literal"
ISTRING = 86, // "localized string"
FLOAT = 87, // "float"
INTEGER = 88, // "int"
ADD_ARRAY = 89, // ADD_ARRAY
THEN = 90, // THEN
NEG = 91, // NEG
ANIMREF = 92, // ANIMREF
PREINC = 93, // PREINC
PREDEC = 94, // PREDEC
POSTINC = 95, // POSTINC
POSTDEC = 96 // POSTDEC
QMARK = 50, // "?"
INCREMENT = 51, // "++"
DECREMENT = 52, // "--"
LSHIFT = 53, // "<<"
RSHIFT = 54, // ">>"
OR = 55, // "||"
AND = 56, // "&&"
EQUALITY = 57, // "=="
INEQUALITY = 58, // "!="
LESS_EQUAL = 59, // "<="
GREATER_EQUAL = 60, // ">="
LESS = 61, // "<"
GREATER = 62, // ">"
NOT = 63, // "!"
COMPLEMENT = 64, // "~"
ASSIGN = 65, // "="
ASSIGN_ADD = 66, // "+="
ASSIGN_SUB = 67, // "-="
ASSIGN_MULT = 68, // "*="
ASSIGN_DIV = 69, // "/="
ASSIGN_MOD = 70, // "%="
ASSIGN_BITWISE_OR = 71, // "|="
ASSIGN_BITWISE_AND = 72, // "&="
ASSIGN_BITWISE_EXOR = 73, // "^="
ASSIGN_RSHIFT = 74, // ">>="
ASSIGN_LSHIFT = 75, // "<<="
BITWISE_OR = 76, // "|"
BITWISE_AND = 77, // "&"
BITWISE_EXOR = 78, // "^"
ADD = 79, // "+"
SUB = 80, // "-"
MULT = 81, // "*"
DIV = 82, // "/"
MOD = 83, // "%"
FILE = 84, // "file path"
NAME = 85, // "identifier"
STRING = 86, // "string literal"
ISTRING = 87, // "localized string"
FLOAT = 88, // "float"
INTEGER = 89, // "int"
ADD_ARRAY = 90, // ADD_ARRAY
THEN = 91, // THEN
TERN = 92, // TERN
NEG = 93, // NEG
ANIMREF = 94, // ANIMREF
PREINC = 95, // PREINC
PREDEC = 96, // PREDEC
POSTINC = 97, // POSTINC
POSTDEC = 98 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -759,7 +762,7 @@ namespace xsk { namespace gsc { namespace iw7 {
{
enum symbol_kind_type
{
YYNTOKENS = 97, ///< Number of tokens.
YYNTOKENS = 99, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
@ -811,128 +814,131 @@ namespace xsk { namespace gsc { namespace iw7 {
S_DOUBLECOLON = 47, // "::"
S_COLON = 48, // ":"
S_SEMICOLON = 49, // ";"
S_INCREMENT = 50, // "++"
S_DECREMENT = 51, // "--"
S_LSHIFT = 52, // "<<"
S_RSHIFT = 53, // ">>"
S_OR = 54, // "||"
S_AND = 55, // "&&"
S_EQUALITY = 56, // "=="
S_INEQUALITY = 57, // "!="
S_LESS_EQUAL = 58, // "<="
S_GREATER_EQUAL = 59, // ">="
S_LESS = 60, // "<"
S_GREATER = 61, // ">"
S_NOT = 62, // "!"
S_COMPLEMENT = 63, // "~"
S_ASSIGN = 64, // "="
S_ASSIGN_ADD = 65, // "+="
S_ASSIGN_SUB = 66, // "-="
S_ASSIGN_MULT = 67, // "*="
S_ASSIGN_DIV = 68, // "/="
S_ASSIGN_MOD = 69, // "%="
S_ASSIGN_BITWISE_OR = 70, // "|="
S_ASSIGN_BITWISE_AND = 71, // "&="
S_ASSIGN_BITWISE_EXOR = 72, // "^="
S_ASSIGN_RSHIFT = 73, // ">>="
S_ASSIGN_LSHIFT = 74, // "<<="
S_BITWISE_OR = 75, // "|"
S_BITWISE_AND = 76, // "&"
S_BITWISE_EXOR = 77, // "^"
S_ADD = 78, // "+"
S_SUB = 79, // "-"
S_MULT = 80, // "*"
S_DIV = 81, // "/"
S_MOD = 82, // "%"
S_FILE = 83, // "file path"
S_NAME = 84, // "identifier"
S_STRING = 85, // "string literal"
S_ISTRING = 86, // "localized string"
S_FLOAT = 87, // "float"
S_INTEGER = 88, // "int"
S_ADD_ARRAY = 89, // ADD_ARRAY
S_THEN = 90, // THEN
S_NEG = 91, // NEG
S_ANIMREF = 92, // ANIMREF
S_PREINC = 93, // PREINC
S_PREDEC = 94, // PREDEC
S_POSTINC = 95, // POSTINC
S_POSTDEC = 96, // POSTDEC
S_YYACCEPT = 97, // $accept
S_root = 98, // root
S_program = 99, // program
S_include = 100, // include
S_define = 101, // define
S_usingtree = 102, // usingtree
S_constant = 103, // constant
S_thread = 104, // thread
S_parameters = 105, // parameters
S_stmt = 106, // stmt
S_stmt_block = 107, // stmt_block
S_stmt_list = 108, // stmt_list
S_stmt_call = 109, // stmt_call
S_stmt_assign = 110, // stmt_assign
S_stmt_endon = 111, // stmt_endon
S_stmt_notify = 112, // stmt_notify
S_stmt_wait = 113, // stmt_wait
S_stmt_waittill = 114, // stmt_waittill
S_stmt_waittillmatch = 115, // stmt_waittillmatch
S_stmt_waittillframeend = 116, // stmt_waittillframeend
S_stmt_if = 117, // stmt_if
S_stmt_ifelse = 118, // stmt_ifelse
S_stmt_while = 119, // stmt_while
S_stmt_for = 120, // stmt_for
S_stmt_foreach = 121, // stmt_foreach
S_stmt_switch = 122, // stmt_switch
S_stmt_case = 123, // stmt_case
S_stmt_default = 124, // stmt_default
S_stmt_break = 125, // stmt_break
S_stmt_continue = 126, // stmt_continue
S_stmt_return = 127, // stmt_return
S_stmt_breakpoint = 128, // stmt_breakpoint
S_stmt_prof_begin = 129, // stmt_prof_begin
S_stmt_prof_end = 130, // stmt_prof_end
S_for_stmt = 131, // for_stmt
S_for_expr = 132, // for_expr
S_expr = 133, // expr
S_expr_assign = 134, // expr_assign
S_expr_compare = 135, // expr_compare
S_expr_binary = 136, // expr_binary
S_expr_primitive = 137, // expr_primitive
S_expr_call = 138, // expr_call
S_expr_call_thread = 139, // expr_call_thread
S_expr_call_childthread = 140, // expr_call_childthread
S_expr_call_function = 141, // expr_call_function
S_expr_call_pointer = 142, // expr_call_pointer
S_expr_arguments = 143, // expr_arguments
S_expr_arguments_filled = 144, // expr_arguments_filled
S_expr_arguments_empty = 145, // expr_arguments_empty
S_expr_function = 146, // expr_function
S_expr_add_array = 147, // expr_add_array
S_expr_array = 148, // expr_array
S_expr_field = 149, // expr_field
S_expr_size = 150, // expr_size
S_object = 151, // object
S_thisthread = 152, // thisthread
S_empty_array = 153, // empty_array
S_undefined = 154, // undefined
S_game = 155, // game
S_self = 156, // self
S_anim = 157, // anim
S_level = 158, // level
S_animation = 159, // animation
S_animtree = 160, // animtree
S_name = 161, // name
S_file = 162, // file
S_istring = 163, // istring
S_string = 164, // string
S_vector = 165, // vector
S_neg_float = 166, // neg_float
S_neg_integer = 167, // neg_integer
S_float = 168, // float
S_integer = 169, // integer
S_false = 170, // false
S_true = 171 // true
S_QMARK = 50, // "?"
S_INCREMENT = 51, // "++"
S_DECREMENT = 52, // "--"
S_LSHIFT = 53, // "<<"
S_RSHIFT = 54, // ">>"
S_OR = 55, // "||"
S_AND = 56, // "&&"
S_EQUALITY = 57, // "=="
S_INEQUALITY = 58, // "!="
S_LESS_EQUAL = 59, // "<="
S_GREATER_EQUAL = 60, // ">="
S_LESS = 61, // "<"
S_GREATER = 62, // ">"
S_NOT = 63, // "!"
S_COMPLEMENT = 64, // "~"
S_ASSIGN = 65, // "="
S_ASSIGN_ADD = 66, // "+="
S_ASSIGN_SUB = 67, // "-="
S_ASSIGN_MULT = 68, // "*="
S_ASSIGN_DIV = 69, // "/="
S_ASSIGN_MOD = 70, // "%="
S_ASSIGN_BITWISE_OR = 71, // "|="
S_ASSIGN_BITWISE_AND = 72, // "&="
S_ASSIGN_BITWISE_EXOR = 73, // "^="
S_ASSIGN_RSHIFT = 74, // ">>="
S_ASSIGN_LSHIFT = 75, // "<<="
S_BITWISE_OR = 76, // "|"
S_BITWISE_AND = 77, // "&"
S_BITWISE_EXOR = 78, // "^"
S_ADD = 79, // "+"
S_SUB = 80, // "-"
S_MULT = 81, // "*"
S_DIV = 82, // "/"
S_MOD = 83, // "%"
S_FILE = 84, // "file path"
S_NAME = 85, // "identifier"
S_STRING = 86, // "string literal"
S_ISTRING = 87, // "localized string"
S_FLOAT = 88, // "float"
S_INTEGER = 89, // "int"
S_ADD_ARRAY = 90, // ADD_ARRAY
S_THEN = 91, // THEN
S_TERN = 92, // TERN
S_NEG = 93, // NEG
S_ANIMREF = 94, // ANIMREF
S_PREINC = 95, // PREINC
S_PREDEC = 96, // PREDEC
S_POSTINC = 97, // POSTINC
S_POSTDEC = 98, // POSTDEC
S_YYACCEPT = 99, // $accept
S_root = 100, // root
S_program = 101, // program
S_include = 102, // include
S_define = 103, // define
S_usingtree = 104, // usingtree
S_constant = 105, // constant
S_thread = 106, // thread
S_parameters = 107, // parameters
S_stmt = 108, // stmt
S_stmt_block = 109, // stmt_block
S_stmt_list = 110, // stmt_list
S_stmt_call = 111, // stmt_call
S_stmt_assign = 112, // stmt_assign
S_stmt_endon = 113, // stmt_endon
S_stmt_notify = 114, // stmt_notify
S_stmt_wait = 115, // stmt_wait
S_stmt_waittill = 116, // stmt_waittill
S_stmt_waittillmatch = 117, // stmt_waittillmatch
S_stmt_waittillframeend = 118, // stmt_waittillframeend
S_stmt_if = 119, // stmt_if
S_stmt_ifelse = 120, // stmt_ifelse
S_stmt_while = 121, // stmt_while
S_stmt_for = 122, // stmt_for
S_stmt_foreach = 123, // stmt_foreach
S_stmt_switch = 124, // stmt_switch
S_stmt_case = 125, // stmt_case
S_stmt_default = 126, // stmt_default
S_stmt_break = 127, // stmt_break
S_stmt_continue = 128, // stmt_continue
S_stmt_return = 129, // stmt_return
S_stmt_breakpoint = 130, // stmt_breakpoint
S_stmt_prof_begin = 131, // stmt_prof_begin
S_stmt_prof_end = 132, // stmt_prof_end
S_for_stmt = 133, // for_stmt
S_for_expr = 134, // for_expr
S_expr = 135, // expr
S_expr_assign = 136, // expr_assign
S_expr_compare = 137, // expr_compare
S_expr_ternary = 138, // expr_ternary
S_expr_binary = 139, // expr_binary
S_expr_primitive = 140, // expr_primitive
S_expr_call = 141, // expr_call
S_expr_call_thread = 142, // expr_call_thread
S_expr_call_childthread = 143, // expr_call_childthread
S_expr_call_function = 144, // expr_call_function
S_expr_call_pointer = 145, // expr_call_pointer
S_expr_arguments = 146, // expr_arguments
S_expr_arguments_filled = 147, // expr_arguments_filled
S_expr_arguments_empty = 148, // expr_arguments_empty
S_expr_function = 149, // expr_function
S_expr_add_array = 150, // expr_add_array
S_expr_array = 151, // expr_array
S_expr_field = 152, // expr_field
S_expr_size = 153, // expr_size
S_object = 154, // object
S_thisthread = 155, // thisthread
S_empty_array = 156, // empty_array
S_undefined = 157, // undefined
S_game = 158, // game
S_self = 159, // self
S_anim = 160, // anim
S_level = 161, // level
S_animation = 162, // animation
S_animtree = 163, // animtree
S_name = 164, // name
S_file = 165, // file
S_istring = 166, // istring
S_string = 167, // string
S_vector = 168, // vector
S_neg_float = 169, // neg_float
S_neg_integer = 170, // neg_integer
S_float = 171, // float
S_integer = 172, // integer
S_false = 173, // false
S_true = 174 // true
};
};
@ -1017,6 +1023,7 @@ namespace xsk { namespace gsc { namespace iw7 {
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (std::move (that.value));
@ -2093,6 +2100,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.template destroy< expr_ptr > ();
@ -3198,6 +3206,21 @@ switch (yykind)
return symbol_type (token::SEMICOLON, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_QMARK (location_type l)
{
return symbol_type (token::QMARK, std::move (l));
}
#else
static
symbol_type
make_QMARK (const location_type& l)
{
return symbol_type (token::QMARK, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -3813,6 +3836,21 @@ switch (yykind)
return symbol_type (token::THEN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_TERN (location_type l)
{
return symbol_type (token::TERN, std::move (l));
}
#else
static
symbol_type
make_TERN (const location_type& l)
{
return symbol_type (token::TERN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4247,8 +4285,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 1591, ///< Last index in yytable_.
yynnts_ = 75, ///< Number of nonterminal symbols.
yylast_ = 1836, ///< Last index in yytable_.
yynnts_ = 76, ///< Number of nonterminal symbols.
yyfinal_ = 15 ///< Termination state number.
};
@ -4324,6 +4362,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.copy< expr_ptr > (YY_MOVE (that.value));
@ -4600,6 +4639,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (YY_MOVE (s.value));
@ -4862,7 +4902,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw7
#line 4866 "parser.hpp"
#line 4906 "parser.hpp"

View File

@ -115,7 +115,6 @@ void assembler::assemble(const std::string& file, std::vector<gsc::function_ptr>
functions_ = std::move(functions);
script_->write<std::uint8_t>(static_cast<std::uint8_t>(opcode::OP_End));
stack_->write<std::uint32_t>(0x69773630);
for (const auto& func : functions_)
{

View File

@ -409,7 +409,7 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -465,7 +465,7 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -540,7 +540,7 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -752,6 +752,7 @@ void compiler::emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
{
switch(expr.as_node->type)
{
case gsc::node_t::expr_ternary: emit_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: emit_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: emit_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: emit_expr_binary(ctx, expr.as_binary); break;
@ -849,6 +850,30 @@ void compiler::emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_ass
}
}
void compiler::emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
auto else_loc = create_label();
auto end_loc = create_label();
if(expr->cond.as_node->type == gsc::node_t::expr_not)
{
emit_expr(ctx, expr->cond.as_not->rvalue);
emit_opcode(ctx, opcode::OP_JumpOnTrue, else_loc);
}
else
{
emit_expr(ctx, expr->cond);
emit_opcode(ctx, opcode::OP_JumpOnFalse, else_loc);
}
emit_expr(ctx, expr->lvalue);
emit_opcode(ctx, opcode::OP_jump, end_loc);
insert_label(else_loc);
emit_expr(ctx, expr->rvalue);
insert_label(end_loc);
}
void compiler::emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
emit_expr(ctx, expr->lvalue);

View File

@ -68,6 +68,7 @@ private:
void emit_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr);
void emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
void emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void emit_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void emit_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -96,6 +96,14 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
decompile_expr();
}
}
for(auto& entry : tern_labels_)
{
if(entry == itr->second)
{
decompile_ternary();
}
}
}
switch (opcode(inst->opcode))
@ -1833,6 +1841,7 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
{
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1916,6 +1925,29 @@ void decompiler::decompile_expr()
}
}
void decompiler::decompile_ternary()
{
auto rvalue = std::move(stack_.top());
stack_.pop();
auto lvalue = std::move(stack_.top());
stack_.pop();
func_->block->stmts.pop_back();
auto stmt = std::move(func_->block->stmts.back());
func_->block->stmts.pop_back();
if(stmt.as_node->type == node_t::asm_jump_cond)
{
auto loc = stmt.as_cond->loc;
auto e = std::make_unique<gsc::node_expr_ternary>(loc, std::move(stmt.as_cond->expr), std::move(lvalue), std::move(rvalue));
stack_.push(std::move(e));
}
else
{
throw gsc::decomp_error("TRIED TO DECOMPILE INVALID TERNARY EXPR!");
}
}
void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
{
this->decompile_search_infinite(block);
@ -3006,6 +3038,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
case gsc::node_t::expr_assign_bitwise_or: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_and: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_exor: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_ternary: process_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: process_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: process_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: process_expr_binary(ctx, expr.as_binary); break;
@ -3106,6 +3139,13 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assi
}
}
void decompiler::process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
process_expr(ctx, expr->cond);
process_expr(ctx, expr->lvalue);
process_expr(ctx, expr->rvalue);
}
void decompiler::process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
process_expr(ctx, expr->lvalue);

View File

@ -16,6 +16,7 @@ class decompiler : public gsc::decompiler
gsc::thread_ptr func_;
std::unordered_map<std::uint32_t, std::string> labels_;
std::vector<std::string> expr_labels_;
std::vector<std::string> tern_labels_;
std::stack<gsc::node_ptr> stack_;
std::vector<gsc::context> blocks_;
@ -27,6 +28,7 @@ private:
void decompile_function(const gsc::function_ptr& func);
void decompile_statements(const gsc::function_ptr& func);
void decompile_expr();
void decompile_ternary();
void decompile_block(const gsc::stmt_list_ptr& block);
void decompile_search_infinite(const gsc::stmt_list_ptr& block);
void decompile_search_loop(const gsc::stmt_list_ptr& block);
@ -68,6 +70,7 @@ private:
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
void process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -553,8 +553,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 100
#define YY_END_OF_BUFFER 101
#define YY_NUM_RULES 101
#define YY_END_OF_BUFFER 102
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -562,42 +562,42 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[305] =
static const flex_int16_t yy_accept[306] =
{ 0,
0, 0, 0, 0, 0, 0, 101, 99, 1, 2,
88, 99, 99, 87, 91, 99, 49, 50, 85, 83,
55, 84, 56, 86, 98, 58, 59, 72, 82, 73,
94, 53, 54, 92, 94, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
51, 90, 52, 89, 5, 6, 5, 9, 10, 9,
69, 0, 96, 0, 0, 0, 0, 78, 0, 67,
0, 80, 0, 0, 76, 60, 74, 61, 75, 97,
0, 8, 4, 3, 77, 97, 98, 0, 0, 57,
64, 70, 68, 71, 65, 94, 81, 94, 94, 94,
0, 0, 0, 0, 0, 0, 102, 100, 1, 2,
89, 100, 100, 88, 92, 100, 49, 50, 86, 84,
55, 85, 56, 87, 99, 58, 59, 73, 83, 74,
60, 95, 53, 54, 93, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 51, 91, 52, 90, 5, 6, 5, 9, 10,
9, 70, 0, 97, 0, 0, 0, 0, 79, 0,
68, 0, 81, 0, 0, 77, 61, 75, 62, 76,
98, 0, 8, 4, 3, 78, 98, 99, 0, 0,
57, 65, 71, 69, 72, 66, 95, 82, 95, 95,
94, 94, 94, 94, 94, 94, 94, 94, 25, 30,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 79, 66, 7, 11, 0, 96, 0, 0, 0,
0, 0, 95, 0, 0, 0, 0, 96, 0, 97,
0, 3, 97, 97, 93, 62, 63, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 28, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 0, 0, 0, 0, 95, 0, 0, 95, 0,
0, 47, 94, 40, 32, 94, 94, 94, 26, 94,
94, 94, 45, 94, 94, 94, 94, 46, 94, 94,
95, 95, 95, 95, 95, 95, 95, 95, 95, 25,
30, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 80, 67, 7, 11, 0, 97, 0, 0,
0, 0, 0, 96, 0, 0, 0, 0, 97, 0,
98, 0, 3, 98, 98, 94, 63, 64, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 28, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 0, 0, 0, 0, 96, 0, 0, 96,
0, 0, 47, 95, 40, 32, 95, 95, 95, 26,
95, 95, 95, 45, 95, 95, 95, 95, 46, 95,
94, 41, 94, 20, 94, 0, 0, 0, 44, 34,
94, 94, 94, 18, 42, 94, 48, 94, 94, 94,
94, 94, 94, 94, 94, 94, 27, 0, 0, 0,
94, 94, 94, 94, 94, 19, 94, 94, 36, 31,
94, 37, 94, 94, 94, 0, 0, 0, 94, 94,
94, 33, 29, 94, 94, 94, 94, 94, 94, 0,
15, 0, 94, 94, 35, 94, 14, 94, 94, 94,
21, 17, 0, 94, 94, 94, 94, 43, 24, 94,
94, 0, 12, 94, 13, 39, 94, 94, 0, 38,
94, 94, 0, 94, 94, 0, 94, 22, 0, 94,
95, 95, 41, 95, 20, 95, 0, 0, 0, 44,
34, 95, 95, 95, 18, 42, 95, 48, 95, 95,
95, 95, 95, 95, 95, 95, 95, 27, 0, 0,
0, 95, 95, 95, 95, 95, 19, 95, 95, 36,
31, 95, 37, 95, 95, 95, 0, 0, 0, 95,
95, 95, 33, 29, 95, 95, 95, 95, 95, 95,
0, 15, 0, 95, 95, 35, 95, 14, 95, 95,
95, 21, 17, 0, 95, 95, 95, 95, 43, 24,
95, 95, 0, 12, 95, 13, 39, 95, 95, 0,
38, 95, 95, 0, 95, 95, 0, 95, 22, 0,
16, 94, 23, 0
95, 16, 95, 23, 0
} ;
static const YY_CHAR yy_ec[256] =
@ -608,14 +608,14 @@ static const YY_CHAR yy_ec[256] =
1, 2, 4, 5, 6, 1, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 19, 20, 21,
22, 23, 1, 1, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 26, 27, 28, 29, 1, 30, 31, 32, 33,
22, 23, 24, 1, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 27, 28, 29, 30, 1, 31, 32, 33, 34,
34, 35, 36, 37, 38, 24, 39, 40, 41, 42,
43, 44, 24, 45, 46, 47, 48, 49, 50, 24,
51, 52, 53, 54, 55, 56, 1, 1, 1, 1,
35, 36, 37, 38, 39, 25, 40, 41, 42, 43,
44, 45, 25, 46, 47, 48, 49, 50, 51, 25,
52, 53, 54, 55, 56, 57, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -632,240 +632,240 @@ static const YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
static const YY_CHAR yy_meta[57] =
static const YY_CHAR yy_meta[58] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 4, 1, 1,
1, 1, 1, 4, 1, 5, 1, 1, 4, 4,
1, 1, 1, 1, 4, 1, 5, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1
4, 4, 4, 1, 1, 1, 1
} ;
static const flex_int16_t yy_base[319] =
static const flex_int16_t yy_base[320] =
{ 0,
0, 0, 54, 55, 56, 57, 574, 575, 575, 575,
551, 56, 35, 550, 63, 55, 575, 575, 549, 56,
575, 55, 56, 74, 71, 551, 575, 54, 547, 70,
542, 575, 575, 545, 53, 58, 64, 72, 73, 74,
79, 84, 82, 85, 86, 88, 95, 97, 94, 107,
575, 96, 575, 575, 575, 575, 549, 575, 575, 548,
575, 120, 575, 127, 522, 521, 516, 575, 122, 575,
115, 575, 126, 140, 575, 575, 575, 575, 575, 120,
523, 575, 575, 0, 575, 121, 141, 135, 0, 575,
538, 575, 575, 575, 537, 532, 575, 132, 128, 134,
0, 0, 55, 56, 57, 58, 575, 576, 576, 576,
552, 57, 34, 551, 66, 60, 576, 576, 550, 57,
576, 63, 48, 74, 74, 552, 576, 55, 548, 59,
576, 542, 576, 576, 546, 62, 66, 71, 72, 67,
73, 87, 70, 76, 89, 92, 93, 94, 96, 97,
99, 576, 100, 576, 576, 576, 576, 550, 576, 576,
549, 576, 120, 576, 136, 522, 521, 516, 576, 122,
576, 123, 576, 126, 143, 576, 576, 576, 576, 576,
118, 523, 576, 576, 0, 576, 125, 140, 132, 0,
576, 539, 576, 576, 576, 538, 532, 576, 130, 133,
137, 139, 138, 142, 114, 143, 145, 146, 531, 530,
150, 151, 152, 153, 156, 159, 163, 158, 160, 165,
166, 575, 575, 575, 575, 189, 197, 202, 517, 522,
515, 204, 575, 207, 205, 208, 209, 210, 213, 575,
500, 0, 202, 575, 525, 575, 575, 199, 212, 187,
195, 206, 198, 217, 215, 218, 222, 224, 225, 226,
227, 228, 229, 231, 236, 230, 238, 241, 244, 243,
245, 509, 509, 506, 268, 269, 276, 271, 273, 283,
513, 520, 261, 519, 518, 258, 263, 262, 517, 270,
272, 277, 516, 278, 279, 282, 287, 515, 289, 290,
124, 135, 137, 139, 145, 149, 146, 150, 151, 531,
530, 152, 155, 154, 157, 158, 161, 162, 163, 170,
167, 168, 576, 576, 576, 576, 186, 204, 211, 517,
522, 515, 205, 576, 212, 202, 215, 210, 213, 217,
576, 500, 0, 205, 576, 525, 576, 576, 194, 203,
206, 200, 216, 198, 218, 221, 223, 224, 225, 226,
227, 231, 228, 232, 236, 238, 241, 239, 242, 248,
246, 249, 509, 509, 506, 273, 274, 277, 275, 276,
284, 513, 520, 104, 519, 518, 262, 268, 264, 517,
265, 270, 279, 516, 271, 282, 287, 288, 515, 289,
293, 514, 291, 294, 296, 492, 490, 501, 575, 298,
299, 301, 305, 510, 509, 302, 508, 307, 313, 309,
312, 322, 324, 314, 310, 327, 507, 487, 498, 501,
328, 330, 334, 336, 335, 503, 340, 337, 502, 501,
342, 500, 338, 343, 344, 491, 490, 493, 350, 349,
351, 496, 495, 355, 360, 363, 364, 366, 369, 486,
575, 477, 370, 374, 492, 373, 491, 375, 377, 380,
378, 575, 478, 376, 390, 389, 391, 489, 488, 392,
395, 472, 486, 396, 472, 424, 400, 401, 402, 421,
402, 406, 397, 407, 408, 406, 410, 352, 259, 409,
272, 292, 514, 294, 297, 300, 492, 490, 501, 576,
298, 299, 301, 305, 510, 509, 304, 508, 302, 321,
309, 311, 312, 324, 328, 313, 330, 507, 487, 498,
501, 333, 334, 314, 335, 337, 503, 338, 339, 502,
501, 341, 500, 343, 347, 344, 491, 490, 493, 349,
352, 354, 496, 495, 353, 357, 365, 366, 367, 369,
486, 576, 477, 368, 370, 492, 375, 491, 372, 379,
377, 380, 576, 478, 381, 388, 390, 391, 489, 488,
393, 396, 472, 473, 394, 425, 424, 399, 397, 402,
422, 404, 405, 398, 407, 409, 405, 408, 315, 193,
575, 413, 200, 575, 451, 456, 461, 466, 469, 471,
476, 481, 486, 491, 496, 84, 501, 506
410, 576, 414, 159, 576, 453, 458, 463, 468, 471,
473, 478, 483, 488, 493, 498, 68, 503, 508
} ;
static const flex_int16_t yy_def[319] =
static const flex_int16_t yy_def[320] =
{ 0,
304, 1, 305, 305, 306, 306, 304, 304, 304, 304,
304, 307, 304, 304, 304, 308, 304, 304, 304, 304,
304, 304, 304, 304, 309, 304, 304, 304, 304, 304,
310, 304, 304, 304, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 307, 304, 311, 304, 304, 304, 304, 312, 304,
313, 304, 308, 314, 304, 304, 304, 304, 304, 304,
304, 304, 304, 315, 304, 304, 309, 309, 316, 304,
304, 304, 304, 304, 304, 310, 304, 310, 310, 310,
305, 1, 306, 306, 307, 307, 305, 305, 305, 305,
305, 308, 305, 305, 305, 309, 305, 305, 305, 305,
305, 305, 305, 305, 310, 305, 305, 305, 305, 305,
305, 311, 305, 305, 305, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 308, 305, 312, 305, 305, 305, 305, 313,
305, 314, 305, 309, 315, 305, 305, 305, 305, 305,
305, 305, 305, 305, 316, 305, 305, 310, 310, 317,
305, 305, 305, 305, 305, 305, 311, 305, 311, 311,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 304, 304, 307, 307, 311, 304, 304,
304, 312, 304, 317, 313, 318, 308, 308, 314, 304,
304, 315, 304, 304, 316, 304, 304, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 304, 312, 312, 317, 313, 313, 318,
304, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 305, 305, 308, 308, 312, 305,
305, 305, 313, 305, 318, 314, 319, 309, 309, 315,
305, 305, 316, 305, 305, 317, 305, 305, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 305, 313, 313, 318, 314, 314,
319, 305, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
310, 310, 310, 310, 310, 304, 304, 304, 304, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 304, 304, 304,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 304, 304, 304, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 304,
304, 304, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 310, 310, 310, 310, 310, 310, 310,
310, 304, 310, 310, 310, 310, 310, 310, 304, 310,
310, 310, 304, 310, 310, 304, 310, 310, 304, 310,
311, 311, 311, 311, 311, 311, 305, 305, 305, 305,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 305, 305,
305, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 305, 305, 305, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
305, 305, 305, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 311, 311, 311, 311, 311, 311,
311, 311, 305, 311, 311, 311, 311, 311, 311, 305,
311, 311, 311, 305, 311, 311, 305, 311, 311, 305,
304, 310, 310, 0, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304
311, 305, 311, 311, 0, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305
} ;
static const flex_int16_t yy_nxt[632] =
static const flex_int16_t yy_nxt[634] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 8, 33, 34, 31, 35,
36, 37, 38, 39, 40, 41, 31, 42, 31, 43,
31, 44, 31, 45, 46, 47, 48, 49, 31, 50,
31, 31, 51, 52, 53, 54, 56, 56, 59, 59,
63, 60, 60, 63, 65, 57, 57, 69, 76, 78,
70, 71, 66, 80, 91, 92, 79, 77, 89, 82,
74, 64, 67, 89, 72, 83, 86, 145, 87, 89,
84, 94, 95, 100, 98, 85, 89, 89, 89, 89,
28, 29, 30, 31, 32, 33, 8, 34, 35, 32,
36, 37, 38, 39, 40, 41, 42, 32, 43, 32,
44, 32, 45, 32, 46, 47, 48, 49, 50, 32,
51, 32, 32, 52, 53, 54, 55, 57, 57, 60,
60, 64, 61, 61, 66, 81, 58, 58, 64, 77,
70, 146, 67, 71, 72, 92, 93, 79, 78, 83,
95, 96, 68, 65, 80, 84, 75, 73, 90, 87,
85, 88, 90, 90, 82, 86, 90, 90, 90, 90,
101, 81, 99, 106, 89, 103, 102, 89, 108, 89,
89, 89, 104, 89, 105, 111, 107, 122, 109, 89,
89, 114, 89, 133, 63, 110, 133, 112, 115, 62,
113, 127, 89, 117, 63, 119, 120, 80, 143, 89,
136, 118, 73, 121, 116, 64, 156, 134, 138, 123,
304, 74, 128, 89, 140, 144, 86, 89, 87, 89,
89, 149, 89, 89, 89, 139, 89, 89, 89, 148,
89, 89, 154, 150, 152, 89, 89, 89, 89, 151,
153, 89, 157, 89, 89, 89, 159, 155, 89, 158,
89, 89, 169, 63, 162, 164, 165, 161, 160, 163,
90, 101, 90, 107, 99, 110, 104, 105, 102, 106,
112, 100, 111, 90, 103, 90, 108, 109, 90, 90,
90, 123, 90, 90, 64, 90, 134, 115, 116, 121,
90, 134, 113, 118, 64, 81, 122, 114, 63, 120,
128, 119, 144, 211, 117, 74, 65, 305, 135, 137,
90, 139, 75, 141, 124, 87, 90, 88, 90, 90,
145, 90, 129, 90, 151, 90, 90, 150, 149, 140,
152, 90, 90, 153, 155, 90, 90, 90, 90, 154,
90, 90, 157, 90, 90, 90, 158, 90, 90, 90,
64, 156, 160, 90, 90, 159, 90, 163, 165, 166,
166, 63, 170, 171, 62, 168, 127, 167, 133, 132,
135, 176, 89, 133, 64, 73, 179, 63, 63, 143,
89, 138, 64, 89, 89, 89, 184, 128, 185, 134,
136, 89, 177, 180, 74, 74, 144, 89, 139, 182,
89, 183, 89, 89, 187, 186, 188, 89, 189, 89,
89, 89, 89, 89, 89, 89, 89, 192, 193, 194,
190, 89, 196, 89, 195, 198, 89, 191, 89, 89,
89, 201, 133, 133, 202, 200, 197, 203, 132, 133,
176, 133, 199, 89, 205, 135, 89, 89, 89, 204,
211, 179, 301, 134, 134, 89, 136, 89, 136, 210,
167, 161, 162, 170, 164, 171, 172, 168, 64, 134,
134, 169, 65, 63, 133, 128, 177, 136, 64, 74,
90, 64, 144, 180, 90, 139, 90, 302, 137, 90,
65, 135, 90, 184, 186, 183, 75, 129, 178, 75,
145, 181, 90, 140, 90, 188, 185, 90, 189, 90,
90, 90, 90, 90, 90, 190, 187, 90, 90, 193,
194, 195, 90, 197, 90, 90, 191, 90, 90, 196,
192, 199, 90, 202, 90, 90, 203, 134, 134, 133,
198, 177, 204, 134, 134, 200, 136, 201, 90, 206,
90, 90, 180, 205, 90, 212, 90, 90, 90, 135,
212, 177, 89, 89, 89, 215, 216, 89, 180, 213,
219, 214, 89, 218, 89, 89, 89, 217, 89, 89,
221, 89, 223, 89, 89, 224, 89, 89, 225, 227,
89, 220, 89, 235, 89, 89, 222, 89, 89, 89,
226, 231, 233, 237, 234, 232, 238, 89, 240, 89,
239, 243, 89, 89, 244, 89, 242, 236, 241, 89,
89, 89, 89, 89, 245, 89, 250, 89, 89, 89,
249, 253, 258, 254, 89, 89, 89, 89, 255, 257,
89, 251, 252, 259, 265, 89, 256, 263, 89, 89,
266, 89, 267, 264, 89, 89, 268, 269, 89, 89,
135, 137, 137, 178, 216, 90, 213, 215, 90, 217,
181, 218, 214, 90, 90, 90, 220, 219, 90, 223,
90, 222, 224, 90, 90, 90, 90, 90, 90, 225,
90, 90, 226, 221, 228, 90, 236, 90, 90, 90,
90, 90, 232, 234, 227, 235, 233, 90, 241, 242,
90, 240, 238, 237, 90, 239, 90, 243, 245, 90,
90, 90, 252, 90, 90, 90, 244, 90, 246, 90,
90, 251, 255, 90, 254, 90, 250, 259, 90, 90,
90, 256, 253, 90, 260, 258, 257, 264, 266, 267,
268, 90, 90, 90, 90, 90, 90, 265, 90, 269,
89, 89, 89, 89, 277, 89, 270, 275, 271, 278,
276, 274, 280, 279, 89, 89, 89, 89, 281, 284,
89, 89, 283, 286, 288, 89, 89, 89, 290, 291,
285, 89, 89, 89, 89, 89, 287, 295, 89, 299,
297, 296, 294, 300, 298, 303, 89, 292, 293, 89,
302, 55, 55, 55, 55, 55, 58, 58, 58, 58,
58, 62, 62, 62, 62, 62, 73, 73, 73, 73,
73, 88, 88, 88, 96, 96, 126, 126, 126, 126,
126, 132, 132, 132, 132, 132, 135, 135, 135, 135,
135, 137, 137, 137, 137, 137, 142, 89, 142, 142,
270, 90, 278, 90, 276, 90, 90, 90, 271, 272,
275, 280, 279, 277, 90, 281, 90, 90, 285, 90,
90, 282, 90, 90, 287, 90, 289, 291, 284, 292,
90, 90, 286, 90, 90, 90, 90, 296, 288, 300,
90, 298, 301, 297, 293, 295, 299, 304, 90, 294,
90, 90, 303, 56, 56, 56, 56, 56, 59, 59,
59, 59, 59, 63, 63, 63, 63, 63, 74, 74,
74, 74, 74, 89, 89, 89, 97, 97, 127, 127,
127, 127, 127, 133, 133, 133, 133, 133, 136, 136,
136, 136, 136, 138, 138, 138, 138, 138, 143, 90,
142, 175, 175, 175, 175, 175, 178, 178, 178, 178,
178, 89, 289, 89, 89, 282, 89, 89, 273, 272,
89, 89, 262, 261, 260, 89, 89, 89, 89, 248,
247, 246, 89, 89, 89, 89, 230, 229, 228, 89,
89, 89, 89, 89, 89, 89, 209, 208, 207, 206,
89, 181, 174, 173, 172, 89, 89, 89, 147, 146,
141, 131, 130, 129, 125, 124, 97, 89, 93, 90,
75, 68, 61, 304, 7, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
143, 143, 143, 176, 176, 176, 176, 176, 179, 179,
179, 179, 179, 290, 90, 90, 283, 90, 90, 274,
273, 90, 90, 263, 262, 261, 90, 90, 90, 90,
249, 248, 247, 90, 90, 90, 90, 231, 230, 229,
90, 90, 90, 90, 90, 90, 90, 210, 209, 208,
207, 90, 182, 175, 174, 173, 90, 90, 90, 148,
147, 142, 132, 131, 130, 126, 125, 98, 90, 94,
91, 76, 69, 62, 305, 7, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305
} ;
static const flex_int16_t yy_chk[632] =
static const flex_int16_t yy_chk[634] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 4, 5, 6,
12, 5, 6, 16, 13, 3, 4, 15, 20, 22,
15, 15, 13, 23, 28, 28, 22, 20, 35, 24,
16, 12, 13, 36, 15, 24, 25, 316, 25, 37,
24, 30, 30, 37, 35, 24, 25, 38, 39, 40,
1, 1, 1, 1, 1, 1, 1, 3, 4, 5,
6, 12, 5, 6, 13, 23, 3, 4, 16, 20,
15, 317, 13, 15, 15, 28, 28, 22, 20, 24,
30, 30, 13, 12, 22, 24, 16, 15, 36, 25,
24, 25, 37, 40, 23, 24, 43, 38, 39, 41,
37, 23, 36, 40, 41, 38, 37, 43, 41, 42,
44, 45, 39, 46, 39, 43, 40, 52, 42, 49,
47, 46, 48, 71, 62, 42, 69, 44, 47, 64,
45, 64, 50, 48, 73, 49, 50, 80, 86, 105,
71, 48, 74, 50, 47, 62, 105, 69, 74, 52,
88, 73, 64, 99, 80, 86, 87, 98, 87, 100,
88, 99, 101, 103, 102, 74, 87, 104, 106, 98,
107, 108, 103, 100, 101, 111, 112, 113, 114, 100,
102, 115, 106, 118, 116, 119, 108, 104, 117, 107,
120, 121, 119, 126, 113, 115, 116, 112, 111, 114,
25, 38, 44, 41, 36, 43, 39, 40, 38, 40,
44, 37, 43, 42, 38, 45, 41, 42, 46, 47,
48, 53, 49, 50, 63, 51, 70, 47, 48, 51,
184, 72, 45, 49, 74, 81, 51, 46, 65, 50,
65, 49, 87, 184, 48, 75, 63, 89, 70, 72,
101, 75, 74, 81, 53, 88, 99, 88, 89, 100,
87, 102, 65, 103, 101, 104, 88, 100, 99, 75,
101, 105, 107, 102, 104, 106, 108, 109, 112, 103,
114, 113, 106, 115, 116, 304, 107, 117, 118, 119,
127, 105, 109, 121, 122, 108, 120, 114, 116, 117,
117, 127, 120, 121, 128, 118, 128, 117, 132, 134,
136, 134, 150, 135, 126, 139, 136, 137, 138, 143,
151, 139, 127, 153, 148, 303, 150, 128, 151, 132,
135, 152, 134, 136, 137, 138, 143, 149, 139, 148,
155, 149, 154, 156, 153, 152, 154, 157, 155, 158,
159, 160, 161, 162, 163, 166, 164, 158, 159, 160,
156, 165, 162, 167, 161, 164, 168, 157, 170, 169,
171, 167, 175, 176, 168, 166, 163, 169, 177, 178,
177, 179, 165, 186, 171, 180, 183, 188, 187, 170,
186, 180, 299, 175, 176, 190, 178, 191, 179, 183,
118, 112, 113, 120, 115, 121, 122, 118, 128, 133,
136, 119, 127, 129, 135, 129, 135, 137, 138, 140,
149, 139, 144, 137, 154, 140, 152, 300, 136, 150,
128, 133, 151, 150, 152, 149, 138, 129, 135, 139,
144, 137, 153, 140, 155, 154, 151, 156, 155, 157,
158, 159, 160, 161, 163, 156, 153, 162, 164, 159,
160, 161, 165, 163, 166, 168, 157, 167, 169, 162,
158, 165, 171, 168, 170, 172, 169, 176, 177, 178,
164, 178, 170, 179, 180, 166, 181, 167, 187, 172,
189, 191, 181, 171, 188, 187, 192, 195, 201, 176,
187, 177, 192, 194, 195, 191, 192, 196, 180, 188,
196, 190, 197, 195, 199, 200, 203, 194, 201, 204,
199, 205, 201, 210, 211, 203, 212, 216, 204, 205,
213, 197, 218, 216, 220, 225, 200, 221, 219, 224,
204, 210, 212, 219, 213, 211, 219, 222, 221, 223,
220, 224, 226, 231, 225, 232, 223, 218, 222, 233,
235, 234, 238, 243, 226, 237, 232, 241, 244, 245,
231, 235, 244, 237, 250, 249, 251, 298, 238, 243,
254, 233, 234, 245, 251, 255, 241, 249, 256, 257,
254, 258, 255, 250, 259, 263, 256, 257, 266, 264,
177, 179, 180, 178, 192, 193, 188, 191, 196, 193,
181, 195, 189, 197, 198, 200, 197, 196, 202, 201,
204, 200, 202, 205, 211, 212, 206, 213, 219, 204,
217, 214, 205, 198, 206, 221, 217, 222, 223, 226,
234, 299, 211, 213, 205, 214, 212, 220, 222, 223,
224, 221, 220, 219, 225, 220, 227, 224, 226, 232,
233, 235, 234, 236, 238, 239, 225, 242, 227, 244,
246, 233, 238, 245, 236, 250, 232, 245, 251, 255,
252, 239, 235, 256, 246, 244, 242, 250, 252, 255,
256, 257, 258, 259, 264, 260, 265, 251, 269, 257,
268, 274, 269, 271, 268, 270, 258, 264, 259, 269,
266, 263, 271, 270, 276, 275, 277, 280, 271, 275,
281, 284, 274, 277, 281, 287, 288, 291, 284, 287,
276, 292, 294, 295, 300, 297, 280, 292, 302, 296,
294, 293, 291, 297, 295, 302, 290, 288, 289, 286,
300, 305, 305, 305, 305, 305, 306, 306, 306, 306,
306, 307, 307, 307, 307, 307, 308, 308, 308, 308,
308, 309, 309, 309, 310, 310, 311, 311, 311, 311,
311, 312, 312, 312, 312, 312, 313, 313, 313, 313,
313, 314, 314, 314, 314, 314, 315, 285, 315, 315,
258, 267, 269, 271, 265, 270, 272, 275, 259, 260,
264, 271, 270, 267, 276, 272, 277, 278, 276, 281,
285, 272, 282, 289, 278, 288, 282, 285, 275, 288,
292, 293, 277, 295, 298, 296, 301, 293, 281, 297,
303, 295, 298, 294, 289, 292, 296, 303, 291, 290,
287, 286, 301, 306, 306, 306, 306, 306, 307, 307,
307, 307, 307, 308, 308, 308, 308, 308, 309, 309,
309, 309, 309, 310, 310, 310, 311, 311, 312, 312,
312, 312, 312, 313, 313, 313, 313, 313, 314, 314,
314, 314, 314, 315, 315, 315, 315, 315, 316, 284,
315, 317, 317, 317, 317, 317, 318, 318, 318, 318,
318, 283, 282, 279, 278, 273, 267, 265, 262, 260,
253, 252, 248, 247, 246, 242, 240, 239, 236, 230,
229, 228, 227, 217, 215, 214, 208, 207, 206, 202,
198, 193, 189, 185, 184, 182, 181, 174, 173, 172,
145, 141, 131, 130, 129, 110, 109, 96, 95, 91,
81, 67, 66, 65, 60, 57, 34, 31, 29, 26,
19, 14, 11, 7, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
316, 316, 316, 318, 318, 318, 318, 318, 319, 319,
319, 319, 319, 283, 280, 279, 274, 268, 266, 263,
261, 254, 253, 249, 248, 247, 243, 241, 240, 237,
231, 230, 229, 228, 218, 216, 215, 209, 208, 207,
203, 199, 194, 190, 186, 185, 183, 182, 175, 174,
173, 146, 142, 132, 131, 130, 111, 110, 97, 96,
92, 82, 68, 67, 66, 61, 58, 35, 32, 29,
26, 19, 14, 11, 7, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305
} ;
/* The intent behind this definition is that it'll catch
@ -1183,13 +1183,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_current_state != 304 );
while ( yy_current_state != 305 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1510,218 +1510,223 @@ YY_RULE_SETUP
case 60:
YY_RULE_SETUP
#line 107 "lexer.lpp"
{ return s1::parser::make_INCREMENT(loc); }
{ return s1::parser::make_QMARK(loc); }
YY_BREAK
case 61:
YY_RULE_SETUP
#line 108 "lexer.lpp"
{ return s1::parser::make_DECREMENT(loc); }
{ return s1::parser::make_INCREMENT(loc); }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 109 "lexer.lpp"
{ return s1::parser::make_ASSIGN_LSHIFT(loc); }
{ return s1::parser::make_DECREMENT(loc); }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 110 "lexer.lpp"
{ return s1::parser::make_ASSIGN_RSHIFT(loc); }
{ return s1::parser::make_ASSIGN_LSHIFT(loc); }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 111 "lexer.lpp"
{ return s1::parser::make_LSHIFT(loc); }
{ return s1::parser::make_ASSIGN_RSHIFT(loc); }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 112 "lexer.lpp"
{ return s1::parser::make_RSHIFT(loc); }
{ return s1::parser::make_LSHIFT(loc); }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 113 "lexer.lpp"
{ return s1::parser::make_OR(loc); }
{ return s1::parser::make_RSHIFT(loc); }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 114 "lexer.lpp"
{ return s1::parser::make_AND(loc); }
{ return s1::parser::make_OR(loc); }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 115 "lexer.lpp"
{ return s1::parser::make_EQUALITY(loc); }
{ return s1::parser::make_AND(loc); }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 116 "lexer.lpp"
{ return s1::parser::make_INEQUALITY(loc); }
{ return s1::parser::make_EQUALITY(loc); }
YY_BREAK
case 70:
YY_RULE_SETUP
#line 117 "lexer.lpp"
{ return s1::parser::make_LESS_EQUAL(loc); }
{ return s1::parser::make_INEQUALITY(loc); }
YY_BREAK
case 71:
YY_RULE_SETUP
#line 118 "lexer.lpp"
{ return s1::parser::make_GREATER_EQUAL(loc); }
{ return s1::parser::make_LESS_EQUAL(loc); }
YY_BREAK
case 72:
YY_RULE_SETUP
#line 119 "lexer.lpp"
{ return s1::parser::make_LESS(loc); }
{ return s1::parser::make_GREATER_EQUAL(loc); }
YY_BREAK
case 73:
YY_RULE_SETUP
#line 120 "lexer.lpp"
{ return s1::parser::make_GREATER(loc); }
{ return s1::parser::make_LESS(loc); }
YY_BREAK
case 74:
YY_RULE_SETUP
#line 121 "lexer.lpp"
{ return s1::parser::make_ASSIGN_ADD(loc); }
{ return s1::parser::make_GREATER(loc); }
YY_BREAK
case 75:
YY_RULE_SETUP
#line 122 "lexer.lpp"
{ return s1::parser::make_ASSIGN_SUB(loc); }
{ return s1::parser::make_ASSIGN_ADD(loc); }
YY_BREAK
case 76:
YY_RULE_SETUP
#line 123 "lexer.lpp"
{ return s1::parser::make_ASSIGN_MULT(loc); }
{ return s1::parser::make_ASSIGN_SUB(loc); }
YY_BREAK
case 77:
YY_RULE_SETUP
#line 124 "lexer.lpp"
{ return s1::parser::make_ASSIGN_DIV(loc); }
{ return s1::parser::make_ASSIGN_MULT(loc); }
YY_BREAK
case 78:
YY_RULE_SETUP
#line 125 "lexer.lpp"
{ return s1::parser::make_ASSIGN_MOD(loc); }
{ return s1::parser::make_ASSIGN_DIV(loc); }
YY_BREAK
case 79:
YY_RULE_SETUP
#line 126 "lexer.lpp"
{ return s1::parser::make_ASSIGN_BITWISE_OR(loc); }
{ return s1::parser::make_ASSIGN_MOD(loc); }
YY_BREAK
case 80:
YY_RULE_SETUP
#line 127 "lexer.lpp"
{ return s1::parser::make_ASSIGN_BITWISE_AND(loc); }
{ return s1::parser::make_ASSIGN_BITWISE_OR(loc); }
YY_BREAK
case 81:
YY_RULE_SETUP
#line 128 "lexer.lpp"
{ return s1::parser::make_ASSIGN_BITWISE_EXOR(loc); }
{ return s1::parser::make_ASSIGN_BITWISE_AND(loc); }
YY_BREAK
case 82:
YY_RULE_SETUP
#line 129 "lexer.lpp"
{ return s1::parser::make_ASSIGN(loc); }
{ return s1::parser::make_ASSIGN_BITWISE_EXOR(loc); }
YY_BREAK
case 83:
YY_RULE_SETUP
#line 130 "lexer.lpp"
{ return s1::parser::make_ADD(loc); }
{ return s1::parser::make_ASSIGN(loc); }
YY_BREAK
case 84:
YY_RULE_SETUP
#line 131 "lexer.lpp"
{ return s1::parser::make_SUB(loc); }
{ return s1::parser::make_ADD(loc); }
YY_BREAK
case 85:
YY_RULE_SETUP
#line 132 "lexer.lpp"
{ return s1::parser::make_MULT(loc); }
{ return s1::parser::make_SUB(loc); }
YY_BREAK
case 86:
YY_RULE_SETUP
#line 133 "lexer.lpp"
{ return s1::parser::make_DIV(loc); }
{ return s1::parser::make_MULT(loc); }
YY_BREAK
case 87:
YY_RULE_SETUP
#line 134 "lexer.lpp"
{ return s1::parser::make_MOD(loc); }
{ return s1::parser::make_DIV(loc); }
YY_BREAK
case 88:
YY_RULE_SETUP
#line 135 "lexer.lpp"
{ return s1::parser::make_NOT(loc); }
{ return s1::parser::make_MOD(loc); }
YY_BREAK
case 89:
YY_RULE_SETUP
#line 136 "lexer.lpp"
{ return s1::parser::make_COMPLEMENT(loc); }
{ return s1::parser::make_NOT(loc); }
YY_BREAK
case 90:
YY_RULE_SETUP
#line 137 "lexer.lpp"
{ return s1::parser::make_BITWISE_OR(loc); }
{ return s1::parser::make_COMPLEMENT(loc); }
YY_BREAK
case 91:
YY_RULE_SETUP
#line 138 "lexer.lpp"
{ return s1::parser::make_BITWISE_AND(loc); }
{ return s1::parser::make_BITWISE_OR(loc); }
YY_BREAK
case 92:
YY_RULE_SETUP
#line 139 "lexer.lpp"
{ return s1::parser::make_BITWISE_EXOR(loc); }
{ return s1::parser::make_BITWISE_AND(loc); }
YY_BREAK
case 93:
YY_RULE_SETUP
#line 140 "lexer.lpp"
{ return s1::parser::make_FILE(utils::string::fordslash(yytext), loc); }
{ return s1::parser::make_BITWISE_EXOR(loc); }
YY_BREAK
case 94:
YY_RULE_SETUP
#line 141 "lexer.lpp"
{ return s1::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
{ return s1::parser::make_FILE(utils::string::fordslash(yytext), loc); }
YY_BREAK
case 95:
/* rule 95 can match eol */
YY_RULE_SETUP
#line 142 "lexer.lpp"
{ return s1::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
{ return s1::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 143 "lexer.lpp"
{ return s1::parser::make_STRING(std::string(yytext), loc); }
{ return s1::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
YY_BREAK
case 97:
/* rule 97 can match eol */
YY_RULE_SETUP
#line 144 "lexer.lpp"
{ return s1::parser::make_FLOAT(std::string(yytext), loc); }
{ return s1::parser::make_STRING(std::string(yytext), loc); }
YY_BREAK
case 98:
YY_RULE_SETUP
#line 145 "lexer.lpp"
{ return s1::parser::make_FLOAT(std::string(yytext), loc); }
YY_BREAK
case 99:
YY_RULE_SETUP
#line 146 "lexer.lpp"
{ return s1::parser::make_INTEGER(std::string(yytext), loc); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT_BLOCK_STATE):
case YY_STATE_EOF(DEVELOPER_BLOCK_STATE):
#line 146 "lexer.lpp"
#line 147 "lexer.lpp"
{ return s1::parser::make_S1EOF(loc); }
YY_BREAK
case 99:
/* rule 99 can match eol */
case 100:
/* rule 100 can match eol */
YY_RULE_SETUP
#line 147 "lexer.lpp"
#line 148 "lexer.lpp"
{ throw s1::parser::syntax_error(loc, "bad token: \'" + std::string(yytext) + "\'"); }
YY_BREAK
case 100:
case 101:
YY_RULE_SETUP
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"
ECHO;
YY_BREAK
#line 1724 "lexer.cpp"
#line 1729 "lexer.cpp"
case YY_END_OF_BUFFER:
{
@ -2019,7 +2024,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@ -2048,11 +2053,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 304);
yy_is_jam = (yy_current_state == 305);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@ -2851,6 +2856,6 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"

View File

@ -700,7 +700,7 @@ extern int yylex (yyscan_t yyscanner);
#undef yyTABLES_NAME
#endif
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"
#line 706 "lexer.hpp"

File diff suppressed because it is too large Load Diff

View File

@ -446,6 +446,7 @@ namespace xsk { namespace gsc { namespace s1 {
// for_expr
// expr
// expr_compare
// expr_ternary
// expr_binary
// expr_primitive
char dummy11[sizeof (expr_ptr)];
@ -700,53 +701,55 @@ namespace xsk { namespace gsc { namespace s1 {
DOUBLECOLON = 48, // "::"
COLON = 49, // ":"
SEMICOLON = 50, // ";"
INCREMENT = 51, // "++"
DECREMENT = 52, // "--"
LSHIFT = 53, // "<<"
RSHIFT = 54, // ">>"
OR = 55, // "||"
AND = 56, // "&&"
EQUALITY = 57, // "=="
INEQUALITY = 58, // "!="
LESS_EQUAL = 59, // "<="
GREATER_EQUAL = 60, // ">="
LESS = 61, // "<"
GREATER = 62, // ">"
NOT = 63, // "!"
COMPLEMENT = 64, // "~"
ASSIGN = 65, // "="
ASSIGN_ADD = 66, // "+="
ASSIGN_SUB = 67, // "-="
ASSIGN_MULT = 68, // "*="
ASSIGN_DIV = 69, // "/="
ASSIGN_MOD = 70, // "%="
ASSIGN_BITWISE_OR = 71, // "|="
ASSIGN_BITWISE_AND = 72, // "&="
ASSIGN_BITWISE_EXOR = 73, // "^="
ASSIGN_RSHIFT = 74, // ">>="
ASSIGN_LSHIFT = 75, // "<<="
BITWISE_OR = 76, // "|"
BITWISE_AND = 77, // "&"
BITWISE_EXOR = 78, // "^"
ADD = 79, // "+"
SUB = 80, // "-"
MULT = 81, // "*"
DIV = 82, // "/"
MOD = 83, // "%"
FILE = 84, // "file path"
NAME = 85, // "identifier"
STRING = 86, // "string literal"
ISTRING = 87, // "localized string"
FLOAT = 88, // "float"
INTEGER = 89, // "int"
ADD_ARRAY = 90, // ADD_ARRAY
THEN = 91, // THEN
NEG = 92, // NEG
ANIMREF = 93, // ANIMREF
PREINC = 94, // PREINC
PREDEC = 95, // PREDEC
POSTINC = 96, // POSTINC
POSTDEC = 97 // POSTDEC
QMARK = 51, // "?"
INCREMENT = 52, // "++"
DECREMENT = 53, // "--"
LSHIFT = 54, // "<<"
RSHIFT = 55, // ">>"
OR = 56, // "||"
AND = 57, // "&&"
EQUALITY = 58, // "=="
INEQUALITY = 59, // "!="
LESS_EQUAL = 60, // "<="
GREATER_EQUAL = 61, // ">="
LESS = 62, // "<"
GREATER = 63, // ">"
NOT = 64, // "!"
COMPLEMENT = 65, // "~"
ASSIGN = 66, // "="
ASSIGN_ADD = 67, // "+="
ASSIGN_SUB = 68, // "-="
ASSIGN_MULT = 69, // "*="
ASSIGN_DIV = 70, // "/="
ASSIGN_MOD = 71, // "%="
ASSIGN_BITWISE_OR = 72, // "|="
ASSIGN_BITWISE_AND = 73, // "&="
ASSIGN_BITWISE_EXOR = 74, // "^="
ASSIGN_RSHIFT = 75, // ">>="
ASSIGN_LSHIFT = 76, // "<<="
BITWISE_OR = 77, // "|"
BITWISE_AND = 78, // "&"
BITWISE_EXOR = 79, // "^"
ADD = 80, // "+"
SUB = 81, // "-"
MULT = 82, // "*"
DIV = 83, // "/"
MOD = 84, // "%"
FILE = 85, // "file path"
NAME = 86, // "identifier"
STRING = 87, // "string literal"
ISTRING = 88, // "localized string"
FLOAT = 89, // "float"
INTEGER = 90, // "int"
ADD_ARRAY = 91, // ADD_ARRAY
THEN = 92, // THEN
TERN = 93, // TERN
NEG = 94, // NEG
ANIMREF = 95, // ANIMREF
PREINC = 96, // PREINC
PREDEC = 97, // PREDEC
POSTINC = 98, // POSTINC
POSTDEC = 99 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -763,7 +766,7 @@ namespace xsk { namespace gsc { namespace s1 {
{
enum symbol_kind_type
{
YYNTOKENS = 98, ///< Number of tokens.
YYNTOKENS = 100, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
@ -816,129 +819,132 @@ namespace xsk { namespace gsc { namespace s1 {
S_DOUBLECOLON = 48, // "::"
S_COLON = 49, // ":"
S_SEMICOLON = 50, // ";"
S_INCREMENT = 51, // "++"
S_DECREMENT = 52, // "--"
S_LSHIFT = 53, // "<<"
S_RSHIFT = 54, // ">>"
S_OR = 55, // "||"
S_AND = 56, // "&&"
S_EQUALITY = 57, // "=="
S_INEQUALITY = 58, // "!="
S_LESS_EQUAL = 59, // "<="
S_GREATER_EQUAL = 60, // ">="
S_LESS = 61, // "<"
S_GREATER = 62, // ">"
S_NOT = 63, // "!"
S_COMPLEMENT = 64, // "~"
S_ASSIGN = 65, // "="
S_ASSIGN_ADD = 66, // "+="
S_ASSIGN_SUB = 67, // "-="
S_ASSIGN_MULT = 68, // "*="
S_ASSIGN_DIV = 69, // "/="
S_ASSIGN_MOD = 70, // "%="
S_ASSIGN_BITWISE_OR = 71, // "|="
S_ASSIGN_BITWISE_AND = 72, // "&="
S_ASSIGN_BITWISE_EXOR = 73, // "^="
S_ASSIGN_RSHIFT = 74, // ">>="
S_ASSIGN_LSHIFT = 75, // "<<="
S_BITWISE_OR = 76, // "|"
S_BITWISE_AND = 77, // "&"
S_BITWISE_EXOR = 78, // "^"
S_ADD = 79, // "+"
S_SUB = 80, // "-"
S_MULT = 81, // "*"
S_DIV = 82, // "/"
S_MOD = 83, // "%"
S_FILE = 84, // "file path"
S_NAME = 85, // "identifier"
S_STRING = 86, // "string literal"
S_ISTRING = 87, // "localized string"
S_FLOAT = 88, // "float"
S_INTEGER = 89, // "int"
S_ADD_ARRAY = 90, // ADD_ARRAY
S_THEN = 91, // THEN
S_NEG = 92, // NEG
S_ANIMREF = 93, // ANIMREF
S_PREINC = 94, // PREINC
S_PREDEC = 95, // PREDEC
S_POSTINC = 96, // POSTINC
S_POSTDEC = 97, // POSTDEC
S_YYACCEPT = 98, // $accept
S_root = 99, // root
S_program = 100, // program
S_include = 101, // include
S_define = 102, // define
S_usingtree = 103, // usingtree
S_constant = 104, // constant
S_thread = 105, // thread
S_parameters = 106, // parameters
S_stmt = 107, // stmt
S_stmt_block = 108, // stmt_block
S_stmt_list = 109, // stmt_list
S_stmt_call = 110, // stmt_call
S_stmt_assign = 111, // stmt_assign
S_stmt_endon = 112, // stmt_endon
S_stmt_notify = 113, // stmt_notify
S_stmt_wait = 114, // stmt_wait
S_stmt_waittill = 115, // stmt_waittill
S_stmt_waittillmatch = 116, // stmt_waittillmatch
S_stmt_waittillframeend = 117, // stmt_waittillframeend
S_stmt_waitframe = 118, // stmt_waitframe
S_stmt_if = 119, // stmt_if
S_stmt_ifelse = 120, // stmt_ifelse
S_stmt_while = 121, // stmt_while
S_stmt_for = 122, // stmt_for
S_stmt_foreach = 123, // stmt_foreach
S_stmt_switch = 124, // stmt_switch
S_stmt_case = 125, // stmt_case
S_stmt_default = 126, // stmt_default
S_stmt_break = 127, // stmt_break
S_stmt_continue = 128, // stmt_continue
S_stmt_return = 129, // stmt_return
S_stmt_breakpoint = 130, // stmt_breakpoint
S_stmt_prof_begin = 131, // stmt_prof_begin
S_stmt_prof_end = 132, // stmt_prof_end
S_for_stmt = 133, // for_stmt
S_for_expr = 134, // for_expr
S_expr = 135, // expr
S_expr_assign = 136, // expr_assign
S_expr_compare = 137, // expr_compare
S_expr_binary = 138, // expr_binary
S_expr_primitive = 139, // expr_primitive
S_expr_call = 140, // expr_call
S_expr_call_thread = 141, // expr_call_thread
S_expr_call_childthread = 142, // expr_call_childthread
S_expr_call_function = 143, // expr_call_function
S_expr_call_pointer = 144, // expr_call_pointer
S_expr_arguments = 145, // expr_arguments
S_expr_arguments_filled = 146, // expr_arguments_filled
S_expr_arguments_empty = 147, // expr_arguments_empty
S_expr_function = 148, // expr_function
S_expr_add_array = 149, // expr_add_array
S_expr_array = 150, // expr_array
S_expr_field = 151, // expr_field
S_expr_size = 152, // expr_size
S_object = 153, // object
S_thisthread = 154, // thisthread
S_empty_array = 155, // empty_array
S_undefined = 156, // undefined
S_game = 157, // game
S_self = 158, // self
S_anim = 159, // anim
S_level = 160, // level
S_animation = 161, // animation
S_animtree = 162, // animtree
S_name = 163, // name
S_file = 164, // file
S_istring = 165, // istring
S_string = 166, // string
S_vector = 167, // vector
S_neg_float = 168, // neg_float
S_neg_integer = 169, // neg_integer
S_float = 170, // float
S_integer = 171, // integer
S_false = 172, // false
S_true = 173 // true
S_QMARK = 51, // "?"
S_INCREMENT = 52, // "++"
S_DECREMENT = 53, // "--"
S_LSHIFT = 54, // "<<"
S_RSHIFT = 55, // ">>"
S_OR = 56, // "||"
S_AND = 57, // "&&"
S_EQUALITY = 58, // "=="
S_INEQUALITY = 59, // "!="
S_LESS_EQUAL = 60, // "<="
S_GREATER_EQUAL = 61, // ">="
S_LESS = 62, // "<"
S_GREATER = 63, // ">"
S_NOT = 64, // "!"
S_COMPLEMENT = 65, // "~"
S_ASSIGN = 66, // "="
S_ASSIGN_ADD = 67, // "+="
S_ASSIGN_SUB = 68, // "-="
S_ASSIGN_MULT = 69, // "*="
S_ASSIGN_DIV = 70, // "/="
S_ASSIGN_MOD = 71, // "%="
S_ASSIGN_BITWISE_OR = 72, // "|="
S_ASSIGN_BITWISE_AND = 73, // "&="
S_ASSIGN_BITWISE_EXOR = 74, // "^="
S_ASSIGN_RSHIFT = 75, // ">>="
S_ASSIGN_LSHIFT = 76, // "<<="
S_BITWISE_OR = 77, // "|"
S_BITWISE_AND = 78, // "&"
S_BITWISE_EXOR = 79, // "^"
S_ADD = 80, // "+"
S_SUB = 81, // "-"
S_MULT = 82, // "*"
S_DIV = 83, // "/"
S_MOD = 84, // "%"
S_FILE = 85, // "file path"
S_NAME = 86, // "identifier"
S_STRING = 87, // "string literal"
S_ISTRING = 88, // "localized string"
S_FLOAT = 89, // "float"
S_INTEGER = 90, // "int"
S_ADD_ARRAY = 91, // ADD_ARRAY
S_THEN = 92, // THEN
S_TERN = 93, // TERN
S_NEG = 94, // NEG
S_ANIMREF = 95, // ANIMREF
S_PREINC = 96, // PREINC
S_PREDEC = 97, // PREDEC
S_POSTINC = 98, // POSTINC
S_POSTDEC = 99, // POSTDEC
S_YYACCEPT = 100, // $accept
S_root = 101, // root
S_program = 102, // program
S_include = 103, // include
S_define = 104, // define
S_usingtree = 105, // usingtree
S_constant = 106, // constant
S_thread = 107, // thread
S_parameters = 108, // parameters
S_stmt = 109, // stmt
S_stmt_block = 110, // stmt_block
S_stmt_list = 111, // stmt_list
S_stmt_call = 112, // stmt_call
S_stmt_assign = 113, // stmt_assign
S_stmt_endon = 114, // stmt_endon
S_stmt_notify = 115, // stmt_notify
S_stmt_wait = 116, // stmt_wait
S_stmt_waittill = 117, // stmt_waittill
S_stmt_waittillmatch = 118, // stmt_waittillmatch
S_stmt_waittillframeend = 119, // stmt_waittillframeend
S_stmt_waitframe = 120, // stmt_waitframe
S_stmt_if = 121, // stmt_if
S_stmt_ifelse = 122, // stmt_ifelse
S_stmt_while = 123, // stmt_while
S_stmt_for = 124, // stmt_for
S_stmt_foreach = 125, // stmt_foreach
S_stmt_switch = 126, // stmt_switch
S_stmt_case = 127, // stmt_case
S_stmt_default = 128, // stmt_default
S_stmt_break = 129, // stmt_break
S_stmt_continue = 130, // stmt_continue
S_stmt_return = 131, // stmt_return
S_stmt_breakpoint = 132, // stmt_breakpoint
S_stmt_prof_begin = 133, // stmt_prof_begin
S_stmt_prof_end = 134, // stmt_prof_end
S_for_stmt = 135, // for_stmt
S_for_expr = 136, // for_expr
S_expr = 137, // expr
S_expr_assign = 138, // expr_assign
S_expr_compare = 139, // expr_compare
S_expr_ternary = 140, // expr_ternary
S_expr_binary = 141, // expr_binary
S_expr_primitive = 142, // expr_primitive
S_expr_call = 143, // expr_call
S_expr_call_thread = 144, // expr_call_thread
S_expr_call_childthread = 145, // expr_call_childthread
S_expr_call_function = 146, // expr_call_function
S_expr_call_pointer = 147, // expr_call_pointer
S_expr_arguments = 148, // expr_arguments
S_expr_arguments_filled = 149, // expr_arguments_filled
S_expr_arguments_empty = 150, // expr_arguments_empty
S_expr_function = 151, // expr_function
S_expr_add_array = 152, // expr_add_array
S_expr_array = 153, // expr_array
S_expr_field = 154, // expr_field
S_expr_size = 155, // expr_size
S_object = 156, // object
S_thisthread = 157, // thisthread
S_empty_array = 158, // empty_array
S_undefined = 159, // undefined
S_game = 160, // game
S_self = 161, // self
S_anim = 162, // anim
S_level = 163, // level
S_animation = 164, // animation
S_animtree = 165, // animtree
S_name = 166, // name
S_file = 167, // file
S_istring = 168, // istring
S_string = 169, // string
S_vector = 170, // vector
S_neg_float = 171, // neg_float
S_neg_integer = 172, // neg_integer
S_float = 173, // float
S_integer = 174, // integer
S_false = 175, // false
S_true = 176 // true
};
};
@ -1023,6 +1029,7 @@ namespace xsk { namespace gsc { namespace s1 {
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (std::move (that.value));
@ -2117,6 +2124,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.template destroy< expr_ptr > ();
@ -3241,6 +3249,21 @@ switch (yykind)
return symbol_type (token::SEMICOLON, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_QMARK (location_type l)
{
return symbol_type (token::QMARK, std::move (l));
}
#else
static
symbol_type
make_QMARK (const location_type& l)
{
return symbol_type (token::QMARK, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -3856,6 +3879,21 @@ switch (yykind)
return symbol_type (token::THEN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_TERN (location_type l)
{
return symbol_type (token::TERN, std::move (l));
}
#else
static
symbol_type
make_TERN (const location_type& l)
{
return symbol_type (token::TERN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4290,8 +4328,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 1646, ///< Last index in yytable_.
yynnts_ = 76, ///< Number of nonterminal symbols.
yylast_ = 1842, ///< Last index in yytable_.
yynnts_ = 77, ///< Number of nonterminal symbols.
yyfinal_ = 15 ///< Termination state number.
};
@ -4367,6 +4405,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.copy< expr_ptr > (YY_MOVE (that.value));
@ -4647,6 +4686,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (YY_MOVE (s.value));
@ -4913,7 +4953,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::s1
#line 4917 "parser.hpp"
#line 4957 "parser.hpp"

View File

@ -115,7 +115,6 @@ void assembler::assemble(const std::string& file, std::vector<gsc::function_ptr>
functions_ = std::move(functions);
script_->write<std::uint8_t>(static_cast<std::uint8_t>(opcode::OP_End));
stack_->write<std::uint32_t>(0x69773630);
for (const auto& func : functions_)
{

View File

@ -409,7 +409,7 @@ void compiler::emit_stmt_while(const gsc::context_ptr& ctx, const gsc::stmt_whil
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -465,7 +465,7 @@ void compiler::emit_stmt_for(const gsc::context_ptr& ctx, const gsc::stmt_for_pt
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -540,7 +540,7 @@ void compiler::emit_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt_fo
ctx->local_vars_create_count = stmt->ctx->local_vars_create_count;
for(auto i = 0; i < ctx->local_vars_create_count; i++)
for(auto i = 0u; i < ctx->local_vars_create_count; i++)
{
if(!ctx->local_vars.at(i).init)
ctx->local_vars.at(i).init = true;
@ -752,6 +752,7 @@ void compiler::emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr)
{
switch(expr.as_node->type)
{
case gsc::node_t::expr_ternary: emit_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: emit_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: emit_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: emit_expr_binary(ctx, expr.as_binary); break;
@ -849,6 +850,30 @@ void compiler::emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_ass
}
}
void compiler::emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
auto else_loc = create_label();
auto end_loc = create_label();
if(expr->cond.as_node->type == gsc::node_t::expr_not)
{
emit_expr(ctx, expr->cond.as_not->rvalue);
emit_opcode(ctx, opcode::OP_JumpOnTrue, else_loc);
}
else
{
emit_expr(ctx, expr->cond);
emit_opcode(ctx, opcode::OP_JumpOnFalse, else_loc);
}
emit_expr(ctx, expr->lvalue);
emit_opcode(ctx, opcode::OP_jump, end_loc);
insert_label(else_loc);
emit_expr(ctx, expr->rvalue);
insert_label(end_loc);
}
void compiler::emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
emit_expr(ctx, expr->lvalue);

View File

@ -68,6 +68,7 @@ private:
void emit_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void emit_expr(const gsc::context_ptr& ctx, const gsc::expr_ptr& expr);
void emit_expr_assign(const gsc::context_ptr& ctx, const gsc::expr_assign_ptr& expr);
void emit_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void emit_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void emit_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void emit_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -96,6 +96,14 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
decompile_expr();
}
}
for(auto& entry : tern_labels_)
{
if(entry == itr->second)
{
decompile_ternary();
}
}
}
switch (opcode(inst->opcode))
@ -1833,6 +1841,7 @@ void decompiler::decompile_statements(const gsc::function_ptr& func)
{
auto expr = std::make_unique<gsc::node_asm_jump>(loc, inst->data[0]);
func_->block->stmts.push_back(gsc::stmt_ptr(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1925,6 +1934,29 @@ void decompiler::decompile_expr()
}
}
void decompiler::decompile_ternary()
{
auto rvalue = std::move(stack_.top());
stack_.pop();
auto lvalue = std::move(stack_.top());
stack_.pop();
func_->block->stmts.pop_back();
auto stmt = std::move(func_->block->stmts.back());
func_->block->stmts.pop_back();
if(stmt.as_node->type == node_t::asm_jump_cond)
{
auto loc = stmt.as_cond->loc;
auto e = std::make_unique<gsc::node_expr_ternary>(loc, std::move(stmt.as_cond->expr), std::move(lvalue), std::move(rvalue));
stack_.push(std::move(e));
}
else
{
throw gsc::decomp_error("TRIED TO DECOMPILE INVALID TERNARY EXPR!");
}
}
void decompiler::decompile_block(const gsc::stmt_list_ptr& block)
{
this->decompile_search_infinite(block);
@ -3015,6 +3047,7 @@ void decompiler::process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr)
case gsc::node_t::expr_assign_bitwise_or: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_and: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_assign_bitwise_exor: process_expr_assign(ctx, expr.as_assign); break;
case gsc::node_t::expr_ternary: process_expr_ternary(ctx, expr.as_ternary); break;
case gsc::node_t::expr_and: process_expr_and(ctx, expr.as_and); break;
case gsc::node_t::expr_or: process_expr_or(ctx, expr.as_or); break;
case gsc::node_t::expr_equality: process_expr_binary(ctx, expr.as_binary); break;
@ -3115,6 +3148,13 @@ void decompiler::process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assi
}
}
void decompiler::process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr)
{
process_expr(ctx, expr->cond);
process_expr(ctx, expr->lvalue);
process_expr(ctx, expr->rvalue);
}
void decompiler::process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr)
{
process_expr(ctx, expr->lvalue);

View File

@ -16,6 +16,7 @@ class decompiler : public gsc::decompiler
gsc::thread_ptr func_;
std::unordered_map<std::uint32_t, std::string> labels_;
std::vector<std::string> expr_labels_;
std::vector<std::string> tern_labels_;
std::stack<gsc::node_ptr> stack_;
std::vector<gsc::context> blocks_;
@ -27,6 +28,7 @@ private:
void decompile_function(const gsc::function_ptr& func);
void decompile_statements(const gsc::function_ptr& func);
void decompile_expr();
void decompile_ternary();
void decompile_block(const gsc::stmt_list_ptr& block);
void decompile_search_infinite(const gsc::stmt_list_ptr& block);
void decompile_search_loop(const gsc::stmt_list_ptr& block);
@ -68,6 +70,7 @@ private:
void process_stmt_return(const gsc::context_ptr& ctx, const gsc::stmt_return_ptr& stmt);
void process_expr(const gsc::context_ptr& ctx, gsc::expr_ptr& expr);
void process_expr_assign(const gsc::context_ptr& ctx, gsc::expr_assign_ptr& expr);
void process_expr_ternary(const gsc::context_ptr& ctx, const gsc::expr_ternary_ptr& expr);
void process_expr_binary(const gsc::context_ptr& ctx, const gsc::expr_binary_ptr& expr);
void process_expr_and(const gsc::context_ptr& ctx, const gsc::expr_and_ptr& expr);
void process_expr_or(const gsc::context_ptr& ctx, const gsc::expr_or_ptr& expr);

View File

@ -553,8 +553,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 100
#define YY_END_OF_BUFFER 101
#define YY_NUM_RULES 101
#define YY_END_OF_BUFFER 102
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -562,42 +562,42 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[305] =
static const flex_int16_t yy_accept[306] =
{ 0,
0, 0, 0, 0, 0, 0, 101, 99, 1, 2,
88, 99, 99, 87, 91, 99, 49, 50, 85, 83,
55, 84, 56, 86, 98, 58, 59, 72, 82, 73,
94, 53, 54, 92, 94, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
51, 90, 52, 89, 5, 6, 5, 9, 10, 9,
69, 0, 96, 0, 0, 0, 0, 78, 0, 67,
0, 80, 0, 0, 76, 60, 74, 61, 75, 97,
0, 8, 4, 3, 77, 97, 98, 0, 0, 57,
64, 70, 68, 71, 65, 94, 81, 94, 94, 94,
0, 0, 0, 0, 0, 0, 102, 100, 1, 2,
89, 100, 100, 88, 92, 100, 49, 50, 86, 84,
55, 85, 56, 87, 99, 58, 59, 73, 83, 74,
60, 95, 53, 54, 93, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 51, 91, 52, 90, 5, 6, 5, 9, 10,
9, 70, 0, 97, 0, 0, 0, 0, 79, 0,
68, 0, 81, 0, 0, 77, 61, 75, 62, 76,
98, 0, 8, 4, 3, 78, 98, 99, 0, 0,
57, 65, 71, 69, 72, 66, 95, 82, 95, 95,
94, 94, 94, 94, 94, 94, 94, 94, 25, 30,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 79, 66, 7, 11, 0, 96, 0, 0, 0,
0, 0, 95, 0, 0, 0, 0, 96, 0, 97,
0, 3, 97, 97, 93, 62, 63, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 28, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 0, 0, 0, 0, 95, 0, 0, 95, 0,
0, 47, 94, 40, 32, 94, 94, 94, 26, 94,
94, 94, 45, 94, 94, 94, 94, 46, 94, 94,
95, 95, 95, 95, 95, 95, 95, 95, 95, 25,
30, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 80, 67, 7, 11, 0, 97, 0, 0,
0, 0, 0, 96, 0, 0, 0, 0, 97, 0,
98, 0, 3, 98, 98, 94, 63, 64, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95, 28, 95,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 0, 0, 0, 0, 96, 0, 0, 96,
0, 0, 47, 95, 40, 32, 95, 95, 95, 26,
95, 95, 95, 45, 95, 95, 95, 95, 46, 95,
94, 41, 94, 20, 94, 0, 0, 0, 44, 34,
94, 94, 94, 18, 42, 94, 48, 94, 94, 94,
94, 94, 94, 94, 94, 94, 27, 0, 0, 0,
94, 94, 94, 94, 94, 19, 94, 94, 36, 31,
94, 37, 94, 94, 94, 0, 0, 0, 94, 94,
94, 33, 29, 94, 94, 94, 94, 94, 94, 0,
15, 0, 94, 94, 35, 94, 14, 94, 94, 94,
21, 17, 0, 94, 94, 94, 94, 43, 24, 94,
94, 0, 12, 94, 13, 39, 94, 94, 0, 38,
94, 94, 0, 94, 94, 0, 94, 22, 0, 94,
95, 95, 41, 95, 20, 95, 0, 0, 0, 44,
34, 95, 95, 95, 18, 42, 95, 48, 95, 95,
95, 95, 95, 95, 95, 95, 95, 27, 0, 0,
0, 95, 95, 95, 95, 95, 19, 95, 95, 36,
31, 95, 37, 95, 95, 95, 0, 0, 0, 95,
95, 95, 33, 29, 95, 95, 95, 95, 95, 95,
0, 15, 0, 95, 95, 35, 95, 14, 95, 95,
95, 21, 17, 0, 95, 95, 95, 95, 43, 24,
95, 95, 0, 12, 95, 13, 39, 95, 95, 0,
38, 95, 95, 0, 95, 95, 0, 95, 22, 0,
16, 94, 23, 0
95, 16, 95, 23, 0
} ;
static const YY_CHAR yy_ec[256] =
@ -608,14 +608,14 @@ static const YY_CHAR yy_ec[256] =
1, 2, 4, 5, 6, 1, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 19, 20, 21,
22, 23, 1, 1, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 26, 27, 28, 29, 1, 30, 31, 32, 33,
22, 23, 24, 1, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 27, 28, 29, 30, 1, 31, 32, 33, 34,
34, 35, 36, 37, 38, 24, 39, 40, 41, 42,
43, 44, 24, 45, 46, 47, 48, 49, 50, 24,
51, 52, 53, 54, 55, 56, 1, 1, 1, 1,
35, 36, 37, 38, 39, 25, 40, 41, 42, 43,
44, 45, 25, 46, 47, 48, 49, 50, 51, 25,
52, 53, 54, 55, 56, 57, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -632,240 +632,240 @@ static const YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
static const YY_CHAR yy_meta[57] =
static const YY_CHAR yy_meta[58] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 3, 1, 4, 1, 1,
1, 1, 1, 4, 1, 5, 1, 1, 4, 4,
1, 1, 1, 1, 4, 1, 5, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1
4, 4, 4, 1, 1, 1, 1
} ;
static const flex_int16_t yy_base[319] =
static const flex_int16_t yy_base[320] =
{ 0,
0, 0, 54, 55, 56, 57, 574, 575, 575, 575,
551, 56, 35, 550, 63, 55, 575, 575, 549, 56,
575, 55, 56, 74, 71, 551, 575, 54, 547, 70,
542, 575, 575, 545, 53, 58, 64, 72, 73, 74,
79, 84, 82, 85, 86, 88, 95, 97, 94, 107,
575, 96, 575, 575, 575, 575, 549, 575, 575, 548,
575, 120, 575, 127, 522, 521, 516, 575, 122, 575,
115, 575, 126, 140, 575, 575, 575, 575, 575, 120,
523, 575, 575, 0, 575, 121, 141, 135, 0, 575,
538, 575, 575, 575, 537, 532, 575, 132, 128, 134,
0, 0, 55, 56, 57, 58, 575, 576, 576, 576,
552, 57, 34, 551, 66, 60, 576, 576, 550, 57,
576, 63, 48, 74, 74, 552, 576, 55, 548, 59,
576, 542, 576, 576, 546, 62, 66, 71, 72, 67,
73, 87, 70, 76, 89, 92, 93, 94, 96, 97,
99, 576, 100, 576, 576, 576, 576, 550, 576, 576,
549, 576, 120, 576, 136, 522, 521, 516, 576, 122,
576, 123, 576, 126, 143, 576, 576, 576, 576, 576,
118, 523, 576, 576, 0, 576, 125, 140, 132, 0,
576, 539, 576, 576, 576, 538, 532, 576, 130, 133,
137, 139, 138, 142, 114, 143, 145, 146, 531, 530,
150, 151, 152, 153, 156, 159, 163, 158, 160, 165,
166, 575, 575, 575, 575, 189, 197, 202, 517, 522,
515, 204, 575, 207, 205, 208, 209, 210, 213, 575,
500, 0, 202, 575, 525, 575, 575, 199, 212, 187,
195, 206, 198, 217, 215, 218, 222, 224, 225, 226,
227, 228, 229, 231, 236, 230, 238, 241, 244, 243,
245, 509, 509, 506, 268, 269, 276, 271, 273, 283,
513, 520, 261, 519, 518, 258, 263, 262, 517, 270,
272, 277, 516, 278, 279, 282, 287, 515, 289, 290,
124, 135, 137, 139, 145, 149, 146, 150, 151, 531,
530, 152, 155, 154, 157, 158, 161, 162, 163, 170,
167, 168, 576, 576, 576, 576, 186, 204, 211, 517,
522, 515, 205, 576, 212, 202, 215, 210, 213, 217,
576, 500, 0, 205, 576, 525, 576, 576, 194, 203,
206, 200, 216, 198, 218, 221, 223, 224, 225, 226,
227, 231, 228, 232, 236, 238, 241, 239, 242, 248,
246, 249, 509, 509, 506, 273, 274, 277, 275, 276,
284, 513, 520, 104, 519, 518, 262, 268, 264, 517,
265, 270, 279, 516, 271, 282, 287, 288, 515, 289,
293, 514, 291, 294, 296, 492, 490, 501, 575, 298,
299, 301, 305, 510, 509, 302, 508, 307, 313, 309,
312, 322, 324, 314, 310, 327, 507, 487, 498, 501,
328, 330, 334, 336, 335, 503, 340, 337, 502, 501,
342, 500, 338, 343, 344, 491, 490, 493, 350, 349,
351, 496, 495, 355, 360, 363, 364, 366, 369, 486,
575, 477, 370, 374, 492, 373, 491, 375, 377, 380,
378, 575, 478, 376, 390, 389, 391, 489, 488, 392,
395, 472, 486, 396, 472, 424, 400, 401, 402, 421,
402, 406, 397, 407, 408, 406, 410, 352, 259, 409,
272, 292, 514, 294, 297, 300, 492, 490, 501, 576,
298, 299, 301, 305, 510, 509, 304, 508, 302, 321,
309, 311, 312, 324, 328, 313, 330, 507, 487, 498,
501, 333, 334, 314, 335, 337, 503, 338, 339, 502,
501, 341, 500, 343, 347, 344, 491, 490, 493, 349,
352, 354, 496, 495, 353, 357, 365, 366, 367, 369,
486, 576, 477, 368, 370, 492, 375, 491, 372, 379,
377, 380, 576, 478, 381, 388, 390, 391, 489, 488,
393, 396, 472, 473, 394, 425, 424, 399, 397, 402,
422, 404, 405, 398, 407, 409, 405, 408, 315, 193,
575, 413, 200, 575, 451, 456, 461, 466, 469, 471,
476, 481, 486, 491, 496, 84, 501, 506
410, 576, 414, 159, 576, 453, 458, 463, 468, 471,
473, 478, 483, 488, 493, 498, 68, 503, 508
} ;
static const flex_int16_t yy_def[319] =
static const flex_int16_t yy_def[320] =
{ 0,
304, 1, 305, 305, 306, 306, 304, 304, 304, 304,
304, 307, 304, 304, 304, 308, 304, 304, 304, 304,
304, 304, 304, 304, 309, 304, 304, 304, 304, 304,
310, 304, 304, 304, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 307, 304, 311, 304, 304, 304, 304, 312, 304,
313, 304, 308, 314, 304, 304, 304, 304, 304, 304,
304, 304, 304, 315, 304, 304, 309, 309, 316, 304,
304, 304, 304, 304, 304, 310, 304, 310, 310, 310,
305, 1, 306, 306, 307, 307, 305, 305, 305, 305,
305, 308, 305, 305, 305, 309, 305, 305, 305, 305,
305, 305, 305, 305, 310, 305, 305, 305, 305, 305,
305, 311, 305, 305, 305, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 308, 305, 312, 305, 305, 305, 305, 313,
305, 314, 305, 309, 315, 305, 305, 305, 305, 305,
305, 305, 305, 305, 316, 305, 305, 310, 310, 317,
305, 305, 305, 305, 305, 305, 311, 305, 311, 311,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 304, 304, 307, 307, 311, 304, 304,
304, 312, 304, 317, 313, 318, 308, 308, 314, 304,
304, 315, 304, 304, 316, 304, 304, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 304, 312, 312, 317, 313, 313, 318,
304, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 305, 305, 308, 308, 312, 305,
305, 305, 313, 305, 318, 314, 319, 309, 309, 315,
305, 305, 316, 305, 305, 317, 305, 305, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 305, 313, 313, 318, 314, 314,
319, 305, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
310, 310, 310, 310, 310, 304, 304, 304, 304, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 310, 310, 304, 304, 304,
310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
310, 310, 310, 310, 310, 304, 304, 304, 310, 310,
310, 310, 310, 310, 310, 310, 310, 310, 310, 304,
304, 304, 310, 310, 310, 310, 310, 310, 310, 310,
310, 304, 304, 310, 310, 310, 310, 310, 310, 310,
310, 304, 310, 310, 310, 310, 310, 310, 304, 310,
310, 310, 304, 310, 310, 304, 310, 310, 304, 310,
311, 311, 311, 311, 311, 311, 305, 305, 305, 305,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 311, 311, 305, 305,
305, 311, 311, 311, 311, 311, 311, 311, 311, 311,
311, 311, 311, 311, 311, 311, 305, 305, 305, 311,
311, 311, 311, 311, 311, 311, 311, 311, 311, 311,
305, 305, 305, 311, 311, 311, 311, 311, 311, 311,
311, 311, 305, 305, 311, 311, 311, 311, 311, 311,
311, 311, 305, 311, 311, 311, 311, 311, 311, 305,
311, 311, 311, 305, 311, 311, 305, 311, 311, 305,
304, 310, 310, 0, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304
311, 305, 311, 311, 0, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305
} ;
static const flex_int16_t yy_nxt[632] =
static const flex_int16_t yy_nxt[634] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 8, 33, 34, 31, 35,
36, 37, 38, 39, 40, 41, 31, 42, 31, 43,
31, 44, 31, 45, 46, 47, 48, 49, 31, 50,
31, 31, 51, 52, 53, 54, 56, 56, 59, 59,
63, 60, 60, 63, 65, 57, 57, 69, 76, 78,
70, 71, 66, 80, 91, 92, 79, 77, 89, 82,
74, 64, 67, 89, 72, 83, 86, 145, 87, 89,
84, 94, 95, 100, 98, 85, 89, 89, 89, 89,
28, 29, 30, 31, 32, 33, 8, 34, 35, 32,
36, 37, 38, 39, 40, 41, 42, 32, 43, 32,
44, 32, 45, 32, 46, 47, 48, 49, 50, 32,
51, 32, 32, 52, 53, 54, 55, 57, 57, 60,
60, 64, 61, 61, 66, 81, 58, 58, 64, 77,
70, 146, 67, 71, 72, 92, 93, 79, 78, 83,
95, 96, 68, 65, 80, 84, 75, 73, 90, 87,
85, 88, 90, 90, 82, 86, 90, 90, 90, 90,
101, 81, 99, 106, 89, 103, 102, 89, 108, 89,
89, 89, 104, 89, 105, 111, 107, 122, 109, 89,
89, 114, 89, 133, 63, 110, 133, 112, 115, 62,
113, 127, 89, 117, 63, 119, 120, 80, 143, 89,
136, 118, 73, 121, 116, 64, 156, 134, 138, 123,
304, 74, 128, 89, 140, 144, 86, 89, 87, 89,
89, 149, 89, 89, 89, 139, 89, 89, 89, 148,
89, 89, 154, 150, 152, 89, 89, 89, 89, 151,
153, 89, 157, 89, 89, 89, 159, 155, 89, 158,
89, 89, 169, 63, 162, 164, 165, 161, 160, 163,
90, 101, 90, 107, 99, 110, 104, 105, 102, 106,
112, 100, 111, 90, 103, 90, 108, 109, 90, 90,
90, 123, 90, 90, 64, 90, 134, 115, 116, 121,
90, 134, 113, 118, 64, 81, 122, 114, 63, 120,
128, 119, 144, 211, 117, 74, 65, 305, 135, 137,
90, 139, 75, 141, 124, 87, 90, 88, 90, 90,
145, 90, 129, 90, 151, 90, 90, 150, 149, 140,
152, 90, 90, 153, 155, 90, 90, 90, 90, 154,
90, 90, 157, 90, 90, 90, 158, 90, 90, 90,
64, 156, 160, 90, 90, 159, 90, 163, 165, 166,
166, 63, 170, 171, 62, 168, 127, 167, 133, 132,
135, 176, 89, 133, 64, 73, 179, 63, 63, 143,
89, 138, 64, 89, 89, 89, 184, 128, 185, 134,
136, 89, 177, 180, 74, 74, 144, 89, 139, 182,
89, 183, 89, 89, 187, 186, 188, 89, 189, 89,
89, 89, 89, 89, 89, 89, 89, 192, 193, 194,
190, 89, 196, 89, 195, 198, 89, 191, 89, 89,
89, 201, 133, 133, 202, 200, 197, 203, 132, 133,
176, 133, 199, 89, 205, 135, 89, 89, 89, 204,
211, 179, 301, 134, 134, 89, 136, 89, 136, 210,
167, 161, 162, 170, 164, 171, 172, 168, 64, 134,
134, 169, 65, 63, 133, 128, 177, 136, 64, 74,
90, 64, 144, 180, 90, 139, 90, 302, 137, 90,
65, 135, 90, 184, 186, 183, 75, 129, 178, 75,
145, 181, 90, 140, 90, 188, 185, 90, 189, 90,
90, 90, 90, 90, 90, 190, 187, 90, 90, 193,
194, 195, 90, 197, 90, 90, 191, 90, 90, 196,
192, 199, 90, 202, 90, 90, 203, 134, 134, 133,
198, 177, 204, 134, 134, 200, 136, 201, 90, 206,
90, 90, 180, 205, 90, 212, 90, 90, 90, 135,
212, 177, 89, 89, 89, 215, 216, 89, 180, 213,
219, 214, 89, 218, 89, 89, 89, 217, 89, 89,
221, 89, 223, 89, 89, 224, 89, 89, 225, 227,
89, 220, 89, 235, 89, 89, 222, 89, 89, 89,
226, 231, 233, 237, 234, 232, 238, 89, 240, 89,
239, 243, 89, 89, 244, 89, 242, 236, 241, 89,
89, 89, 89, 89, 245, 89, 250, 89, 89, 89,
249, 253, 258, 254, 89, 89, 89, 89, 255, 257,
89, 251, 252, 259, 265, 89, 256, 263, 89, 89,
266, 89, 267, 264, 89, 89, 268, 269, 89, 89,
135, 137, 137, 178, 216, 90, 213, 215, 90, 217,
181, 218, 214, 90, 90, 90, 220, 219, 90, 223,
90, 222, 224, 90, 90, 90, 90, 90, 90, 225,
90, 90, 226, 221, 228, 90, 236, 90, 90, 90,
90, 90, 232, 234, 227, 235, 233, 90, 241, 242,
90, 240, 238, 237, 90, 239, 90, 243, 245, 90,
90, 90, 252, 90, 90, 90, 244, 90, 246, 90,
90, 251, 255, 90, 254, 90, 250, 259, 90, 90,
90, 256, 253, 90, 260, 258, 257, 264, 266, 267,
268, 90, 90, 90, 90, 90, 90, 265, 90, 269,
89, 89, 89, 89, 277, 89, 270, 275, 271, 278,
276, 274, 280, 279, 89, 89, 89, 89, 281, 284,
89, 89, 283, 286, 288, 89, 89, 89, 290, 291,
285, 89, 89, 89, 89, 89, 287, 295, 89, 299,
297, 296, 294, 300, 298, 303, 89, 292, 293, 89,
302, 55, 55, 55, 55, 55, 58, 58, 58, 58,
58, 62, 62, 62, 62, 62, 73, 73, 73, 73,
73, 88, 88, 88, 96, 96, 126, 126, 126, 126,
126, 132, 132, 132, 132, 132, 135, 135, 135, 135,
135, 137, 137, 137, 137, 137, 142, 89, 142, 142,
270, 90, 278, 90, 276, 90, 90, 90, 271, 272,
275, 280, 279, 277, 90, 281, 90, 90, 285, 90,
90, 282, 90, 90, 287, 90, 289, 291, 284, 292,
90, 90, 286, 90, 90, 90, 90, 296, 288, 300,
90, 298, 301, 297, 293, 295, 299, 304, 90, 294,
90, 90, 303, 56, 56, 56, 56, 56, 59, 59,
59, 59, 59, 63, 63, 63, 63, 63, 74, 74,
74, 74, 74, 89, 89, 89, 97, 97, 127, 127,
127, 127, 127, 133, 133, 133, 133, 133, 136, 136,
136, 136, 136, 138, 138, 138, 138, 138, 143, 90,
142, 175, 175, 175, 175, 175, 178, 178, 178, 178,
178, 89, 289, 89, 89, 282, 89, 89, 273, 272,
89, 89, 262, 261, 260, 89, 89, 89, 89, 248,
247, 246, 89, 89, 89, 89, 230, 229, 228, 89,
89, 89, 89, 89, 89, 89, 209, 208, 207, 206,
89, 181, 174, 173, 172, 89, 89, 89, 147, 146,
141, 131, 130, 129, 125, 124, 97, 89, 93, 90,
75, 68, 61, 304, 7, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
143, 143, 143, 176, 176, 176, 176, 176, 179, 179,
179, 179, 179, 290, 90, 90, 283, 90, 90, 274,
273, 90, 90, 263, 262, 261, 90, 90, 90, 90,
249, 248, 247, 90, 90, 90, 90, 231, 230, 229,
90, 90, 90, 90, 90, 90, 90, 210, 209, 208,
207, 90, 182, 175, 174, 173, 90, 90, 90, 148,
147, 142, 132, 131, 130, 126, 125, 98, 90, 94,
91, 76, 69, 62, 305, 7, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305
} ;
static const flex_int16_t yy_chk[632] =
static const flex_int16_t yy_chk[634] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 4, 5, 6,
12, 5, 6, 16, 13, 3, 4, 15, 20, 22,
15, 15, 13, 23, 28, 28, 22, 20, 35, 24,
16, 12, 13, 36, 15, 24, 25, 316, 25, 37,
24, 30, 30, 37, 35, 24, 25, 38, 39, 40,
1, 1, 1, 1, 1, 1, 1, 3, 4, 5,
6, 12, 5, 6, 13, 23, 3, 4, 16, 20,
15, 317, 13, 15, 15, 28, 28, 22, 20, 24,
30, 30, 13, 12, 22, 24, 16, 15, 36, 25,
24, 25, 37, 40, 23, 24, 43, 38, 39, 41,
37, 23, 36, 40, 41, 38, 37, 43, 41, 42,
44, 45, 39, 46, 39, 43, 40, 52, 42, 49,
47, 46, 48, 71, 62, 42, 69, 44, 47, 64,
45, 64, 50, 48, 73, 49, 50, 80, 86, 105,
71, 48, 74, 50, 47, 62, 105, 69, 74, 52,
88, 73, 64, 99, 80, 86, 87, 98, 87, 100,
88, 99, 101, 103, 102, 74, 87, 104, 106, 98,
107, 108, 103, 100, 101, 111, 112, 113, 114, 100,
102, 115, 106, 118, 116, 119, 108, 104, 117, 107,
120, 121, 119, 126, 113, 115, 116, 112, 111, 114,
25, 38, 44, 41, 36, 43, 39, 40, 38, 40,
44, 37, 43, 42, 38, 45, 41, 42, 46, 47,
48, 53, 49, 50, 63, 51, 70, 47, 48, 51,
184, 72, 45, 49, 74, 81, 51, 46, 65, 50,
65, 49, 87, 184, 48, 75, 63, 89, 70, 72,
101, 75, 74, 81, 53, 88, 99, 88, 89, 100,
87, 102, 65, 103, 101, 104, 88, 100, 99, 75,
101, 105, 107, 102, 104, 106, 108, 109, 112, 103,
114, 113, 106, 115, 116, 304, 107, 117, 118, 119,
127, 105, 109, 121, 122, 108, 120, 114, 116, 117,
117, 127, 120, 121, 128, 118, 128, 117, 132, 134,
136, 134, 150, 135, 126, 139, 136, 137, 138, 143,
151, 139, 127, 153, 148, 303, 150, 128, 151, 132,
135, 152, 134, 136, 137, 138, 143, 149, 139, 148,
155, 149, 154, 156, 153, 152, 154, 157, 155, 158,
159, 160, 161, 162, 163, 166, 164, 158, 159, 160,
156, 165, 162, 167, 161, 164, 168, 157, 170, 169,
171, 167, 175, 176, 168, 166, 163, 169, 177, 178,
177, 179, 165, 186, 171, 180, 183, 188, 187, 170,
186, 180, 299, 175, 176, 190, 178, 191, 179, 183,
118, 112, 113, 120, 115, 121, 122, 118, 128, 133,
136, 119, 127, 129, 135, 129, 135, 137, 138, 140,
149, 139, 144, 137, 154, 140, 152, 300, 136, 150,
128, 133, 151, 150, 152, 149, 138, 129, 135, 139,
144, 137, 153, 140, 155, 154, 151, 156, 155, 157,
158, 159, 160, 161, 163, 156, 153, 162, 164, 159,
160, 161, 165, 163, 166, 168, 157, 167, 169, 162,
158, 165, 171, 168, 170, 172, 169, 176, 177, 178,
164, 178, 170, 179, 180, 166, 181, 167, 187, 172,
189, 191, 181, 171, 188, 187, 192, 195, 201, 176,
187, 177, 192, 194, 195, 191, 192, 196, 180, 188,
196, 190, 197, 195, 199, 200, 203, 194, 201, 204,
199, 205, 201, 210, 211, 203, 212, 216, 204, 205,
213, 197, 218, 216, 220, 225, 200, 221, 219, 224,
204, 210, 212, 219, 213, 211, 219, 222, 221, 223,
220, 224, 226, 231, 225, 232, 223, 218, 222, 233,
235, 234, 238, 243, 226, 237, 232, 241, 244, 245,
231, 235, 244, 237, 250, 249, 251, 298, 238, 243,
254, 233, 234, 245, 251, 255, 241, 249, 256, 257,
254, 258, 255, 250, 259, 263, 256, 257, 266, 264,
177, 179, 180, 178, 192, 193, 188, 191, 196, 193,
181, 195, 189, 197, 198, 200, 197, 196, 202, 201,
204, 200, 202, 205, 211, 212, 206, 213, 219, 204,
217, 214, 205, 198, 206, 221, 217, 222, 223, 226,
234, 299, 211, 213, 205, 214, 212, 220, 222, 223,
224, 221, 220, 219, 225, 220, 227, 224, 226, 232,
233, 235, 234, 236, 238, 239, 225, 242, 227, 244,
246, 233, 238, 245, 236, 250, 232, 245, 251, 255,
252, 239, 235, 256, 246, 244, 242, 250, 252, 255,
256, 257, 258, 259, 264, 260, 265, 251, 269, 257,
268, 274, 269, 271, 268, 270, 258, 264, 259, 269,
266, 263, 271, 270, 276, 275, 277, 280, 271, 275,
281, 284, 274, 277, 281, 287, 288, 291, 284, 287,
276, 292, 294, 295, 300, 297, 280, 292, 302, 296,
294, 293, 291, 297, 295, 302, 290, 288, 289, 286,
300, 305, 305, 305, 305, 305, 306, 306, 306, 306,
306, 307, 307, 307, 307, 307, 308, 308, 308, 308,
308, 309, 309, 309, 310, 310, 311, 311, 311, 311,
311, 312, 312, 312, 312, 312, 313, 313, 313, 313,
313, 314, 314, 314, 314, 314, 315, 285, 315, 315,
258, 267, 269, 271, 265, 270, 272, 275, 259, 260,
264, 271, 270, 267, 276, 272, 277, 278, 276, 281,
285, 272, 282, 289, 278, 288, 282, 285, 275, 288,
292, 293, 277, 295, 298, 296, 301, 293, 281, 297,
303, 295, 298, 294, 289, 292, 296, 303, 291, 290,
287, 286, 301, 306, 306, 306, 306, 306, 307, 307,
307, 307, 307, 308, 308, 308, 308, 308, 309, 309,
309, 309, 309, 310, 310, 310, 311, 311, 312, 312,
312, 312, 312, 313, 313, 313, 313, 313, 314, 314,
314, 314, 314, 315, 315, 315, 315, 315, 316, 284,
315, 317, 317, 317, 317, 317, 318, 318, 318, 318,
318, 283, 282, 279, 278, 273, 267, 265, 262, 260,
253, 252, 248, 247, 246, 242, 240, 239, 236, 230,
229, 228, 227, 217, 215, 214, 208, 207, 206, 202,
198, 193, 189, 185, 184, 182, 181, 174, 173, 172,
145, 141, 131, 130, 129, 110, 109, 96, 95, 91,
81, 67, 66, 65, 60, 57, 34, 31, 29, 26,
19, 14, 11, 7, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
316, 316, 316, 318, 318, 318, 318, 318, 319, 319,
319, 319, 319, 283, 280, 279, 274, 268, 266, 263,
261, 254, 253, 249, 248, 247, 243, 241, 240, 237,
231, 230, 229, 228, 218, 216, 215, 209, 208, 207,
203, 199, 194, 190, 186, 185, 183, 182, 175, 174,
173, 146, 142, 132, 131, 130, 111, 110, 97, 96,
92, 82, 68, 67, 66, 61, 58, 35, 32, 29,
26, 19, 14, 11, 7, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304, 304, 304, 304, 304, 304, 304, 304, 304, 304,
304
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305, 305, 305, 305, 305, 305, 305, 305,
305, 305, 305
} ;
/* The intent behind this definition is that it'll catch
@ -1183,13 +1183,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_current_state != 304 );
while ( yy_current_state != 305 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1510,218 +1510,223 @@ YY_RULE_SETUP
case 60:
YY_RULE_SETUP
#line 107 "lexer.lpp"
{ return s2::parser::make_INCREMENT(loc); }
{ return s2::parser::make_QMARK(loc); }
YY_BREAK
case 61:
YY_RULE_SETUP
#line 108 "lexer.lpp"
{ return s2::parser::make_DECREMENT(loc); }
{ return s2::parser::make_INCREMENT(loc); }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 109 "lexer.lpp"
{ return s2::parser::make_ASSIGN_LSHIFT(loc); }
{ return s2::parser::make_DECREMENT(loc); }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 110 "lexer.lpp"
{ return s2::parser::make_ASSIGN_RSHIFT(loc); }
{ return s2::parser::make_ASSIGN_LSHIFT(loc); }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 111 "lexer.lpp"
{ return s2::parser::make_LSHIFT(loc); }
{ return s2::parser::make_ASSIGN_RSHIFT(loc); }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 112 "lexer.lpp"
{ return s2::parser::make_RSHIFT(loc); }
{ return s2::parser::make_LSHIFT(loc); }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 113 "lexer.lpp"
{ return s2::parser::make_OR(loc); }
{ return s2::parser::make_RSHIFT(loc); }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 114 "lexer.lpp"
{ return s2::parser::make_AND(loc); }
{ return s2::parser::make_OR(loc); }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 115 "lexer.lpp"
{ return s2::parser::make_EQUALITY(loc); }
{ return s2::parser::make_AND(loc); }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 116 "lexer.lpp"
{ return s2::parser::make_INEQUALITY(loc); }
{ return s2::parser::make_EQUALITY(loc); }
YY_BREAK
case 70:
YY_RULE_SETUP
#line 117 "lexer.lpp"
{ return s2::parser::make_LESS_EQUAL(loc); }
{ return s2::parser::make_INEQUALITY(loc); }
YY_BREAK
case 71:
YY_RULE_SETUP
#line 118 "lexer.lpp"
{ return s2::parser::make_GREATER_EQUAL(loc); }
{ return s2::parser::make_LESS_EQUAL(loc); }
YY_BREAK
case 72:
YY_RULE_SETUP
#line 119 "lexer.lpp"
{ return s2::parser::make_LESS(loc); }
{ return s2::parser::make_GREATER_EQUAL(loc); }
YY_BREAK
case 73:
YY_RULE_SETUP
#line 120 "lexer.lpp"
{ return s2::parser::make_GREATER(loc); }
{ return s2::parser::make_LESS(loc); }
YY_BREAK
case 74:
YY_RULE_SETUP
#line 121 "lexer.lpp"
{ return s2::parser::make_ASSIGN_ADD(loc); }
{ return s2::parser::make_GREATER(loc); }
YY_BREAK
case 75:
YY_RULE_SETUP
#line 122 "lexer.lpp"
{ return s2::parser::make_ASSIGN_SUB(loc); }
{ return s2::parser::make_ASSIGN_ADD(loc); }
YY_BREAK
case 76:
YY_RULE_SETUP
#line 123 "lexer.lpp"
{ return s2::parser::make_ASSIGN_MULT(loc); }
{ return s2::parser::make_ASSIGN_SUB(loc); }
YY_BREAK
case 77:
YY_RULE_SETUP
#line 124 "lexer.lpp"
{ return s2::parser::make_ASSIGN_DIV(loc); }
{ return s2::parser::make_ASSIGN_MULT(loc); }
YY_BREAK
case 78:
YY_RULE_SETUP
#line 125 "lexer.lpp"
{ return s2::parser::make_ASSIGN_MOD(loc); }
{ return s2::parser::make_ASSIGN_DIV(loc); }
YY_BREAK
case 79:
YY_RULE_SETUP
#line 126 "lexer.lpp"
{ return s2::parser::make_ASSIGN_BITWISE_OR(loc); }
{ return s2::parser::make_ASSIGN_MOD(loc); }
YY_BREAK
case 80:
YY_RULE_SETUP
#line 127 "lexer.lpp"
{ return s2::parser::make_ASSIGN_BITWISE_AND(loc); }
{ return s2::parser::make_ASSIGN_BITWISE_OR(loc); }
YY_BREAK
case 81:
YY_RULE_SETUP
#line 128 "lexer.lpp"
{ return s2::parser::make_ASSIGN_BITWISE_EXOR(loc); }
{ return s2::parser::make_ASSIGN_BITWISE_AND(loc); }
YY_BREAK
case 82:
YY_RULE_SETUP
#line 129 "lexer.lpp"
{ return s2::parser::make_ASSIGN(loc); }
{ return s2::parser::make_ASSIGN_BITWISE_EXOR(loc); }
YY_BREAK
case 83:
YY_RULE_SETUP
#line 130 "lexer.lpp"
{ return s2::parser::make_ADD(loc); }
{ return s2::parser::make_ASSIGN(loc); }
YY_BREAK
case 84:
YY_RULE_SETUP
#line 131 "lexer.lpp"
{ return s2::parser::make_SUB(loc); }
{ return s2::parser::make_ADD(loc); }
YY_BREAK
case 85:
YY_RULE_SETUP
#line 132 "lexer.lpp"
{ return s2::parser::make_MULT(loc); }
{ return s2::parser::make_SUB(loc); }
YY_BREAK
case 86:
YY_RULE_SETUP
#line 133 "lexer.lpp"
{ return s2::parser::make_DIV(loc); }
{ return s2::parser::make_MULT(loc); }
YY_BREAK
case 87:
YY_RULE_SETUP
#line 134 "lexer.lpp"
{ return s2::parser::make_MOD(loc); }
{ return s2::parser::make_DIV(loc); }
YY_BREAK
case 88:
YY_RULE_SETUP
#line 135 "lexer.lpp"
{ return s2::parser::make_NOT(loc); }
{ return s2::parser::make_MOD(loc); }
YY_BREAK
case 89:
YY_RULE_SETUP
#line 136 "lexer.lpp"
{ return s2::parser::make_COMPLEMENT(loc); }
{ return s2::parser::make_NOT(loc); }
YY_BREAK
case 90:
YY_RULE_SETUP
#line 137 "lexer.lpp"
{ return s2::parser::make_BITWISE_OR(loc); }
{ return s2::parser::make_COMPLEMENT(loc); }
YY_BREAK
case 91:
YY_RULE_SETUP
#line 138 "lexer.lpp"
{ return s2::parser::make_BITWISE_AND(loc); }
{ return s2::parser::make_BITWISE_OR(loc); }
YY_BREAK
case 92:
YY_RULE_SETUP
#line 139 "lexer.lpp"
{ return s2::parser::make_BITWISE_EXOR(loc); }
{ return s2::parser::make_BITWISE_AND(loc); }
YY_BREAK
case 93:
YY_RULE_SETUP
#line 140 "lexer.lpp"
{ return s2::parser::make_FILE(utils::string::fordslash(yytext), loc); }
{ return s2::parser::make_BITWISE_EXOR(loc); }
YY_BREAK
case 94:
YY_RULE_SETUP
#line 141 "lexer.lpp"
{ return s2::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
{ return s2::parser::make_FILE(utils::string::fordslash(yytext), loc); }
YY_BREAK
case 95:
/* rule 95 can match eol */
YY_RULE_SETUP
#line 142 "lexer.lpp"
{ return s2::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
{ return s2::parser::make_NAME((std::string(yytext, 3) == "_ID") ? std::string(yytext) : utils::string::to_lower(yytext), loc); }
YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 143 "lexer.lpp"
{ return s2::parser::make_STRING(std::string(yytext), loc); }
{ return s2::parser::make_ISTRING(std::string(yytext).substr(1), loc); }
YY_BREAK
case 97:
/* rule 97 can match eol */
YY_RULE_SETUP
#line 144 "lexer.lpp"
{ return s2::parser::make_FLOAT(std::string(yytext), loc); }
{ return s2::parser::make_STRING(std::string(yytext), loc); }
YY_BREAK
case 98:
YY_RULE_SETUP
#line 145 "lexer.lpp"
{ return s2::parser::make_FLOAT(std::string(yytext), loc); }
YY_BREAK
case 99:
YY_RULE_SETUP
#line 146 "lexer.lpp"
{ return s2::parser::make_INTEGER(std::string(yytext), loc); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT_BLOCK_STATE):
case YY_STATE_EOF(DEVELOPER_BLOCK_STATE):
#line 146 "lexer.lpp"
#line 147 "lexer.lpp"
{ return s2::parser::make_S2EOF(loc); }
YY_BREAK
case 99:
/* rule 99 can match eol */
case 100:
/* rule 100 can match eol */
YY_RULE_SETUP
#line 147 "lexer.lpp"
#line 148 "lexer.lpp"
{ throw s2::parser::syntax_error(loc, "bad token: \'" + std::string(yytext) + "\'"); }
YY_BREAK
case 100:
case 101:
YY_RULE_SETUP
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"
ECHO;
YY_BREAK
#line 1724 "lexer.cpp"
#line 1729 "lexer.cpp"
case YY_END_OF_BUFFER:
{
@ -2019,7 +2024,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@ -2048,11 +2053,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 305 )
if ( yy_current_state >= 306 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 304);
yy_is_jam = (yy_current_state == 305);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@ -2851,6 +2856,6 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"

View File

@ -700,7 +700,7 @@ extern int yylex (yyscan_t yyscanner);
#undef yyTABLES_NAME
#endif
#line 149 "lexer.lpp"
#line 150 "lexer.lpp"
#line 706 "lexer.hpp"

File diff suppressed because it is too large Load Diff

View File

@ -446,6 +446,7 @@ namespace xsk { namespace gsc { namespace s2 {
// for_expr
// expr
// expr_compare
// expr_ternary
// expr_binary
// expr_primitive
char dummy11[sizeof (expr_ptr)];
@ -700,53 +701,55 @@ namespace xsk { namespace gsc { namespace s2 {
DOUBLECOLON = 48, // "::"
COLON = 49, // ":"
SEMICOLON = 50, // ";"
INCREMENT = 51, // "++"
DECREMENT = 52, // "--"
LSHIFT = 53, // "<<"
RSHIFT = 54, // ">>"
OR = 55, // "||"
AND = 56, // "&&"
EQUALITY = 57, // "=="
INEQUALITY = 58, // "!="
LESS_EQUAL = 59, // "<="
GREATER_EQUAL = 60, // ">="
LESS = 61, // "<"
GREATER = 62, // ">"
NOT = 63, // "!"
COMPLEMENT = 64, // "~"
ASSIGN = 65, // "="
ASSIGN_ADD = 66, // "+="
ASSIGN_SUB = 67, // "-="
ASSIGN_MULT = 68, // "*="
ASSIGN_DIV = 69, // "/="
ASSIGN_MOD = 70, // "%="
ASSIGN_BITWISE_OR = 71, // "|="
ASSIGN_BITWISE_AND = 72, // "&="
ASSIGN_BITWISE_EXOR = 73, // "^="
ASSIGN_RSHIFT = 74, // ">>="
ASSIGN_LSHIFT = 75, // "<<="
BITWISE_OR = 76, // "|"
BITWISE_AND = 77, // "&"
BITWISE_EXOR = 78, // "^"
ADD = 79, // "+"
SUB = 80, // "-"
MULT = 81, // "*"
DIV = 82, // "/"
MOD = 83, // "%"
FILE = 84, // "file path"
NAME = 85, // "identifier"
STRING = 86, // "string literal"
ISTRING = 87, // "localized string"
FLOAT = 88, // "float"
INTEGER = 89, // "int"
ADD_ARRAY = 90, // ADD_ARRAY
THEN = 91, // THEN
NEG = 92, // NEG
ANIMREF = 93, // ANIMREF
PREINC = 94, // PREINC
PREDEC = 95, // PREDEC
POSTINC = 96, // POSTINC
POSTDEC = 97 // POSTDEC
QMARK = 51, // "?"
INCREMENT = 52, // "++"
DECREMENT = 53, // "--"
LSHIFT = 54, // "<<"
RSHIFT = 55, // ">>"
OR = 56, // "||"
AND = 57, // "&&"
EQUALITY = 58, // "=="
INEQUALITY = 59, // "!="
LESS_EQUAL = 60, // "<="
GREATER_EQUAL = 61, // ">="
LESS = 62, // "<"
GREATER = 63, // ">"
NOT = 64, // "!"
COMPLEMENT = 65, // "~"
ASSIGN = 66, // "="
ASSIGN_ADD = 67, // "+="
ASSIGN_SUB = 68, // "-="
ASSIGN_MULT = 69, // "*="
ASSIGN_DIV = 70, // "/="
ASSIGN_MOD = 71, // "%="
ASSIGN_BITWISE_OR = 72, // "|="
ASSIGN_BITWISE_AND = 73, // "&="
ASSIGN_BITWISE_EXOR = 74, // "^="
ASSIGN_RSHIFT = 75, // ">>="
ASSIGN_LSHIFT = 76, // "<<="
BITWISE_OR = 77, // "|"
BITWISE_AND = 78, // "&"
BITWISE_EXOR = 79, // "^"
ADD = 80, // "+"
SUB = 81, // "-"
MULT = 82, // "*"
DIV = 83, // "/"
MOD = 84, // "%"
FILE = 85, // "file path"
NAME = 86, // "identifier"
STRING = 87, // "string literal"
ISTRING = 88, // "localized string"
FLOAT = 89, // "float"
INTEGER = 90, // "int"
ADD_ARRAY = 91, // ADD_ARRAY
THEN = 92, // THEN
TERN = 93, // TERN
NEG = 94, // NEG
ANIMREF = 95, // ANIMREF
PREINC = 96, // PREINC
PREDEC = 97, // PREDEC
POSTINC = 98, // POSTINC
POSTDEC = 99 // POSTDEC
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
@ -763,7 +766,7 @@ namespace xsk { namespace gsc { namespace s2 {
{
enum symbol_kind_type
{
YYNTOKENS = 98, ///< Number of tokens.
YYNTOKENS = 100, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
@ -816,129 +819,132 @@ namespace xsk { namespace gsc { namespace s2 {
S_DOUBLECOLON = 48, // "::"
S_COLON = 49, // ":"
S_SEMICOLON = 50, // ";"
S_INCREMENT = 51, // "++"
S_DECREMENT = 52, // "--"
S_LSHIFT = 53, // "<<"
S_RSHIFT = 54, // ">>"
S_OR = 55, // "||"
S_AND = 56, // "&&"
S_EQUALITY = 57, // "=="
S_INEQUALITY = 58, // "!="
S_LESS_EQUAL = 59, // "<="
S_GREATER_EQUAL = 60, // ">="
S_LESS = 61, // "<"
S_GREATER = 62, // ">"
S_NOT = 63, // "!"
S_COMPLEMENT = 64, // "~"
S_ASSIGN = 65, // "="
S_ASSIGN_ADD = 66, // "+="
S_ASSIGN_SUB = 67, // "-="
S_ASSIGN_MULT = 68, // "*="
S_ASSIGN_DIV = 69, // "/="
S_ASSIGN_MOD = 70, // "%="
S_ASSIGN_BITWISE_OR = 71, // "|="
S_ASSIGN_BITWISE_AND = 72, // "&="
S_ASSIGN_BITWISE_EXOR = 73, // "^="
S_ASSIGN_RSHIFT = 74, // ">>="
S_ASSIGN_LSHIFT = 75, // "<<="
S_BITWISE_OR = 76, // "|"
S_BITWISE_AND = 77, // "&"
S_BITWISE_EXOR = 78, // "^"
S_ADD = 79, // "+"
S_SUB = 80, // "-"
S_MULT = 81, // "*"
S_DIV = 82, // "/"
S_MOD = 83, // "%"
S_FILE = 84, // "file path"
S_NAME = 85, // "identifier"
S_STRING = 86, // "string literal"
S_ISTRING = 87, // "localized string"
S_FLOAT = 88, // "float"
S_INTEGER = 89, // "int"
S_ADD_ARRAY = 90, // ADD_ARRAY
S_THEN = 91, // THEN
S_NEG = 92, // NEG
S_ANIMREF = 93, // ANIMREF
S_PREINC = 94, // PREINC
S_PREDEC = 95, // PREDEC
S_POSTINC = 96, // POSTINC
S_POSTDEC = 97, // POSTDEC
S_YYACCEPT = 98, // $accept
S_root = 99, // root
S_program = 100, // program
S_include = 101, // include
S_define = 102, // define
S_usingtree = 103, // usingtree
S_constant = 104, // constant
S_thread = 105, // thread
S_parameters = 106, // parameters
S_stmt = 107, // stmt
S_stmt_block = 108, // stmt_block
S_stmt_list = 109, // stmt_list
S_stmt_call = 110, // stmt_call
S_stmt_assign = 111, // stmt_assign
S_stmt_endon = 112, // stmt_endon
S_stmt_notify = 113, // stmt_notify
S_stmt_wait = 114, // stmt_wait
S_stmt_waittill = 115, // stmt_waittill
S_stmt_waittillmatch = 116, // stmt_waittillmatch
S_stmt_waittillframeend = 117, // stmt_waittillframeend
S_stmt_waitframe = 118, // stmt_waitframe
S_stmt_if = 119, // stmt_if
S_stmt_ifelse = 120, // stmt_ifelse
S_stmt_while = 121, // stmt_while
S_stmt_for = 122, // stmt_for
S_stmt_foreach = 123, // stmt_foreach
S_stmt_switch = 124, // stmt_switch
S_stmt_case = 125, // stmt_case
S_stmt_default = 126, // stmt_default
S_stmt_break = 127, // stmt_break
S_stmt_continue = 128, // stmt_continue
S_stmt_return = 129, // stmt_return
S_stmt_breakpoint = 130, // stmt_breakpoint
S_stmt_prof_begin = 131, // stmt_prof_begin
S_stmt_prof_end = 132, // stmt_prof_end
S_for_stmt = 133, // for_stmt
S_for_expr = 134, // for_expr
S_expr = 135, // expr
S_expr_assign = 136, // expr_assign
S_expr_compare = 137, // expr_compare
S_expr_binary = 138, // expr_binary
S_expr_primitive = 139, // expr_primitive
S_expr_call = 140, // expr_call
S_expr_call_thread = 141, // expr_call_thread
S_expr_call_childthread = 142, // expr_call_childthread
S_expr_call_function = 143, // expr_call_function
S_expr_call_pointer = 144, // expr_call_pointer
S_expr_arguments = 145, // expr_arguments
S_expr_arguments_filled = 146, // expr_arguments_filled
S_expr_arguments_empty = 147, // expr_arguments_empty
S_expr_function = 148, // expr_function
S_expr_add_array = 149, // expr_add_array
S_expr_array = 150, // expr_array
S_expr_field = 151, // expr_field
S_expr_size = 152, // expr_size
S_object = 153, // object
S_thisthread = 154, // thisthread
S_empty_array = 155, // empty_array
S_undefined = 156, // undefined
S_game = 157, // game
S_self = 158, // self
S_anim = 159, // anim
S_level = 160, // level
S_animation = 161, // animation
S_animtree = 162, // animtree
S_name = 163, // name
S_file = 164, // file
S_istring = 165, // istring
S_string = 166, // string
S_vector = 167, // vector
S_neg_float = 168, // neg_float
S_neg_integer = 169, // neg_integer
S_float = 170, // float
S_integer = 171, // integer
S_false = 172, // false
S_true = 173 // true
S_QMARK = 51, // "?"
S_INCREMENT = 52, // "++"
S_DECREMENT = 53, // "--"
S_LSHIFT = 54, // "<<"
S_RSHIFT = 55, // ">>"
S_OR = 56, // "||"
S_AND = 57, // "&&"
S_EQUALITY = 58, // "=="
S_INEQUALITY = 59, // "!="
S_LESS_EQUAL = 60, // "<="
S_GREATER_EQUAL = 61, // ">="
S_LESS = 62, // "<"
S_GREATER = 63, // ">"
S_NOT = 64, // "!"
S_COMPLEMENT = 65, // "~"
S_ASSIGN = 66, // "="
S_ASSIGN_ADD = 67, // "+="
S_ASSIGN_SUB = 68, // "-="
S_ASSIGN_MULT = 69, // "*="
S_ASSIGN_DIV = 70, // "/="
S_ASSIGN_MOD = 71, // "%="
S_ASSIGN_BITWISE_OR = 72, // "|="
S_ASSIGN_BITWISE_AND = 73, // "&="
S_ASSIGN_BITWISE_EXOR = 74, // "^="
S_ASSIGN_RSHIFT = 75, // ">>="
S_ASSIGN_LSHIFT = 76, // "<<="
S_BITWISE_OR = 77, // "|"
S_BITWISE_AND = 78, // "&"
S_BITWISE_EXOR = 79, // "^"
S_ADD = 80, // "+"
S_SUB = 81, // "-"
S_MULT = 82, // "*"
S_DIV = 83, // "/"
S_MOD = 84, // "%"
S_FILE = 85, // "file path"
S_NAME = 86, // "identifier"
S_STRING = 87, // "string literal"
S_ISTRING = 88, // "localized string"
S_FLOAT = 89, // "float"
S_INTEGER = 90, // "int"
S_ADD_ARRAY = 91, // ADD_ARRAY
S_THEN = 92, // THEN
S_TERN = 93, // TERN
S_NEG = 94, // NEG
S_ANIMREF = 95, // ANIMREF
S_PREINC = 96, // PREINC
S_PREDEC = 97, // PREDEC
S_POSTINC = 98, // POSTINC
S_POSTDEC = 99, // POSTDEC
S_YYACCEPT = 100, // $accept
S_root = 101, // root
S_program = 102, // program
S_include = 103, // include
S_define = 104, // define
S_usingtree = 105, // usingtree
S_constant = 106, // constant
S_thread = 107, // thread
S_parameters = 108, // parameters
S_stmt = 109, // stmt
S_stmt_block = 110, // stmt_block
S_stmt_list = 111, // stmt_list
S_stmt_call = 112, // stmt_call
S_stmt_assign = 113, // stmt_assign
S_stmt_endon = 114, // stmt_endon
S_stmt_notify = 115, // stmt_notify
S_stmt_wait = 116, // stmt_wait
S_stmt_waittill = 117, // stmt_waittill
S_stmt_waittillmatch = 118, // stmt_waittillmatch
S_stmt_waittillframeend = 119, // stmt_waittillframeend
S_stmt_waitframe = 120, // stmt_waitframe
S_stmt_if = 121, // stmt_if
S_stmt_ifelse = 122, // stmt_ifelse
S_stmt_while = 123, // stmt_while
S_stmt_for = 124, // stmt_for
S_stmt_foreach = 125, // stmt_foreach
S_stmt_switch = 126, // stmt_switch
S_stmt_case = 127, // stmt_case
S_stmt_default = 128, // stmt_default
S_stmt_break = 129, // stmt_break
S_stmt_continue = 130, // stmt_continue
S_stmt_return = 131, // stmt_return
S_stmt_breakpoint = 132, // stmt_breakpoint
S_stmt_prof_begin = 133, // stmt_prof_begin
S_stmt_prof_end = 134, // stmt_prof_end
S_for_stmt = 135, // for_stmt
S_for_expr = 136, // for_expr
S_expr = 137, // expr
S_expr_assign = 138, // expr_assign
S_expr_compare = 139, // expr_compare
S_expr_ternary = 140, // expr_ternary
S_expr_binary = 141, // expr_binary
S_expr_primitive = 142, // expr_primitive
S_expr_call = 143, // expr_call
S_expr_call_thread = 144, // expr_call_thread
S_expr_call_childthread = 145, // expr_call_childthread
S_expr_call_function = 146, // expr_call_function
S_expr_call_pointer = 147, // expr_call_pointer
S_expr_arguments = 148, // expr_arguments
S_expr_arguments_filled = 149, // expr_arguments_filled
S_expr_arguments_empty = 150, // expr_arguments_empty
S_expr_function = 151, // expr_function
S_expr_add_array = 152, // expr_add_array
S_expr_array = 153, // expr_array
S_expr_field = 154, // expr_field
S_expr_size = 155, // expr_size
S_object = 156, // object
S_thisthread = 157, // thisthread
S_empty_array = 158, // empty_array
S_undefined = 159, // undefined
S_game = 160, // game
S_self = 161, // self
S_anim = 162, // anim
S_level = 163, // level
S_animation = 164, // animation
S_animtree = 165, // animtree
S_name = 166, // name
S_file = 167, // file
S_istring = 168, // istring
S_string = 169, // string
S_vector = 170, // vector
S_neg_float = 171, // neg_float
S_neg_integer = 172, // neg_integer
S_float = 173, // float
S_integer = 174, // integer
S_false = 175, // false
S_true = 176 // true
};
};
@ -1023,6 +1029,7 @@ namespace xsk { namespace gsc { namespace s2 {
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (std::move (that.value));
@ -2117,6 +2124,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.template destroy< expr_ptr > ();
@ -3241,6 +3249,21 @@ switch (yykind)
return symbol_type (token::SEMICOLON, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_QMARK (location_type l)
{
return symbol_type (token::QMARK, std::move (l));
}
#else
static
symbol_type
make_QMARK (const location_type& l)
{
return symbol_type (token::QMARK, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -3856,6 +3879,21 @@ switch (yykind)
return symbol_type (token::THEN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
make_TERN (location_type l)
{
return symbol_type (token::TERN, std::move (l));
}
#else
static
symbol_type
make_TERN (const location_type& l)
{
return symbol_type (token::TERN, l);
}
#endif
#if 201103L <= YY_CPLUSPLUS
static
symbol_type
@ -4290,8 +4328,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 1646, ///< Last index in yytable_.
yynnts_ = 76, ///< Number of nonterminal symbols.
yylast_ = 1842, ///< Last index in yytable_.
yynnts_ = 77, ///< Number of nonterminal symbols.
yyfinal_ = 15 ///< Termination state number.
};
@ -4367,6 +4405,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.copy< expr_ptr > (YY_MOVE (that.value));
@ -4647,6 +4686,7 @@ switch (yykind)
case symbol_kind::S_for_expr: // for_expr
case symbol_kind::S_expr: // expr
case symbol_kind::S_expr_compare: // expr_compare
case symbol_kind::S_expr_ternary: // expr_ternary
case symbol_kind::S_expr_binary: // expr_binary
case symbol_kind::S_expr_primitive: // expr_primitive
value.move< expr_ptr > (YY_MOVE (s.value));
@ -4913,7 +4953,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::s2
#line 4917 "parser.hpp"
#line 4957 "parser.hpp"

View File

@ -59,6 +59,7 @@ enum class node_t
expr_greater,
expr_or,
expr_and,
expr_ternary,
expr_assign_equal,
expr_assign_add,
expr_assign_sub,
@ -169,6 +170,7 @@ struct node_expr_less;
struct node_expr_greater;
struct node_expr_or;
struct node_expr_and;
struct node_expr_ternary;
struct node_expr_assign;
struct node_expr_assign_equal;
struct node_expr_assign_add;
@ -276,6 +278,7 @@ using expr_less_ptr = std::unique_ptr<node_expr_less>;
using expr_greater_ptr = std::unique_ptr<node_expr_greater>;
using expr_or_ptr = std::unique_ptr<node_expr_or>;
using expr_and_ptr = std::unique_ptr<node_expr_and>;
using expr_ternary_ptr = std::unique_ptr<node_expr_ternary>;
using expr_assign_ptr = std::unique_ptr<node_expr_assign>;
using expr_assign_equal_ptr = std::unique_ptr<node_expr_assign_equal>;
using expr_assign_add_ptr = std::unique_ptr<node_expr_assign_add>;
@ -396,6 +399,7 @@ union expr_ptr
expr_greater_ptr as_greater;
expr_or_ptr as_or;
expr_and_ptr as_and;
expr_ternary_ptr as_ternary;
expr_binary_ptr as_binary;
expr_assign_ptr as_assign;
expr_assign_equal_ptr as_assign_equal;
@ -1459,6 +1463,24 @@ struct node_expr_and : public node_expr_binary
}
};
struct node_expr_ternary : public node
{
expr_ptr cond;
expr_ptr lvalue;
expr_ptr rvalue;
node_expr_ternary(expr_ptr cond, expr_ptr lvalue, expr_ptr rvalue)
: node(node_t::expr_ternary), cond(std::move(cond)), lvalue(std::move(lvalue)), rvalue(std::move(rvalue)) {}
node_expr_ternary(const location& loc, expr_ptr cond, expr_ptr lvalue, expr_ptr rvalue)
: node(node_t::expr_ternary, loc), cond(std::move(cond)), lvalue(std::move(lvalue)), rvalue(std::move(rvalue)) {}
auto print() -> std::string override
{
return cond.as_node->print() + " ? " + lvalue.as_node->print() + " : " + rvalue.as_node->print();
}
};
struct node_expr_assign: public node
{
expr_ptr lvalue;