Struct regex_syntax::ast::parse::Parser[][src]

pub struct Parser {
    pos: Cell<Position>,
    capture_index: Cell<u32>,
    nest_limit: u32,
    octal: bool,
    initial_ignore_whitespace: bool,
    ignore_whitespace: Cell<bool>,
    comments: RefCell<Vec<Comment>>,
    stack_group: RefCell<Vec<GroupState>>,
    stack_class: RefCell<Vec<ClassState>>,
    capture_names: RefCell<Vec<CaptureName>>,
    scratch: RefCell<String>,
}

A regular expression parser.

This parses a string representation of a regular expression into an abstract syntax tree. The size of the tree is proportional to the length of the regular expression pattern.

A Parser can be configured in more detail via a ParserBuilder.

Fields

The current position of the parser.

The current capture index.

The maximum number of open parens/brackets allowed. If the parser exceeds this number, then an error is returned.

Whether to support octal syntax or not. When false, the parser will return an error helpfully pointing out that backreferences are not supported.

The initial setting for ignore_whitespace as provided by ThParserBuilder. is is used when reseting the parser's state.

Whether whitespace should be ignored. When enabled, comments are also permitted.

A list of comments, in order of appearance.

A stack of grouped sub-expressions, including alternations.

A stack of nested character classes. This is only non-empty when parsing a class.

A sorted sequence of capture names. This is used to detect duplicate capture names and report an error if one is detected.

A scratch buffer used in various places. Mostly this is used to accumulate relevant characters from parts of a pattern.

Methods

impl Parser
[src]

Create a new parser with a default configuration.

The parser can be run with either the parse or parse_with_comments methods. The parse methods return an abstract syntax tree.

To set configuration options on the parser, use ParserBuilder.

Parse the regular expression into an abstract syntax tree.

Parse the regular expression and return an abstract syntax tree with all of the comments found in the pattern.

Reset the internal state of a parser.

This is called at the beginning of every parse. This prevents the parser from running with inconsistent state (say, if a previous invocation returned an error and the parser is reused).

Trait Implementations

impl Clone for Parser
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Parser
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Parser

impl !Sync for Parser