MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / parse_logical_xor_expression

Function parse_logical_xor_expression

crates/gitql-parser/src/parser.rs:1859–1943  ·  view source on GitHub ↗
(
    context: &mut ParserContext,
    env: &mut Environment,
    tokens: &[Token],
    position: &mut usize,
)

Source from the content-addressed store, hash-verified

1857}
1858
1859fn parse_logical_xor_expression(
1860 context: &mut ParserContext,
1861 env: &mut Environment,
1862 tokens: &[Token],
1863 position: &mut usize,
1864) -> Result<Box<dyn Expr>, Box<Diagnostic>> {
1865 let mut lhs = parse_bitwise_and_expression(context, env, tokens, position)?;
1866
1867 'parse_expr: while is_current_token(tokens, position, TokenKind::XorKeyword) {
1868 let operator = &tokens[*position];
1869
1870 // Consume`XOR` operator
1871 *position += 1;
1872
1873 let rhs = parse_bitwise_and_expression(context, env, tokens, position)?;
1874
1875 let lhs_type = lhs.expr_type();
1876 let rhs_type = rhs.expr_type();
1877
1878 let expected_rhs_types = lhs_type.can_perform_logical_xor_op_with();
1879
1880 // Can perform this operator between LHS and RHS
1881 if expected_rhs_types.contains(&rhs_type) {
1882 lhs = Box::new(LogicalExpr {
1883 left: lhs,
1884 operator: BinaryLogicalOperator::Xor,
1885 right: rhs,
1886 });
1887
1888 continue 'parse_expr;
1889 }
1890
1891 // Check if RHS expr can be implicit casted to Expected LHS type to make this
1892 // Expression valid
1893 for expected_type in expected_rhs_types.iter() {
1894 if !expected_type.has_implicit_cast_from(&rhs) {
1895 continue;
1896 }
1897
1898 let casting = Box::new(CastExpr {
1899 value: rhs,
1900 result_type: expected_type.clone(),
1901 });
1902
1903 lhs = Box::new(LogicalExpr {
1904 left: lhs,
1905 operator: BinaryLogicalOperator::Xor,
1906 right: casting,
1907 });
1908
1909 continue 'parse_expr;
1910 }
1911
1912 // Check if LHS expr can be implicit casted to Expected RHS type to make this
1913 // Expression valid
1914 let expected_lhs_types = rhs_type.can_perform_logical_xor_op_with();
1915 for expected_type in expected_lhs_types.iter() {
1916 if !expected_type.has_implicit_cast_from(&lhs) {

Callers 1

Calls 8

is_current_tokenFunction · 0.85
expr_typeMethod · 0.80
containsMethod · 0.80
as_boxedMethod · 0.80
with_locationMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…