MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / multiplicative_expression

Function multiplicative_expression

graphlite/src/ast/parser.rs:1893–1923  ·  view source on GitHub ↗

Parse multiplicative expressions: postfix (*|/) postfix

(tokens: &[Token])

Source from the content-addressed store, hash-verified

1891
1892/// Parse multiplicative expressions: postfix (*|/) postfix
1893fn multiplicative_expression(tokens: &[Token]) -> IResult<&[Token], Expression> {
1894 map(
1895 tuple((
1896 postfix_expression,
1897 many0(tuple((
1898 alt((
1899 expect_token(Token::Star),
1900 expect_token(Token::Slash),
1901 expect_token(Token::Percent),
1902 )),
1903 postfix_expression,
1904 ))),
1905 )),
1906 |(first, rest)| {
1907 rest.into_iter().fold(first, |left, (op, right)| {
1908 let operator = match op {
1909 Token::Star => Operator::Star,
1910 Token::Slash => Operator::Slash,
1911 Token::Percent => Operator::Percent,
1912 _ => Operator::Star, // Should not happen
1913 };
1914 Expression::Binary(BinaryExpression {
1915 left: Box::new(left),
1916 operator,
1917 right: Box::new(right),
1918 location: Location::default(),
1919 })
1920 })
1921 },
1922 )(tokens)
1923}
1924
1925/// Parse array expression: [expr1, expr2, ...]
1926/// Returns a Literal::Vector if all elements are numeric, otherwise fails

Callers

nothing calls this directly

Calls 1

expect_tokenFunction · 0.85

Tested by

no test coverage detected