[−][src]Module kontroli::parse
Parsing to unshared, reference-free data structures.
All basic parsers operate on byte slices (&[u8]
) instead of strings (&str
).
This enables efficient parsing using a circular buffer.
The parsers for all primitives in this file assume that they are being given input that has been lexed; that is, leading whitespace has been removed. This has a few practical implications:
- If a parser consists of a sequence of other parsers, then it has to lex every parser in that sequence except the first. (We could also lex the first parser, but then, we would duplicate work, because we know by assumption that the whole parser is lexed.)
- If a parser consists of an alternative of parsers
alt(p1, ..., pn)
, then its lexed version should be the lexed alternative of parserslex(alt(p1, ..., pn))
instead of the alternative of lexed parsersalt(lex(p1), ..., lex(pn))
. This avoids redoing the lexing for all alternatives.
Re-exports
pub use term::Term; |
Modules
term | Unshared terms, not distinguishing bound and unbound symbols. |
Structs
Pattern | |
Symbol | Symbol consisting of a relative module path and a symbol name. |
Traits
Parser | A trait similar to |
Functions
comment | Parse a (potentially nested) comment. |
nested | Parse arbitrary nesting of strings delimited by non-empty start and end tags. |
opt_lex | Parse whitespace/comments to |
parse | Parse a string phrase and discard remaining input. |
phrase | Parse a phrase, i.e. a given function terminated by a dot. |
Type Definitions
Command | Signature-changing command. |
Intro | |
Parse | Result of a parser. |
Rule | Rewrite rules with arguments as bound variables, and preterms as left- and right-hand sides. |