implemented nullable type notation

This commit is contained in:
cozis
2022-12-04 18:39:42 +01:00
parent d610a973f4
commit 7a07a1eb3c
12 changed files with 156 additions and 9 deletions
+5 -1
View File
@@ -63,6 +63,7 @@
typedef enum {
TOPT = '?',
TPOS = '+',
TNEG = '-',
@@ -556,6 +557,7 @@ static Node *parse_statement(Context *ctx)
case '[':
case '+':
case '-':
case '?':
case TINT:
case TFLOAT:
case TSTRING:
@@ -1544,6 +1546,7 @@ static Node *parse_prefix_expression(Context *ctx)
case '+':
case '-':
case '?':
case TKWNOT:
{
Token *unary_operator = current_token(ctx);
@@ -1569,6 +1572,7 @@ static Node *parse_prefix_expression(Context *ctx)
switch(unary_operator->kind)
{
case '?': temp->base.kind = EXPR_NULLABLETYPE; break;
case '+': temp->base.kind = EXPR_POS; break;
case '-': temp->base.kind = EXPR_NEG; break;
case TKWNOT: temp->base.kind = EXPR_NOT; break;
@@ -2217,4 +2221,4 @@ static Node *parse_dowhile_statement(Context *ctx)
}
return (Node*) dowhl;
}
}