I forgot about commas
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
#include "SolsLiteral.h"
|
#include "SolsLiteral.h"
|
||||||
|
|
||||||
typedef enum SolsTokenType {
|
typedef enum SolsTokenType {
|
||||||
STT_IDENTIFIER, STT_LITERAL, STT_TYPE, STT_DOT, STT_OPEN_CURLY, STT_CLOSE_CURLY, STT_OPEN_PAREN, STT_CLOSE_PAREN, STT_OP_ADD, STT_OP_SUB, STT_OP_MUL, STT_OP_DIV, STT_OP_ADDTO, STT_OP_SUBTO, STT_OP_MULTO, STT_OP_DIVTO, STT_OP_INCREMENT, STT_OP_DECREMENT, STT_OP_SET, STT_OP_GREATER, STT_OP_LESSER, STT_OP_EQUAL, STT_OP_INEQUAL, STT_OP_EQGREATER, STT_OP_EQLESSER, STT_KW_DEF, STT_KW_LAMBDA, STT_KW_STRUCT, STT_KW_PUTS, STT_KW_IF, STT_KW_WHILE, STT_KW_NEW, STT_KW_GROUND, STT_LINE_END
|
STT_IDENTIFIER, STT_LITERAL, STT_TYPE, STT_DOT, STT_OPEN_CURLY, STT_CLOSE_CURLY, STT_OPEN_PAREN, STT_CLOSE_PAREN, STT_OP_ADD, STT_OP_SUB, STT_OP_MUL, STT_OP_DIV, STT_OP_ADDTO, STT_OP_SUBTO, STT_OP_MULTO, STT_OP_DIVTO, STT_OP_INCREMENT, STT_OP_DECREMENT, STT_OP_SET, STT_OP_GREATER, STT_OP_LESSER, STT_OP_EQUAL, STT_OP_INEQUAL, STT_OP_EQGREATER, STT_OP_EQLESSER, STT_KW_DEF, STT_KW_LAMBDA, STT_KW_STRUCT, STT_KW_PUTS, STT_KW_IF, STT_KW_WHILE, STT_KW_NEW, STT_KW_GROUND, STT_LINE_END, STT_COMMA
|
||||||
} SolsTokenType;
|
} SolsTokenType;
|
||||||
|
|
||||||
typedef char* charptr;
|
typedef char* charptr;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ struct _SolsTokenTypeMap SolsTokenTypeMap[] = {
|
|||||||
{"<=", STT_OP_EQLESSER},
|
{"<=", STT_OP_EQLESSER},
|
||||||
{"\n", STT_LINE_END},
|
{"\n", STT_LINE_END},
|
||||||
{";", STT_LINE_END},
|
{";", STT_LINE_END},
|
||||||
|
{",", STT_COMMA},
|
||||||
// Shh, this is our little secret
|
// Shh, this is our little secret
|
||||||
// Your reward for actually reading the source code
|
// Your reward for actually reading the source code
|
||||||
// Enable this by adding -DSUPER_SILLY_MODE to your
|
// Enable this by adding -DSUPER_SILLY_MODE to your
|
||||||
|
|||||||
@@ -1165,7 +1165,7 @@ static inline ResultType(Nothing, charptr) parseLambda(SolsParser* parser) {
|
|||||||
return Error(Nothing, charptr, type.as.error);
|
return Error(Nothing, charptr, type.as.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pattern of type, name
|
// Pattern of type, name, comma
|
||||||
|
|
||||||
SolsType tmpType;
|
SolsType tmpType;
|
||||||
|
|
||||||
@@ -1191,6 +1191,19 @@ static inline ResultType(Nothing, charptr) parseLambda(SolsParser* parser) {
|
|||||||
// Add type to constructed SolsType
|
// Add type to constructed SolsType
|
||||||
addChildToSolsType(&type.as.success, tmpType, argName);
|
addChildToSolsType(&type.as.success, tmpType, argName);
|
||||||
parserConsume(parser);
|
parserConsume(parser);
|
||||||
|
|
||||||
|
next = parserPeek(parser, 1);
|
||||||
|
if (next.error) {
|
||||||
|
return Error(Nothing, charptr, "Expecting a comma or closing bracket");
|
||||||
|
}
|
||||||
|
if (next.as.success.type == STT_CLOSE_PAREN) {
|
||||||
|
parserConsume(parser);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (next.as.success.type != STT_COMMA) {
|
||||||
|
return Error(Nothing, charptr, "Expecting a comma or closing bracket");
|
||||||
|
}
|
||||||
|
parserConsume(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse type at the end
|
// Parse type at the end
|
||||||
|
|||||||
Reference in New Issue
Block a user