StringTokenizer

Struct 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)
5fn main() {
6    let args: Vec<String> = env::args().collect();
7
8    if args.len() != 2 {
9        eprintln!("Usage: prog2json <program>");
10        return;
11    }
12
13    let mut tokenizer = StringTokenizer::with_input(&args[1]);
14    let prog = CelCompiler::with_tokenizer(&mut tokenizer)
15        .compile()
16        .unwrap();
17
18    println!("{}", serde_json::to_string_pretty(&prog).unwrap());
19}

Trait Implementations§

Source§

impl Tokenizer for StringTokenizer<'_>

Source§

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

Source§

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

Source§

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

Source§

fn location(&self) -> SourceLocation

Auto Trait Implementations§

§

impl<'l> Freeze for StringTokenizer<'l>

§

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> Same for T

Source§

type Output = T

Should always be Self
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.