mirror of
https://github.com/danog/parser.git
synced 2024-11-27 04:14:55 +01:00
parser: abstract var for consistency
This commit is contained in:
parent
d4cae32474
commit
b4f8b1bf00
@ -14,4 +14,8 @@ impl Parser {
|
||||
pub(crate) fn full_name(&mut self) -> ParseResult<String> {
|
||||
Ok(expect!(self, TokenKind::Identifier(i) | TokenKind::QualifiedIdentifier(i) | TokenKind::FullyQualifiedIdentifier(i), i, "expected identifier"))
|
||||
}
|
||||
|
||||
pub(crate) fn var(&mut self) -> ParseResult<String> {
|
||||
Ok(expect!(self, TokenKind::Variable(v), v, "expected variable name"))
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user