[−][src]Module arithmetic_parser::grammars
Grammar functionality and a collection of standard grammars.
Defining grammars
To define a Grammar, you'll need a ParseLiteral implementation, which defines
how literals are parsed (numbers, strings, chars, hex- / base64-encoded byte sequences, etc.).
There are standard impls for floating-point number parsing and the complex numbers
(if the relevant feature is on).
You may define how to parse type annotations by implementing Grammar explicitly.
Alternatively, if you don't need type annotations, a Grammar can be obtained from
a ParseLiteral impl by wrapping it into Untyped.
Once you have a Grammar, you can supply it as a Base for Parse. Parse methods
allow to parse complete or streaming Blocks of statements.
Note that Untyped and Typed wrappers allow to avoid an explicit Parse impl.
See ParseLiteral, Grammar and Parse docs for the examples of various grammar
definitions.
Structs
| Features | Parsing features used to configure |
| NumGrammar | Single-type numeric grammar parameterized by the literal type. |
| Typed | Wrapper for |
| Untyped | Wrapper for |
Traits
| Grammar | Extension of |
| IntoInputSpan | Helper trait allowing |
| NumLiteral | Numeric literal used in |
| Parse | Unites all necessary parsers to form a complete grammar definition. |
| ParseLiteral | Encapsulates parsing literals in a grammar. |
Functions
| ensure_no_overlap | Ensures that the child parser does not consume a part of a larger expression by rejecting
if the part following the input is an alphanumeric char or |
Type Definitions
| F32Grammar | Type alias for a grammar on |
| F64Grammar | Type alias for a grammar on |