Parser

Struct Parser 

Source
pub struct Parser { /* private fields */ }
Expand description

Parser.

Implementations§

Source§

impl Parser

Source

pub fn new(s: String) -> Parser

Constructor.

Source

pub fn new_with_config(s: String, config: Config) -> Parser

Constructor with config.

Source

pub fn config(&self) -> &Config

Get config reference.

Source

pub fn input(&self) -> &str

Get input string at current position.

Source

pub fn input_len(&self) -> usize

Return remaining input length.

Source

pub fn pos(&self) -> usize

Return parser cusor position.

Source

pub fn pos_add(&mut self, pos: usize)

Move cursor position forward.

Source

pub fn line(&self) -> usize

Return line number.

Source

pub fn line_add(&self, len: usize)

Add len to line number.

Source

pub fn column_add(&self, num: usize)

Add chars to column.

Source

pub fn column_set_from(&self, l: &str)

Set chars to column from last linefeed.

Source

pub fn save_token(&mut self, token: Token)

Save token to saved.

Source

pub fn load_token(&mut self) -> Option<Token>

Load token from saved.

Source

pub fn peek_token(&mut self) -> Result<Token, YangError>

Get a token and save it.

Source

pub fn get_token(&mut self) -> Result<Token, YangError>

Get a token except whitespace and comment.

Source

pub fn get_single_token(&mut self) -> Result<(Token, usize), YangError>

Get a single token and position.

Source

pub fn parse_yang(&mut self) -> Result<YangStmt, YangError>

Entry point of YANG parser. An input and a config has to be set. It will return a module or submodule statement.

Source

pub fn parse_yang_from_string( s: String, config: Config, ) -> Result<YangStmt, Error>

Parse string as an input, and return YangStmt. Encapsulate YangError into io::Error.

Auto Trait Implementations§

§

impl !Freeze for Parser

§

impl !RefUnwindSafe for Parser

§

impl Send for Parser

§

impl !Sync for Parser

§

impl Unpin for Parser

§

impl UnwindSafe for Parser

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.