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