diff --git a/trunk_parser/src/parser/ident.rs b/trunk_parser/src/parser/ident.rs index 0ab3a60..0f3074d 100644 --- a/trunk_parser/src/parser/ident.rs +++ b/trunk_parser/src/parser/ident.rs @@ -14,4 +14,8 @@ impl Parser { pub(crate) fn full_name(&mut self) -> ParseResult { Ok(expect!(self, TokenKind::Identifier(i) | TokenKind::QualifiedIdentifier(i) | TokenKind::FullyQualifiedIdentifier(i), i, "expected identifier")) } + + pub(crate) fn var(&mut self) -> ParseResult { + Ok(expect!(self, TokenKind::Variable(v), v, "expected variable name")) + } } \ No newline at end of file diff --git a/trunk_parser/src/parser/mod.rs b/trunk_parser/src/parser/mod.rs index a537f8b..eedf533 100644 --- a/trunk_parser/src/parser/mod.rs +++ b/trunk_parser/src/parser/mod.rs @@ -545,7 +545,7 @@ impl Parser { var_type = Some(self.type_string()?); } - let var = expect!(self, TokenKind::Variable(i), i, "expected variable name"); + let var = self.var()?; let mut value = None; if self.current.kind == TokenKind::Equals { @@ -631,7 +631,7 @@ impl Parser { }, TokenKind::Question | TokenKind::Identifier(_) | TokenKind::QualifiedIdentifier(_) | TokenKind::FullyQualifiedIdentifier(_) => { let prop_type = self.type_string()?; - let var = expect!(self, TokenKind::Variable(v), v, "expected variable name"); + let var = self.var()?; let mut value = None; if self.current.kind == TokenKind::Equals { @@ -647,7 +647,7 @@ impl Parser { Ok(Statement::Property { var, value, r#type: Some(prop_type), flags: flags.into_iter().map(|f| f.into()).collect() }) }, TokenKind::Variable(_) => { - let var = expect!(self, TokenKind::Variable(v), v, "expected variable name"); + let var = self.var()?; let mut value = None; if self.current.kind == TokenKind::Equals {