Changed name of TokenType to Token.
This commit is contained in:
parent
cfdb31ed7a
commit
94e7c083cd
|
@ -3,11 +3,11 @@ use logos::Logos;
|
|||
use logos::Lexer;
|
||||
use core::iter::Peekable;
|
||||
|
||||
pub use TokenType::*;
|
||||
pub use Token::*;
|
||||
|
||||
#[derive(Debug, Logos, PartialEq, Eq)]
|
||||
#[logos(skip r"[ \t\n\f]+")]
|
||||
pub enum TokenType {
|
||||
pub enum Token {
|
||||
// SINGLE CHARACTER TOKENS
|
||||
#[token(";")]
|
||||
Semicolon, // ;
|
||||
|
@ -82,23 +82,23 @@ pub enum TokenType {
|
|||
|
||||
// LITERALS
|
||||
#[regex(r#"("[^"]*")|('[^']*')"#)]
|
||||
String, // A string literal.
|
||||
#[regex("[0-9]+")]
|
||||
Number, // An integer.
|
||||
String, // A string literal.
|
||||
#[regex("[0-9]+", |lex| lex.slice().parse().ok())]
|
||||
Number(u64), // An integer.
|
||||
#[regex(r#"[^[0-9]^"^-^[ \t\n\f]^\.^=^(^)^{^}.^,^;]+[^"^-^=^\..^[ \t\n\f]^(^)^{^}^,^;]*"#)]
|
||||
Identifier, // An identifier.
|
||||
Identifier, // An identifier.
|
||||
#[token("true")]
|
||||
True, // true
|
||||
True, // true
|
||||
#[token("false")]
|
||||
False, // false
|
||||
False, // false
|
||||
#[token("none")]
|
||||
Null, // none
|
||||
Null, // none
|
||||
}
|
||||
|
||||
pub fn lex_str(this: &str) -> Vec<(TokenType, &str)> {
|
||||
pub fn lex_str(this: &str) -> Vec<(Token, &str)> {
|
||||
println!("\"{}\"", this);
|
||||
let mut buf = Vec::new();
|
||||
let mut lexer = TokenType::lexer(this);
|
||||
let mut lexer = Token::lexer(this);
|
||||
while let Some(Ok(token)) = lexer.next() {
|
||||
buf.push((token, lexer.slice()));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#![allow(warnings)]
|
||||
|
||||
pub mod lex;
|
||||
use crate::lex::tok::*;
|
||||
pub mod codegen;
|
||||
use crate::codegen::fasm::*;
|
||||
use crate::lex::tok::*;
|
||||
use crate::parse::ast::*;
|
||||
|
||||
pub mod parse;
|
||||
|
||||
fn main() {
|
||||
|
@ -42,5 +43,4 @@ fn main() {
|
|||
|
||||
|
||||
// println!("{}", fc);
|
||||
println!("{:#?}", lex_str("macro_rules! println { () => {} }"))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue