declaration method
Implementation
AstNode declaration() {
try {
switch (peek().type) {
case TokenType.flutterParam:
advance();
return flutterParameter();
case TokenType.flutterWidget:
advance();
return flutterWidgetDeclaration();
case TokenType.tartVar:
case TokenType.tartConst:
case TokenType.tartFinal:
advance();
return varDeclaration();
case TokenType.tartFunction:
advance();
return functionDeclaration();
case TokenType.leftParen:
advance();
return anonymousFunction();
case TokenType.identifier:
if (peek().type == TokenType.leftParen) {
advance();
return functionDeclaration();
}
return statement();
case TokenType.tartFor:
advance();
return forStatement();
case TokenType.tartReturn:
advance();
return returnStatement();
case TokenType.tartIf:
advance();
return ifStatement();
case TokenType.tartWhile:
advance();
return whileStatement();
default:
return statement();
}
} catch (e) {
synchronize();
// ignore: avoid_print
print(errors);
throw error(peek(), "Expected declaration/statement.");
}
}