Skip to content

Commit

Permalink
refactor: remove regex dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
garritfra committed Dec 10, 2024
1 parent e8708b1 commit e5a6ec6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
**Maintenance**

- Refactored command execution for better error handling and code organization
- Remove regex dependency

## v0.8.0 (2024-04-05)

Expand Down
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ structopt = "0.3.26"
rust-embed = "5.7.0"
inkwell = { version = "0.5.0", features = ["llvm10-0"], optional = true }
qbe = "1.0.0"
regex = "1.11.1"
lazy_static = "1.5.0"
14 changes: 4 additions & 10 deletions src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ pub(crate) mod cursor;

use self::TokenKind::*;
use cursor::Cursor;
use lazy_static::lazy_static;
use regex::Regex;

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -208,20 +206,16 @@ pub fn is_whitespace(c: char) -> bool {
/// See [Antimony specification](https://antimony-lang.github.io/antimony/developers/specification.html#identifiers) for
/// a formal definition of valid identifier name.
pub fn is_id_start(c: char) -> bool {
lazy_static! {
static ref ID_START: Regex = Regex::new(r"[\pL_]").unwrap();
}
ID_START.is_match(&c.to_string())
// Valid identifier start is either an underscore or any Unicode letter
c == '_' || c.is_alphabetic()
}

/// True if `c` is a valid continuation of an identifier
/// See [Antimony specification](https://antimony-lang.github.io/antimony/developers/specification.html#identifiers) for
/// a formal definition of valid identifier name.
pub fn is_id_continue(c: char) -> bool {
lazy_static! {
static ref ID_CONTINUE: Regex = Regex::new(r"[\pL\p{Nd}_]").unwrap();
}
ID_CONTINUE.is_match(&c.to_string())
// Valid identifier continuation is underscore, letter, or number
c == '_' || c.is_alphabetic() || c.is_numeric()
}

impl Cursor<'_> {
Expand Down
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
extern crate lazy_static;
extern crate qbe;
extern crate regex;
/**
* Copyright 2020 Garrit Franke
*
Expand All @@ -16,6 +13,8 @@ extern crate regex;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
extern crate lazy_static;
extern crate qbe;
extern crate rust_embed;
extern crate structopt;

Expand Down

0 comments on commit e5a6ec6

Please sign in to comment.