diff options
author | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-01-18 21:03:23 +0330 |
---|---|---|
committer | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-01-18 21:03:23 +0330 |
commit | 6372d439068482a847fabcb9e97d9e240ccb8a47 (patch) | |
tree | 82dfcbd76c752eea8b9601d0c233cc2f15e5cc82 /src | |
parent | 43392fc66ab207e53a6924a2edbcd7ca0acecea8 (diff) |
add multi line comment
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/lexer.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/compiler/lexer.c b/src/compiler/lexer.c index b919be0..90eb36d 100644 --- a/src/compiler/lexer.c +++ b/src/compiler/lexer.c @@ -94,8 +94,17 @@ LexerNodeArray lexer(char *str) { } else if (c == '*') { lexerPushClear(&result, &result_size, iter - 1, &node_str_begin, &node_token, LEXER_TOKEN_NONE); - printLog("Not implemented"); // TODO: implement it - exit(1); + ++iter; + int in = 1; + for (; in != 0; ++iter) { + if (*iter == '*' && *(iter + 1) == '/') { + --in; + } else if (*iter == '/' && *(iter + 1) == '*') { + ++in; + } else if (*iter == '\0') { + goto RETURN_ERROR; + } + } } } if (isSpace(c)) { @@ -121,6 +130,7 @@ LexerNodeArray lexer(char *str) { lexerPushClear(&result, &result_size, iter, &node_str_begin, &node_token, LEXER_TOKEN_SYMBOL); } else { + RETURN_ERROR: free(result.data); printLog("Unexpected character '%c' at position %ld", c, iter - str); return LEXER_NODE_ARRAY_ERROR; |