parser: strings

This commit is contained in:
2026-04-22 17:32:35 +02:00
parent 5b99c73a1a
commit 3d72500c5c
2 changed files with 13 additions and 1 deletions

View File

@@ -25,6 +25,8 @@ const char *noomP_formatNodeType(noomP_NodeType node_type) {
return "boolean literal";
case NOOMP_NODE_NILLITERAL:
return "nil literal";
case NOOMP_NODE_STRINGLITERAL:
return "string literal";
case NOOMP_NODE_UNARYOPERATOR:
return "unary operator";
case NOOMP_NODE_BINARYOPERATOR:
@@ -92,7 +94,6 @@ noomP_Node* noomP_parseRawExpression(noomP_Parser* parser) {
noomP_peek(parser, &token);
if (token.type == NOOML_TOKEN_NUMBER) {
// uhh figure it out, future me!
noomP_skip(parser, &token);
noomP_Node* numNode = noomP_allocNode(parser);
@@ -101,6 +102,16 @@ noomP_Node* noomP_parseRawExpression(noomP_Parser* parser) {
numNode->type = NOOMP_NODE_NUMBERLITERAL;
numNode->source_offset = token.offset;
return numNode;
} else if (token.type == NOOML_TOKEN_STRING) {
noomP_skip(parser, &token);
noomP_Node* numNode = noomP_allocNode(parser);
if (numNode == 0) return 0;
numNode->type = NOOMP_NODE_STRINGLITERAL;
numNode->source_offset = token.offset;
return numNode;
} else if (token.type == NOOML_TOKEN_IDENTIFIER) {
noomP_skip(parser, &token);

View File

@@ -17,6 +17,7 @@ typedef enum noomP_NodeType {
NOOMP_NODE_NUMBERLITERAL,
NOOMP_NODE_BOOLEANLITERAL,
NOOMP_NODE_NILLITERAL,
NOOMP_NODE_STRINGLITERAL,
NOOMP_NODE_UNARYOPERATOR,
NOOMP_NODE_BINARYOPERATOR,