Remove lazy_static dependency

I just learned about thread local storage, so we really don't
lazy_static for anything anymore - it was only being used for the lexer
regex.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-01-18 14:31:32 -08:00
parent aad0e8adc2
commit c57c4f1ab3
3 changed files with 36 additions and 37 deletions

1
Cargo.lock generated
View File

@@ -203,7 +203,6 @@ name = "sybil"
version = "0.1.0"
dependencies = [
"gc",
"lazy_static",
"regex",
"structopt",
"thiserror",

View File

@@ -9,5 +9,4 @@ edition = "2021"
thiserror = "1.0"
structopt = "0.3"
regex = "1.5"
lazy_static = "1.4"
gc = { version = "0.4", features = ["derive"] }

View File

@@ -1,10 +1,9 @@
use crate::syn::{error::*, span::*, token::*};
use lazy_static::lazy_static;
use regex::{Regex, RegexBuilder};
use std::rc::Rc;
lazy_static! {
static ref LEX_PAT: Regex = RegexBuilder::new(
thread_local! {
static LEX_PAT: Regex = RegexBuilder::new(
r#"^(
(?P<float>[-+]?[0-9]+\.[0-9]+([eE][+\-][0-9]+)?)
| (?P<int>[-+]?[0-9]+)
@@ -88,7 +87,8 @@ impl<'t> Lexer<'t> {
return Ok(None);
}
if let Some(cap) = LEX_PAT.captures(&self.text[self.start.byte..]) {
LEX_PAT.with(|lex| {
if let Some(cap) = lex.captures(&self.text[self.start.byte..]) {
self.end = self.end.next_str(cap.get(0).unwrap().as_str());
let sp_token = if let Some(_) = cap.name("assign") {
self.make_token(Token::Assign)
@@ -121,6 +121,7 @@ impl<'t> Lexer<'t> {
got: expected_got_char(self.curr().unwrap()),
})
}
})
}
}