MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / var_declaration

Method var_declaration

aiscript-vm/src/parser/mod.rs:1071–1091  ·  view source on GitHub ↗
(&mut self, visibility: Visibility)

Source from the content-addressed store, hash-verified

1069 }
1070
1071 fn var_declaration(&mut self, visibility: Visibility) -> Option<Stmt<'gc>> {
1072 self.consume(TokenType::Identifier, "Expect variable name.");
1073 let name = self.previous;
1074
1075 let initializer = if self.match_token(TokenType::Equal) {
1076 Some(self.expression()?)
1077 } else {
1078 None
1079 };
1080
1081 self.consume(
1082 TokenType::Semicolon,
1083 "Expect ';' after variable declaration.",
1084 );
1085 Some(Stmt::Let(VariableDecl {
1086 name,
1087 initializer,
1088 visibility,
1089 line: name.line,
1090 }))
1091 }
1092
1093 fn while_statement(&mut self) -> Option<Stmt<'gc>> {
1094 // Set flag before parsing condition

Callers 2

declarationMethod · 0.80
for_statementMethod · 0.80

Calls 3

match_tokenMethod · 0.80
expressionMethod · 0.80
consumeMethod · 0.45

Tested by

no test coverage detected