Enum piston_meta::Rule [] [src]

pub enum Rule {
    Whitespace(Whitespace),
    Token(Token),
    UntilAny(UntilAny),
    UntilAnyOrWhitespace(UntilAnyOrWhitespace),
    Text(Text),
    Number(Number),
    Select(Select),
    Sequence(Sequence),
    SeparatedBy(Box<SeparatedBy>),
    Lines(Box<Lines>),
    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.

UntilAny(UntilAny)

Reads until any character.

UntilAnyOrWhitespace(UntilAnyOrWhitespace)

Read until any character 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.

Lines(Box<Lines>)

Repeat rule separated by one or more lines.

Node(NodeRef)

Read node.

Optional(Optional)

Read optional.

Methods

impl Rule
[src]

fn parse(&self, tokenizer: &mut Tokenizer, state: &TokenizerState, chars: &[char], offset: usize) -> ParseResult<TokenizerState>

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.