Crates.io | tusk_lexer |
lib.rs | tusk_lexer |
version | 0.4.7 |
source | src |
created_at | 2021-05-26 12:57:14.580551 |
updated_at | 2021-06-01 20:25:32.951704 |
description | The lexical analysis component of Tusk. |
homepage | |
repository | https://github.com/tuskphp/lexer |
max_upload_size | |
id | 402264 |
size | 16,081 |
The lexical analysis component of Tusk.
This crate provides the Lexer
and Token
implementations used in Tusk. It allows you to provide a &str
of input and stream Token
instances on demand.
To use the crate, first add it to your Cargo.toml
:
[dependencies]
tusk_lexer = "0.2.*"
To create a new Lexer
, import the struct
and use the Lexer::new()
method.
use tusk_lexer::Lexer;
fn main() {
let mut lexer = Lexer::new("$hello = 'cool'");
}
To get the next token from the input, use the Lexer::next()
method:
use tusk_lexer::Lexer;
fn main() {
let mut lexer = Lexer::new("$hello = 'cool'");
let maybe_some_token = lexer.next();
}
This method returns a Token
. This struct has 3 fields:
struct Token {
pub kind: TokenType,
pub slice: &str,
pub range: TextRange,
}
For more information, please read the CONTRIBUTING document.
This repository is distributed under the MIT license. For more information, please read the LICENSE document.