Expand description
Parsing rule modules
This module contains extracted parsing logic organized by category. Each module focuses on a specific aspect of parsing (expressions, statements, etc.)
§Design Notes
Expression parsing logic is implemented directly in state.rs using methods
on ParserState for optimal performance and simpler control flow. The precedence
climbing algorithm for binary expressions and all primary/unary expression parsing
are integrated into the main parser state.
JSX fragment detection (<>) is performed inline during parsing rather than via
lookahead for efficiency - no backtracking is needed when we can check for >
immediately after consuming <.
Functions§
- is_
identifier_ or_ keyword - Check if a token is an identifier or any keyword token.
- look_
ahead_ is - Look ahead to check if current token is followed by a token matching
check. - look_
ahead_ is_ abstract_ declaration - Look ahead to check if “abstract” is followed by a declaration keyword.
- look_
ahead_ is_ async_ declaration - Look ahead to check if “async” is followed by a declaration keyword.
- look_
ahead_ is_ const_ enum - Look ahead to check if we have
const enum. - look_
ahead_ is_ import_ call - Look ahead to check if we have
import (/import.(dynamic import forms). - look_
ahead_ is_ import_ equals - Look ahead to check if current token begins an import equals declaration.
- look_
ahead_ is_ module_ declaration - Look ahead to check if
namespace/moduleis followed by a declaration name on the same line. ASI prevents treatingnamespace\nfooas a namespace declaration. - look_
ahead_ is_ type_ alias_ declaration - Look ahead to check if
typebegins a type alias declaration. ASI prevents treatingtype\nFoo = ...as a type alias declaration.