[go: up one dir, main page]

Enum piston_meta::Rule [] [src]

pub enum Rule {
    Whitespace(Whitespace),
    Token(Token),
    UntilAnyOrWhitespace(UntilAnyOrWhitespace),
    Text(Text),
    Number(Number),
    Select(Select),
    Sequence(Sequence),
    SeparatedBy(Box<SeparatedBy>),
    Node(NodeRef),
    Optional(Optional),
}

A rule describes how some section of a document should be parsed.

Variants

Whitespace(Whitespace)

Read whitespace.

Token(Token)

Match against a token.

UntilAnyOrWhitespace(UntilAnyOrWhitespace)

Read until any or whitespace.

Text(Text)

Read text.

Number(Number)

Read number.

Select(Select)

Select one of the sub rules. If the first one does not succeed, try another and so on. If all sub rules fail, then the rule fails.

Sequence(Sequence)

Run each sub rule in sequence. If any sub rule fails, the rule fails.

SeparatedBy(Box<SeparatedBy>)

Repeat rule separated by another rule.

Node(NodeRef)

Read node.

Optional(Optional)

Read optional.

Methods

impl Rule
[src]

fn parse<M>(&self, meta_reader: &mut M, state: &M::State, chars: &[char], offset: usize) -> ParseResult<M::State> where M: MetaReader

Parses rule.

fn update_refs(&mut self, refs: &[(Rc<String>, Rc<RefCell<Node>>)])

Updates replacing names with the references.

The references contains the name, but this can not be borrowed as when the same reference is updated.