MCPcopy Create free account
hub / github.com/AlenVelocity/MeowScript / parse_set_statement

Method parse_set_statement

src/parser.rs:66–96  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

64 }
65
66 pub fn parse_set_statement(&mut self) -> Option<Statement> {
67 match &self.peek_token {
68 Token::Ident(_) => self.next_token(),
69 _ => {
70 self.peek_error(Token::Ident(String::new()));
71 return None;
72 }
73 }
74
75 let name: Ident = match self.parse_ident() {
76 Some(Expr::Ident(ref mut s)) => s.clone(),
77 _ => return None,
78 };
79
80 if !self.expect_peek(Token::Assign) {
81 return None;
82 }
83
84 self.next_token();
85
86 let lit: Expr = match self.parse_expr(Precedence::Lowest) {
87 Some(e) => e,
88 None => return None,
89 };
90
91 while !self.current_token(Token::Semicolon) {
92 self.next_token();
93 }
94
95 Some(Statement::Set(name, lit))
96 }
97
98 pub fn parse_return_statement(&mut self) -> Option<Statement> {
99 self.next_token();

Callers 1

parse_statementMethod · 0.80

Calls 7

IdentClass · 0.85
peek_errorMethod · 0.80
parse_identMethod · 0.80
expect_peekMethod · 0.80
parse_exprMethod · 0.80
current_tokenMethod · 0.80
next_tokenMethod · 0.45

Tested by

no test coverage detected