pub struct ParseFlags {
pub parse_flow: bool,
pub parse_flow_component_syntax: bool,
pub parse_flow_records: bool,
pub parse_flow_match: bool,
pub parse_ts: bool,
pub parse_jsx: bool,
pub strict_mode: bool,
}Expand description
Which dialect(s) the parser accepts, plus forced strict mode.
Default is plain ECMAScript, non-strict — every flag false. Each field
maps to the identically-named hermes_ast::context::Context flag, which is
where the parser reads it from; the C++ Context getters cited in that
module are the authoritative semantics. Two fields set more than their own
flag, as documented below.
use hermes_parser::ParseFlags;
let flags = ParseFlags { parse_flow: true, ..Default::default() };Fields§
§parse_flow: boolParse the Flow type grammar (hermesc -parse-flow).
This also enables the Flow ambiguous-expression grammar (typed
arrows, as, type-args on call/new, type casts), because hermesc’s
-parse-flow means ParseFlowSetting::ALL. Flow and TypeScript are
mutually exclusive dialects: do not set this together with
Self::parse_ts.
parse_flow_component_syntax: boolParse Flow component/hook declarations
(hermesc -Xparse-component-syntax). Implies Self::parse_flow.
parse_flow_records: boolParse Flow record declarations and expressions
(hermesc -Xparse-flow-records). Implies Self::parse_flow.
parse_flow_match: boolParse Flow match expressions and statements
(hermesc -Xparse-flow-match). Implies Self::parse_flow.
parse_ts: boolParse the TypeScript type grammar (hermesc -parse-ts). Mutually
exclusive with Self::parse_flow and its extensions.
parse_jsx: boolParse JSX (hermesc -parse-jsx). Independent of the type dialect:
combines with Flow, with TypeScript, or with neither. Note that
enabling JSX disables the TypeScript <Type>expr assertion grammar,
exactly as in the C++ parser.
strict_mode: boolForce strict mode for the whole source, as if it began with a
"use strict" directive. Sets Context::enable_strict_mode.
Trait Implementations§
Source§impl Clone for ParseFlags
impl Clone for ParseFlags
Source§fn clone(&self) -> ParseFlags
fn clone(&self) -> ParseFlags
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more