parser: strings
This commit is contained in:
13
src/parser.c
13
src/parser.c
@@ -25,6 +25,8 @@ const char *noomP_formatNodeType(noomP_NodeType node_type) {
|
|||||||
return "boolean literal";
|
return "boolean literal";
|
||||||
case NOOMP_NODE_NILLITERAL:
|
case NOOMP_NODE_NILLITERAL:
|
||||||
return "nil literal";
|
return "nil literal";
|
||||||
|
case NOOMP_NODE_STRINGLITERAL:
|
||||||
|
return "string literal";
|
||||||
case NOOMP_NODE_UNARYOPERATOR:
|
case NOOMP_NODE_UNARYOPERATOR:
|
||||||
return "unary operator";
|
return "unary operator";
|
||||||
case NOOMP_NODE_BINARYOPERATOR:
|
case NOOMP_NODE_BINARYOPERATOR:
|
||||||
@@ -92,7 +94,6 @@ noomP_Node* noomP_parseRawExpression(noomP_Parser* parser) {
|
|||||||
noomP_peek(parser, &token);
|
noomP_peek(parser, &token);
|
||||||
|
|
||||||
if (token.type == NOOML_TOKEN_NUMBER) {
|
if (token.type == NOOML_TOKEN_NUMBER) {
|
||||||
// uhh figure it out, future me!
|
|
||||||
noomP_skip(parser, &token);
|
noomP_skip(parser, &token);
|
||||||
|
|
||||||
noomP_Node* numNode = noomP_allocNode(parser);
|
noomP_Node* numNode = noomP_allocNode(parser);
|
||||||
@@ -101,6 +102,16 @@ noomP_Node* noomP_parseRawExpression(noomP_Parser* parser) {
|
|||||||
numNode->type = NOOMP_NODE_NUMBERLITERAL;
|
numNode->type = NOOMP_NODE_NUMBERLITERAL;
|
||||||
numNode->source_offset = token.offset;
|
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;
|
return numNode;
|
||||||
} else if (token.type == NOOML_TOKEN_IDENTIFIER) {
|
} else if (token.type == NOOML_TOKEN_IDENTIFIER) {
|
||||||
noomP_skip(parser, &token);
|
noomP_skip(parser, &token);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ typedef enum noomP_NodeType {
|
|||||||
NOOMP_NODE_NUMBERLITERAL,
|
NOOMP_NODE_NUMBERLITERAL,
|
||||||
NOOMP_NODE_BOOLEANLITERAL,
|
NOOMP_NODE_BOOLEANLITERAL,
|
||||||
NOOMP_NODE_NILLITERAL,
|
NOOMP_NODE_NILLITERAL,
|
||||||
|
NOOMP_NODE_STRINGLITERAL,
|
||||||
|
|
||||||
NOOMP_NODE_UNARYOPERATOR,
|
NOOMP_NODE_UNARYOPERATOR,
|
||||||
NOOMP_NODE_BINARYOPERATOR,
|
NOOMP_NODE_BINARYOPERATOR,
|
||||||
|
|||||||
Reference in New Issue
Block a user