Crate logosky

Crate logosky 

Source
Expand description

LogoSky

A seamless integration layer between Logos and Chumsky parser combinator, providing zero-copy TokenStream adapter and Parseable trait for building robust parsers

github LoC Build codecov

docs.rs crates.io crates.io license

English | 简体中文

§Overview

LogoSky is a Rust library that bridges Logos and Chumsky, combining the speed of Logos’ lexical analysis with the expressiveness of Chumsky’s parser combinators. It provides a seamless integration layer that allows you to use Logos for tokenization and Chumsky for parsing in a unified, type-safe manner.

§Features

  • 🚀 High-performance tokenization with Logos
  • 🎯 Expressive parser combinators with Chumsky
  • 🔗 Seamless integration via TokenStream adapter
  • 📍 Rich span tracking with Span and Spanned types
  • 🎨 Flexible parseable trait for building composable parsers
  • 🔧 No-std support with optional allocator
  • 🧩 Multiple source types support (str, [u8], Bytes, BStr, HipStr)
  • Zero-cost abstractions for efficient parsing

§Installation

Add this to your Cargo.toml:

[dependencies]
logosky = "0.1"

§Feature Flags

  • std (default) - Enable standard library support
  • alloc - Enable allocator support for no-std environments
  • bytes - Support for bytes::Bytes as token source
  • bstr - Support for bstr::BStr as token source
  • hipstr - Support for hipstr::HipStr as token source
  • either - Enable Either<L, R> parseable support
  • among - Enable Among<L, M, R> parseable support
  • smallvec - Enable small vector optimization utilities

§Core Components

  • TokenStream<'a, T>

    An zero-copy adapter that bridges Logos lexer output to Chumsky parser input. Implements Chumsky’s Input, ValueInput, SliceInput, and ExactSizeInput traits.

  • Token<'a> Trait

    The core trait for defining tokens. Requires:

    • Char: Character type (usually char or u8)
    • Kind: Token kind discriminator
    • Logos: Associated Logos token enum
  • Parseable<'a, I, T, Error> Trait

    A trait for types that can be parsed from a token stream. Implement this to create composable parsers.

  • Span and Spanned<T>

    • Span: Lightweight span tracking (start/end positions)
    • Spanned<T>: Wraps a value with its source span
  • Utility Traits

    • IsAsciiChar: ASCII character checking utilities
    • AsSpan / IntoSpan: Span access traits
    • IntoComponents: Destructure parsed elements

§Who uses logosky?

  • smear: Blazing fast, fully spec-compliant, reusable parser combinators for standard GraphQL and GraphQL-like DSLs.

§License

logosky is dual-licensed under:

You may choose either license for your purposes.

Copyright (c) 2025 Al Liu.

Re-exports§

pub use chumsky;
pub use logos;

Modules§

iter
Iterators for TokenStream
source
The source related structures and traits
token
The token related structures and traits
utils
Common utilities for working with tokens and lexers.

Structs§

TokenStream
The logos token stream adapter for chumsky’s parsers

Enums§

LexError
The lexer error
Lexed
An item produced by the lexer: either a recognized token T or a lexing error.

Traits§

FromLexError
A trait for converting a lexer error into the target error.
Lexable
A trait for types that can be lexed from the input.
Logos
Trait implemented for an enum representing all tokens. You should never have to implement it manually, use the #[derive(Logos)] attribute on your enum.
Parseable
A trait for types that can be parsed directly from a I: Tokenizer<'a, T> which yields T: Token<'a> and may produce an Error.
Source
Trait for types the Lexer can read from.
State
The state trait for lexers
Token
The token trait.
TokenExt
The token extension trait.
Tokenizer
Tokenizer trait

Derive Macros§

Logos