MCPcopy Index your code
hub / github.com/endbasic/endbasic / parse_dim_as

Method parse_dim_as

core/src/parser.rs:534–552  ·  view source on GitHub ↗

Parses the `AS typename` clause of a `DIM` statement. The caller has already consumed the `AS` token.

(&mut self)

Source from the content-addressed store, hash-verified

532 /// Parses the `AS typename` clause of a `DIM` statement. The caller has already consumed the
533 /// `AS` token.
534 fn parse_dim_as(&mut self) -> Result<(ExprType, LineCol)> {
535 let peeked = self.lexer.peek()?;
536 let (vtype, vtype_pos) = match peeked.token {
537 Token::Eof | Token::Eol => (ExprType::Integer, peeked.pos),
538 Token::As => {
539 self.lexer.consume_peeked();
540 self.parse_as_type()?
541 }
542 _ => return Err(Error::Bad(peeked.pos, "Expected AS or end of statement".to_owned())),
543 };
544
545 let next = self.lexer.peek()?;
546 match &next.token {
547 Token::Eof | Token::Eol => (),
548 t => return Err(Error::Bad(next.pos, format!("Unexpected {} in DIM statement", t))),
549 }
550
551 Ok((vtype, vtype_pos))
552 }
553
554 /// Parses a `DIM` statement.
555 fn parse_dim(&mut self) -> Result<Statement> {

Callers 1

parse_dimMethod · 0.80

Calls 3

consume_peekedMethod · 0.80
parse_as_typeMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected