diff --git a/src/lib.rs b/src/lib.rs index 831ec45..e35631a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,6 +59,20 @@ pub struct Lexer { pub current_char: Option, } +/// Instantiates Lexer and retrieves Tokens of given source. +/// Returns Arc<[Token]> +/// Equivalent to: +/// ``` +/// let source = "some source"; +/// let lexed = Lexer::new(source).get_tokens(); +/// ``` +#[macro_export] +macro_rules! lex { + ($source:expr) => {{ + $crate::Lexer::get_tokens(&mut $crate::Lexer::new($source)) + }}; +} + impl Lexer { /// Instantiates the [`Lexer`] pub fn new(input: &str) -> Self {