# sipha-core
[](https://opensource.org/licenses/MIT)
[](https://github.com/NyalephTheCat/sipha)
[](https://crates.io/crates/sipha-core)
[](https://docs.rs/sipha-core)
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`:
```toml
[dependencies]
sipha-core = "0.1.1"
```
With optional features:
```toml
[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
```rust
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:
- [Architecture Guide](https://github.com/NyalephTheCat/sipha/blob/release/docs/concepts/architecture.md)
- [Main README](https://github.com/NyalephTheCat/sipha/blob/release/README.md)
## License
This project is licensed under the MIT License - see the [LICENSE](../LICENSE) file for details.
## See Also
- [sipha](https://crates.io/crates/sipha) - Umbrella crate with feature flags
- [sipha-tree](../sipha-tree) - CST/AST construction
- [sipha-parse](../sipha-parse) - Parsing engine
- [sipha-error](../sipha-error) - Error handling