chore: fmt

This commit is contained in:
Ryan Chandler 2022-11-30 00:58:30 +00:00
parent 29946919ad
commit 9a2109b31d
No known key found for this signature in database
GPG Key ID: F113BCADDB3B0CCA
3 changed files with 96 additions and 86 deletions

View File

@ -69,82 +69,85 @@ impl Parser {
}
pub(crate) fn is_reserved_ident(kind: &TokenKind) -> bool {
matches!(kind, TokenKind::Static
| TokenKind::Abstract
| TokenKind::Final
| TokenKind::For
| TokenKind::Private
| TokenKind::Protected
| TokenKind::Public
| TokenKind::Include
| TokenKind::IncludeOnce
| TokenKind::Eval
| TokenKind::Require
| TokenKind::RequireOnce
| TokenKind::LogicalOr
| TokenKind::LogicalXor
| TokenKind::LogicalAnd
| TokenKind::Instanceof
| TokenKind::New
| TokenKind::Clone
| TokenKind::Exit
| TokenKind::If
| TokenKind::ElseIf
| TokenKind::Else
| TokenKind::EndIf
| TokenKind::Echo
| TokenKind::Do
| TokenKind::While
| TokenKind::EndWhile
| TokenKind::EndFor
| TokenKind::Foreach
| TokenKind::EndForeach
| TokenKind::Declare
| TokenKind::EndDeclare
| TokenKind::As
| TokenKind::Try
| TokenKind::Catch
| TokenKind::Finally
| TokenKind::Throw
| TokenKind::Use
| TokenKind::Insteadof
| TokenKind::Global
| TokenKind::Var
| TokenKind::Unset
| TokenKind::Isset
| TokenKind::Empty
| TokenKind::Continue
| TokenKind::Goto
| TokenKind::Function
| TokenKind::Const
| TokenKind::Return
| TokenKind::Print
| TokenKind::Yield
| TokenKind::List
| TokenKind::Switch
| TokenKind::EndSwitch
| TokenKind::Case
| TokenKind::Default
| TokenKind::Break
| TokenKind::Array
| TokenKind::Callable
| TokenKind::Extends
| TokenKind::Implements
| TokenKind::Namespace
| TokenKind::Trait
| TokenKind::Interface
| TokenKind::Class
| TokenKind::ClassConstant
| TokenKind::TraitConstant
| TokenKind::FunctionConstant
| TokenKind::MethodConstant
| TokenKind::LineConstant
| TokenKind::FileConstant
| TokenKind::DirConstant
| TokenKind::NamespaceConstant
| TokenKind::HaltCompiler
| TokenKind::Fn
| TokenKind::Match
| TokenKind::Enum
| TokenKind::From)
}
matches!(
kind,
TokenKind::Static
| TokenKind::Abstract
| TokenKind::Final
| TokenKind::For
| TokenKind::Private
| TokenKind::Protected
| TokenKind::Public
| TokenKind::Include
| TokenKind::IncludeOnce
| TokenKind::Eval
| TokenKind::Require
| TokenKind::RequireOnce
| TokenKind::LogicalOr
| TokenKind::LogicalXor
| TokenKind::LogicalAnd
| TokenKind::Instanceof
| TokenKind::New
| TokenKind::Clone
| TokenKind::Exit
| TokenKind::If
| TokenKind::ElseIf
| TokenKind::Else
| TokenKind::EndIf
| TokenKind::Echo
| TokenKind::Do
| TokenKind::While
| TokenKind::EndWhile
| TokenKind::EndFor
| TokenKind::Foreach
| TokenKind::EndForeach
| TokenKind::Declare
| TokenKind::EndDeclare
| TokenKind::As
| TokenKind::Try
| TokenKind::Catch
| TokenKind::Finally
| TokenKind::Throw
| TokenKind::Use
| TokenKind::Insteadof
| TokenKind::Global
| TokenKind::Var
| TokenKind::Unset
| TokenKind::Isset
| TokenKind::Empty
| TokenKind::Continue
| TokenKind::Goto
| TokenKind::Function
| TokenKind::Const
| TokenKind::Return
| TokenKind::Print
| TokenKind::Yield
| TokenKind::List
| TokenKind::Switch
| TokenKind::EndSwitch
| TokenKind::Case
| TokenKind::Default
| TokenKind::Break
| TokenKind::Array
| TokenKind::Callable
| TokenKind::Extends
| TokenKind::Implements
| TokenKind::Namespace
| TokenKind::Trait
| TokenKind::Interface
| TokenKind::Class
| TokenKind::ClassConstant
| TokenKind::TraitConstant
| TokenKind::FunctionConstant
| TokenKind::MethodConstant
| TokenKind::LineConstant
| TokenKind::FileConstant
| TokenKind::DirConstant
| TokenKind::NamespaceConstant
| TokenKind::HaltCompiler
| TokenKind::Fn
| TokenKind::Match
| TokenKind::Enum
| TokenKind::From
)
}

View File

@ -1822,7 +1822,7 @@ impl Parser {
TokenKind::Static if matches!(self.peek.kind, TokenKind::DoubleColon) => {
self.next();
Expression::Static
},
}
TokenKind::LiteralString(s) => {
let e = Expression::LiteralString { value: s.clone() };
self.next();
@ -2212,7 +2212,12 @@ impl Parser {
prefix(&op, rhs)
}
TokenKind::Dollar => self.dynamic_variable()?,
_ => return Err(ParseError::UnexpectedToken(self.current.kind.to_string(), self.current.span)),
_ => {
return Err(ParseError::UnexpectedToken(
self.current.kind.to_string(),
self.current.span,
))
}
};
if self.current.kind == TokenKind::SemiColon {
@ -2366,10 +2371,12 @@ impl Parser {
TokenKind::Class => {
self.next();
// FIXME: Can this be represented in a nicer way? Kind of hacky.
Expression::Identifier { name: "class".into() }
},
_ if is_reserved_ident(&self.current.kind) => {
Expression::Identifier { name: self.ident_maybe_reserved()?.into() }
Expression::Identifier {
name: "class".into(),
}
}
_ if is_reserved_ident(&self.current.kind) => Expression::Identifier {
name: self.ident_maybe_reserved()?.into(),
},
_ => {
return expected_token_err!(["`{`", "`$`", "an identifier"], self);

View File

@ -16,7 +16,7 @@ impl Parser {
let mut param_type = None;
let mut flags: Vec<PropertyFlag> = Vec::new();
// FIXME: You should only be able to have a combination of 1 visibility + readonly modifier.
while matches!(
self.current.kind,