1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! ECMAScript parser.
//!
//! Consumes a slice of [`ecma_lex_cat::token::Token`] and produces an
//! [`ecma_syntax_cat::program::Program`].
//!
//! Two entry points cover the two ECMA-262 goals:
//!
//! * [`parse_script`] for `Script`s (no `import`/`export` at top level).
//! * [`parse_module`] for `Module`s.
//!
//! Both expect a token slice that ends in `TokenKind::Eof` (the form
//! [`ecma_lex_cat`] produces). The parser is recursive-descent for
//! statements and precedence-climbing for expressions; cover-grammar
//! refinement re-interprets parenthesised expressions as arrow-function
//! parameter lists when a trailing `=>` appears.
//!
//! # Examples
//!
//! ```
//! use ecma_lex_cat::lex;
//! use ecma_parse_cat::parse_script;
//!
//! # fn main() -> Result<(), ecma_parse_cat::Error> {
//! let tokens = lex("let x = 1 + 2;")?;
//! let program = parse_script(&tokens)?;
//! assert!(matches!(
//! program.value(),
//! ecma_syntax_cat::program::ProgramKind::Script { .. }
//! ));
//! # Ok(())
//! # }
//! ```
// Recursive-descent parsers naturally pair `after_lparen`/`after_rparen`,
// `after_lbrace`/`after_rbrace`, etc. These trip pedantic::similar_names
// but renaming them would obscure the grammar correspondence.
pub use Error;
pub use ;