private ParameterSyntax ParseParameter() { SyntaxToken identifier = MatchToken(SyntaxKind.IdentifierToken); TypeClauseSyntax type = ParseTypeClause(); return(new ParameterSyntax(identifier, type)); }
private StatementSyntax ParseVariableDeclaration() { SyntaxKind expected = Current.Kind == SyntaxKind.LetKeyword ? SyntaxKind.LetKeyword : SyntaxKind.VarKeyword; SyntaxToken keyword = MatchToken(expected); SyntaxToken identifier = MatchToken(SyntaxKind.IdentifierToken); TypeClauseSyntax typeClause = ParseOptionalTypeClause(); SyntaxToken equals = MatchToken(SyntaxKind.EqualsToken); ExpressionSyntax initializer = ParseExpression(); return(new VariableDeclarationSyntax(keyword, identifier, typeClause, equals, initializer)); }
private MemberSyntax ParseFunctionDeclaration() { SyntaxToken functionKeyword = MatchToken(SyntaxKind.FunctionKeyword); SyntaxToken identifier = MatchToken(SyntaxKind.IdentifierToken); SyntaxToken openParenthesisToken = MatchToken(SyntaxKind.OpenParenthesisToken); SeparatedSyntaxList <ParameterSyntax> parameters = ParseParameterList(); SyntaxToken closeParenthesisToken = MatchToken(SyntaxKind.CloseParenthesisToken); TypeClauseSyntax type = ParseOptionalTypeClause(); BlockStatementSyntax body = ParseBlockStatement(); return(new FunctionDeclarationSyntax(functionKeyword, identifier, openParenthesisToken, parameters, closeParenthesisToken, type, body)); }