aboutsummaryrefslogtreecommitdiff
path: root/src/compiler/parser.c
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-05-07 14:32:53 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-05-07 14:32:53 +0330
commit20ff73d84b85db77aecb2171ce4d0e13253cccfd (patch)
tree2cc8b7f8816bc12ad97fe4a979ffccd29d347059 /src/compiler/parser.c
parentd7c31e44861b4d98fbddc177002e0a311a6d26af (diff)
add lazy to variables
Diffstat (limited to 'src/compiler/parser.c')
-rw-r--r--src/compiler/parser.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/parser.c b/src/compiler/parser.c
index 0d41a25..4781122 100644
--- a/src/compiler/parser.c
+++ b/src/compiler/parser.c
@@ -306,7 +306,7 @@ void parserNodePrint(const ParserNode *node, int indent) {
case PARSER_TOKEN_CONSTANT:
case PARSER_TOKEN_VARIABLE: {
const ParserNodeVariableMetadata *metadata = node->metadata;
- printf(",\n");
+ printf("isLazy=%b,\n", metadata->isLazy);
for (int i = 0; i < indent; ++i)
printf(" ");
printf("name=\n");
@@ -1829,6 +1829,14 @@ ParserNode *parserVariable(LexerNode *node, LexerNode *begin, LexerNode *end,
metadata->name = name;
metadata->type = type;
+ LexerNode *flagNode = nameNode - 1;
+ if (flagNode >= begin && flagNode->parserNode == NULL && flagNode->token == LEXER_TOKEN_KEYWORD_LAZY) {
+ metadata->isLazy = true;
+ flagNode->parserNode = variableNode;
+ } else {
+ metadata->isLazy = false;
+ }
+
variableNode->metadata = metadata;
if (value != NULL) {