MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / parse_subscript

Method parse_subscript

crates/hll-to-ir/src/parser.rs:973–1006  ·  view source on GitHub ↗

Parse the contents of a `[...]` subscript: either a single index or a range (`a..b`, `a..=b`, `a..`, `..b`, `..`). Brackets are consumed by the caller.

(&mut self)

Source from the content-addressed store, hash-verified

971 rvalue: Box::new(rvalue),
972 })
973 } else {
974 Ok(left)
975 }
976 }
977
978 fn parse_or(&mut self) -> Result<Expression, ParserError> {
979 let mut expr = self.parse_and()?;
980 while self.match_or() {
981 self.consume_terminators();
982 let right = self.parse_and()?;
983 expr = Expression::Binary {
984 op: BinaryOp::Or,
985 left: Box::new(expr),
986 right: Box::new(right),
987 };
988 }
989 Ok(expr)
990 }
991
992 fn parse_and(&mut self) -> Result<Expression, ParserError> {
993 let mut expr = self.parse_equality()?;
994 while self.match_and() {
995 self.consume_terminators();
996 let right = self.parse_equality()?;
997 expr = Expression::Binary {
998 op: BinaryOp::And,
999 left: Box::new(expr),
1000 right: Box::new(right),
1001 };
1002 }
1003 Ok(expr)
1004 }
1005
1006 // Bitwise operators bind tighter than the comparisons (as in Rust, unlike C),
1007 // so `flags & MASK == 0` is `(flags & MASK) == 0`.
1008 fn parse_bitwise_or(&mut self) -> Result<Expression, ParserError> {
1009 let mut expr = self.parse_bitwise_xor()?;

Callers 1

parse_postfixMethod · 0.80

Calls 4

match_dot_dot_eqMethod · 0.80
match_dot_dotMethod · 0.80
parse_expressionMethod · 0.80

Tested by

no test coverage detected