1
0
mirror of synced 2024-11-24 15:50:16 +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,
BoolXor,
BoolNot,
TernaryConditional
TernaryConditional,
Dollar
};
enum class ValueType {
@ -225,6 +226,7 @@ namespace hex::lang {
#define OPERATOR_BOOLXOR COMPONENT(Operator, BoolXor)
#define OPERATOR_BOOLNOT COMPONENT(Operator, BoolNot)
#define OPERATOR_TERNARYCONDITIONAL COMPONENT(Operator, TernaryConditional)
#define OPERATOR_DOLLAR COMPONENT(Operator, Dollar)
#define VALUETYPE_CUSTOMTYPE COMPONENT(ValueType, CustomType)
#define VALUETYPE_PADDING COMPONENT(ValueType, Padding)

View File

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

View File

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