Crates.io | atlas-core |
lib.rs | atlas-core |
version | 0.6.0-beta5 |
source | src |
created_at | 2023-10-24 12:40:35.666685 |
updated_at | 2024-08-21 16:52:13.167021 |
description | (In Alpha) Embeddable functional programming language |
homepage | https://redgear.tk/ |
repository | https://github.com/RedGear-Studio/atlas-core |
max_upload_size | |
id | 1012332 |
size | 68,342 |
Crate to host the Atlas77 project. An embeddable functional language.
atlas_core
is a Rust library designed to facilitate lexical analysis and token parsing for programming languages. It provides a flexible and customizable lexer implementation, along with macros to define language-specific tokens, keywords, and symbols.
Features
Add the following to your Cargo.toml
:
[dependencies]
atlas_core = "0.6.0"
Everything is under refactoring, so it won't work like that. Stay tuned for update!
Use the symbols!
macro to define symbols used in your language:
symbols! {
'+' => Plus,
'-' => Minus,
'*' => Asterisk,
'/' => Slash,
// Add more symbols as needed
}
Use the keyword!
macro to define keywords:
keyword! {
"if",
"else",
"while",
// Add more keywords as needed
}
Use the number!
macro to configure number parsing options:
number! {
enable_f64: true,
enable_i64: true
}
Use the lexer!
macro to generate the lexer with default or customized configurations:
lexer!();
Here's an example of using atlas_core
to create a simple lexer:
use atlas_core::prelude::*;
symbols! {
'+' => Plus,
'{' => LBracket,
'}' => RBracket,
';' => SemiColon,
}
keyword! {
"if",
"return"
}
number! {
enable_f64: true,
enable_i64: true
}
lexer!();
fn main() {
let source = "if x + y { return 42; }";
let tokens = Lexer::tokenize("example.rs", source).unwrap();
for token in tokens {
println!("{:?}", token);
}
}
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.