Parser.hpp: Parse properties and methods
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
bd48d270be
commit
4fa72c0459
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue