Skip to main content

ParseFlags

Struct ParseFlags 

Source
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: bool

Parse 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: bool

Parse Flow component/hook declarations (hermesc -Xparse-component-syntax). Implies Self::parse_flow.

§parse_flow_records: bool

Parse Flow record declarations and expressions (hermesc -Xparse-flow-records). Implies Self::parse_flow.

§parse_flow_match: bool

Parse Flow match expressions and statements (hermesc -Xparse-flow-match). Implies Self::parse_flow.

§parse_ts: bool

Parse the TypeScript type grammar (hermesc -parse-ts). Mutually exclusive with Self::parse_flow and its extensions.

§parse_jsx: bool

Parse 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: bool

Force 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

Source§

fn clone(&self) -> ParseFlags

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ParseFlags

Source§

impl Debug for ParseFlags

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ParseFlags

Source§

fn default() -> ParseFlags

Returns the “default value” for a type. Read more
Source§

impl Eq for ParseFlags

Source§

impl PartialEq for ParseFlags

Source§

fn eq(&self, other: &ParseFlags) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ParseFlags

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.