asciimath-parser

Crates.ioasciimath-parser
lib.rsasciimath-parser
version0.1.1
sourcesrc
created_at2023-03-05 23:17:45.067108
updated_at2023-03-05 23:18:59.949542
descriptionA fast extensible memory-efficient asciimath parser
homepage
repositoryhttps://github.com/erikbrinkman/asciimath-parser
max_upload_size
id801851
size81,538
Erik Brinkman (erikbrinkman)

documentation

README

Asciimath Parser

crates.io docs license tests

A fast extensible memory-efficient asciimath parser

This parser produces a parsed tree representation rooted as an Expression. The parsed structure keeps refrences to the underlying string in order to avoid copies, but these strings must still be interpreted as the correct tokens to use the structure.

Usage

cargo add asciimath-parser

then

asciimath_parser::parse("x / y");

Comparisons

This library is meant to be a fast extensible parser. There are a number of rust libraries that parse and format, or parse and evaluate, but don't expose their underlying parsing logic. Only asciimath_rs actual parses expressions. However, that parser allocates extra strings, and produces a relatively complicated parse tree. This creates a relatively simpler parse tree with string slices as tokens. This allows this parser be several times faster than asciimath_rs.

test asciimath_parser::example ... bench:       7,912 ns/iter (+/- 1,348)
test asciimath_rs::example     ... bench:      41,605 ns/iter (+/- 14,262)

test asciimath_parser::random  ... bench:     360,495 ns/iter (+/- 32,231)
test asciimath_rs::random      ... bench:   2,522,810 ns/iter (+/- 168,133)
Commit count: 4

cargo fmt