===
Basic parameter
===

function Test
{
    param(
        $Name
    )
}

---

(program
  (statement_list
    (function_statement
      (function_name)
      (script_block
        (param_block
          (parameter_list
            (script_parameter
              (variable))))))))

===
Basic parameter with type
===

function Test
{
    param(
        [String]
        $Name
    )
}

---

(program
  (statement_list
    (function_statement
      (function_name)
      (script_block
        (param_block
          (parameter_list
            (script_parameter
              (attribute_list
                (attribute
                  (type_literal
                    (type_spec
                      (type_name
                        (type_identifier))))))
              (variable))))))))

===
Basic parameter with type and default value
===

function Test
{
    param(
        [String]
        $Name = ""
    )
}

---

(program
  (statement_list
    (function_statement
      (function_name)
      (script_block
        (param_block
          (parameter_list
            (script_parameter
              (attribute_list
                (attribute
                  (type_literal
                    (type_spec
                      (type_name
                        (type_identifier))))))
              (variable)
              (script_parameter_default
                (logical_expression
                  (bitwise_expression
                    (comparison_expression
                      (additive_expression
                        (multiplicative_expression
                          (format_expression
                            (range_expression
                              (array_literal_expression
                                (unary_expression
                                  (string_literal
                                    (expandable_string_literal)))))))))))))))))))

===
Basic parameter with output type
===

function Test
{
    [OutputType([Hashtable])]
    param(
        [String]
        $Name
    )
}

---

(program
  (statement_list
    (function_statement
      (function_name)
      (script_block
        (param_block
          (attribute_list
            (attribute
              (attribute_name
                (type_spec
                  (type_name
                    (type_identifier))))
              (attribute_arguments
                (attribute_argument
                  (logical_expression
                    (bitwise_expression
                      (comparison_expression
                        (additive_expression
                          (multiplicative_expression
                            (format_expression
                              (range_expression
                                (array_literal_expression
                                  (unary_expression
                                    (type_literal
                                      (type_spec
                                        (type_name
                                          (type_identifier)))))))))))))))))
          (parameter_list
            (script_parameter
              (attribute_list
                (attribute
                  (type_literal
                    (type_spec
                      (type_name
                        (type_identifier))))))
              (variable))))))))

===
Basic parameter with ValidateNotNull
===

function Test
{
    [OutputType([Hashtable])]
    param(
        [ValidateNotNull()]
        [String]
        $Name
    )
}

---

(program
  (statement_list
    (function_statement
      (function_name)
      (script_block
        (param_block
          (attribute_list
            (attribute
              (attribute_name
                (type_spec
                  (type_name
                    (type_identifier))))
              (attribute_arguments
                (attribute_argument
                  (logical_expression
                    (bitwise_expression
                      (comparison_expression
                        (additive_expression
                          (multiplicative_expression
                            (format_expression
                              (range_expression
                                (array_literal_expression
                                  (unary_expression
                                    (type_literal
                                      (type_spec
                                        (type_name
                                          (type_identifier)))))))))))))))))
          (parameter_list
            (script_parameter
              (attribute_list
                (attribute
                  (attribute_name
                    (type_spec
                      (type_name
                        (type_identifier)))))
                (attribute
                  (type_literal
                    (type_spec
                      (type_name
                        (type_identifier))))))
              (variable))))))))

===
Basic parameter with ValidateScript
===

function Test
{
    [OutputType([Hashtable])]
    param(
        [ValidateScript({($_ -is [Reflection.Emit.ModuleBuilder]) -or ($_ -is [Reflection.Assembly])})]
        [String]
        $Name
    )
}

---

(program
  (statement_list
    (function_statement
      (function_name)
      (script_block
        (param_block
          (attribute_list
            (attribute
              (attribute_name
                (type_spec
                  (type_name
                    (type_identifier))))
              (attribute_arguments
                (attribute_argument
                  (logical_expression
                    (bitwise_expression
                      (comparison_expression
                        (additive_expression
                          (multiplicative_expression
                            (format_expression
                              (range_expression
                                (array_literal_expression
                                  (unary_expression
                                    (type_literal
                                      (type_spec
                                        (type_name
                                          (type_identifier)))))))))))))))))
          (parameter_list
            (script_parameter
              (attribute_list
                (attribute
                  (attribute_name
                    (type_spec
                      (type_name
                        (type_identifier))))
                  (attribute_arguments
                    (attribute_argument
                      (logical_expression
                        (bitwise_expression
                          (comparison_expression
                            (additive_expression
                              (multiplicative_expression
                                (format_expression
                                  (range_expression
                                    (array_literal_expression
                                      (unary_expression
                                        (script_block_expression
                                          (script_block
                                            (script_block_body
                                              (statement_list
                                                (pipeline
                                                  (pipeline_chain
                                                    (logical_expression
                                                      (logical_expression
                                                        (bitwise_expression
                                                          (comparison_expression
                                                            (additive_expression
                                                              (multiplicative_expression
                                                                (format_expression
                                                                  (range_expression
                                                                    (array_literal_expression
                                                                      (unary_expression
                                                                        (parenthesized_expression
                                                                          (pipeline
                                                                            (pipeline_chain
                                                                              (logical_expression
                                                                                (bitwise_expression
                                                                                  (comparison_expression
                                                                                    (comparison_expression
                                                                                      (additive_expression
                                                                                        (multiplicative_expression
                                                                                          (format_expression
                                                                                            (range_expression
                                                                                              (array_literal_expression
                                                                                                (unary_expression
                                                                                                  (variable))))))))
                                                                                    (comparison_operator)
                                                                                    (additive_expression
                                                                                      (multiplicative_expression
                                                                                        (format_expression
                                                                                          (range_expression
                                                                                            (array_literal_expression
                                                                                              (unary_expression
                                                                                                (type_literal
                                                                                                  (type_spec
                                                                                                    (type_name
                                                                                                      (type_name
                                                                                                        (type_name
                                                                                                          (type_identifier))
                                                                                                        (type_identifier))
                                                                                                      (type_identifier)))))))))))))))))))))))))
                                                      (bitwise_expression
                                                        (comparison_expression
                                                          (additive_expression
                                                            (multiplicative_expression
                                                              (format_expression
                                                                (range_expression
                                                                  (array_literal_expression
                                                                    (unary_expression
                                                                      (parenthesized_expression
                                                                        (pipeline
                                                                          (pipeline_chain
                                                                            (logical_expression
                                                                              (bitwise_expression
                                                                                (comparison_expression
                                                                                  (comparison_expression
                                                                                    (additive_expression
                                                                                      (multiplicative_expression
                                                                                        (format_expression
                                                                                          (range_expression
                                                                                            (array_literal_expression
                                                                                              (unary_expression
                                                                                                (variable))))))))
                                                                                  (comparison_operator)
                                                                                  (additive_expression
                                                                                    (multiplicative_expression
                                                                                      (format_expression
                                                                                        (range_expression
                                                                                          (array_literal_expression
                                                                                            (unary_expression
                                                                                              (type_literal
                                                                                                (type_spec
                                                                                                  (type_name
                                                                                                    (type_name
                                                                                                      (type_identifier))
                                                                                                    (type_identifier)))))))))))))))))))))))))))))))))))))))))))
                (attribute
                  (type_literal
                    (type_spec
                      (type_name
                        (type_identifier))))))
              (variable))))))))

===
Basic parameter with Parameter with many paramters
===

function Test
{
    [OutputType([Hashtable])]
    param(
        [Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True)]
        [String]
        $Name
    )
}

---

(program
  (statement_list
    (function_statement
      (function_name)
      (script_block
        (param_block
          (attribute_list
            (attribute
              (attribute_name
                (type_spec
                  (type_name
                    (type_identifier))))
              (attribute_arguments
                (attribute_argument
                  (logical_expression
                    (bitwise_expression
                      (comparison_expression
                        (additive_expression
                          (multiplicative_expression
                            (format_expression
                              (range_expression
                                (array_literal_expression
                                  (unary_expression
                                    (type_literal
                                      (type_spec
                                        (type_name
                                          (type_identifier)))))))))))))))))
          (parameter_list
            (script_parameter
              (attribute_list
                (attribute
                  (attribute_name
                    (type_spec
                      (type_name
                        (type_identifier))))
                  (attribute_arguments
                    (attribute_argument
                      (simple_name)
                      (logical_expression
                        (bitwise_expression
                          (comparison_expression
                            (additive_expression
                              (multiplicative_expression
                                (format_expression
                                  (range_expression
                                    (array_literal_expression
                                      (unary_expression
                                        (variable)))))))))))
                    (attribute_argument
                      (simple_name)
                      (logical_expression
                        (bitwise_expression
                          (comparison_expression
                            (additive_expression
                              (multiplicative_expression
                                (format_expression
                                  (range_expression
                                    (array_literal_expression
                                      (unary_expression
                                        (variable)))))))))))))
                (attribute
                  (type_literal
                    (type_spec
                      (type_name
                        (type_identifier))))))
              (variable))))))))

===
Named scriptblock_expression
===

function Test
{
    begin
    {

    }
    process
    {

    }
}

---

(program
  (statement_list
    (function_statement
      (function_name)
      (script_block
        (script_block_body
          (named_block_list
            (named_block
              (block_name)
              (statement_block))
            (named_block
              (block_name)
              (statement_block))))))))

===
A complex but valid function name
===

function 1+1{
    param(
        $Name
    )
}

---

(program
  (statement_list
    (function_statement
      (function_name)
      (script_block
        (param_block
          (parameter_list
            (script_parameter
              (variable))))))))


===
Function name as keyword
===

function while {}

---

(program
  (statement_list
    (function_statement
      (function_name))))
