parseMemberExpression method
Implementation
Expression parseMemberExpression(Token? newTok) {
int start = token?.startOffset??0;
Expression exp = parsePrimary();
loop:
while (true) {
int line = token?.line??0;
switch (token?.type) {
case Token.DOT:
next();
Name name = parseName();
exp = new MemberExpression(exp, name)
..start = start
..end = endOffset
..line = line;
break;
case Token.LBRACKET:
next();
Expression index = parseExpression();
requireNext(Token.RBRACKET);
exp = new IndexExpression(exp, index)
..start = start
..end = endOffset
..line = line;
break;
case Token.LPAREN:
List<Expression> args = parseArguments();
if (newTok != null) {
start = newTok.startOffset;
exp = new CallExpression.newCall(exp, args)
..start = start
..end = endOffset
..line = line;
newTok = null;
} else {
exp = new CallExpression(exp, args)
..start = start
..end = endOffset
..line = line;
}
break;
default:
break loop;
}
}
if (newTok != null) {
exp = new CallExpression.newCall(exp, <Expression>[])
..start = newTok.startOffset
..end = endOffset
..line = newTok.line;
}
return exp;
}