1
0
mirror of synced 2025-02-17 18:59:21 +01:00

Added "dollar operator" to get the current offset

This commit is contained in:
WerWolv 2021-01-20 22:56:31 +01:00
parent 31426a289c
commit f0ab13ebc3
3 changed files with 8 additions and 1 deletions

View File

@ -59,7 +59,8 @@ namespace hex::lang {
BoolOr, BoolOr,
BoolXor, BoolXor,
BoolNot, BoolNot,
TernaryConditional TernaryConditional,
Dollar
}; };
enum class ValueType { enum class ValueType {
@ -225,6 +226,7 @@ namespace hex::lang {
#define OPERATOR_BOOLXOR COMPONENT(Operator, BoolXor) #define OPERATOR_BOOLXOR COMPONENT(Operator, BoolXor)
#define OPERATOR_BOOLNOT COMPONENT(Operator, BoolNot) #define OPERATOR_BOOLNOT COMPONENT(Operator, BoolNot)
#define OPERATOR_TERNARYCONDITIONAL COMPONENT(Operator, TernaryConditional) #define OPERATOR_TERNARYCONDITIONAL COMPONENT(Operator, TernaryConditional)
#define OPERATOR_DOLLAR COMPONENT(Operator, Dollar)
#define VALUETYPE_CUSTOMTYPE COMPONENT(ValueType, CustomType) #define VALUETYPE_CUSTOMTYPE COMPONENT(ValueType, CustomType)
#define VALUETYPE_PADDING COMPONENT(ValueType, Padding) #define VALUETYPE_PADDING COMPONENT(ValueType, Padding)

View File

@ -362,6 +362,9 @@ namespace hex::lang {
} else if (c == '?') { } else if (c == '?') {
tokens.emplace_back(TOKEN(Operator, TernaryConditional)); tokens.emplace_back(TOKEN(Operator, TernaryConditional));
offset += 1; offset += 1;
} else if (c == '$') {
tokens.emplace_back(TOKEN(Operator, Dollar));
offset += 1;
} else if (c == '\'') { } else if (c == '\'') {
auto character = getCharacterLiteral(code.substr(offset)); auto character = getCharacterLiteral(code.substr(offset));

View File

@ -97,6 +97,8 @@ namespace hex::lang {
} else if (MATCHES(sequence(IDENTIFIER))) { } else if (MATCHES(sequence(IDENTIFIER))) {
std::vector<std::string> path; std::vector<std::string> path;
return this->parseRValue(path); return this->parseRValue(path);
} else if (MATCHES(sequence(OPERATOR_DOLLAR))) {
return new ASTNodeRValue({ "$" });
} else } else
throwParseError("expected integer or parenthesis"); throwParseError("expected integer or parenthesis");
} }