1use oak_core::{ElementType, UniversalElementRole};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum PhpElementType {
7 Whitespace,
9 Newline,
11
12 Comment,
14
15 StringLiteral,
17 NumberLiteral,
19 BooleanLiteral,
21 NullLiteral,
23
24 Identifier,
26 Variable,
28 Abstract,
30 And,
32 Array,
34 As,
36 Break,
38 Callable,
40 Case,
42 Catch,
44 Class,
46 Clone,
48 Const,
50 Continue,
52 Declare,
54 Default,
56 Do,
58 Echo,
60 Else,
62 Elseif,
64 Empty,
66 Enddeclare,
68 Endfor,
70 Endforeach,
72 Endif,
74 Endswitch,
76 Endwhile,
78 Eval,
80 Exit,
82 Extends,
84 Final,
86 Finally,
88 For,
90 Foreach,
92 Function,
94 Global,
96 Goto,
98 If,
100 Implements,
102 Include,
104 IncludeOnce,
106 Instanceof,
108 Insteadof,
110 Interface,
112 Isset,
114 List,
116 Namespace,
118 New,
120 Or,
122 Print,
124 Private,
126 Protected,
128 Public,
130 Require,
132 RequireOnce,
134 Return,
136 Static,
138 Switch,
140 Throw,
142 Trait,
144 Try,
146 Unset,
148 Use,
150 Var,
152 While,
154 Xor,
156 Yield,
158 YieldFrom,
160
161 Plus,
163 Minus,
165 Multiply,
167 Divide,
169 Modulo,
171 Power,
173 Concat,
175 Equal,
177 Identical,
179 NotEqual,
181 NotIdentical,
183 Less,
185 Greater,
187 LessEqual,
189 GreaterEqual,
191 Spaceship,
193 LogicalAnd,
195 LogicalOr,
197 LogicalXor,
199 LogicalNot,
201 BitwiseAnd,
203 BitwiseOr,
205 BitwiseXor,
207 BitwiseNot,
209 LeftShift,
211 RightShift,
213 Assign,
215 PlusAssign,
217 MinusAssign,
219 MultiplyAssign,
221 DivideAssign,
223 ModuloAssign,
225 PowerAssign,
227 ConcatAssign,
229 BitwiseAndAssign,
231 BitwiseOrAssign,
233 BitwiseXorAssign,
235 LeftShiftAssign,
237 RightShiftAssign,
239 Increment,
241 Decrement,
243 Arrow,
245 DoubleArrow,
247 NullCoalesce,
249 NullCoalesceAssign,
251 Ellipsis,
253
254 LeftParen,
256 RightParen,
258 LeftBracket,
260 RightBracket,
262 LeftBrace,
264 RightBrace,
266 Semicolon,
268 Comma,
270 Dot,
272 Question,
274 Colon,
276 DoubleColon,
278 Backslash,
280 At,
282 Dollar,
284
285 OpenTag,
287 CloseTag,
289 EchoTag,
291
292 Eof,
294 Error,
296
297 Root,
299 ClassDef,
301 FunctionDef,
303 MethodDef,
305 PropertyDef,
307 ConstDef,
309 TraitDef,
311 InterfaceDef,
313 NamespaceDef,
315 UseStatement,
317 IfStatement,
319 WhileStatement,
321 DoWhileStatement,
323 ForStatement,
325 ForeachStatement,
327 SwitchStatement,
329 TryStatement,
331 CatchBlock,
333 FinallyBlock,
335 ExpressionStatement,
337 ReturnStatement,
339 ThrowStatement,
341 BreakStatement,
343 ContinueStatement,
345 EchoStatement,
347 GlobalStatement,
349 StaticStatement,
351 UnsetStatement,
353 CompoundStatement,
355
356 Literal,
358 ParenthesizedExpression,
360 CallExpression,
362 ArrayAccessExpression,
364 MemberAccessExpression,
366 BinaryExpression,
368}
369
370impl ElementType for PhpElementType {
371 type Role = UniversalElementRole;
372
373 fn role(&self) -> Self::Role {
374 match self {
375 _ => UniversalElementRole::None,
376 }
377 }
378}
379
380impl From<crate::lexer::token_type::PhpTokenType> for PhpElementType {
381 fn from(token: crate::lexer::token_type::PhpTokenType) -> Self {
382 match token {
383 crate::lexer::token_type::PhpTokenType::Whitespace => PhpElementType::Whitespace,
385 crate::lexer::token_type::PhpTokenType::Newline => PhpElementType::Newline,
386
387 crate::lexer::token_type::PhpTokenType::Comment => PhpElementType::Comment,
389
390 crate::lexer::token_type::PhpTokenType::StringLiteral => PhpElementType::StringLiteral,
392 crate::lexer::token_type::PhpTokenType::NumberLiteral => PhpElementType::NumberLiteral,
393 crate::lexer::token_type::PhpTokenType::BooleanLiteral => PhpElementType::BooleanLiteral,
394 crate::lexer::token_type::PhpTokenType::NullLiteral => PhpElementType::NullLiteral,
395
396 crate::lexer::token_type::PhpTokenType::Identifier => PhpElementType::Identifier,
398 crate::lexer::token_type::PhpTokenType::Variable => PhpElementType::Variable,
399 crate::lexer::token_type::PhpTokenType::Abstract => PhpElementType::Abstract,
400 crate::lexer::token_type::PhpTokenType::And => PhpElementType::And,
401 crate::lexer::token_type::PhpTokenType::Array => PhpElementType::Array,
402 crate::lexer::token_type::PhpTokenType::As => PhpElementType::As,
403 crate::lexer::token_type::PhpTokenType::Break => PhpElementType::Break,
404 crate::lexer::token_type::PhpTokenType::Callable => PhpElementType::Callable,
405 crate::lexer::token_type::PhpTokenType::Case => PhpElementType::Case,
406 crate::lexer::token_type::PhpTokenType::Catch => PhpElementType::Catch,
407 crate::lexer::token_type::PhpTokenType::Class => PhpElementType::Class,
408 crate::lexer::token_type::PhpTokenType::Clone => PhpElementType::Clone,
409 crate::lexer::token_type::PhpTokenType::Const => PhpElementType::Const,
410 crate::lexer::token_type::PhpTokenType::Continue => PhpElementType::Continue,
411 crate::lexer::token_type::PhpTokenType::Declare => PhpElementType::Declare,
412 crate::lexer::token_type::PhpTokenType::Default => PhpElementType::Default,
413 crate::lexer::token_type::PhpTokenType::Do => PhpElementType::Do,
414 crate::lexer::token_type::PhpTokenType::Echo => PhpElementType::Echo,
415 crate::lexer::token_type::PhpTokenType::Else => PhpElementType::Else,
416 crate::lexer::token_type::PhpTokenType::Elseif => PhpElementType::Elseif,
417 crate::lexer::token_type::PhpTokenType::Empty => PhpElementType::Empty,
418 crate::lexer::token_type::PhpTokenType::Enddeclare => PhpElementType::Enddeclare,
419 crate::lexer::token_type::PhpTokenType::Endfor => PhpElementType::Endfor,
420 crate::lexer::token_type::PhpTokenType::Endforeach => PhpElementType::Endforeach,
421 crate::lexer::token_type::PhpTokenType::Endif => PhpElementType::Endif,
422 crate::lexer::token_type::PhpTokenType::Endswitch => PhpElementType::Endswitch,
423 crate::lexer::token_type::PhpTokenType::Endwhile => PhpElementType::Endwhile,
424 crate::lexer::token_type::PhpTokenType::Eval => PhpElementType::Eval,
425 crate::lexer::token_type::PhpTokenType::Exit => PhpElementType::Exit,
426 crate::lexer::token_type::PhpTokenType::Extends => PhpElementType::Extends,
427 crate::lexer::token_type::PhpTokenType::Final => PhpElementType::Final,
428 crate::lexer::token_type::PhpTokenType::Finally => PhpElementType::Finally,
429 crate::lexer::token_type::PhpTokenType::For => PhpElementType::For,
430 crate::lexer::token_type::PhpTokenType::Foreach => PhpElementType::Foreach,
431 crate::lexer::token_type::PhpTokenType::Function => PhpElementType::Function,
432 crate::lexer::token_type::PhpTokenType::Global => PhpElementType::Global,
433 crate::lexer::token_type::PhpTokenType::Goto => PhpElementType::Goto,
434 crate::lexer::token_type::PhpTokenType::If => PhpElementType::If,
435 crate::lexer::token_type::PhpTokenType::Implements => PhpElementType::Implements,
436 crate::lexer::token_type::PhpTokenType::Include => PhpElementType::Include,
437 crate::lexer::token_type::PhpTokenType::IncludeOnce => PhpElementType::IncludeOnce,
438 crate::lexer::token_type::PhpTokenType::Instanceof => PhpElementType::Instanceof,
439 crate::lexer::token_type::PhpTokenType::Insteadof => PhpElementType::Insteadof,
440 crate::lexer::token_type::PhpTokenType::Interface => PhpElementType::Interface,
441 crate::lexer::token_type::PhpTokenType::Isset => PhpElementType::Isset,
442 crate::lexer::token_type::PhpTokenType::List => PhpElementType::List,
443 crate::lexer::token_type::PhpTokenType::Namespace => PhpElementType::Namespace,
444 crate::lexer::token_type::PhpTokenType::New => PhpElementType::New,
445 crate::lexer::token_type::PhpTokenType::Or => PhpElementType::Or,
446 crate::lexer::token_type::PhpTokenType::Print => PhpElementType::Print,
447 crate::lexer::token_type::PhpTokenType::Private => PhpElementType::Private,
448 crate::lexer::token_type::PhpTokenType::Protected => PhpElementType::Protected,
449 crate::lexer::token_type::PhpTokenType::Public => PhpElementType::Public,
450 crate::lexer::token_type::PhpTokenType::Require => PhpElementType::Require,
451 crate::lexer::token_type::PhpTokenType::RequireOnce => PhpElementType::RequireOnce,
452 crate::lexer::token_type::PhpTokenType::Return => PhpElementType::Return,
453 crate::lexer::token_type::PhpTokenType::Static => PhpElementType::Static,
454 crate::lexer::token_type::PhpTokenType::Switch => PhpElementType::Switch,
455 crate::lexer::token_type::PhpTokenType::Throw => PhpElementType::Throw,
456 crate::lexer::token_type::PhpTokenType::Trait => PhpElementType::Trait,
457 crate::lexer::token_type::PhpTokenType::Try => PhpElementType::Try,
458 crate::lexer::token_type::PhpTokenType::Unset => PhpElementType::Unset,
459 crate::lexer::token_type::PhpTokenType::Use => PhpElementType::Use,
460 crate::lexer::token_type::PhpTokenType::Var => PhpElementType::Var,
461 crate::lexer::token_type::PhpTokenType::While => PhpElementType::While,
462 crate::lexer::token_type::PhpTokenType::Xor => PhpElementType::Xor,
463 crate::lexer::token_type::PhpTokenType::Yield => PhpElementType::Yield,
464 crate::lexer::token_type::PhpTokenType::YieldFrom => PhpElementType::YieldFrom,
465
466 crate::lexer::token_type::PhpTokenType::Plus => PhpElementType::Plus,
468 crate::lexer::token_type::PhpTokenType::Minus => PhpElementType::Minus,
469 crate::lexer::token_type::PhpTokenType::Multiply => PhpElementType::Multiply,
470 crate::lexer::token_type::PhpTokenType::Divide => PhpElementType::Divide,
471 crate::lexer::token_type::PhpTokenType::Modulo => PhpElementType::Modulo,
472 crate::lexer::token_type::PhpTokenType::Power => PhpElementType::Power,
473 crate::lexer::token_type::PhpTokenType::Concat => PhpElementType::Concat,
474 crate::lexer::token_type::PhpTokenType::Equal => PhpElementType::Equal,
475 crate::lexer::token_type::PhpTokenType::Identical => PhpElementType::Identical,
476 crate::lexer::token_type::PhpTokenType::NotEqual => PhpElementType::NotEqual,
477 crate::lexer::token_type::PhpTokenType::NotIdentical => PhpElementType::NotIdentical,
478 crate::lexer::token_type::PhpTokenType::Less => PhpElementType::Less,
479 crate::lexer::token_type::PhpTokenType::Greater => PhpElementType::Greater,
480 crate::lexer::token_type::PhpTokenType::LessEqual => PhpElementType::LessEqual,
481 crate::lexer::token_type::PhpTokenType::GreaterEqual => PhpElementType::GreaterEqual,
482 crate::lexer::token_type::PhpTokenType::Spaceship => PhpElementType::Spaceship,
483 crate::lexer::token_type::PhpTokenType::LogicalAnd => PhpElementType::LogicalAnd,
484 crate::lexer::token_type::PhpTokenType::LogicalOr => PhpElementType::LogicalOr,
485 crate::lexer::token_type::PhpTokenType::LogicalXor => PhpElementType::LogicalXor,
486 crate::lexer::token_type::PhpTokenType::LogicalNot => PhpElementType::LogicalNot,
487 crate::lexer::token_type::PhpTokenType::BitwiseAnd => PhpElementType::BitwiseAnd,
488 crate::lexer::token_type::PhpTokenType::BitwiseOr => PhpElementType::BitwiseOr,
489 crate::lexer::token_type::PhpTokenType::BitwiseXor => PhpElementType::BitwiseXor,
490 crate::lexer::token_type::PhpTokenType::BitwiseNot => PhpElementType::BitwiseNot,
491 crate::lexer::token_type::PhpTokenType::LeftShift => PhpElementType::LeftShift,
492 crate::lexer::token_type::PhpTokenType::RightShift => PhpElementType::RightShift,
493 crate::lexer::token_type::PhpTokenType::Assign => PhpElementType::Assign,
494 crate::lexer::token_type::PhpTokenType::PlusAssign => PhpElementType::PlusAssign,
495 crate::lexer::token_type::PhpTokenType::MinusAssign => PhpElementType::MinusAssign,
496 crate::lexer::token_type::PhpTokenType::MultiplyAssign => PhpElementType::MultiplyAssign,
497 crate::lexer::token_type::PhpTokenType::DivideAssign => PhpElementType::DivideAssign,
498 crate::lexer::token_type::PhpTokenType::ModuloAssign => PhpElementType::ModuloAssign,
499 crate::lexer::token_type::PhpTokenType::PowerAssign => PhpElementType::PowerAssign,
500 crate::lexer::token_type::PhpTokenType::ConcatAssign => PhpElementType::ConcatAssign,
501 crate::lexer::token_type::PhpTokenType::BitwiseAndAssign => PhpElementType::BitwiseAndAssign,
502 crate::lexer::token_type::PhpTokenType::BitwiseOrAssign => PhpElementType::BitwiseOrAssign,
503 crate::lexer::token_type::PhpTokenType::BitwiseXorAssign => PhpElementType::BitwiseXorAssign,
504 crate::lexer::token_type::PhpTokenType::LeftShiftAssign => PhpElementType::LeftShiftAssign,
505 crate::lexer::token_type::PhpTokenType::RightShiftAssign => PhpElementType::RightShiftAssign,
506 crate::lexer::token_type::PhpTokenType::Increment => PhpElementType::Increment,
507 crate::lexer::token_type::PhpTokenType::Decrement => PhpElementType::Decrement,
508 crate::lexer::token_type::PhpTokenType::Arrow => PhpElementType::Arrow,
509 crate::lexer::token_type::PhpTokenType::DoubleArrow => PhpElementType::DoubleArrow,
510 crate::lexer::token_type::PhpTokenType::NullCoalesce => PhpElementType::NullCoalesce,
511 crate::lexer::token_type::PhpTokenType::NullCoalesceAssign => PhpElementType::NullCoalesceAssign,
512 crate::lexer::token_type::PhpTokenType::Ellipsis => PhpElementType::Ellipsis,
513
514 crate::lexer::token_type::PhpTokenType::LeftParen => PhpElementType::LeftParen,
516 crate::lexer::token_type::PhpTokenType::RightParen => PhpElementType::RightParen,
517 crate::lexer::token_type::PhpTokenType::LeftBracket => PhpElementType::LeftBracket,
518 crate::lexer::token_type::PhpTokenType::RightBracket => PhpElementType::RightBracket,
519 crate::lexer::token_type::PhpTokenType::LeftBrace => PhpElementType::LeftBrace,
520 crate::lexer::token_type::PhpTokenType::RightBrace => PhpElementType::RightBrace,
521 crate::lexer::token_type::PhpTokenType::Semicolon => PhpElementType::Semicolon,
522 crate::lexer::token_type::PhpTokenType::Comma => PhpElementType::Comma,
523 crate::lexer::token_type::PhpTokenType::Dot => PhpElementType::Dot,
524 crate::lexer::token_type::PhpTokenType::Question => PhpElementType::Question,
525 crate::lexer::token_type::PhpTokenType::Colon => PhpElementType::Colon,
526 crate::lexer::token_type::PhpTokenType::DoubleColon => PhpElementType::DoubleColon,
527 crate::lexer::token_type::PhpTokenType::Backslash => PhpElementType::Backslash,
528 crate::lexer::token_type::PhpTokenType::At => PhpElementType::At,
529 crate::lexer::token_type::PhpTokenType::Dollar => PhpElementType::Dollar,
530
531 crate::lexer::token_type::PhpTokenType::OpenTag => PhpElementType::OpenTag,
533 crate::lexer::token_type::PhpTokenType::CloseTag => PhpElementType::CloseTag,
534 crate::lexer::token_type::PhpTokenType::EchoTag => PhpElementType::EchoTag,
535
536 crate::lexer::token_type::PhpTokenType::Eof => PhpElementType::Eof,
538 crate::lexer::token_type::PhpTokenType::Error => PhpElementType::Error,
539
540 crate::lexer::token_type::PhpTokenType::Root => PhpElementType::Root,
542 crate::lexer::token_type::PhpTokenType::ClassDef => PhpElementType::ClassDef,
543 crate::lexer::token_type::PhpTokenType::FunctionDef => PhpElementType::FunctionDef,
544 crate::lexer::token_type::PhpTokenType::MethodDef => PhpElementType::MethodDef,
545 crate::lexer::token_type::PhpTokenType::PropertyDef => PhpElementType::PropertyDef,
546 crate::lexer::token_type::PhpTokenType::ConstDef => PhpElementType::ConstDef,
547 crate::lexer::token_type::PhpTokenType::TraitDef => PhpElementType::TraitDef,
548 crate::lexer::token_type::PhpTokenType::InterfaceDef => PhpElementType::InterfaceDef,
549 crate::lexer::token_type::PhpTokenType::NamespaceDef => PhpElementType::NamespaceDef,
550 crate::lexer::token_type::PhpTokenType::UseStatement => PhpElementType::UseStatement,
551 crate::lexer::token_type::PhpTokenType::IfStatement => PhpElementType::IfStatement,
552 crate::lexer::token_type::PhpTokenType::WhileStatement => PhpElementType::WhileStatement,
553 crate::lexer::token_type::PhpTokenType::DoWhileStatement => PhpElementType::DoWhileStatement,
554 crate::lexer::token_type::PhpTokenType::ForStatement => PhpElementType::ForStatement,
555 crate::lexer::token_type::PhpTokenType::ForeachStatement => PhpElementType::ForeachStatement,
556 crate::lexer::token_type::PhpTokenType::SwitchStatement => PhpElementType::SwitchStatement,
557 crate::lexer::token_type::PhpTokenType::TryStatement => PhpElementType::TryStatement,
558 crate::lexer::token_type::PhpTokenType::CatchBlock => PhpElementType::CatchBlock,
559 crate::lexer::token_type::PhpTokenType::FinallyBlock => PhpElementType::FinallyBlock,
560 crate::lexer::token_type::PhpTokenType::ExpressionStatement => PhpElementType::ExpressionStatement,
561 crate::lexer::token_type::PhpTokenType::ReturnStatement => PhpElementType::ReturnStatement,
562 crate::lexer::token_type::PhpTokenType::ThrowStatement => PhpElementType::ThrowStatement,
563 crate::lexer::token_type::PhpTokenType::BreakStatement => PhpElementType::BreakStatement,
564 crate::lexer::token_type::PhpTokenType::ContinueStatement => PhpElementType::ContinueStatement,
565 crate::lexer::token_type::PhpTokenType::EchoStatement => PhpElementType::EchoStatement,
566 crate::lexer::token_type::PhpTokenType::GlobalStatement => PhpElementType::GlobalStatement,
567 crate::lexer::token_type::PhpTokenType::StaticStatement => PhpElementType::StaticStatement,
568 crate::lexer::token_type::PhpTokenType::UnsetStatement => PhpElementType::UnsetStatement,
569 crate::lexer::token_type::PhpTokenType::CompoundStatement => PhpElementType::CompoundStatement,
570
571 crate::lexer::token_type::PhpTokenType::Literal => PhpElementType::Literal,
573 crate::lexer::token_type::PhpTokenType::ParenthesizedExpression => PhpElementType::ParenthesizedExpression,
574 crate::lexer::token_type::PhpTokenType::CallExpression => PhpElementType::CallExpression,
575 crate::lexer::token_type::PhpTokenType::ArrayAccessExpression => PhpElementType::ArrayAccessExpression,
576 crate::lexer::token_type::PhpTokenType::MemberAccessExpression => PhpElementType::MemberAccessExpression,
577 crate::lexer::token_type::PhpTokenType::BinaryExpression => PhpElementType::BinaryExpression,
578 }
579 }
580}