mirror of
https://github.com/danog/parser.git
synced 2024-12-02 09:27:50 +01:00
chore: fmt
This commit is contained in:
parent
29946919ad
commit
9a2109b31d
@ -69,82 +69,85 @@ impl Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_reserved_ident(kind: &TokenKind) -> bool {
|
pub(crate) fn is_reserved_ident(kind: &TokenKind) -> bool {
|
||||||
matches!(kind, TokenKind::Static
|
matches!(
|
||||||
| TokenKind::Abstract
|
kind,
|
||||||
| TokenKind::Final
|
TokenKind::Static
|
||||||
| TokenKind::For
|
| TokenKind::Abstract
|
||||||
| TokenKind::Private
|
| TokenKind::Final
|
||||||
| TokenKind::Protected
|
| TokenKind::For
|
||||||
| TokenKind::Public
|
| TokenKind::Private
|
||||||
| TokenKind::Include
|
| TokenKind::Protected
|
||||||
| TokenKind::IncludeOnce
|
| TokenKind::Public
|
||||||
| TokenKind::Eval
|
| TokenKind::Include
|
||||||
| TokenKind::Require
|
| TokenKind::IncludeOnce
|
||||||
| TokenKind::RequireOnce
|
| TokenKind::Eval
|
||||||
| TokenKind::LogicalOr
|
| TokenKind::Require
|
||||||
| TokenKind::LogicalXor
|
| TokenKind::RequireOnce
|
||||||
| TokenKind::LogicalAnd
|
| TokenKind::LogicalOr
|
||||||
| TokenKind::Instanceof
|
| TokenKind::LogicalXor
|
||||||
| TokenKind::New
|
| TokenKind::LogicalAnd
|
||||||
| TokenKind::Clone
|
| TokenKind::Instanceof
|
||||||
| TokenKind::Exit
|
| TokenKind::New
|
||||||
| TokenKind::If
|
| TokenKind::Clone
|
||||||
| TokenKind::ElseIf
|
| TokenKind::Exit
|
||||||
| TokenKind::Else
|
| TokenKind::If
|
||||||
| TokenKind::EndIf
|
| TokenKind::ElseIf
|
||||||
| TokenKind::Echo
|
| TokenKind::Else
|
||||||
| TokenKind::Do
|
| TokenKind::EndIf
|
||||||
| TokenKind::While
|
| TokenKind::Echo
|
||||||
| TokenKind::EndWhile
|
| TokenKind::Do
|
||||||
| TokenKind::EndFor
|
| TokenKind::While
|
||||||
| TokenKind::Foreach
|
| TokenKind::EndWhile
|
||||||
| TokenKind::EndForeach
|
| TokenKind::EndFor
|
||||||
| TokenKind::Declare
|
| TokenKind::Foreach
|
||||||
| TokenKind::EndDeclare
|
| TokenKind::EndForeach
|
||||||
| TokenKind::As
|
| TokenKind::Declare
|
||||||
| TokenKind::Try
|
| TokenKind::EndDeclare
|
||||||
| TokenKind::Catch
|
| TokenKind::As
|
||||||
| TokenKind::Finally
|
| TokenKind::Try
|
||||||
| TokenKind::Throw
|
| TokenKind::Catch
|
||||||
| TokenKind::Use
|
| TokenKind::Finally
|
||||||
| TokenKind::Insteadof
|
| TokenKind::Throw
|
||||||
| TokenKind::Global
|
| TokenKind::Use
|
||||||
| TokenKind::Var
|
| TokenKind::Insteadof
|
||||||
| TokenKind::Unset
|
| TokenKind::Global
|
||||||
| TokenKind::Isset
|
| TokenKind::Var
|
||||||
| TokenKind::Empty
|
| TokenKind::Unset
|
||||||
| TokenKind::Continue
|
| TokenKind::Isset
|
||||||
| TokenKind::Goto
|
| TokenKind::Empty
|
||||||
| TokenKind::Function
|
| TokenKind::Continue
|
||||||
| TokenKind::Const
|
| TokenKind::Goto
|
||||||
| TokenKind::Return
|
| TokenKind::Function
|
||||||
| TokenKind::Print
|
| TokenKind::Const
|
||||||
| TokenKind::Yield
|
| TokenKind::Return
|
||||||
| TokenKind::List
|
| TokenKind::Print
|
||||||
| TokenKind::Switch
|
| TokenKind::Yield
|
||||||
| TokenKind::EndSwitch
|
| TokenKind::List
|
||||||
| TokenKind::Case
|
| TokenKind::Switch
|
||||||
| TokenKind::Default
|
| TokenKind::EndSwitch
|
||||||
| TokenKind::Break
|
| TokenKind::Case
|
||||||
| TokenKind::Array
|
| TokenKind::Default
|
||||||
| TokenKind::Callable
|
| TokenKind::Break
|
||||||
| TokenKind::Extends
|
| TokenKind::Array
|
||||||
| TokenKind::Implements
|
| TokenKind::Callable
|
||||||
| TokenKind::Namespace
|
| TokenKind::Extends
|
||||||
| TokenKind::Trait
|
| TokenKind::Implements
|
||||||
| TokenKind::Interface
|
| TokenKind::Namespace
|
||||||
| TokenKind::Class
|
| TokenKind::Trait
|
||||||
| TokenKind::ClassConstant
|
| TokenKind::Interface
|
||||||
| TokenKind::TraitConstant
|
| TokenKind::Class
|
||||||
| TokenKind::FunctionConstant
|
| TokenKind::ClassConstant
|
||||||
| TokenKind::MethodConstant
|
| TokenKind::TraitConstant
|
||||||
| TokenKind::LineConstant
|
| TokenKind::FunctionConstant
|
||||||
| TokenKind::FileConstant
|
| TokenKind::MethodConstant
|
||||||
| TokenKind::DirConstant
|
| TokenKind::LineConstant
|
||||||
| TokenKind::NamespaceConstant
|
| TokenKind::FileConstant
|
||||||
| TokenKind::HaltCompiler
|
| TokenKind::DirConstant
|
||||||
| TokenKind::Fn
|
| TokenKind::NamespaceConstant
|
||||||
| TokenKind::Match
|
| TokenKind::HaltCompiler
|
||||||
| TokenKind::Enum
|
| TokenKind::Fn
|
||||||
| TokenKind::From)
|
| TokenKind::Match
|
||||||
}
|
| TokenKind::Enum
|
||||||
|
| TokenKind::From
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -1822,7 +1822,7 @@ impl Parser {
|
|||||||
TokenKind::Static if matches!(self.peek.kind, TokenKind::DoubleColon) => {
|
TokenKind::Static if matches!(self.peek.kind, TokenKind::DoubleColon) => {
|
||||||
self.next();
|
self.next();
|
||||||
Expression::Static
|
Expression::Static
|
||||||
},
|
}
|
||||||
TokenKind::LiteralString(s) => {
|
TokenKind::LiteralString(s) => {
|
||||||
let e = Expression::LiteralString { value: s.clone() };
|
let e = Expression::LiteralString { value: s.clone() };
|
||||||
self.next();
|
self.next();
|
||||||
@ -2212,7 +2212,12 @@ impl Parser {
|
|||||||
prefix(&op, rhs)
|
prefix(&op, rhs)
|
||||||
}
|
}
|
||||||
TokenKind::Dollar => self.dynamic_variable()?,
|
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 {
|
if self.current.kind == TokenKind::SemiColon {
|
||||||
@ -2366,10 +2371,12 @@ impl Parser {
|
|||||||
TokenKind::Class => {
|
TokenKind::Class => {
|
||||||
self.next();
|
self.next();
|
||||||
// FIXME: Can this be represented in a nicer way? Kind of hacky.
|
// FIXME: Can this be represented in a nicer way? Kind of hacky.
|
||||||
Expression::Identifier { name: "class".into() }
|
Expression::Identifier {
|
||||||
},
|
name: "class".into(),
|
||||||
_ if is_reserved_ident(&self.current.kind) => {
|
}
|
||||||
Expression::Identifier { name: self.ident_maybe_reserved()?.into() }
|
}
|
||||||
|
_ if is_reserved_ident(&self.current.kind) => Expression::Identifier {
|
||||||
|
name: self.ident_maybe_reserved()?.into(),
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
return expected_token_err!(["`{`", "`$`", "an identifier"], self);
|
return expected_token_err!(["`{`", "`$`", "an identifier"], self);
|
||||||
|
@ -16,7 +16,7 @@ impl Parser {
|
|||||||
let mut param_type = None;
|
let mut param_type = None;
|
||||||
|
|
||||||
let mut flags: Vec<PropertyFlag> = Vec::new();
|
let mut flags: Vec<PropertyFlag> = Vec::new();
|
||||||
|
|
||||||
// FIXME: You should only be able to have a combination of 1 visibility + readonly modifier.
|
// FIXME: You should only be able to have a combination of 1 visibility + readonly modifier.
|
||||||
while matches!(
|
while matches!(
|
||||||
self.current.kind,
|
self.current.kind,
|
||||||
|
Loading…
Reference in New Issue
Block a user