// Parses the whole expression starting with identifier:
// - single identifier
// - function call
Parses the whole expression starting with identifier:
single identifier
function call
Parses the whole expression starting with identifier : single identifier function call
fn parse_ident_expression(parser: &mut Parser) -> Option<Expr> {
    let name_location = parser.peek_token().location;
    let start = BytePos(name_location.range.start.try_into().unwrap());
    let name = parser.expect_identifier()?;
    let mut left = Expr {
        id: parser.next_id(),
        span: Span {
            start: start,
            end: parser.last_pos,
        },
        kind: ExprKind::Identifier(IdentifierExpression {
            name: name,
            name_location: name_location,
        }),
    };
    loop {
        match parser.peek_token().token_type {
            TokenType::LeftParenthesis => {
                parser.advance();
                let arguments =
                    parser.parse_list(|p| p.parse_expression(), TokenType::RightParenthesis)?;
                left = Expr {
                    id: parser.next_id(),
                    span: Span {
                        start: start,
                        end: parser.last_pos,
                    },
                    kind: ExprKind::Function(FunctionExpression {
                        callee: Box::new(left),
                        arguments: arguments,
                    }),
                };
            }
            TokenType::LeftBracket => {
                parser.advance();
                let idx = parse_array_subscript(parser)?;
                parser.expect_token(TokenType::RightBracket)?;
                left = Expr {
                    id: parser.next_id(),
                    span: Span {
                        start: start,
                        end: parser.last_pos,
                    },
                    kind: ExprKind::ArraySubscript(ArraySubscriptExpression {
                        base: Box::new(left),
                        idx: Box::new(idx),
                    }),
                };
            }
            _ => return Some(left),
        }
    }
}
fn parse_ident_expression ( parser : & mut Parser ) -> Option < Expr > { let name_location = parser . peek_token ( ) . location ; let start = BytePos ( name_location . range . start . try_into ( ) . unwrap ( ) ) ; let name = parser . expect_identifier ( ) ? ; let mut left = Expr { id : parser . next_id ( ) , span : Span { start : start , end : parser . last_pos , } , kind : ExprKind :: Identifier ( IdentifierExpression { name : name , name_location : name_location , } ) , } ; loop { match parser . peek_token ( ) . token_type { TokenType :: LeftParenthesis => { parser . advance ( ) ; let arguments = parser . parse_list ( | p | p . parse_expression ( ) , TokenType :: RightParenthesis ) ? ; left = Expr { id : parser . next_id ( ) , span : Span { start : start , end : parser . last_pos , } , kind : ExprKind :: Function ( FunctionExpression { callee : Box :: new ( left ) , arguments : arguments , } ) , } ; } TokenType :: LeftBracket => { parser . advance ( ) ; let idx = parse_array_subscript ( parser ) ? ; parser . expect_token ( TokenType :: RightBracket ) ? ; left = Expr { id : parser . next_id ( ) , span : Span { start : start , end : parser . last_pos , } , kind : ExprKind :: ArraySubscript ( ArraySubscriptExpression { base : Box :: new ( left ) , idx : Box :: new ( idx ) , } ) , } ; } _ => return Some ( left ) , } } }
Parses the whole expression starting with identifier:
 single identifier
 function call
Parses the whole expression starting with identifier : single identifier function call
parser
&mut Parser