sipha-core

Crates.iosipha-core
lib.rssipha-core
version0.3.0
created_at2025-11-18 16:32:36.462332+00
updated_at2025-11-22 09:47:52.551989+00
descriptionCore foundation types and traits for sipha - minimal dependencies, no parsing logic
homepage
repositoryhttps://github.com/NyalephTheCat/sipha
max_upload_size
id1938646
size41,955
Nyaleph (NyalephTheCat)

documentation

README

sipha-core

License: MIT Repository Crates.io docs.rs

Core foundation types and traits for sipha - minimal dependencies, no parsing logic.

Overview

sipha-core is the minimal foundation of the sipha parser ecosystem. It provides only the essential traits and types that are shared across all other sipha crates:

  • Core traits: TokenKind, RuleId, NodeId, SymbolId, GrammarContext, AstNode
  • Basic types: Span, Token, TokenTrivia

This crate has minimal dependencies and contains no parsing logic, focusing solely on defining the interfaces for tokens, rules, nodes, and spans.

Quick Start

Add sipha-core to your Cargo.toml:

[dependencies]
sipha-core = "0.1.1"

With optional features:

[dependencies]
sipha-core = { version = "0.1.1", features = ["serde"] }

Features

  • default: No features enabled (minimal dependencies)
  • serde: Enables serialization/deserialization for Span and Token

Example

use sipha_core::traits::{TokenKind, RuleId, NodeId};
use sipha_core::span::Span;
use sipha_core::token::Token;

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum MyToken {
    Ident,
    Number,
}

impl TokenKind for MyToken {
    fn is_trivia(&self) -> bool {
        false
    }
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum MyRule {
    Expression,
    Term,
}

impl RuleId for MyRule {}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct MyNodeId(usize);

impl NodeId for MyNodeId {
    fn from_raw(raw: usize) -> Self {
        MyNodeId(raw)
    }
    fn to_raw(self) -> usize {
        self.0
    }
}

Documentation

For more information, see:

License

This project is licensed under the MIT License - see the LICENSE file for details.

See Also

Commit count: 0

cargo fmt