i don't remember what i changed

This commit is contained in:
2026-04-14 20:38:14 +02:00
parent a577ffe094
commit 9ac3df1f37
4 changed files with 52 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ int noomL_isalphanum(char c) {
} }
int noomL_iswhitespace(char c) { int noomL_iswhitespace(char c) {
return c == ' ' || c == '\r' || c == '\n' || c == '\t'; return c == ' ' || c == '\r' || c == '\n' || c == '\t' || c == '\v' || c == '\f';
} }
noom_uint_t noomL_getsymbol(const char* s) { // TODO: maybe find some less shit crap holy crap noom_uint_t noomL_getsymbol(const char* s) { // TODO: maybe find some less shit crap holy crap
@@ -27,6 +27,13 @@ noom_uint_t noomL_getsymbol(const char* s) { // TODO: maybe find some less shit
if (noom_startswith(s, ">=")) return 2; if (noom_startswith(s, ">=")) return 2;
if (noom_startswith(s, "..")) return 2; if (noom_startswith(s, "..")) return 2;
if (noom_startswith(s, "::")) return 2;
if (noom_startswith(s, "//")) return 2;
if (noom_startswith(s, ">>")) return 2;
if (noom_startswith(s, "<<")) return 2;
if (noom_startswith(s, "+")) return 1; if (noom_startswith(s, "+")) return 1;
if (noom_startswith(s, "-")) return 1; if (noom_startswith(s, "-")) return 1;
if (noom_startswith(s, "*")) return 1; if (noom_startswith(s, "*")) return 1;
@@ -52,6 +59,10 @@ noom_uint_t noomL_getsymbol(const char* s) { // TODO: maybe find some less shit
if (noom_startswith(s, ";")) return 1; if (noom_startswith(s, ";")) return 1;
if (noom_startswith(s, "&")) return 1;
if (noom_startswith(s, "|")) return 1;
if (noom_startswith(s, "~")) return 1;
return 0; // no symbol return 0; // no symbol
} }

View File

@@ -33,7 +33,7 @@ void print_node(noomP_Node* node, noom_uint_t depth) {
int main(int argc, char** argv) { int main(int argc, char** argv) {
// uhh uhhh uhhhhh // uhh uhhh uhhhhh
const char* code = "if 6 then local a = 2 + 2; end"; const char* code = "if false or true then local a = 5 end";
noom_uint_t pos = 0; noom_uint_t pos = 0;
printf("LEX OUTPUT:\n"); printf("LEX OUTPUT:\n");

View File

@@ -79,6 +79,38 @@ noomP_Node* noomP_parseRawExpression(noomP_Parser* parser) {
varNode->source_offset = token.offset; varNode->source_offset = token.offset;
return varNode; return varNode;
} else if (token.type == NOOML_TOKEN_KEYWORD) {
if (noom_streql(parser->code + token.offset, token.length, "true", 4)) {
noomP_skip(parser, &token);
noomP_Node* litNode = noomP_allocNode(parser);
if (litNode == 0) return 0;
litNode->type = NOOMP_NODE_BOOLEANLITERAL;
litNode->source_offset = token.offset;
return litNode;
} else if (noom_streql(parser->code + token.offset, token.length, "false", 5)) {
noomP_skip(parser, &token);
noomP_Node* litNode = noomP_allocNode(parser);
if (litNode == 0) return 0;
litNode->type = NOOMP_NODE_BOOLEANLITERAL;
litNode->source_offset = token.offset;
return litNode;
} else if (noom_streql(parser->code + token.offset, token.length, "nil", 3)) {
noomP_skip(parser, &token);
noomP_Node* litNode = noomP_allocNode(parser);
if (litNode == 0) return 0;
litNode->type = NOOMP_NODE_NILLITERAL;
litNode->source_offset = token.offset;
return litNode;
}
} }
return 0; return 0;

View File

@@ -3,13 +3,18 @@
typedef enum noomP_NodeType { typedef enum noomP_NodeType {
NOOMP_NODE_PROGRAM, NOOMP_NODE_PROGRAM,
NOOMP_NODE_VARNAME, NOOMP_NODE_VARNAME,
NOOMP_NODE_VARIABLE,
NOOMP_NODE_NUMBERLITERAL,
NOOMP_NODE_LOCALDECLARATION, NOOMP_NODE_LOCALDECLARATION,
NOOMP_NODE_IFSTATEMENT, NOOMP_NODE_IFSTATEMENT,
NOOMP_NODE_BLOCK, NOOMP_NODE_BLOCK,
NOOMP_NODE_VARIABLE,
NOOMP_NODE_NUMBERLITERAL,
NOOMP_NODE_BOOLEANLITERAL,
NOOMP_NODE_NILLITERAL,
NOOMP_NODE_UNARYOPERATOR, NOOMP_NODE_UNARYOPERATOR,
NOOMP_NODE_BINARYOPERATOR NOOMP_NODE_BINARYOPERATOR
} noomP_NodeType; } noomP_NodeType;