Skip to content

Commit

Permalink
feat(arc): impl waitrealtime (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
xensik committed Jan 5, 2024
1 parent fb755ef commit 8e1326c
Show file tree
Hide file tree
Showing 13 changed files with 2,190 additions and 2,086 deletions.
10 changes: 10 additions & 0 deletions gen/arc/parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace xsk::arc
%token ENDON "endon"
%token NOTIFY "notify"
%token WAIT "wait"
%token WAITREALTIME "waitrealtime"
%token WAITTILL "waittill"
%token WAITTILLMATCH "waittillmatch"
%token WAITTILLFRAMEEND "waittillframeend"
Expand Down Expand Up @@ -183,6 +184,7 @@ namespace xsk::arc
%type <stmt_endon::ptr> stmt_endon
%type <stmt_notify::ptr> stmt_notify
%type <stmt_wait::ptr> stmt_wait
%type <stmt_waitrealtime::ptr> stmt_waitrealtime
%type <stmt_waittill::ptr> stmt_waittill
%type <stmt_waittillmatch::ptr> stmt_waittillmatch
%type <stmt_waittillframeend::ptr> stmt_waittillframeend
Expand Down Expand Up @@ -357,6 +359,7 @@ stmt
| stmt_endon { $$ = std::move($1); }
| stmt_notify { $$ = std::move($1); }
| stmt_wait { $$ = std::move($1); }
| stmt_waitrealtime { $$ = std::move($1); }
| stmt_waittill { $$ = std::move($1); }
| stmt_waittillmatch { $$ = std::move($1); }
| stmt_waittillframeend { $$ = std::move($1); }
Expand Down Expand Up @@ -462,6 +465,11 @@ stmt_wait
{ $$ = stmt_wait::make(@$, std::move($2)); }
;

stmt_waitrealtime
: WAITREALTIME expr SEMICOLON
{ $$ = stmt_waitrealtime::make(@$, std::move($2)); }
;

stmt_waittill
: expr_object WAITTILL LPAREN expr COMMA expr_arguments_no_empty RPAREN SEMICOLON
{ $$ = stmt_waittill::make(@$, std::move($1), std::move($4), std::move($6)); }
Expand Down Expand Up @@ -1230,6 +1238,7 @@ std::unordered_map<token::kind, parser::token::token_kind_type> const tok_to_par
{ token::ENDON, parser::token::ENDON },
{ token::NOTIFY, parser::token::NOTIFY },
{ token::WAIT, parser::token::WAIT },
{ token::WAITREALTIME, parser::token::WAITREALTIME },
{ token::WAITTILL, parser::token::WAITTILL },
{ token::WAITTILLMATCH, parser::token::WAITTILLMATCH },
{ token::WAITTILLFRAMEEND, parser::token::WAITTILLFRAMEEND },
Expand Down Expand Up @@ -1289,6 +1298,7 @@ std::unordered_map<std::string_view, parser::token::token_kind_type> const keywo
{ "endon", parser::token::ENDON },
{ "notify", parser::token::NOTIFY },
{ "wait", parser::token::WAIT },
{ "waitrealtime", parser::token::WAITREALTIME},
{ "waittill", parser::token::WAITTILL },
{ "waittillmatch", parser::token::WAITTILLMATCH },
{ "waittillframeend", parser::token::WAITTILLFRAMEEND },
Expand Down
22 changes: 11 additions & 11 deletions include/xsk/arc/common/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ struct node
stmt_endon,
stmt_notify,
stmt_wait,
stmt_waitrealtime,
stmt_waittill,
stmt_waittillmatch,
stmt_waittillframeend,
stmt_waitrealtime,
stmt_if,
stmt_ifelse,
stmt_while,
Expand Down Expand Up @@ -1001,6 +1001,16 @@ struct stmt_wait : public stmt
XSK_ARC_AST_MAKE(stmt_wait)
};

struct stmt_waitrealtime : public stmt
{
using ptr = std::unique_ptr<stmt_waitrealtime>;

expr::ptr time;

stmt_waitrealtime(location const& loc, expr::ptr time);
XSK_ARC_AST_MAKE(stmt_waitrealtime)
};

struct stmt_waittill : public stmt
{
using ptr = std::unique_ptr<stmt_waittill>;
Expand Down Expand Up @@ -1033,16 +1043,6 @@ struct stmt_waittillframeend : public stmt
XSK_ARC_AST_MAKE(stmt_waittillframeend)
};

struct stmt_waitrealtime : public stmt
{
using ptr = std::unique_ptr<stmt_waitrealtime>;

expr::ptr time;

stmt_waitrealtime(location const& loc, expr::ptr time);
XSK_ARC_AST_MAKE(stmt_waitrealtime)
};

struct stmt_if : public stmt
{
using ptr = std::unique_ptr<stmt_if>;
Expand Down
6 changes: 3 additions & 3 deletions include/xsk/arc/common/token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ struct token
NAME, PATH, STRING, ISTRING, HASHSTR, INT, FLT,

DEVBEGIN, DEVEND, INLINE, INCLUDE, USINGTREE, ANIMTREE, AUTOEXEC, CODECALL, PRIVATE,
ENDON, NOTIFY, WAIT, WAITTILL, WAITTILLMATCH, WAITTILLFRAMEEND, IF, ELSE, DO, WHILE,
FOR, FOREACH, IN, SWITCH, CASE, DEFAULT, BREAK, CONTINUE, RETURN, PROFBEGIN, PROFEND,
THREAD, TRUE, FALSE, UNDEFINED, SIZE, GAME, SELF, ANIM, LEVEL,
ENDON, NOTIFY, WAIT, WAITREALTIME, WAITTILL, WAITTILLMATCH, WAITTILLFRAMEEND, IF, ELSE,
DO, WHILE, FOR, FOREACH, IN, SWITCH, CASE, DEFAULT, BREAK, CONTINUE, RETURN, PROFBEGIN,
PROFEND, THREAD, TRUE, FALSE, UNDEFINED, SIZE, GAME, SELF, ANIM, LEVEL,
CONST, ISDEFINED, VECTORSCALE, ANGLESTOUP, ANGLESTORIGHT, ANGLESTOFORWARD, ANGLECLAMP180,
VECTORTOANGLES, ABS, GETTIME, GETDVAR, GETDVARINT, GETDVARFLOAT, GETDVARVECTOR, GETDVARCOLORRED,
GETDVARCOLORGREEN, GETDVARCOLORBLUE, GETDVARCOLORALPHA, GETFIRSTARRAYKEY, GETNEXTARRAYKEY,
Expand Down
1 change: 1 addition & 0 deletions include/xsk/arc/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class compiler
auto emit_stmt_endon(stmt_endon const& stm) -> void;
auto emit_stmt_notify(stmt_notify const& stm) -> void;
auto emit_stmt_wait(stmt_wait const& stm) -> void;
auto emit_stmt_waitrealtime(stmt_waitrealtime const& stm) -> void;
auto emit_stmt_waittill(stmt_waittill const& stm) -> void;
auto emit_stmt_waittillmatch(stmt_waittillmatch const& stm) -> void;
auto emit_stmt_waittillframeend(stmt_waittillframeend const& stm) -> void;
Expand Down
2 changes: 1 addition & 1 deletion include/xsk/arc/decompiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class decompiler
auto process_stmt_endon(stmt_endon& stm) -> void;
auto process_stmt_notify(stmt_notify& stm) -> void;
auto process_stmt_wait(stmt_wait& stm) -> void;
auto process_stmt_waitrealtime(stmt_waitrealtime& stm) -> void;
auto process_stmt_waittill(stmt_waittill& stm) -> void;
auto process_stmt_waittillmatch(stmt_waittillmatch& stm) -> void;
auto process_stmt_waitrealtime(stmt_waitrealtime& stm) -> void;
auto process_stmt_if(stmt_if& stm) -> void;
auto process_stmt_ifelse(stmt_ifelse& stm) -> void;
auto process_stmt_while(stmt_while& stm) -> void;
Expand Down
Loading

0 comments on commit 8e1326c

Please sign in to comment.