diff --git a/Cargo.lock b/Cargo.lock index d0ebf8a..7b1695a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -132,6 +132,10 @@ dependencies = [ "logos-codegen", ] +[[package]] +name = "lopal" +version = "0.1.0" + [[package]] name = "lopal_core" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 810b8e5..7738d82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = [ + "crates/lopal", "crates/lopal_core", "crates/lopal_json" ] diff --git a/crates/lopal/Cargo.toml b/crates/lopal/Cargo.toml new file mode 100644 index 0000000..6aa670f --- /dev/null +++ b/crates/lopal/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "lopal" +version = "0.1.0" +edition = "2024" + +[dependencies] + +[lints] +workspace = true diff --git a/crates/lopal/README.md b/crates/lopal/README.md new file mode 100644 index 0000000..691a63b --- /dev/null +++ b/crates/lopal/README.md @@ -0,0 +1,5 @@ +# LOssless PArser Library + +Yeah :3 + +Reserved for the main crate, work is currently happening over in [lopal_core] diff --git a/crates/lopal/src/main.rs b/crates/lopal/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/crates/lopal/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/crates/lopal_core/README.md b/crates/lopal_core/README.md new file mode 100644 index 0000000..2e3cba3 --- /dev/null +++ b/crates/lopal_core/README.md @@ -0,0 +1,3 @@ +# LoPaL Core + +Currently most development is happening here, until i get to a lot of rewriting and stuff. diff --git a/crates/lopal_core/src/lib.rs b/crates/lopal_core/src/lib.rs index 26d8679..66d856b 100644 --- a/crates/lopal_core/src/lib.rs +++ b/crates/lopal_core/src/lib.rs @@ -1,3 +1,8 @@ +//! Heavily in-dev parser library. +//! +//! Inspired by rust-analyzer. +//! +//! See [_Modern Parser Generator_](https://matklad.github.io/2018/06/06/modern-parser-generator.html) by Matklad #![feature(iter_collect_into)] pub mod parser; diff --git a/crates/lopal_core/src/parser.rs b/crates/lopal_core/src/parser.rs index c592cdb..d37a4ca 100644 --- a/crates/lopal_core/src/parser.rs +++ b/crates/lopal_core/src/parser.rs @@ -15,6 +15,7 @@ pub mod marker; pub mod output; /// this is used to define some required SyntaxKinds like an EOF token or an error token +/// These should be different, idk what happens if they're the same. pub trait SyntaxElement where Self: EnumSetType @@ -32,6 +33,10 @@ where const SYNTAX_ROOT: Self; } +/// The core parser that you interact with. +/// Should be passed to all parser functions as first argument. +/// Currently very minimal/bare-bones. +/// See the [`lopal_json`](https://forge.katzen.cafe/schrottkatze/lopal/src/branch/main/crates/lopal_json) source code for reference. pub struct Parser<'src, SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError> { input: Input<'src, SyntaxKind>, pos: usize, diff --git a/crates/lopal_core/src/parser/error.rs b/crates/lopal_core/src/parser/error.rs index 9c9d893..65c383c 100644 --- a/crates/lopal_core/src/parser/error.rs +++ b/crates/lopal_core/src/parser/error.rs @@ -1,7 +1,10 @@ use std::fmt; /// A marker trait... for now! -// TODO: constrain that conversion to `NodeKind::Error` is enforced to be possible +/// +/// Marks a type as, well, an error type. +/// +/// TODO: constrain that conversion to `NodeKind::Error` is enforced to be possible pub trait SyntaxError where Self: fmt::Debug + Clone + PartialEq + Eq, diff --git a/crates/lopal_core/src/parser/event.rs b/crates/lopal_core/src/parser/event.rs index 1b71d8e..46525e5 100644 --- a/crates/lopal_core/src/parser/event.rs +++ b/crates/lopal_core/src/parser/event.rs @@ -2,7 +2,7 @@ use enumset::EnumSetType; use super::{error::SyntaxError, SyntaxElement}; -pub enum Event { +pub(crate) enum Event { Start { kind: NodeKind, forward_parent: Option, @@ -23,7 +23,7 @@ impl Event { +pub(crate) enum NodeKind { Tombstone, Syntax(SyntaxKind), Error(SyntaxErr), diff --git a/flake.nix b/flake.nix index 1519a03..eabfc74 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,7 @@ { default = pkgs.mkShell rec { buildInputs = with pkgs; [ + cargo-watch toolchain ]; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;