gsc-tool/include/xsk/arc/common/ast.hpp

1375 lines
31 KiB
C++
Raw Normal View History

// Copyright 2024 xensik. All rights reserved.
2023-01-23 17:31:08 -05:00
//
// Use of this source code is governed by a GNU GPLv3 license
// that can be found in the LICENSE file.
#pragma once
namespace xsk::arc
2023-01-23 17:31:08 -05:00
{
struct node
{
using ptr = std::unique_ptr<node>;
enum type
{
node_null,
node_prescriptcall,
node_voidcodepos,
expr_empty,
2023-01-23 17:31:08 -05:00
expr_true,
expr_false,
expr_integer,
expr_float,
expr_vector,
expr_hash,
2023-01-23 17:31:08 -05:00
expr_string,
expr_istring,
expr_path,
expr_identifier,
expr_animtree,
expr_animation,
expr_classes,
expr_world,
2023-01-23 17:31:08 -05:00
expr_level,
expr_anim,
expr_self,
expr_game,
expr_undefined,
expr_empty_array,
expr_ellipsis,
2023-01-23 17:31:08 -05:00
expr_paren,
expr_size,
expr_field,
expr_array,
expr_reference,
expr_getnextarraykey,
expr_getfirstarraykey,
expr_getdvarcoloralpha,
expr_getdvarcolorblue,
expr_getdvarcolorgreen,
expr_getdvarcolorred,
expr_getdvarvector,
expr_getdvarfloat,
expr_getdvarint,
expr_getdvar,
expr_gettime,
expr_abs,
expr_vectortoangles,
expr_angleclamp180,
expr_anglestoforward,
expr_anglestoright,
expr_anglestoup,
expr_vectorscale,
2023-01-23 17:31:08 -05:00
expr_isdefined,
expr_arguments,
expr_parameters,
expr_member,
2023-01-23 17:31:08 -05:00
expr_pointer,
expr_function,
expr_method,
expr_call,
expr_new,
2023-01-23 17:31:08 -05:00
expr_complement,
expr_negate,
expr_not,
expr_binary,
2023-01-23 17:31:08 -05:00
expr_ternary,
expr_const,
expr_assign,
2023-01-23 17:31:08 -05:00
expr_increment,
expr_decrement,
stmt_empty,
2023-01-23 17:31:08 -05:00
stmt_list,
2023-01-24 06:53:39 -05:00
stmt_comp,
2023-01-23 17:31:08 -05:00
stmt_dev,
stmt_expr,
stmt_endon,
stmt_notify,
stmt_wait,
2024-01-05 10:33:16 -05:00
stmt_waitrealtime,
2023-01-23 17:31:08 -05:00
stmt_waittill,
stmt_waittillmatch,
stmt_waittillframeend,
stmt_if,
stmt_ifelse,
stmt_while,
stmt_dowhile,
stmt_for,
stmt_foreach,
stmt_switch,
stmt_case,
stmt_default,
stmt_break,
stmt_continue,
stmt_return,
stmt_breakpoint,
stmt_prof_begin,
stmt_prof_end,
stmt_jmp,
stmt_jmp_back,
stmt_jmp_cond,
stmt_jmp_true,
stmt_jmp_false,
stmt_jmp_switch,
stmt_jmp_endswitch,
stmt_jmp_dev,
decl_empty,
2023-01-23 17:31:08 -05:00
decl_function,
decl_usingtree,
decl_namespace,
2023-01-23 17:31:08 -05:00
decl_dev_begin,
decl_dev_end,
include,
program,
};
virtual ~node() = default;
auto kind() const -> type { return kind_; }
auto loc() const -> location const& { return loc_; }
auto label() const -> std::string { return loc_.label(); }
auto is_special_stmt() -> bool;
auto is_special_stmt_dev() -> bool;
auto is_special_stmt_noif() -> bool;
auto is_special_stmt_dev_noif() -> bool;
auto is_boolean() -> bool;
2023-01-23 17:31:08 -05:00
auto is_binary() -> bool;
auto is_assign() -> bool;
virtual auto precedence() -> u8;
template<typename T>
static auto as(node::ptr) -> std::unique_ptr<T>;
protected:
node(type t) : kind_(t) {}
node(type t, location const& loc) : kind_(t), loc_(loc) {}
2023-01-23 17:31:08 -05:00
private:
type kind_;
location loc_;
};
struct expr : node
{
using ptr = std::unique_ptr<expr>;
virtual ~expr() = default;
2023-01-23 17:31:08 -05:00
friend auto operator==(expr const& lhs, expr const& rhs) -> bool;
template<typename T>
auto is() const -> bool;
template<typename T>
auto as() const -> T const&;
template<typename T>
auto as() -> T&;
protected:
expr(type t);
expr(type t, location const& loc);
};
struct call : expr
{
using ptr = std::unique_ptr<call>;
enum class mode { normal, thread, };
virtual ~call() = default;
template<typename T>
auto is() const -> bool;
template<typename T>
auto as() const -> T const&;
template<typename T>
auto as() -> T&;
protected:
call(node::type t);
call(node::type t, location const& loc);
};
struct stmt : node
{
using ptr = std::unique_ptr<stmt>;
virtual ~stmt() = default;
template<typename T>
auto is() const -> bool;
template<typename T>
auto as() const -> T const&;
template<typename T>
auto as() -> T&;
protected:
stmt(type t);
stmt(type t, location const& loc);
};
struct decl : node
{
using ptr = std::unique_ptr<decl>;
virtual ~decl() = default;
template<typename T>
auto is() const -> bool;
template<typename T>
auto as() const -> T const&;
template<typename T>
auto as() -> T&;
protected:
decl(type t);
decl(type t, location const& loc);
};
#define XSK_ARC_AST_MAKE(node_type) \
template<class... Args> \
inline static auto make(Args&&... args) -> std::unique_ptr<node_type> \
{ \
return std::unique_ptr<node_type>(new node_type(std::forward<Args>(args)...)); \
}
struct node_prescriptcall : public node
{
using ptr = std::unique_ptr<node_prescriptcall>;
node_prescriptcall(location const& loc);
XSK_ARC_AST_MAKE(node_prescriptcall)
};
struct node_voidcodepos : public node
{
using ptr = std::unique_ptr<node_voidcodepos>;
node_voidcodepos(location const& loc);
XSK_ARC_AST_MAKE(node_voidcodepos)
};
struct expr_empty : public expr
{
using ptr = std::unique_ptr<expr_empty>;
expr_empty(location const& loc);
friend auto operator==(expr_empty const& lhs, expr_empty const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_empty)
};
struct expr_true : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_true>;
expr_true(location const& loc);
friend auto operator==(expr_true const& lhs, expr_true const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_true)
2023-01-23 17:31:08 -05:00
};
struct expr_false : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_false>;
expr_false(location const& loc);
friend auto operator==(expr_false const& lhs, expr_false const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_false)
2023-01-23 17:31:08 -05:00
};
struct expr_integer : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_integer>;
std::string value;
expr_integer(location const& loc, std::string const& value);
friend auto operator==(expr_integer const& lhs, expr_integer const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_integer)
2023-01-23 17:31:08 -05:00
};
struct expr_float : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_float>;
std::string value;
expr_float(location const& loc, std::string const& value);
friend auto operator==(expr_float const& lhs, expr_float const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_float)
2023-01-23 17:31:08 -05:00
};
struct expr_vector : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_vector>;
expr::ptr x;
expr::ptr y;
expr::ptr z;
2023-01-23 17:31:08 -05:00
expr_vector(location const& loc, expr::ptr x, expr::ptr y, expr::ptr z);
2023-01-23 17:31:08 -05:00
friend auto operator==(expr_vector const& lhs, expr_vector const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_vector)
2023-01-23 17:31:08 -05:00
};
struct expr_hash : public expr
{
using ptr = std::unique_ptr<expr_hash>;
std::string value;
expr_hash(location const& loc, std::string const& value);
friend auto operator==(expr_hash const& lhs, expr_hash const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_hash)
};
struct expr_string : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_string>;
std::string value;
expr_string(location const& loc, std::string const& value);
friend auto operator==(expr_string const& lhs, expr_string const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_string)
2023-01-23 17:31:08 -05:00
};
struct expr_istring : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_istring>;
std::string value;
expr_istring(location const& loc, std::string const& value);
friend auto operator==(expr_istring const& lhs, expr_istring const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_istring)
2023-01-23 17:31:08 -05:00
};
struct expr_path : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_path>;
std::string value;
expr_path(location const& loc);
expr_path(location const& loc, std::string const& value);
friend auto operator==(expr_path const& lhs, expr_path const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_path)
2023-01-23 17:31:08 -05:00
};
struct expr_identifier : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_identifier>;
std::string value;
expr_identifier(location const& loc, std::string const& value);
friend auto operator==(expr_identifier const& lhs, expr_identifier const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_identifier)
2023-01-23 17:31:08 -05:00
};
struct expr_animtree : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_animtree>;
expr_animtree(location const& loc);
friend auto operator==(expr_animtree const& lhs, expr_animtree const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_animtree)
2023-01-23 17:31:08 -05:00
};
struct expr_animation : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_animation>;
std::string value;
expr_animation(location const& loc, std::string const& value);
friend auto operator==(expr_animation const& lhs, expr_animation const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_animation)
2023-01-23 17:31:08 -05:00
};
struct expr_classes : public expr
{
using ptr = std::unique_ptr<expr_classes>;
expr_classes(location const& loc);
friend auto operator==(expr_classes const& lhs, expr_classes const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_classes)
};
struct expr_world : public expr
{
using ptr = std::unique_ptr<expr_world>;
expr_world(location const& loc);
friend auto operator==(expr_world const& lhs, expr_world const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_world)
};
struct expr_level : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_level>;
expr_level(location const& loc);
friend auto operator==(expr_level const& lhs, expr_level const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_level)
2023-01-23 17:31:08 -05:00
};
struct expr_anim : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_anim>;
expr_anim(location const& loc);
friend auto operator==(expr_anim const& lhs, expr_anim const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_anim)
2023-01-23 17:31:08 -05:00
};
struct expr_self : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_self>;
expr_self(location const& loc);
friend auto operator==(expr_self const& lhs, expr_self const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_self)
2023-01-23 17:31:08 -05:00
};
struct expr_game : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_game>;
expr_game(location const& loc);
friend auto operator==(expr_game const& lhs, expr_game const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_game)
2023-01-23 17:31:08 -05:00
};
struct expr_undefined : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_undefined>;
expr_undefined(location const& loc);
friend auto operator==(expr_undefined const& lhs, expr_undefined const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_undefined)
2023-01-23 17:31:08 -05:00
};
struct expr_empty_array : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_empty_array>;
expr_empty_array(location const& loc);
friend auto operator==(expr_empty_array const& lhs, expr_empty_array const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_empty_array)
};
struct expr_ellipsis : public expr
{
using ptr = std::unique_ptr<expr_ellipsis>;
expr_ellipsis(location const& loc);
friend auto operator==(expr_ellipsis const& lhs, expr_ellipsis const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_ellipsis)
2023-01-23 17:31:08 -05:00
};
struct expr_paren : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_paren>;
expr::ptr value;
2023-01-23 17:31:08 -05:00
expr_paren(location const& loc, expr::ptr value);
2023-01-23 17:31:08 -05:00
friend auto operator==(expr_paren const& lhs, expr_paren const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_paren)
2023-01-23 17:31:08 -05:00
};
struct expr_size : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_size>;
expr::ptr obj;
2023-01-23 17:31:08 -05:00
expr_size(location const& loc, expr::ptr obj);
2023-01-23 17:31:08 -05:00
friend auto operator==(expr_size const& lhs, expr_size const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_size)
2023-01-23 17:31:08 -05:00
};
struct expr_field : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_field>;
expr::ptr obj;
2023-01-23 17:31:08 -05:00
expr_identifier::ptr field;
expr_field(location const& loc, expr::ptr obj, expr_identifier::ptr field);
2023-01-23 17:31:08 -05:00
friend auto operator==(expr_field const& lhs, expr_field const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_field)
2023-01-23 17:31:08 -05:00
};
struct expr_array : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_array>;
expr::ptr obj;
expr::ptr key;
2023-01-23 17:31:08 -05:00
expr_array(location const& loc, expr::ptr obj, expr::ptr key);
2023-01-23 17:31:08 -05:00
friend auto operator==(expr_array const& lhs, expr_array const& rhs) -> bool;
XSK_ARC_AST_MAKE(expr_array)
2023-01-23 17:31:08 -05:00
};
struct expr_reference : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_reference>;
expr_path::ptr path;
expr_identifier::ptr name;
expr_reference(location const& loc, expr_path::ptr path, expr_identifier::ptr name);
XSK_ARC_AST_MAKE(expr_reference)
2023-01-23 17:31:08 -05:00
};
struct expr_getnextarraykey : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_getnextarraykey>;
2023-01-23 17:31:08 -05:00
expr::ptr arg1;
expr::ptr arg2;
expr_getnextarraykey(location const& loc, expr::ptr arg1, expr::ptr arg2);
XSK_ARC_AST_MAKE(expr_getnextarraykey)
};
struct expr_getfirstarraykey : public expr
{
using ptr = std::unique_ptr<expr_getfirstarraykey>;
expr::ptr arg;
expr_getfirstarraykey(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_getfirstarraykey)
};
struct expr_getdvarcoloralpha : public expr
{
using ptr = std::unique_ptr<expr_getdvarcoloralpha>;
expr::ptr arg;
expr_getdvarcoloralpha(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_getdvarcoloralpha)
};
struct expr_getdvarcolorblue : public expr
{
using ptr = std::unique_ptr<expr_getdvarcolorblue>;
expr::ptr arg;
expr_getdvarcolorblue(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_getdvarcolorblue)
};
struct expr_getdvarcolorgreen : public expr
{
using ptr = std::unique_ptr<expr_getdvarcolorgreen>;
expr::ptr arg;
expr_getdvarcolorgreen(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_getdvarcolorgreen)
};
struct expr_getdvarcolorred : public expr
{
using ptr = std::unique_ptr<expr_getdvarcolorred>;
expr::ptr arg;
expr_getdvarcolorred(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_getdvarcolorred)
};
struct expr_getdvarvector : public expr
{
using ptr = std::unique_ptr<expr_getdvarvector>;
expr::ptr arg;
expr_getdvarvector(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_getdvarvector)
};
struct expr_getdvarfloat : public expr
{
using ptr = std::unique_ptr<expr_getdvarfloat>;
expr::ptr arg;
expr_getdvarfloat(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_getdvarfloat)
};
struct expr_getdvarint : public expr
{
using ptr = std::unique_ptr<expr_getdvarint>;
expr::ptr arg;
expr_getdvarint(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_getdvarint)
};
struct expr_getdvar : public expr
{
using ptr = std::unique_ptr<expr_getdvar>;
expr::ptr arg;
expr_getdvar(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_getdvar)
};
struct expr_gettime : public expr
{
using ptr = std::unique_ptr<expr_gettime>;
expr_gettime(location const& loc);
XSK_ARC_AST_MAKE(expr_gettime)
};
struct expr_abs : public expr
{
using ptr = std::unique_ptr<expr_abs>;
expr::ptr arg;
expr_abs(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_abs)
};
struct expr_vectortoangles : public expr
{
using ptr = std::unique_ptr<expr_vectortoangles>;
expr::ptr arg;
expr_vectortoangles(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_vectortoangles)
};
struct expr_angleclamp180 : public expr
{
using ptr = std::unique_ptr<expr_angleclamp180>;
expr::ptr arg;
expr_angleclamp180(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_angleclamp180)
};
struct expr_anglestoforward : public expr
{
using ptr = std::unique_ptr<expr_anglestoforward>;
expr::ptr arg;
expr_anglestoforward(const location& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_anglestoforward)
};
struct expr_anglestoright : public expr
{
using ptr = std::unique_ptr<expr_anglestoright>;
expr::ptr arg;
2023-01-23 17:31:08 -05:00
expr_anglestoright(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_anglestoright)
};
struct expr_anglestoup : public expr
{
using ptr = std::unique_ptr<expr_anglestoup>;
expr::ptr arg;
expr_anglestoup(location const& loc, expr::ptr arg);
XSK_ARC_AST_MAKE(expr_anglestoup)
};
struct expr_vectorscale : public expr
{
using ptr = std::unique_ptr<expr_vectorscale>;
expr::ptr arg1;
expr::ptr arg2;
expr_vectorscale(location const& loc, expr::ptr arg1, expr::ptr arg2);
XSK_ARC_AST_MAKE(expr_vectorscale)
2023-01-23 17:31:08 -05:00
};
struct expr_isdefined : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_isdefined>;
expr::ptr value;
2023-01-23 17:31:08 -05:00
expr_isdefined(location const& loc, expr::ptr value);
XSK_ARC_AST_MAKE(expr_isdefined)
2023-01-23 17:31:08 -05:00
};
struct expr_arguments : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_arguments>;
std::vector<expr::ptr> list;
2023-01-23 17:31:08 -05:00
expr_arguments(location const& loc);
XSK_ARC_AST_MAKE(expr_arguments)
2023-01-23 17:31:08 -05:00
};
struct expr_parameters : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_parameters>;
std::vector<expr::ptr> list;
2023-01-23 17:31:08 -05:00
expr_parameters(location const& loc);
XSK_ARC_AST_MAKE(expr_parameters)
2023-01-23 17:31:08 -05:00
};
struct expr_member : public call
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_member>;
2023-01-23 17:31:08 -05:00
expr::ptr obj;
expr_identifier::ptr name;
2023-01-23 17:31:08 -05:00
expr_arguments::ptr args;
call::mode mode;
2023-01-23 17:31:08 -05:00
expr_member(location const& loc, expr::ptr obj, expr_identifier::ptr name, expr_arguments::ptr args, call::mode mode);
XSK_ARC_AST_MAKE(expr_member)
2023-01-23 17:31:08 -05:00
};
struct expr_pointer : public call
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_pointer>;
expr::ptr func;
2023-01-23 17:31:08 -05:00
expr_arguments::ptr args;
call::mode mode;
expr_pointer(location const& loc, expr::ptr func, expr_arguments::ptr args, call::mode mode);
XSK_ARC_AST_MAKE(expr_pointer)
2023-01-23 17:31:08 -05:00
};
struct expr_function : public call
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_function>;
expr_path::ptr path;
expr_identifier::ptr name;
expr_arguments::ptr args;
call::mode mode;
expr_function(location const& loc, expr_path::ptr path, expr_identifier::ptr name, expr_arguments::ptr args, call::mode mode);
XSK_ARC_AST_MAKE(expr_function)
2023-01-23 17:31:08 -05:00
};
struct expr_method : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_method>;
expr::ptr obj;
call::ptr value;
2023-01-23 17:31:08 -05:00
expr_method(location const& loc, expr::ptr obj, call::ptr value);
XSK_ARC_AST_MAKE(expr_method)
2023-01-23 17:31:08 -05:00
};
struct expr_call : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_call>;
call::ptr value;
2023-01-23 17:31:08 -05:00
expr_call(location const& loc, call::ptr value);
XSK_ARC_AST_MAKE(expr_call)
2023-01-23 17:31:08 -05:00
};
struct expr_new : public expr
{
using ptr = std::unique_ptr<expr_new>;
expr_identifier::ptr name;
expr_new(location const& loc, expr_identifier::ptr name);
XSK_ARC_AST_MAKE(expr_new)
};
struct expr_complement : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_complement>;
expr::ptr rvalue;
2023-01-23 17:31:08 -05:00
expr_complement(location const& loc, expr::ptr rvalue);
XSK_ARC_AST_MAKE(expr_complement)
2023-01-23 17:31:08 -05:00
};
struct expr_negate : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_negate>;
expr::ptr rvalue;
2023-01-23 17:31:08 -05:00
expr_negate(location const& loc, expr::ptr rvalue);
XSK_ARC_AST_MAKE(expr_negate)
2023-01-23 17:31:08 -05:00
};
struct expr_not : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_not>;
expr::ptr rvalue;
2023-01-23 17:31:08 -05:00
expr_not(location const& loc, expr::ptr rvalue);
XSK_ARC_AST_MAKE(expr_not)
2023-01-23 17:31:08 -05:00
};
struct expr_binary : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_binary>;
enum class op { seq, sne, eq, ne, le, ge, lt, gt, add, sub, mul, div, mod, shl, shr, bwor, bwand, bwexor, bool_or, bool_and };
2023-01-23 17:31:08 -05:00
expr::ptr lvalue;
expr::ptr rvalue;
op oper;
2023-01-23 17:31:08 -05:00
expr_binary(location const& loc, expr::ptr lvalue, expr::ptr rvalue, op oper);
XSK_ARC_AST_MAKE(expr_binary)
auto precedence() -> u8;
2023-01-23 17:31:08 -05:00
};
struct expr_ternary : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_ternary>;
2023-01-23 17:31:08 -05:00
expr::ptr test;
expr::ptr true_expr;
expr::ptr false_expr;
2023-01-23 17:31:08 -05:00
expr_ternary(location const& loc, expr::ptr test, expr::ptr true_expr, expr::ptr false_expr);
XSK_ARC_AST_MAKE(expr_ternary)
2023-01-23 17:31:08 -05:00
};
struct expr_const : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_const>;
2023-01-23 17:31:08 -05:00
expr_identifier::ptr lvalue;
expr::ptr rvalue;
2023-01-23 17:31:08 -05:00
expr_const(location const& loc, expr_identifier::ptr lvalue, expr::ptr rvalue);
XSK_ARC_AST_MAKE(expr_const)
2023-01-23 17:31:08 -05:00
};
struct expr_assign : public expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_assign>;
2023-01-23 17:31:08 -05:00
enum class op { eq, add, sub, mul, div, mod, shl, shr, bwor, bwand, bwexor };
2023-01-23 17:31:08 -05:00
expr::ptr lvalue;
expr::ptr rvalue;
op oper;
2023-01-23 17:31:08 -05:00
expr_assign(location const& loc, expr::ptr lvalue, expr::ptr rvalue, op oper);
XSK_ARC_AST_MAKE(expr_assign)
2023-01-23 17:31:08 -05:00
};
struct expr_increment : expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_increment>;
expr::ptr lvalue;
2023-01-23 17:31:08 -05:00
bool prefix;
expr_increment(location const& loc, expr::ptr lvalue, bool prefix);
XSK_ARC_AST_MAKE(expr_increment)
2023-01-23 17:31:08 -05:00
};
struct expr_decrement : expr
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<expr_decrement>;
expr::ptr lvalue;
2023-01-23 17:31:08 -05:00
bool prefix;
expr_decrement(location const& loc, expr::ptr lvalue, bool prefix);
XSK_ARC_AST_MAKE(expr_decrement)
2023-01-23 17:31:08 -05:00
};
struct stmt_empty : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_empty>;
2023-01-23 17:31:08 -05:00
stmt_empty(location const& loc);
XSK_ARC_AST_MAKE(stmt_empty)
2023-01-23 17:31:08 -05:00
};
struct stmt_list : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_list>;
std::vector<stmt::ptr> list;
2023-01-23 17:31:08 -05:00
stmt_list(location const& loc);
XSK_ARC_AST_MAKE(stmt_list)
2023-01-23 17:31:08 -05:00
};
struct stmt_comp : public stmt
2023-01-24 06:53:39 -05:00
{
using ptr = std::unique_ptr<stmt_comp>;
stmt_list::ptr block;
stmt_comp(location const& loc, stmt_list::ptr block);
XSK_ARC_AST_MAKE(stmt_comp)
2023-01-24 06:53:39 -05:00
};
struct stmt_dev : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_dev>;
2023-01-24 06:53:39 -05:00
stmt_list::ptr block;
2023-01-23 17:31:08 -05:00
2023-01-24 06:53:39 -05:00
stmt_dev(location const& loc, stmt_list::ptr block);
XSK_ARC_AST_MAKE(stmt_dev)
2023-01-23 17:31:08 -05:00
};
struct stmt_expr : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_expr>;
expr::ptr value;
2023-01-23 17:31:08 -05:00
stmt_expr(location const& loc, expr::ptr value);
XSK_ARC_AST_MAKE(stmt_expr)
2023-01-23 17:31:08 -05:00
};
struct stmt_endon : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_endon>;
expr::ptr obj;
expr::ptr event;
2023-01-23 17:31:08 -05:00
stmt_endon(location const& loc, expr::ptr obj, expr::ptr event);
XSK_ARC_AST_MAKE(stmt_endon)
2023-01-23 17:31:08 -05:00
};
struct stmt_notify : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_notify>;
expr::ptr obj;
expr::ptr event;
2023-01-23 17:31:08 -05:00
expr_arguments::ptr args;
stmt_notify(location const& loc, expr::ptr obj, expr::ptr event, expr_arguments::ptr args);
XSK_ARC_AST_MAKE(stmt_notify)
};
struct stmt_wait : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_wait>;
expr::ptr time;
2023-01-23 17:31:08 -05:00
stmt_wait(location const& loc, expr::ptr time);
XSK_ARC_AST_MAKE(stmt_wait)
2023-01-23 17:31:08 -05:00
};
2024-01-05 10:33:16 -05:00
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
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_waittill>;
expr::ptr obj;
expr::ptr event;
2023-01-23 17:31:08 -05:00
expr_arguments::ptr args;
stmt_waittill(location const& loc, expr::ptr obj, expr::ptr event, expr_arguments::ptr args);
XSK_ARC_AST_MAKE(stmt_waittill)
2023-01-23 17:31:08 -05:00
};
struct stmt_waittillmatch : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_waittillmatch>;
expr::ptr obj;
expr::ptr event;
2023-01-23 17:31:08 -05:00
expr_arguments::ptr args;
stmt_waittillmatch(location const& loc, expr::ptr obj, expr::ptr expr, expr_arguments::ptr args);
XSK_ARC_AST_MAKE(stmt_waittillmatch)
2023-01-23 17:31:08 -05:00
};
struct stmt_waittillframeend : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_waittillframeend>;
stmt_waittillframeend(location const& loc);
XSK_ARC_AST_MAKE(stmt_waittillframeend)
2023-01-23 17:31:08 -05:00
};
struct stmt_if : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_if>;
expr::ptr test;
stmt::ptr body;
2023-01-23 17:31:08 -05:00
stmt_if(location const& loc, expr::ptr test, stmt::ptr body);
XSK_ARC_AST_MAKE(stmt_if)
2023-01-23 17:31:08 -05:00
};
struct stmt_ifelse : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_ifelse>;
expr::ptr test;
stmt::ptr stmt_if;
stmt::ptr stmt_else;
2023-01-23 17:31:08 -05:00
stmt_ifelse(location const& loc, expr::ptr test, stmt::ptr stmt_if, stmt::ptr stmt_else);
XSK_ARC_AST_MAKE(stmt_ifelse)
2023-01-23 17:31:08 -05:00
};
struct stmt_while : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_while>;
expr::ptr test;
stmt::ptr body;
2023-01-23 17:31:08 -05:00
stmt_while(location const& loc, expr::ptr test, stmt::ptr body);
XSK_ARC_AST_MAKE(stmt_while)
2023-01-23 17:31:08 -05:00
};
struct stmt_dowhile : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_dowhile>;
expr::ptr test;
stmt::ptr body;
2023-01-23 17:31:08 -05:00
stmt_dowhile(location const& loc, expr::ptr test, stmt::ptr body);
XSK_ARC_AST_MAKE(stmt_dowhile)
2023-01-23 17:31:08 -05:00
};
struct stmt_for : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_for>;
stmt::ptr init;
expr::ptr test;
stmt::ptr iter;
stmt::ptr body;
2023-01-23 17:31:08 -05:00
stmt_for(location const& loc, stmt::ptr init, expr::ptr test, stmt::ptr iter, stmt::ptr body);
XSK_ARC_AST_MAKE(stmt_for)
2023-01-23 17:31:08 -05:00
};
struct stmt_foreach : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_foreach>;
expr::ptr container;
expr::ptr value;
expr::ptr array;
expr::ptr key;
stmt::ptr body;
2023-01-23 17:31:08 -05:00
bool use_key;
stmt_foreach(location const& loc, expr::ptr container, expr::ptr value, expr::ptr array, expr::ptr key, stmt::ptr body, bool use_key);
XSK_ARC_AST_MAKE(stmt_foreach)
2023-01-23 17:31:08 -05:00
};
struct stmt_switch : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_switch>;
expr::ptr test;
2023-01-24 06:53:39 -05:00
stmt_comp::ptr body;
2023-01-23 17:31:08 -05:00
stmt_switch(location const& loc, expr::ptr test, stmt_comp::ptr body);
XSK_ARC_AST_MAKE(stmt_switch)
2023-01-23 17:31:08 -05:00
};
struct stmt_case : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_case>;
expr::ptr value;
2023-01-23 17:31:08 -05:00
stmt_list::ptr body;
stmt_case(location const& loc, expr::ptr value);
stmt_case(location const& loc, expr::ptr value, stmt_list::ptr body);
XSK_ARC_AST_MAKE(stmt_case)
2023-01-23 17:31:08 -05:00
};
struct stmt_default : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_default>;
stmt_list::ptr body;
stmt_default(location const& loc);
stmt_default(location const& loc, stmt_list::ptr body);
XSK_ARC_AST_MAKE(stmt_default)
2023-01-23 17:31:08 -05:00
};
struct stmt_break : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_break>;
stmt_break(location const& loc);
XSK_ARC_AST_MAKE(stmt_break)
2023-01-23 17:31:08 -05:00
};
struct stmt_continue : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_continue>;
stmt_continue(location const& loc);
XSK_ARC_AST_MAKE(stmt_continue)
2023-01-23 17:31:08 -05:00
};
struct stmt_return : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_return>;
expr::ptr value;
2023-01-23 17:31:08 -05:00
stmt_return(location const& loc, expr::ptr value);
XSK_ARC_AST_MAKE(stmt_return)
2023-01-23 17:31:08 -05:00
};
struct stmt_breakpoint : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_breakpoint>;
stmt_breakpoint(location const& loc);
XSK_ARC_AST_MAKE(stmt_breakpoint)
2023-01-23 17:31:08 -05:00
};
struct stmt_prof_begin : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_prof_begin>;
expr_arguments::ptr args;
stmt_prof_begin(location const& loc, expr_arguments::ptr args);
XSK_ARC_AST_MAKE(stmt_prof_begin)
2023-01-23 17:31:08 -05:00
};
struct stmt_prof_end : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_prof_end>;
expr_arguments::ptr args;
stmt_prof_end(location const& loc, expr_arguments::ptr args);
XSK_ARC_AST_MAKE(stmt_prof_end)
2023-01-23 17:31:08 -05:00
};
struct stmt_jmp : public stmt
{
using ptr = std::unique_ptr<stmt_jmp>;
std::string value;
stmt_jmp(location const& loc, std::string const& value);
XSK_ARC_AST_MAKE(stmt_jmp)
};
struct stmt_jmp_back : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_jmp_back>;
2023-01-23 17:31:08 -05:00
std::string value;
2023-01-23 17:31:08 -05:00
stmt_jmp_back(location const& loc, std::string const& value);
XSK_ARC_AST_MAKE(stmt_jmp_back)
2023-01-23 17:31:08 -05:00
};
struct stmt_jmp_cond : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_jmp_cond>;
2023-01-23 17:31:08 -05:00
expr::ptr test;
std::string value;
2023-01-23 17:31:08 -05:00
stmt_jmp_cond(location const& loc, expr::ptr test, std::string const& value);
XSK_ARC_AST_MAKE(stmt_jmp_cond)
2023-01-23 17:31:08 -05:00
};
struct stmt_jmp_true : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_jmp_true>;
2023-01-23 17:31:08 -05:00
expr::ptr test;
std::string value;
2023-01-23 17:31:08 -05:00
stmt_jmp_true(location const& loc, expr::ptr test, std::string const& value);
XSK_ARC_AST_MAKE(stmt_jmp_true)
2023-01-23 17:31:08 -05:00
};
struct stmt_jmp_false : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_jmp_false>;
2023-01-23 17:31:08 -05:00
expr::ptr test;
std::string value;
2023-01-23 17:31:08 -05:00
stmt_jmp_false(location const& loc, expr::ptr test, std::string const& value);
XSK_ARC_AST_MAKE(stmt_jmp_false)
2023-01-23 17:31:08 -05:00
};
struct stmt_jmp_switch : public stmt
{
using ptr = std::unique_ptr<stmt_jmp_switch>;
expr::ptr test;
std::string value;
stmt_jmp_switch(location const& loc, expr::ptr test, std::string const& value);
XSK_ARC_AST_MAKE(stmt_jmp_switch)
};
struct stmt_jmp_endswitch : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_jmp_endswitch>;
2023-01-23 17:31:08 -05:00
std::vector<std::string> data;
2023-01-23 17:31:08 -05:00
stmt_jmp_endswitch(location const& loc, std::vector<std::string> data);
XSK_ARC_AST_MAKE(stmt_jmp_endswitch)
2023-01-23 17:31:08 -05:00
};
struct stmt_jmp_dev : public stmt
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<stmt_jmp_dev>;
2023-01-23 17:31:08 -05:00
std::string value;
stmt_jmp_dev(location const& loc, std::string const& value);
XSK_ARC_AST_MAKE(stmt_jmp_dev)
2023-01-23 17:31:08 -05:00
};
struct decl_empty : public decl
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<decl_empty>;
2023-01-23 17:31:08 -05:00
decl_empty(location const& loc);
XSK_ARC_AST_MAKE(decl_empty)
2023-01-23 17:31:08 -05:00
};
struct decl_function : public decl
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<decl_function>;
2023-01-23 17:31:08 -05:00
expr_identifier::ptr space;
expr_identifier::ptr name;
expr_parameters::ptr params;
stmt_comp::ptr body;
export_flags flags;
2023-01-23 17:31:08 -05:00
decl_function(location const& loc, expr_identifier::ptr space, expr_identifier::ptr name, expr_parameters::ptr params, stmt_comp::ptr body, export_flags flags);
XSK_ARC_AST_MAKE(decl_function)
2023-01-23 17:31:08 -05:00
};
struct decl_usingtree : public decl
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<decl_usingtree>;
2023-01-23 17:31:08 -05:00
expr_string::ptr name;
2023-01-23 17:31:08 -05:00
decl_usingtree(location const& loc, expr_string::ptr name);
XSK_ARC_AST_MAKE(decl_usingtree)
2023-01-23 17:31:08 -05:00
};
struct decl_namespace : public decl
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<decl_namespace>;
2023-01-23 17:31:08 -05:00
expr_string::ptr name;
2023-01-23 17:31:08 -05:00
decl_namespace(location const& loc, expr_string::ptr name);
XSK_ARC_AST_MAKE(decl_namespace)
2023-01-23 17:31:08 -05:00
};
struct decl_dev_begin : public decl
{
using ptr = std::unique_ptr<decl_dev_begin>;
2023-01-23 17:31:08 -05:00
decl_dev_begin(location const& loc);
XSK_ARC_AST_MAKE(decl_dev_begin)
2023-01-23 17:31:08 -05:00
};
struct decl_dev_end : public decl
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<decl_dev_end>;
2023-01-23 17:31:08 -05:00
decl_dev_end(location const& loc);
XSK_ARC_AST_MAKE(decl_dev_end)
2023-01-23 17:31:08 -05:00
};
struct include : public node
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<include>;
2023-01-23 17:31:08 -05:00
expr_path::ptr path;
include(location const& loc, expr_path::ptr path);
XSK_ARC_AST_MAKE(include)
2023-01-23 17:31:08 -05:00
};
struct program : public node
2023-01-23 17:31:08 -05:00
{
using ptr = std::unique_ptr<program>;
2023-01-23 17:31:08 -05:00
std::vector<include::ptr> includes;
std::vector<decl::ptr> declarations;
2023-01-23 17:31:08 -05:00
program();
program(location const& loc);
XSK_ARC_AST_MAKE(program)
2023-01-23 17:31:08 -05:00
};
#undef XSK_GSC_AST_MAKE
} // namespace xsk::arc