Skip to main content

Module lexer

Module lexer 

Source
Expand description

JSLexer, a faithful port of lib/Parser/JSLexer.cpp.

JSLexer lexes the full JavaScript token surface: punctuators, trivia (whitespace and line/block comments), identifiers and keywords, numeric literals, string literals, template literals, regular-expression literals, private identifiers, JSX, and the Flow type context. It also exposes the stateful lexer APIs: optional comment/token storage, magic comment (sourceURL/sourceMappingURL) extraction, SavePoint for backtracking, the directive ("use strict") check, and rescanRBrace for template continuations. The impl<'a> JSLexer<'a> methods are split across the child modules below by concern (escape, identifier, number, string, template, regexp, jsx, dump, state).

Structs§

JSLexer
The Hermes JavaScript lexer. Port of hermes::parser::JSLexer.
SavePoint
Store state of the lexer and allow rescanning from that point. Port of the C++ JSLexer::SavePoint (JSLexer.h:751-821).

Enums§

GrammarContext
The grammar context affecting how some tokens are lexed (e.g. / as a division operator vs. a regular-expression literal). Port of JSLexer::GrammarContext.
IdentifierMode
The identifier-scanning mode, port of JSLexer::IdentifierMode. Affects which extra characters are accepted as identifier parts: JSX accepts -, Flow accepts @.