logosky

Crates.iologosky
lib.rslogosky
version0.2.0
created_at2025-10-15 05:11:19.854062+00
updated_at2025-10-20 21:03:35.862349+00
descriptionA seamless integration layer between Logos lexer and Chumsky parser combinator, providing zero-copy TokenStream adapter and Parseable trait for building robust parsers
homepagehttps://github.com/al8n/logosky
repositoryhttps://github.com/al8n/logosky
max_upload_size
id1883766
size337,804
Al Liu (al8n)

documentation

https://docs.rs/logosky

README

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.2"

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
  • LosslessToken<'a> Trait

    Extends Token<'a> for tokens that preserve all source information, including trivia (whitespace, comments).

    • Provides is_trivia() method to identify non-semantic tokens
    • Essential for building formatters, linters, and language servers that need to preserve formatting
    • Works seamlessly with Tokenizer trivia handling utilities
  • Tokenizer<'a, T> Trait

    Provides parser combinators for working with token streams:

    • skip_trivias(): Skip over trivia tokens (whitespace, comments)
    • collect_trivias(): Collect trivia tokens into a container for later processing
  • 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.

Commit count: 0

cargo fmt