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
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
TokenStreamadapter - 📍 Rich span tracking with
SpanandSpannedtypes - 🎨 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 supportalloc- Enable allocator support for no-std environmentsbytes- Support forbytes::Bytesas token sourcebstr- Support forbstr::BStras token sourcehipstr- Support forhipstr::HipStras token sourceeither- EnableEither<L, R>parseable supportamong- EnableAmong<L, M, R>parseable supportsmallvec- 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, andExactSizeInputtraits. -
Token<'a>TraitThe core trait for defining tokens. Requires:
Char: Character type (usuallycharoru8)Kind: Token kind discriminatorLogos: Associated Logos token enum
-
LosslessToken<'a>TraitExtends
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
Tokenizertrivia handling utilities
- Provides
-
Tokenizer<'a, T>TraitProvides 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>TraitA trait for types that can be parsed from a token stream. Implement this to create composable parsers.
-
SpanandSpanned<T>Span: Lightweight span tracking (start/end positions)Spanned<T>: Wraps a value with its source span
-
Utility Traits
IsAsciiChar: ASCII character checking utilitiesAsSpan/IntoSpan: Span access traitsIntoComponents: 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:
- MIT License (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
You may choose either license for your purposes.
Copyright (c) 2025 Al Liu.
Re-exports§
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§
- Token
Stream - A zero-copy token stream adapter that bridges Logos and Chumsky.
Enums§
- Lexed
- The result of lexing a single token: either a successful token or an error.
Traits§
- 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. - Lossless
Token - A token trait for tokens that preserve all source information during lexing, including trivia.
- Parseable
- A trait for types that can be parsed from a token stream using Chumsky parsers.
- Source
- Trait for types the
Lexercan read from. - State
- The state trait for lexers
- Token
- The core trait for token types used with LogoSky.
- Token
Ext - The token extension trait.
- Tokenizer
- Tokenizer trait providing utilities for working with token streams.