Added iterable objects

__iter and __next are now reserved IStrings, OP_NEXT and OP_ITER have also been added. A new token (TOKEN_IN) has been added to the lexer. The parser now supports the for each loop (for i, ... in <object> do ... end).
savedPushed has been removed from the CCompilerState struct.
This commit is contained in:
2020-12-15 21:21:51 -06:00
parent 4f3f594b82
commit e5eca7bed6
9 changed files with 181 additions and 9 deletions

View File

@@ -49,6 +49,10 @@ CState *cosmoV_newState() {
state->iStrings[ISTRING_GETTER] = cosmoO_copyString(state, "__getter", 8);
state->iStrings[ISTRING_SETTER] = cosmoO_copyString(state, "__setter", 8);
// for iterators
state->iStrings[ISTRING_ITER] = cosmoO_copyString(state, "__iter", 6);
state->iStrings[ISTRING_NEXT] = cosmoO_copyString(state, "__next", 6);
// set the IString flags
for (int i = 0; i < ISTRING_MAX; i++)
state->iStrings[i]->isIString = true;