pub fn parse_simple_column_path(
    lite_arg: &Spanned<String>,
) -> (SpannedExpression, Option<ParseError>) {
    let mut delimiter = '.';
    let mut inside_delimiter = false;
    let mut output = vec![];
    let mut current_part = String::new();
    let mut start_index = 0;
    let mut last_index = 0;

    for (idx, c) in lite_arg.item.char_indices() {
        last_index = idx;
        if inside_delimiter {
            if c == delimiter {
                inside_delimiter = false;
            }
        } else if c == '\'' || c == '"' || c == '`' {
            inside_delimiter = true;
            delimiter = c;
        } else if c == '.' {
            let part_span = Span::new(
                lite_arg.span.start() + start_index,
                lite_arg.span.start() + idx,
            );

            if let Ok(row_number) = current_part.parse::<u64>() {
                output.push(Member::Int(BigInt::from(row_number), part_span));
            } else {
                let trimmed = trim_quotes(&current_part);
                output.push(Member::Bare(trimmed.clone().spanned(part_span)));
            }
            current_part.clear();
            // Note: I believe this is safe because of the delimiter we're using, but if we get fancy with
            // unicode we'll need to change this
            start_index = idx + '.'.len_utf8();
            continue;
        }
        current_part.push(c);
    }

    if !current_part.is_empty() {
        let part_span = Span::new(
            lite_arg.span.start() + start_index,
            lite_arg.span.start() + last_index + 1,
        );
        if let Ok(row_number) = current_part.parse::<u64>() {
            output.push(Member::Int(BigInt::from(row_number), part_span));
        } else {
            let current_part = trim_quotes(&current_part);
            output.push(Member::Bare(current_part.spanned(part_span)));
        }
    }

    (
        SpannedExpression::new(Expression::simple_column_path(output), lite_arg.span),
        None,
    )
}
/// Parses a simple column path, one without a variable (implied or explicit) at the head
Parses a simple column path, one without a variable (implied or explicit) at the head
Parses a simple column path one without a variable ( implied or explicit ) at the head
pub fn parse_simple_column_path(
    lite_arg: &Spanned<String>,
) -> (SpannedExpression, Option<ParseError>) {
    let mut delimiter = '.';
    let mut inside_delimiter = false;
    let mut output = vec![];
    let mut current_part = String::new();
    let mut start_index = 0;
    let mut last_index = 0;
    for (idx, c) in lite_arg.item.char_indices() {
        last_index = idx;
        if inside_delimiter {
            if c == delimiter {
                inside_delimiter = false;
            }
        } else if c == '\'' || c == '"' || c == '`' {
            inside_delimiter = true;
            delimiter = c;
        } else if c == '.' {
            let part_span = Span::new(
                lite_arg.span.start() + start_index,
                lite_arg.span.start() + idx,
            );
            if let Ok(row_number) = current_part.parse::<u64>() {
                output.push(Member::Int(BigInt::from(row_number), part_span));
            } else {
                let trimmed = trim_quotes(&current_part);
                output.push(Member::Bare(trimmed.clone().spanned(part_span)));
            }
            current_part.clear();
            // Note: I believe this is safe because of the delimiter we're using, but if we get fancy with
            // unicode we'll need to change this
            start_index = idx + '.'.len_utf8();
            continue;
        }
        current_part.push(c);
    }
    if !current_part.is_empty() {
        let part_span = Span::new(
            lite_arg.span.start() + start_index,
            lite_arg.span.start() + last_index + 1,
        );
        if let Ok(row_number) = current_part.parse::<u64>() {
            output.push(Member::Int(BigInt::from(row_number), part_span));
        } else {
            let current_part = trim_quotes(&current_part);
            output.push(Member::Bare(current_part.spanned(part_span)));
        }
    }
    (
        SpannedExpression::new(Expression::simple_column_path(output), lite_arg.span),
        None,
    )
}
pub fn parse_simple_column_path ( lite_arg : & Spanned < String > , ) -> ( SpannedExpression , Option < ParseError > ) { let mut delimiter = '.' ; let mut inside_delimiter = false ; let mut output = vec ! [ ] ; let mut current_part = String :: new ( ) ; let mut start_index = 0 ; let mut last_index = 0 ; for ( idx , c ) in lite_arg . item . char_indices ( ) { last_index = idx ; if inside_delimiter { if c == delimiter { inside_delimiter = false ; } } else if c == '\'' || c == '"' || c == '`' { inside_delimiter = true ; delimiter = c ; } else if c == '.' { let part_span = Span :: new ( lite_arg . span . start ( ) + start_index , lite_arg . span . start ( ) + idx , ) ; if let Ok ( row_number ) = current_part . parse :: < u64 > ( ) { output . push ( Member :: Int ( BigInt :: from ( row_number ) , part_span ) ) ; } else { let trimmed = trim_quotes ( & current_part ) ; output . push ( Member :: Bare ( trimmed . clone ( ) . spanned ( part_span ) ) ) ; } current_part . clear ( ) ; // Note: I believe this is safe because of the delimiter we're using, but if we get fancy with // unicode we'll need to change this start_index = idx + '.' . len_utf8 ( ) ; continue ; } current_part . push ( c ) ; } if ! current_part . is_empty ( ) { let part_span = Span :: new ( lite_arg . span . start ( ) + start_index , lite_arg . span . start ( ) + last_index + 1 , ) ; if let Ok ( row_number ) = current_part . parse :: < u64 > ( ) { output . push ( Member :: Int ( BigInt :: from ( row_number ) , part_span ) ) ; } else { let current_part = trim_quotes ( & current_part ) ; output . push ( Member :: Bare ( current_part . spanned ( part_span ) ) ) ; } } ( SpannedExpression :: new ( Expression :: simple_column_path ( output ) , lite_arg . span ) , None , ) }
Parses a simple column path, one without a variable (implied or explicit) at the head
Parses a simple column path one without a variable ( implied or explicit ) at the head
lite_arg
&Spanned<String>
lite_arg
&Spanned<String>