diff --git a/src/ast/ast.rs b/src/ast/ast.rs index 1ff6ded..0b9f98b 100644 --- a/src/ast/ast.rs +++ b/src/ast/ast.rs @@ -1,4 +1,4 @@ -use crate::{lex::lexer::Lexer, tokens::Token}; +use crate::tokens::Token; struct AST { nodes: Vec, diff --git a/src/lex/handlers.rs b/src/lex/handlers.rs index 4a5c52e..83b3dc3 100644 --- a/src/lex/handlers.rs +++ b/src/lex/handlers.rs @@ -1,4 +1,3 @@ -use core::panic; use crate::lex::lexer::Lexer; impl Lexer { @@ -37,7 +36,7 @@ impl Lexer { let mut is_float = false; let mut is_swizzle = false; while let Some(c) = self.current_char { - if c.is_digit(10) + if c.is_ascii_digit() /* && self.peek().unwrap_or_else(|| ' ') == 'f' */ { number.push(c); @@ -47,7 +46,7 @@ impl Lexer { //ALLES HIER DRIN IST NICHT SCHÖN// //////////////////////////////////// - match self.peek().unwrap_or_else(|| ' ') { + match self.peek().unwrap_or(' ') { 'x' | 'y' | 'z' | 'w' | 'r' | 'g' | 'b' | 'a' => { is_swizzle = true; number.push(c); @@ -68,7 +67,7 @@ impl Lexer { break; } } else if c.is_alphabetic() { - if c == '.' && self.peek().unwrap_or_else(|| ' ') == 'e' { + if c == '.' && self.peek().unwrap_or(' ') == 'e' { is_float = true; self.advance(); dbg!("break in alphabetic"); @@ -77,8 +76,7 @@ impl Lexer { is_swizzle = true; number.push(c); self.advance(); - } else { - } + } } if is_float { return crate::tokens::Token::FLOATCONSTANT(number); diff --git a/src/lex/lexer.rs b/src/lex/lexer.rs index d27287f..cf42ec5 100644 --- a/src/lex/lexer.rs +++ b/src/lex/lexer.rs @@ -1,9 +1,7 @@ -use crate::lex::util::make_symbols; use crate::tokens::Token; use std::collections::HashMap; use std::sync::Arc; -use super::util::make_keywords; pub struct Lexer { /// GLSL source @@ -85,7 +83,7 @@ impl Lexer { tokens.push(Token::Whitespace); } else if c.is_alphabetic() || c == '_' { tokens.push(self.consume_identifier_or_keyword()); - } else if c.is_digit(10) { + } else if c.is_ascii_digit() { tokens.push(self.consume_number()); } else if c == '/' && self.peek() == Some('/') { tokens.push(self.consume_comment());