Move all the lexer stuff to a module directory
This commit is contained in:
parent
d333819dee
commit
d4dee92904
5 changed files with 97 additions and 92 deletions
31
src/lexer/char.rs
Normal file
31
src/lexer/char.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* char.rs
|
||||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
|
||||
use lexer::charset;
|
||||
|
||||
pub trait Lexable {
|
||||
fn is_left_paren(&self) -> bool;
|
||||
fn is_right_paren(&self) -> bool;
|
||||
fn is_identifier_initial(&self) -> bool;
|
||||
fn is_identifier_subsequent(&self) -> bool;
|
||||
}
|
||||
|
||||
impl Lexable for char {
|
||||
fn is_left_paren(&self) -> bool {
|
||||
self == &'('
|
||||
}
|
||||
|
||||
fn is_right_paren(&self) -> bool {
|
||||
self == &')'
|
||||
}
|
||||
|
||||
fn is_identifier_initial(&self) -> bool {
|
||||
charset::identifier_initials().contains(&self)
|
||||
}
|
||||
|
||||
fn is_identifier_subsequent(&self) -> bool {
|
||||
charset::identifier_subsequents().contains(&self)
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue