feat(preprocessor): add engine name builtin macro (#179)

This commit is contained in:
Clément Dreptin 2024-01-13 16:53:19 +01:00 committed by GitHub
parent fe0f793d10
commit 6b69996713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -13,11 +13,12 @@ namespace xsk::arc
preprocessor::preprocessor(context* ctx, std::string const& name, char const* data, usize size) : ctx_{ ctx }, curr_expr_{ 0 }, expand_{ 0 }, skip_{ false } preprocessor::preprocessor(context* ctx, std::string const& name, char const* data, usize size) : ctx_{ ctx }, curr_expr_{ 0 }, expand_{ 0 }, skip_{ false }
{ {
lexer_.push(lexer{ ctx, name, data, size }); lexer_.push(lexer{ ctx, name, data, size });
defines_.reserve(4); defines_.reserve(5);
defines_.insert({ "__FILE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__FILE__", { define::BUILTIN,/* false,*/ {}, {} }});
defines_.insert({ "__LINE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__LINE__", { define::BUILTIN,/* false,*/ {}, {} }});
defines_.insert({ "__DATE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__DATE__", { define::BUILTIN,/* false,*/ {}, {} }});
defines_.insert({ "__TIME__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__TIME__", { define::BUILTIN,/* false,*/ {}, {} }});
defines_.insert({ std::string(ctx->engine_name()), { define::BUILTIN,/* false,*/ {}, {} }});
directives_.reserve(15); directives_.reserve(15);
directives_.insert({ "if", directive::IF }); directives_.insert({ "if", directive::IF });
directives_.insert({ "ifdef", directive::IFDEF }); directives_.insert({ "ifdef", directive::IFDEF });

View File

@ -13,11 +13,12 @@ namespace xsk::gsc
preprocessor::preprocessor(context* ctx, std::string const& name, char const* data, usize size) : ctx_{ ctx }, curr_expr_{ 0 }, expand_{ 0 }, skip_{ false } preprocessor::preprocessor(context* ctx, std::string const& name, char const* data, usize size) : ctx_{ ctx }, curr_expr_{ 0 }, expand_{ 0 }, skip_{ false }
{ {
lexer_.push(lexer{ ctx, name, data, size }); lexer_.push(lexer{ ctx, name, data, size });
defines_.reserve(4); defines_.reserve(5);
defines_.insert({ "__FILE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__FILE__", { define::BUILTIN,/* false,*/ {}, {} }});
defines_.insert({ "__LINE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__LINE__", { define::BUILTIN,/* false,*/ {}, {} }});
defines_.insert({ "__DATE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__DATE__", { define::BUILTIN,/* false,*/ {}, {} }});
defines_.insert({ "__TIME__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__TIME__", { define::BUILTIN,/* false,*/ {}, {} }});
defines_.insert({ std::string(ctx->engine_name()), { define::BUILTIN,/* false,*/ {}, {} }});
directives_.reserve(15); directives_.reserve(15);
directives_.insert({ "if", directive::IF }); directives_.insert({ "if", directive::IF });
directives_.insert({ "ifdef", directive::IFDEF }); directives_.insert({ "ifdef", directive::IFDEF });