Expand description
Token kinds, ported from include/hermes/Parser/TokenKinds.def.
Every variant appears in the EXACT order of TokenKinds.def so that
ord(kind) == kind as u16 and the range-marker predicates stay plain
integer comparisons — identical to the C++ lexer.
Enums§
- Token
Kind - JavaScript token kinds.
Constants§
- NUM_
JS_ TOKENS - Number of token kinds = ord(_last_token) + 1.
Functions§
- binop_
precedence - \return the binary-operator precedence of
kind, or None if not a binary op. - match_
reserved_ word - Recognise a reserved word by its bytes (mirrors
matchReservedWordin JSLexer.cpp). ReturnsTokenKind::identifierifbytesis not a reserved word. Pure: no strict-mode filtering (that lives in lexer-core’sscanReservedWord). - ord
- \return the integer ordinal of
kind(matches C++ord). - token_
kind_ str - \return the human-readable name of
kind(matches C++tokenKindStr). - token_
kind_ str_ by_ ord - \return the human-readable name for the token kind with the given ordinal.
Used by the lexer to pre-intern reserved words by ordinal without needing to
reconstruct a
TokenKindvalue (which would require an unsafe transmute). - variant_
name - \return the
.defvariant name ofkind(e.g.l_brace,eof), matching the C++tokenVariantNameswitch used byjs-lexer-dump.