Module parser

Source
Expand description

§JavaScript Parser Module

Provides JavaScript source code parsing capabilities, converting text input into an Abstract Syntax Tree (AST) representation for further processing.

§Overview

The parser module implements a recursive descent parser that handles:

  • Expressions: Arithmetic, logical, assignment, and function calls
  • Statements: Control flow, declarations, and blocks
  • Literals: Objects, arrays, functions, and primitive values
  • Recovery: Error recovery and partial parsing

§Features

  • ECMAScript 2020+ Support: Modern JavaScript syntax
  • Error Recovery: Continues parsing after syntax errors
  • Position Tracking: Accurate source location information
  • Modular Design: Separate parsers for different constructs

§Usage

use jetcrab::parser::{parse, parse_with_recovery};

// Parse with error handling
let ast = parse("let x = 42;")?;

// Parse with recovery for invalid code
let (ast, errors) = parse_with_recovery("let x = ;");

Re-exports§

pub use core::Parser;
pub use error::ParserError;

Modules§

core
error
expressions
literals
recovery
statements
utils

Functions§

parse
parse_with_recovery