Example #1
0
File: Parser.cs Project: luqp/Nova
        private ParameterSyntax ParseParameter()
        {
            SyntaxToken      identifier = MatchToken(SyntaxKind.IdentifierToken);
            TypeClauseSyntax type       = ParseTypeClause();

            return(new ParameterSyntax(identifier, type));
        }
Example #2
0
File: Parser.cs Project: luqp/Nova
        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));
        }
Example #3
0
File: Parser.cs Project: luqp/Nova
        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));
        }