fn parse_id_expr(&mut self) -> Result<Expr, &'static str> {
        let id = match self.curr() {
            Ident(id) => id,
            _ => return Err("Expected identifier."),
        };

        if self.advance().is_err() {
            return Ok(Expr::Variable(id));
        }

        match self.curr() {
            LParen => {
                self.advance()?;

                if let RParen = self.curr() {
                    return Ok(Expr::Call {
                        fn_name: id,
                        args: vec![],
                    });
                }

                let mut args = vec![];

                loop {
                    args.push(self.parse_expr()?);

                    match self.current()? {
                        Comma => (),
                        RParen => break,
                        _ => return Err("Expected ',' character in function call."),
                    }

                    self.advance()?;
                }

                self.advance();

                Ok(Expr::Call {
                    fn_name: id,
                    args: args,
                })
            }

            _ => Ok(Expr::Variable(id)),
        }
    }
/// Parses an expression that starts with an identifier (either a variable or a function call).
Parses an expression that starts with an identifier (either a variable or a function call).
Parses an expression that starts with an identifier ( either a variable or a function call ) .
fn parse_id_expr(&mut self) -> Result<Expr, &'static str> {
        let id = match self.curr() {
            Ident(id) => id,
            _ => return Err("Expected identifier."),
        };
        if self.advance().is_err() {
            return Ok(Expr::Variable(id));
        }
        match self.curr() {
            LParen => {
                self.advance()?;
                if let RParen = self.curr() {
                    return Ok(Expr::Call {
                        fn_name: id,
                        args: vec![],
                    });
                }
                let mut args = vec![];
                loop {
                    args.push(self.parse_expr()?);
                    match self.current()? {
                        Comma => (),
                        RParen => break,
                        _ => return Err("Expected ',' character in function call."),
                    }
                    self.advance()?;
                }
                self.advance();
                Ok(Expr::Call {
                    fn_name: id,
                    args: args,
                })
            }
            _ => Ok(Expr::Variable(id)),
        }
    }
fn parse_id_expr ( & mut self ) -> Result < Expr , & ' static str > { let id = match self . curr ( ) { Ident ( id ) => id , _ => return Err ( " " ) , } ; if self . advance ( ) . is_err ( ) { return Ok ( Expr :: Variable ( id ) ) ; } match self . curr ( ) { LParen => { self . advance ( ) ? ; if let RParen = self . curr ( ) { return Ok ( Expr :: Call { fn_name : id , args : vec ! [ ] , } ) ; } let mut args = vec ! [ ] ; loop { args . push ( self . parse_expr ( ) ? ) ; match self . current ( ) ? { Comma => ( ) , RParen => break , _ => return Err ( " " ) , } self . advance ( ) ? ; } self . advance ( ) ; Ok ( Expr :: Call { fn_name : id , args : args , } ) } _ => Ok ( Expr :: Variable ( id ) ) , } }
Parses an expression that starts with an identifier (either a variable or a function call).
Parses an expression that starts with an identifier ( either a variable or a function call ) .
&mut self
&mut self