Converted parser into a class so that individual parsing methods can be overridden

This commit is contained in:
Hackerpilot 2013-10-18 12:31:09 -07:00
parent 7f9c0a4fb6
commit 77684566ec
1 changed files with 9 additions and 4 deletions

View File

@ -90,7 +90,7 @@ Module parseModule(const(Token)[] tokens, string fileName,
/** /**
* Parser structure * Parser structure
*/ */
struct Parser class Parser
{ {
/** /**
* Parses an AddExpression. * Parses an AddExpression.
@ -2309,7 +2309,12 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
FunctionBody parseFunctionBody() FunctionBody parseFunctionBody()
{ {
auto node = new FunctionBody; auto node = new FunctionBody;
if (currentIs(TokenType.lBrace)) if (currentIs(TokenType.semicolon))
{
advance();
return node;
}
else if (currentIs(TokenType.lBrace))
node.blockStatement = parseBlockStatement(); node.blockStatement = parseBlockStatement();
else else
{ {
@ -5973,7 +5978,7 @@ q{doStuff(5)}c;
this.tokens = tokens; this.tokens = tokens;
} }
private: protected:
bool isCastQualifier() const bool isCastQualifier() const
{ {
@ -6278,7 +6283,7 @@ private:
void skip(alias O, alias C)() void skip(alias O, alias C)()
{ {
assert(currentIs(O)); assert(currentIs(O), current().value);
advance(); advance();
int depth = 1; int depth = 1;
while (moreTokens()) while (moreTokens())