aboutsummaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-30 22:42:20 +0200
committerhachem <im@hachem.wtf>2026-08-30 22:42:20 +0200
commit81799f3e41ad9cab305930b7743a752003ff16ec (patch)
tree20fd67914ac143ab97a00392abcf5817ba11db22 /src/parser
parent294777178f9203283364f3e672569becb4dd1e7c (diff)
feat: sized memory stores bia ^
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/ast.h10
-rw-r--r--src/parser/parser.c14
2 files changed, 24 insertions, 0 deletions
diff --git a/src/parser/ast.h b/src/parser/ast.h
index 8281085..6071c4a 100644
--- a/src/parser/ast.h
+++ b/src/parser/ast.h
@@ -59,6 +59,15 @@ struct Expr
};
};
+enum StoreSize
+{
+ STORE_SIZE_NONE,
+ STORE_SIZE_BYTE,
+ STORE_SIZE_WORD,
+ STORE_SIZE_DWORD,
+ STORE_SIZE_QWORD,
+};
+
enum StatementKind
{
STATEMENT_ASSIGN,
@@ -73,6 +82,7 @@ enum StatementKind
struct AssignStatement
{
bool target_deref;
+ enum StoreSize store_size;
struct Token target;
struct Token op;
struct Expr* value;
diff --git a/src/parser/parser.c b/src/parser/parser.c
index d2a7285..ca14023 100644
--- a/src/parser/parser.c
+++ b/src/parser/parser.c
@@ -344,6 +344,19 @@ static bool parse_statement(struct Parser* parser, struct Statement* out)
bool deref = match_token(parser, TOKEN_CARET);
+ enum StoreSize store_size = STORE_SIZE_NONE;
+ if (deref)
+ {
+ if (match_token(parser, TOKEN_BYTE))
+ store_size = STORE_SIZE_BYTE;
+ else if (match_token(parser, TOKEN_WORD))
+ store_size = STORE_SIZE_WORD;
+ else if (match_token(parser, TOKEN_DWORD))
+ store_size = STORE_SIZE_DWORD;
+ else if (match_token(parser, TOKEN_QWORD))
+ store_size = STORE_SIZE_QWORD;
+ }
+
if (!consume(parser, TOKEN_IDENTIFIER, "expected a statement"))
return false;
struct Token name = parser->previous;
@@ -373,6 +386,7 @@ static bool parse_statement(struct Parser* parser, struct Statement* out)
out->kind = STATEMENT_ASSIGN;
out->assign.target_deref = deref;
+ out->assign.store_size = store_size;
out->assign.target = name;
out->assign.op = op;
out->assign.value = value;