mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Parser is reading variable declarations, read more
This is an incomplete process. It's supposed to be robust enough to support the types of arrays and dictionaries, but arrays and dictionaries aren't implemented in the literals yet, so that's my next task. I'll come back to variable declarations later.
This commit is contained in:
@@ -35,7 +35,6 @@ typedef struct {
|
||||
struct { //for variable names
|
||||
char* ptr;
|
||||
int length;
|
||||
unsigned char types;
|
||||
} identifier;
|
||||
} as;
|
||||
} Literal;
|
||||
@@ -67,7 +66,7 @@ typedef struct {
|
||||
// #define TO_ARRAY_LITERAL
|
||||
// #define TO_DICTIONARY_LITERAL
|
||||
// #define TO_FUNCTION_LITERAL
|
||||
#define TO_IDENTIFIER_LITERAL(value, types) _toIdentifierLiteral(value, types)
|
||||
#define TO_IDENTIFIER_LITERAL(value) _toIdentifierLiteral(value)
|
||||
|
||||
#define MASK(x) (1 >> (x))
|
||||
#define TYPE_CONST 0
|
||||
@@ -86,6 +85,7 @@ typedef struct {
|
||||
#define MASK_ARRAY (MASK(TYPE_ARRAY))
|
||||
#define MASK_DICTIONARY (MASK(TYPE_DICTIONARY))
|
||||
#define MASK_FUNCTION (MASK(TYPE_FUNCTION))
|
||||
#define MASK_ANY (MASK_BOOLEAN|MASK_INTEGER|MASK_FLOAT|MASK_STRING|MASK_ARRAY|MASK_DICTIONARY|MASK_FUNCTION)
|
||||
|
||||
//utils
|
||||
void printLiteral(Literal literal);
|
||||
@@ -101,7 +101,7 @@ void freeLiteral(Literal literal);
|
||||
//BUGFIX: macros are not functions
|
||||
bool _isTruthy(Literal x);
|
||||
Literal _toStringLiteral(char* str);
|
||||
Literal _toIdentifierLiteral(char* str, unsigned char types);
|
||||
Literal _toIdentifierLiteral(char* str);
|
||||
|
||||
//utils
|
||||
char* copyString(char* original, int length);
|
||||
|
||||
Reference in New Issue
Block a user