From 9a2109b31d2f091151d20e73ed582a7026a7b9f2 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Wed, 30 Nov 2022 00:58:30 +0000 Subject: [PATCH] chore: fmt --- src/parser/ident.rs | 161 ++++++++++++++++++++++--------------------- src/parser/mod.rs | 19 +++-- src/parser/params.rs | 2 +- 3 files changed, 96 insertions(+), 86 deletions(-) diff --git a/src/parser/ident.rs b/src/parser/ident.rs index 32aa8b6..7b4f854 100644 --- a/src/parser/ident.rs +++ b/src/parser/ident.rs @@ -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) -} \ No newline at end of file + 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 + ) +} diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 183d054..f63066f 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -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); diff --git a/src/parser/params.rs b/src/parser/params.rs index 0237082..7708eb8 100644 --- a/src/parser/params.rs +++ b/src/parser/params.rs @@ -16,7 +16,7 @@ impl Parser { let mut param_type = None; let mut flags: Vec = Vec::new(); - + // FIXME: You should only be able to have a combination of 1 visibility + readonly modifier. while matches!( self.current.kind,