43 releases (breaking)

0.31.1 Jan 12, 2022
0.30.0 Aug 23, 2021
0.29.1 Jul 23, 2021
0.28.0 Nov 13, 2020
0.6.0 Nov 2, 2018

#205 in Parser implementations

Download history 52/week @ 2021-10-01 48/week @ 2021-10-08 20/week @ 2021-10-15 7/week @ 2021-10-22 33/week @ 2021-10-29 64/week @ 2021-11-05 19/week @ 2021-11-12 17/week @ 2021-11-19 6/week @ 2021-11-26 47/week @ 2021-12-03 7/week @ 2021-12-10 1/week @ 2021-12-17 1/week @ 2021-12-24 49/week @ 2021-12-31 26/week @ 2022-01-07 21/week @ 2022-01-14

97 downloads per month
Used in 2 crates

MIT license

165KB
4.5K SLoC

tptp

A crate of parsers for the TPTP format.

Features

  • nom parsers for maximum flexibility
  • high-performance, streaming, zero-copy parsing
  • convenient abstractions: visitor pattern, input iterator
  • adherence to TPTP BNF
  • complete CNF/FOF dialect support
  • growing TFX support

Documentation and Examples

Documentation on docs.rs. The examples/ directory contains some trivial programs. tptp2json/ contains a slightly-less trivial program to transform TPTP input to JSON Lines via the magic of serde.

Performance

"Fast enough".

Unscientific benchmark:

$ cargo bench
100000 iterations, 970 bytes of SYN000-1.p
0.74 seconds total (130.54 MB/s).
100000 iterations, 1281 bytes of SYN000+1.p
1.51 seconds total (84.75 MB/s).
100000 iterations, 2420 bytes of SYN000_1.p
2.94 seconds total (82.37 MB/s).
100000 iterations, 5209 bytes of SYN000=2.p
6.38 seconds total (81.68 MB/s).
$

examples/validate currently checks 458MB of CSR002+5.ax in under 4 seconds.

Limitations

Since this is effectively recursive-descent parsing, extremely-deeply-nested structures will cause you to run out of stack: this has not been a problem in practice. Parsers work only on bytes in memory: this is by design. If you want to read data from somewhere, either use mmap(2) (useful for large files) or read data in chunks until you can parse an input. See nom's streaming documentation.

Dependencies

~1.1–1.7MB
~37K SLoC

a