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

Method parse_declare

core/src/parser.rs:1455–1470  ·  view source on GitHub ↗

Parses a `DECLARE` statement.

(&mut self)

Source from the content-addressed store, hash-verified

1453
1454 /// Parses a `DECLARE` statement.
1455 fn parse_declare(&mut self) -> Result<Statement> {
1456 let token_span = self.lexer.read()?;
1457 let (name, name_pos, params) = match token_span.token {
1458 Token::Function => self.parse_callable_signature(true, true)?,
1459
1460 Token::Sub => self.parse_callable_signature(true, false)?,
1461
1462 _ => {
1463 return Err(Error::Bad(
1464 token_span.pos,
1465 "Expected FUNCTION or SUB after DECLARE".to_owned(),
1466 ));
1467 }
1468 };
1469 Ok(Statement::Declare(DeclareSpan { name, name_pos, params }))
1470 }
1471
1472 /// Parses the signature of a callable declaration or definition.
1473 fn parse_callable_signature(

Callers 1

parse_oneMethod · 0.80

Calls 2

readMethod · 0.45

Tested by

no test coverage detected