pub fn parse(source: &str, file: &str) -> Result<Vec<Predicate>, Error>Expand description
Reads every predicate defined in source.
file is only used to label errors. Predicates come in the order of their
main forms.
§Limits
No input makes this function panic or overflow the stack of the calling
thread, whatever its size or shape; a debug build with a 1 MiB stack is
enough. The only limit is the nesting of brackets: at most 32 deep,
counting the braces of the function body, so a parenthesized expression
may nest 31 deep. Comments and literals do not count toward it. Sums,
products and runs of unary minus are read in loops, so this function
accepts them at any length; the later steps of crate::generate have
budgets of their own: a sum of 100,000 terms in one chain, for instance,
is rejected by crate::filter_bound with “the expression is too large
for the error bound of the filter”. An error for brackets that are
nested too deeply names the limit and suggests splitting the expression
with let.
Ordinary comments are skipped. Doc comments (///, //!, /** */ and
/*! */) are rejected at their position with “doc comments are not
supported in definitions; use //”, since Rust would read them as
attributes. A predicate is named after a generated module, so its name
must be usable as one: Rust keywords, strict and reserved, _ and raw
identifiers are rejected.
§Errors
Returns the first problem found: a token that the grammar of definitions
does not allow, a doc comment, a predicate name that cannot name a
module, an undefined or redefined name, an unused parameter, or a
misplaced #[exact] form.