get ready for early publish
This commit is contained in:
parent
01de2f385a
commit
fdfff2c33a
11 changed files with 42 additions and 3 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -132,6 +132,10 @@ dependencies = [
|
||||||
"logos-codegen",
|
"logos-codegen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lopal"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lopal_core"
|
name = "lopal_core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
|
"crates/lopal",
|
||||||
"crates/lopal_core",
|
"crates/lopal_core",
|
||||||
"crates/lopal_json"
|
"crates/lopal_json"
|
||||||
]
|
]
|
||||||
|
|
9
crates/lopal/Cargo.toml
Normal file
9
crates/lopal/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "lopal"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
5
crates/lopal/README.md
Normal file
5
crates/lopal/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# LOssless PArser Library
|
||||||
|
|
||||||
|
Yeah :3
|
||||||
|
|
||||||
|
Reserved for the main crate, work is currently happening over in [lopal_core]
|
3
crates/lopal/src/main.rs
Normal file
3
crates/lopal/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
3
crates/lopal_core/README.md
Normal file
3
crates/lopal_core/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# LoPaL Core
|
||||||
|
|
||||||
|
Currently most development is happening here, until i get to a lot of rewriting and stuff.
|
|
@ -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)]
|
#![feature(iter_collect_into)]
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ pub mod marker;
|
||||||
pub mod output;
|
pub mod output;
|
||||||
|
|
||||||
/// this is used to define some required SyntaxKinds like an EOF token or an error token
|
/// 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
|
pub trait SyntaxElement
|
||||||
where
|
where
|
||||||
Self: EnumSetType
|
Self: EnumSetType
|
||||||
|
@ -32,6 +33,10 @@ where
|
||||||
const SYNTAX_ROOT: Self;
|
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> {
|
pub struct Parser<'src, SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError> {
|
||||||
input: Input<'src, SyntaxKind>,
|
input: Input<'src, SyntaxKind>,
|
||||||
pos: usize,
|
pos: usize,
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
/// A marker trait... for now!
|
/// 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
|
pub trait SyntaxError
|
||||||
where
|
where
|
||||||
Self: fmt::Debug + Clone + PartialEq + Eq,
|
Self: fmt::Debug + Clone + PartialEq + Eq,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use enumset::EnumSetType;
|
||||||
|
|
||||||
use super::{error::SyntaxError, SyntaxElement};
|
use super::{error::SyntaxError, SyntaxElement};
|
||||||
|
|
||||||
pub enum Event<SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError> {
|
pub(crate) enum Event<SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError> {
|
||||||
Start {
|
Start {
|
||||||
kind: NodeKind<SyntaxKind, SyntaxErr>,
|
kind: NodeKind<SyntaxKind, SyntaxErr>,
|
||||||
forward_parent: Option<usize>,
|
forward_parent: Option<usize>,
|
||||||
|
@ -23,7 +23,7 @@ impl<SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError> Event<SyntaxKind, Syntax
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq)]
|
#[derive(Clone, PartialEq, Eq)]
|
||||||
pub enum NodeKind<SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError> {
|
pub(crate) enum NodeKind<SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError> {
|
||||||
Tombstone,
|
Tombstone,
|
||||||
Syntax(SyntaxKind),
|
Syntax(SyntaxKind),
|
||||||
Error(SyntaxErr),
|
Error(SyntaxErr),
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
{
|
{
|
||||||
default = pkgs.mkShell rec {
|
default = pkgs.mkShell rec {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
|
cargo-watch
|
||||||
toolchain
|
toolchain
|
||||||
];
|
];
|
||||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue