Crates.io | alkale |
lib.rs | alkale |
version | 2.0.0 |
source | src |
created_at | 2024-09-13 18:50:37.419267 |
updated_at | 2024-11-18 04:49:55.588014 |
description | A simple LL(1) lexer library for Rust. |
homepage | |
repository | https://codeberg.org/AshliKatt/Alkale |
max_upload_size | |
id | 1374067 |
size | 343,903 |
This is the repository for Alkale, a Rust library to assist in making hand-written LL(1) lexers.
Alkale has three specific goals in mind for its design.
Alkale should act as a "base layer" for a larger compiler. It implements datatypes such as Span
s to track where tokens were in the source code. It also
implements Notification
s, which act as a built-in lint and error system.
Alkale does not generate lexers for you, it just provides an API to streamline the production of one. For this reason, it should be fairly efficient and able to be tweaked.
Many aspects of lexers are extremely common and repetitive. Think things such as skipping whitespace, generating string or number tokens, recovering from errors, etc. These common elements should come pre-packaged with Alkale by default.
The core of Alkale is built on two types: SourceCodeScanner
and LexerResult
. The former provides a way to interface with source code
in an organized manner, while the latter acts as an accumulator of Notification
s (errors) and Token
s (Actual output)
See the documentation of these types for more information.
A well-formed Alkale lexer can operate at about 208MB/s on my fairly modest machine. (Derived from the simplex
and deflate
benchmark's results) This is far faster than a simple regex-based lexer, but is still beaten by some other lexers.