marktwin

Crates.iomarktwin
lib.rsmarktwin
version0.5.0
sourcesrc
created_at2021-10-18 15:05:57.632875
updated_at2023-12-03 20:34:47.227421
descriptionMarktwin format support for Eternaltwin.
homepagehttps://gitlab.com/eternal-twin/marktwin
repositoryhttps://gitlab.com/eternal-twin/marktwin
max_upload_size
id466819
size80,882
Charles Samborski (demurgos)

documentation

https://gitlab.com/eternal-twin/marktwin

README

Marktwin parser

This library implements the Marktwin (mkt) parser used by Eternal-Twin. Marktwin is the format used by Eternal-Twin for its messages. It is inspired by Markdown and the Twinoid forum code. See the Marktwin library for more details.

The parser is implemented using Rust and compiled to Wasm. It is compatible with both Node and webpack.

All inputs produce valid parse trees, parsing cannot fail.

Design

The parser uses a pipeline to gradually transform the input into a tree.

  1. Input: A string of valid unicode codepoints. It is up to the consumer to provide handle the encoding and provide this string.
  2. Context-free token stream: The lexer tokenizes the string only using the current index.
  3. Parse-event stream: Contains potentially remapped tokens end start/end events for nodes.
  4. Concrete Syntax Tree: Tree representation of the parse-event stream
  5. Abstract Syntax Tree: An adapter on top of the CST to provide easier access to the data.

Fuzzing

The Rust implementation supports fuzzing:

# Make sure that you have `cargo-fuzz`
cargo install cargo-fuzz
# Fuzz the `lexer`
cargo fuzz run lexer
# Fuzz the `parser`
cargo fuzz run parser
Commit count: 39

cargo fmt