Struct IdentifierParser
struct IdentifierParser<'ident> { ... }
Expression parser/evaluator that supports identifiers.
Implementations
impl<'ident> IdentifierParser<'ident>
fn new(identifiers: &HashMap<Vec<u8>, EvalResult>) -> IdentifierParser<'_>Create a new
IdentifierParserwith a set of known identifiers. When a known identifier is encountered during parsing, it is substituted for the value specified.fn expr<'a>(self: &Self, input: &'a [Token]) -> CResult<'a, EvalResult>Parse and evaluate an expression of a list of tokens.
Returns an error if the input is not a valid expression or if the token stream contains comments, keywords or unknown identifiers.
fn macro_definition<'a>(self: &Self, input: &'a [Token]) -> CResult<'a, (&'a [u8], EvalResult)>Parse and evaluate a macro definition from a list of tokens.
Returns the identifier for the macro and its replacement evaluated as an expression. The input should not include
#define.Returns an error if the replacement is not a valid expression, if called on most function-like macros, or if the token stream contains comments, keywords or unknown identifiers.
N.B. This is intended to fail on function-like macros, but if it the macro takes a single argument, the argument name is defined as an identifier, and the macro otherwise parses as an expression, it will return a result even on function-like macros.
// will evaluate into IDENTIFIER // will evaluate into IDENTIFIER-3
impl<'ident> Debug for IdentifierParser<'ident>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<'ident> Freeze for IdentifierParser<'ident>
impl<'ident> RefUnwindSafe for IdentifierParser<'ident>
impl<'ident> Send for IdentifierParser<'ident>
impl<'ident> Sync for IdentifierParser<'ident>
impl<'ident> Unpin for IdentifierParser<'ident>
impl<'ident> UnwindSafe for IdentifierParser<'ident>
impl<T> Any for IdentifierParser<'ident>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for IdentifierParser<'ident>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for IdentifierParser<'ident>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for IdentifierParser<'ident>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for IdentifierParser<'ident>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for IdentifierParser<'ident>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for IdentifierParser<'ident>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>