Skip to main content

Module parse_rules

Module parse_rules 

Source
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/module is followed by a declaration name on the same line. ASI prevents treating namespace\nfoo as a namespace declaration.
look_ahead_is_type_alias_declaration
Look ahead to check if type begins a type alias declaration. ASI prevents treating type\nFoo = ... as a type alias declaration.