Function parse_argument_list

Source
pub fn parse_argument_list(input: &str) -> IResult<&str, Expression>
Expand description

Parse a comma-separated argument list for function calls.

This function handles parsing of argument lists used in function calls, method calls, and inference calls. Argument lists can be:

  • Empty: ()
  • Single argument: (expression)
  • Multiple arguments: (expr1, expr2, expr3)

The function parses arguments as Closure expressions, which allows for complex expressions including closures and procedures.

§Arguments

  • input - The input string containing the argument list to parse

§Returns

Returns an [IResult] containing:

  • The remaining unparsed input
  • An Expression representing the parsed argument list

§Grammar

The argument list grammar follows:

argument_list = closure (S? ',' S? closure)*

Where closure represents any valid AIMX expression that can be used as a function argument.

§Examples

use aimx::expression::{parse_argument_list, Expression};

// Parse an empty argument list
let (remaining, expr) = parse_argument_list("").unwrap();
assert_eq!(remaining, "");
assert!(matches!(expr, Expression::Empty));

// Parse a single argument
let (remaining, expr) = parse_argument_list("42").unwrap();
assert_eq!(remaining, "");
assert!(matches!(expr, Expression::ArgumentList(_)));

// Parse multiple arguments
let (remaining, expr) = parse_argument_list("1, 2, 3").unwrap();
assert_eq!(remaining, "");
assert!(matches!(expr, Expression::ArgumentList(_)));

§See Also