Struct pest::Token [] [src]

pub struct Token<Rule> {
    pub rule: Rule,
    pub start: usize,
    pub end: usize,
}

A struct representing tokens generated by a parser.

Fields

matched Rule

starting position in Input

ending position in Input

Methods

impl<Rule> Token<Rule>
[src]

Creates a new Token.

Examples

impl_rdp! {
    grammar! {
        expression = _{ paren ~ expression? }
        paren      =  { ["("] ~ expression? ~ [")"] }
    }
}

let token = Token::new(Rule::paren, 0, 1);

assert_eq!(token.rule, Rule::paren);
assert_eq!(token.start, 0);
assert_eq!(token.end, 1);

Trait Implementations

impl<Rule: Clone> Clone for Token<Rule>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<Rule: Copy> Copy for Token<Rule>
[src]

impl<Rule: Debug> Debug for Token<Rule>
[src]

Formats the value using the given formatter.

impl<Rule: Eq> Eq for Token<Rule>
[src]

impl<Rule: Hash> Hash for Token<Rule>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<Rule: PartialEq> PartialEq for Token<Rule>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.