Skip to main content

Parser

Struct Parser 

Source
pub struct Parser {
    pub options: Arc<Options>,
    pub actions: HashMap<String, Action>,
    pub context_actions: HashMap<String, ContextAction>,
    pub matched_actions: HashMap<String, AltAction>,
    pub state_actions: HashMap<String, StateAction>,
    pub token_subscribers: Vec<TokenSubscriber>,
    pub lex_subscribers: Vec<LexSubscriber>,
    pub rule_subscribers: Vec<RuleSubscriber>,
    pub rule_done_subscribers: Vec<RuleDoneSubscriber>,
    pub parse_guards: Vec<ParseGuard>,
    pub instance: InstanceInfo,
    /* private fields */
}

Fields§

§options: Arc<Options>

Shared with the lexer, which never writes to them. Cloning a whole Options was 22% of a small parse, and it was happening twice.

§actions: HashMap<String, Action>§context_actions: HashMap<String, ContextAction>§matched_actions: HashMap<String, AltAction>§state_actions: HashMap<String, StateAction>§token_subscribers: Vec<TokenSubscriber>§lex_subscribers: Vec<LexSubscriber>§rule_subscribers: Vec<RuleSubscriber>§rule_done_subscribers: Vec<RuleDoneSubscriber>§parse_guards: Vec<ParseGuard>§instance: InstanceInfo

Implementations§

Source§

impl Parser

Source

pub fn new(options: Options) -> Self

Source

pub fn from_shared(options: Arc<Options>) -> Self

Parse against a configuration that is already prepared and ordered, shared with every other parse of the same grammar.

Source

pub fn rules(&self) -> &IndexMap<String, Arc<RuleSpec>>

The installed rules, in declaration order.

Read-only: every write goes through Parser::add_rule, which is what keeps the derived tables in step with it.

Source

pub fn add_rule(&mut self, spec: RuleSpec)

Source

pub fn add_action(&mut self, name: String, action: Action)

Source

pub fn add_context_action(&mut self, name: String, action: ContextAction)

Source

pub fn add_matched_action(&mut self, name: String, action: AltAction)

Source

pub fn add_state_action(&mut self, name: String, action: StateAction)

Source

pub fn add_token_subscriber(&mut self, subscriber: TokenSubscriber)

Source

pub fn add_lex_subscriber(&mut self, subscriber: LexSubscriber)

Source

pub fn add_rule_subscriber(&mut self, subscriber: RuleSubscriber)

Source

pub fn add_parse_guard(&mut self, guard: ParseGuard)

Source

pub fn add_rule_done_subscriber(&mut self, subscriber: RuleDoneSubscriber)

Source

pub fn set_instance_info(&mut self, instance: InstanceInfo)

Source

pub fn parse(&self, src: &str) -> Result<Value, TabnasError>

Source

pub fn parse_with_meta( &self, src: &str, meta: Value, ) -> Result<Value, TabnasError>

Source

pub fn parse_recover(&self, src: &str) -> ParseRecovery

Source

pub fn parse_recover_with_meta(&self, src: &str, meta: Value) -> ParseRecovery

Source

pub fn continuations(&self, src: &str) -> Continuations

Return the token kinds that can legally follow src when it is treated as a prefix. The result is an intentional over-approximation: runtime conditions and counters may still reject a listed token.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.