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
pos: Cell<Position>
The current position of the parser.
capture_index: Cell<u32>
The current capture index.
nest_limit: u32
The maximum number of open parens/brackets allowed. If the parser exceeds this number, then an error is returned.
octal: bool
Whether to support octal syntax or not. When false, the parser will
return an error helpfully pointing out that backreferences are not
supported.
initial_ignore_whitespace: bool
The initial setting for ignore_whitespace as provided by
ThParserBuilder. is is used when reseting the parser's state.
ignore_whitespace: Cell<bool>
Whether whitespace should be ignored. When enabled, comments are also permitted.
comments: RefCell<Vec<Comment>>
A list of comments, in order of appearance.
stack_group: RefCell<Vec<GroupState>>
A stack of grouped sub-expressions, including alternations.
stack_class: RefCell<Vec<ClassState>>
A stack of nested character classes. This is only non-empty when parsing a class.
capture_names: RefCell<Vec<CaptureName>>
A sorted sequence of capture names. This is used to detect duplicate capture names and report an error if one is detected.
scratch: RefCell<String>
A scratch buffer used in various places. Mostly this is used to accumulate relevant characters from parts of a pattern.
Methods
impl Parser[src]
impl Parserpub fn new() -> Parser[src]
pub fn new() -> ParserCreate 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.
pub fn parse(&mut self, pattern: &str) -> Result<Ast, Error>[src]
pub fn parse(&mut self, pattern: &str) -> Result<Ast, Error>Parse the regular expression into an abstract syntax tree.
pub fn parse_with_comments(
&mut self,
pattern: &str
) -> Result<WithComments, Error>[src]
pub fn parse_with_comments(
&mut self,
pattern: &str
) -> Result<WithComments, Error>Parse the regular expression and return an abstract syntax tree with all of the comments found in the pattern.
fn reset(&self)[src]
fn reset(&self)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]
impl Clone for Parserfn clone(&self) -> Parser[src]
fn clone(&self) -> ParserReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Debug for Parser[src]
impl Debug for Parser