Parser.hpp: Parse properties and methods

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-07-16 12:36:39 +02:00
parent bd48d270be
commit 4fa72c0459
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 14 additions and 4 deletions

View File

@ -26,7 +26,9 @@ namespace Parser {
const auto nextIterator = iterator + 1;
if (nextIterator->toktype == tok::COMMA) {
tokens.erase(nextIterator);
} else throw ParsingException("Missing comma after \"" + iterator->toktext + '"');
} else if (nextIterator->toktype != tok::DOT && iterator->toktype != tok::DOT) {
throw ParsingException("Missing comma after \"" + iterator->toktext + '"');
}
}
}
}
@ -111,9 +113,17 @@ namespace Parser {
});
parseTree << Define(isFinalDefine, current.toktext, parse(beginning, end));
i += 1 + isFinalDefine + distance(beginning, end);
} else if (next.toktype == LPAR) {
parseTree << Call(current.toktext);
} else parseTree << Reference(current.toktext);
} else {
const bool method = nextAre({DOT, IDENTIFIER, LPAR});
const bool property = not method && nextAre({DOT, IDENTIFIER});
const string name = property or method ? current.toktext + '.' + lexed[i + 2].toktext : current.toktext;
if (method or next.toktype == LPAR) {
parseTree << Call(name);
} else if (property) {
parseTree << Reference(name);
}
if (property or method) i += 2;
}
}
}
case SEMICOLON: break;