mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-16 10:25:02 +01:00
small api changes
This commit is contained in:
parent
b3fde273d6
commit
78f8382502
3 changed files with 8 additions and 10 deletions
10
clippy.toml
10
clippy.toml
|
|
@ -1,8 +1,6 @@
|
||||||
disallowed-types = [
|
disallowed-types = [
|
||||||
# we want to use our custom HashMap/HashSet from `values.rs`, so that consumers can choose between which HashMap they want
|
{ path = "std::collections::HashMap", reason = "may be fxhash or siphash, depending on the feature, stay flexible" },
|
||||||
"std::collections::HashMap",
|
{ path = "std::collections::HashSet", reason = "may be fxhash or siphash, depending on the feature, stay flexible" },
|
||||||
"std::collections::HashSet",
|
{ path = "std::collections::Vec", reason = "we generally want to use bumpalos collections" },
|
||||||
# we want to use bumpalo::collections::Vec, this can be removed later I guess
|
{ path = "std::boxed::Box", reason = "we generally want to use bumpalos allocation" },
|
||||||
"std::collections::Vec",
|
|
||||||
"std::boxed::Box",
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ pub struct Lexer<'code> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'code> Lexer<'code> {
|
impl<'code> Lexer<'code> {
|
||||||
pub fn lex(code: &'code str) -> Self {
|
pub fn new(code: &'code str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
code: code.char_indices().peekable(),
|
code: code.char_indices().peekable(),
|
||||||
src: code,
|
src: code,
|
||||||
|
|
@ -416,7 +416,7 @@ mod test {
|
||||||
type StdString = std::string::String;
|
type StdString = std::string::String;
|
||||||
|
|
||||||
fn lex_types(str: &str) -> Vec<TokenType> {
|
fn lex_types(str: &str) -> Vec<TokenType> {
|
||||||
let lexer = Lexer::lex(str);
|
let lexer = Lexer::new(str);
|
||||||
lexer.map(|token| token.unwrap().kind).collect::<Vec<_>>()
|
lexer.map(|token| token.unwrap().kind).collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@ mod value;
|
||||||
|
|
||||||
use crate::ast::Program;
|
use crate::ast::Program;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
|
|
||||||
pub use lex::*;
|
pub use lex::*;
|
||||||
pub use parse::*;
|
pub use parse::*;
|
||||||
|
|
||||||
pub fn run_program(program: &str) {
|
pub fn run_program(program: &str) {
|
||||||
let lexer = lex::Lexer::lex(program);
|
|
||||||
|
|
||||||
let ast_alloc = Bump::new();
|
let ast_alloc = Bump::new();
|
||||||
|
|
||||||
|
let lexer = lex::Lexer::new(program);
|
||||||
let ast = parse::parse(lexer, &ast_alloc);
|
let ast = parse::parse(lexer, &ast_alloc);
|
||||||
|
|
||||||
match ast {
|
match ast {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue