public FunctionDeclaration(
            SyntaxTree syntaxTree,
            LexToken functionKeyword,
            LexToken identifier,
            LexToken openParentheses,
            SeparatedSyntaxList <ParameterSyntax> parameters,
            LexToken closeParentheses,
            TypeClauseSyntax optionalTypeClause,
            Statement body
            )
            : base(syntaxTree)
        {
            FunctionKeyword    = functionKeyword;
            Identifier         = identifier;
            OpenParentheses    = openParentheses;
            Parameters         = parameters;
            CloseParentheses   = closeParentheses;
            OptionalTypeClause = optionalTypeClause;
            Body = body;

            foreach (var parameter in Parameters)
            {
                parameter.Parent = this;
            }

            if (OptionalTypeClause is not null)
            {
                OptionalTypeClause.Parent = this;
            }

            Body.Parent = this;
        }
示例#2
0
        public ParameterSyntax(SyntaxTree syntaxTree, LexToken identifier, TypeClauseSyntax type)
            : base(syntaxTree)
        {
            Identifier = identifier;
            Type       = type;

            Type.Parent = this;
        }
        public VariableDeclarationStatement(
            SyntaxTree syntaxTree,
            LexToken keywordToken,
            LexToken identifierToken,
            TypeClauseSyntax optionalTypeClause,
            LexToken equalsToken,
            Expression initializer
            )
            : base(syntaxTree)
        {
            KeywordToken       = keywordToken;
            Identifier         = identifierToken;
            OptionalTypeClause = optionalTypeClause;
            EqualsToken        = equalsToken;
            Initializer        = initializer;

            if (OptionalTypeClause is not null)
            {
                OptionalTypeClause.Parent = this;
            }

            Initializer.Parent = this;
        }