MCPcopy Create free account
hub / github.com/aspizu/goboscript / parse_function_define

Method parse_function_define

src/pre_processor.rs:131–161  ·  view source on GitHub ↗
(
        &mut self,
        span: &mut Span,
        define_name: Token,
    )

Source from the content-addressed store, hash-verified

129 }
130
131 fn parse_function_define(
132 &mut self,
133 span: &mut Span,
134 define_name: Token,
135 ) -> Result<bool, Diagnostic> {
136 if !matches!(get_token(&self.tokens[*self.i]), Token::LParen) {
137 return Ok(false);
138 }
139 *self.i += 1;
140 self.expect_no_eof()?;
141 let mut name = get_token(&self.tokens[*self.i]).clone();
142 *self.i -= 1;
143 if !matches!(name, Token::Name(_) | Token::RParen) {
144 return Ok(false);
145 }
146 self.remove_token(span);
147 let mut args = vec![];
148 while name != Token::RParen {
149 if name != Token::Comma {
150 args.push(name);
151 }
152 self.remove_token(span);
153 self.expect_no_eof()?;
154 name = get_token(&self.tokens[*self.i]).clone();
155 }
156 self.remove_token(span);
157 let body = self.parse_define_body(span)?;
158 self.function_defines
159 .insert(define_name.to_string().into(), (args, body));
160 Ok(true)
161 }
162
163 fn parse_simple_define(
164 &mut self,

Callers 1

processMethod · 0.80

Calls 5

get_tokenFunction · 0.85
expect_no_eofMethod · 0.80
remove_tokenMethod · 0.80
parse_define_bodyMethod · 0.80
to_stringMethod · 0.45

Tested by

no test coverage detected