Skip to main content

TokenKind

Enum TokenKind 

Source
#[repr(u8)]
pub enum TokenKind {
Show 169 variants FloatLiteral = 0, FloatLiteralSimple = 1, FloatLiteralLeadingDot = 2, HexIntLiteral = 3, BinIntLiteral = 4, OctIntLiteralNew = 5, OctIntLiteral = 6, IntLiteral = 7, SingleQuotedString = 8, DoubleQuotedString = 9, BacktickString = 10, Variable = 11, Dollar = 12, Identifier = 13, Plus = 14, Minus = 15, Star = 16, Slash = 17, Percent = 18, StarStar = 19, Dot = 20, Equals = 21, PlusEquals = 22, MinusEquals = 23, StarEquals = 24, SlashEquals = 25, PercentEquals = 26, StarStarEquals = 27, DotEquals = 28, AmpersandEquals = 29, PipeEquals = 30, CaretEquals = 31, ShiftLeftEquals = 32, ShiftRightEquals = 33, CoalesceEquals = 34, EqualsEquals = 35, BangEquals = 36, EqualsEqualsEquals = 37, BangEqualsEquals = 38, LessThan = 39, GreaterThan = 40, LessThanEquals = 41, GreaterThanEquals = 42, Spaceship = 43, AmpersandAmpersand = 44, PipePipe = 45, Bang = 46, Ampersand = 47, Pipe = 48, Caret = 49, Tilde = 50, ShiftLeft = 51, ShiftRight = 52, PlusPlus = 53, MinusMinus = 54, Question = 55, QuestionQuestion = 56, Colon = 57, FatArrow = 58, PipeArrow = 59, LeftParen = 60, RightParen = 61, LeftBracket = 62, RightBracket = 63, LeftBrace = 64, RightBrace = 65, Semicolon = 66, Comma = 67, DoubleColon = 68, Arrow = 69, NullsafeArrow = 70, Backslash = 71, At = 72, HashBracket = 73, Ellipsis = 74, If = 75, Else = 76, ElseIf = 77, While = 78, Do = 79, For = 80, Foreach = 81, As = 82, Function = 83, Return = 84, Echo = 85, Print = 86, True = 87, False = 88, Null = 89, And = 90, Or = 91, Xor = 92, Break = 93, Continue = 94, Switch = 95, Case = 96, Default = 97, EndIf = 98, EndWhile = 99, EndFor = 100, EndForeach = 101, Throw = 102, Try = 103, Catch = 104, Finally = 105, Instanceof = 106, Array = 107, List = 108, Goto = 109, Declare = 110, Unset = 111, Global = 112, EndDeclare = 113, EndSwitch = 114, Isset = 115, Empty = 116, Include = 117, IncludeOnce = 118, Require = 119, RequireOnce = 120, Eval = 121, Exit = 122, Die = 123, Clone = 124, New = 125, Class = 126, Abstract = 127, Final = 128, Interface = 129, Trait = 130, Extends = 131, Implements = 132, Public = 133, Protected = 134, Private = 135, Static = 136, Const = 137, Fn_ = 138, Match_ = 139, Namespace = 140, Use = 141, Readonly = 142, Enum_ = 143, Yield_ = 144, From = 145, Self_ = 146, Parent_ = 147, MagicClass = 148, MagicDir = 149, MagicFile = 150, MagicFunction = 151, MagicLine = 152, MagicMethod = 153, MagicNamespace = 154, MagicTrait = 155, MagicProperty = 156, HaltCompiler = 157, OpenTag = 158, CloseTag = 159, InlineHtml = 160, Heredoc = 161, Nowdoc = 162, InvalidNumericLiteral = 163, LineComment = 164, HashComment = 165, BlockComment = 166, DocComment = 167, Eof = 168,
}
Expand description

All token types produced by the PHP lexer.

The variants are grouped by category in source order; the #[repr(u8)] guarantees a compact discriminant layout used by TokenKind::is_assignment_op.

Variants§

§

FloatLiteral = 0

Float in scientific notation: 1e10, 1.5e-3, 1E+10.

§

FloatLiteralSimple = 1

Float with digits on both sides of the decimal point: 1.5, 0.0.

§

FloatLiteralLeadingDot = 2

Float starting with a leading dot: .5, .001.

§

HexIntLiteral = 3

Hexadecimal integer literal: 0x1A, 0xFF.

§

BinIntLiteral = 4

Binary integer literal: 0b1010, 0B0011.

§

OctIntLiteralNew = 5

Octal integer literal in the new 0o prefix form: 0o17 (PHP 8.1+).

§

OctIntLiteral = 6

Octal integer literal in the legacy leading-zero form: 017.

§

IntLiteral = 7

Decimal integer literal: 0, 42, 1_000_000.

§

SingleQuotedString = 8

Single-quoted string literal: 'hello'. Optional b/B prefix allowed.

§

DoubleQuotedString = 9

Double-quoted string literal: "hello $name". Triggers interpolation processing.

§

BacktickString = 10

Backtick string (shell execution): `ls -la`.

§

Variable = 11

A $-prefixed variable name: $foo, $myVar.

§

Dollar = 12

A bare $ not followed by a valid identifier start (variable-variable prefix).

§

Identifier = 13

A bare identifier or keyword that has not yet been resolved. PHP keywords are case-insensitive and are resolved from this token.

§

Plus = 14

+

§

Minus = 15

-

§

Star = 16

*

§

Slash = 17

/

§

Percent = 18

%

§

StarStar = 19

** — exponentiation.

§

Dot = 20

. — string concatenation.

§

Equals = 21

=

§

PlusEquals = 22

+=

§

MinusEquals = 23

-=

§

StarEquals = 24

*=

§

SlashEquals = 25

/=

§

PercentEquals = 26

%=

§

StarStarEquals = 27

**=

§

DotEquals = 28

.=

§

AmpersandEquals = 29

&=

§

PipeEquals = 30

|=

§

CaretEquals = 31

^=

§

ShiftLeftEquals = 32

<<=

§

ShiftRightEquals = 33

>>=

§

CoalesceEquals = 34

??=

§

EqualsEquals = 35

== — loose equality.

§

BangEquals = 36

!= or <> — loose inequality.

§

EqualsEqualsEquals = 37

=== — strict equality.

§

BangEqualsEquals = 38

!== — strict inequality.

§

LessThan = 39

<

§

GreaterThan = 40

>

§

LessThanEquals = 41

<=

§

GreaterThanEquals = 42

>=

§

Spaceship = 43

<=> — spaceship / three-way comparison.

§

AmpersandAmpersand = 44

&& — short-circuit boolean AND.

§

PipePipe = 45

|| — short-circuit boolean OR.

§

Bang = 46

! — boolean NOT.

§

Ampersand = 47

& — bitwise AND (also reference marker in declarations).

§

Pipe = 48

| — bitwise OR.

§

Caret = 49

^ — bitwise XOR.

§

Tilde = 50

~ — bitwise NOT.

§

ShiftLeft = 51

<< — left bit-shift.

§

ShiftRight = 52

>> — right bit-shift.

§

PlusPlus = 53

++

§

MinusMinus = 54

--

§

Question = 55

? — ternary operator or nullable type-hint prefix.

§

QuestionQuestion = 56

?? — null coalescing.

§

Colon = 57

: — ternary separator, named argument separator, or return type separator.

§

FatArrow = 58

=> — key-value separator in arrays and match arms.

§

PipeArrow = 59

|> — pipe operator (PHP 8.5+).

§

LeftParen = 60

(

§

RightParen = 61

)

§

LeftBracket = 62

[

§

RightBracket = 63

]

§

LeftBrace = 64

{

§

RightBrace = 65

}

§

Semicolon = 66

;

§

Comma = 67

,

§

DoubleColon = 68

:: — static access separator.

§

Arrow = 69

-> — object property / method access.

§

NullsafeArrow = 70

?-> — nullsafe property / method access.

§

Backslash = 71

\ — namespace separator.

§

At = 72

@ — error-suppression operator.

§

HashBracket = 73

#[ — attribute syntax opener.

§

Ellipsis = 74

... — splat / variadic operator.

§

If = 75

if

§

Else = 76

else

§

ElseIf = 77

elseif

§

While = 78

while

§

Do = 79

do

§

For = 80

for

§

Foreach = 81

foreach

§

As = 82

as

§

Function = 83

function

§

Return = 84

return

§

Echo = 85

echo

§

Print = 86

print

§

True = 87

true

§

False = 88

false

§

Null = 89

null

§

And = 90

and — low-precedence boolean AND.

§

Or = 91

or — low-precedence boolean OR.

§

Xor = 92

xor — low-precedence boolean XOR.

§

Break = 93

break

§

Continue = 94

continue

§

Switch = 95

switch

§

Case = 96

case

§

Default = 97

default

§

EndIf = 98

endif — alternative if syntax terminator.

§

EndWhile = 99

endwhile — alternative while syntax terminator.

§

EndFor = 100

endfor — alternative for syntax terminator.

§

EndForeach = 101

endforeach — alternative foreach syntax terminator.

§

Throw = 102

throw

§

Try = 103

try

§

Catch = 104

catch

§

Finally = 105

finally

§

Instanceof = 106

instanceof

§

Array = 107

array — as a keyword (e.g. array(1, 2) or array type hint).

§

List = 108

list — destructuring construct: list($a, $b) = ....

§

Goto = 109

goto

§

Declare = 110

declare

§

Unset = 111

unset

§

Global = 112

global

§

EndDeclare = 113

enddeclare — alternative declare syntax terminator.

§

EndSwitch = 114

endswitch — alternative switch syntax terminator.

§

Isset = 115

isset

§

Empty = 116

empty

§

Include = 117

include

§

IncludeOnce = 118

include_once

§

Require = 119

require

§

RequireOnce = 120

require_once

§

Eval = 121

eval

§

Exit = 122

exit

§

Die = 123

die — alias for exit.

§

Clone = 124

clone

§

New = 125

new

§

Class = 126

class

§

Abstract = 127

abstract

§

Final = 128

final

§

Interface = 129

interface

§

Trait = 130

trait

§

Extends = 131

extends

§

Implements = 132

implements

§

Public = 133

public

§

Protected = 134

protected

§

Private = 135

private

§

Static = 136

static

§

Const = 137

const

§

Fn_ = 138

fn — arrow function keyword.

§

Match_ = 139

match — match expression keyword (PHP 8.0+).

§

Namespace = 140

namespace

§

Use = 141

use

§

Readonly = 142

readonly (PHP 8.1+).

§

Enum_ = 143

enum (PHP 8.1+).

§

Yield_ = 144

yield

§

From = 145

from — used in yield from.

§

Self_ = 146

self

§

Parent_ = 147

parent

§

MagicClass = 148

__CLASS__

§

MagicDir = 149

__DIR__

§

MagicFile = 150

__FILE__

§

MagicFunction = 151

__FUNCTION__

§

MagicLine = 152

__LINE__

§

MagicMethod = 153

__METHOD__

§

MagicNamespace = 154

__NAMESPACE__

§

MagicTrait = 155

__TRAIT__

§

MagicProperty = 156

__PROPERTY__ (PHP 8.4+)

§

HaltCompiler = 157

__halt_compiler — stops the parser; remaining bytes are raw data.

§

OpenTag = 158

<?php or <?= opening tag.

§

CloseTag = 159

?> closing tag; switches the lexer back to inline-HTML mode.

§

InlineHtml = 160

Raw HTML text between PHP tags (produced by the Lexer wrapper, not the inner scanner).

§

Heredoc = 161

<<<LABEL … LABEL; — heredoc string (supports interpolation).

§

Nowdoc = 162

<<<'LABEL' … LABEL; — nowdoc string (no interpolation).

§

InvalidNumericLiteral = 163

An invalid numeric literal, e.g. 1_000_ (trailing underscore). The lexer emits this token and records a LexerError for it.

§

LineComment = 164

// … single-line slash comment.

§

HashComment = 165

# … single-line hash comment.

§

BlockComment = 166

/* … */ block comment.

§

DocComment = 167

/** … */ doc-block comment (first non-whitespace char after /* is *).

§

Eof = 168

Sentinel token emitted once all source bytes have been consumed.

Implementations§

Source§

impl TokenKind

Source

pub fn is_comment(self) -> bool

Returns true for the four comment-token variants.

Source§

impl TokenKind

Trait Implementations§

Source§

impl Clone for TokenKind

Source§

fn clone(&self) -> TokenKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TokenKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for TokenKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for TokenKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TokenKind

Source§

fn eq(&self, other: &TokenKind) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for TokenKind

Source§

impl Eq for TokenKind

Source§

impl StructuralPartialEq for TokenKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.