Struct rscel::StringTokenizer

source ·
pub struct StringTokenizer<'l> { /* private fields */ }

Implementations§

source§

impl<'l> StringTokenizer<'l>

source

pub fn with_input(input: &'l str) -> StringTokenizer<'l>

Examples found in repository?
examples/prog2json.rs (line 13)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
fn main() {
    let args: Vec<String> = env::args().collect();

    if args.len() != 2 {
        eprintln!("Usage: prog2json <program>");
        return;
    }

    let mut tokenizer = StringTokenizer::with_input(&args[1]);
    let prog = CelCompiler::with_tokenizer(&mut tokenizer)
        .compile()
        .unwrap();

    println!("{}", serde_json::to_string_pretty(&prog).unwrap());
}

Trait Implementations§

source§

impl Tokenizer for StringTokenizer<'_>

source§

fn peek(&mut self) -> Result<Option<Token>, SyntaxError>

source§

fn next(&mut self) -> Result<Option<Token>, SyntaxError>

source§

fn source<'a>(&'a self) -> &'a str

source§

fn location(&self) -> (usize, usize)

Auto Trait Implementations§

§

impl<'l> RefUnwindSafe for StringTokenizer<'l>

§

impl<'l> Send for StringTokenizer<'l>

§

impl<'l> Sync for StringTokenizer<'l>

§

impl<'l> Unpin for StringTokenizer<'l>

§

impl<'l> UnwindSafe for StringTokenizer<'l>

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>,

§

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>,

§

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.