pub struct CalcToken {
pub token_id: TokenID,
pub value: TokenValue,
pub span: Option<Span>,
}Expand description
A concrete lexical token for the calculator frontend.
CalcToken is a lightweight container that implements parlex::Token,
exposing its identifier and source position. It groups:
- a token kind via
TokenID, - an optional payload via
TokenValue, - a 1-based source line number.
§Trait implementation
Implements Token with:
§Fields
token_id: the token’s category (identifier, number, operator, …)value: associated payload (symbol index or literal)line_no: 1-based source line number
§Example
let tok = CalcToken {
token_id: TokenID::Number,
value: TokenValue::Number(99),
span: span!(0, 0, 0, 2),
};
assert_eq!(tok.token_id(), TokenID::Number);
assert_eq!(tok.span(), span!(0, 0, 0, 2));Fields§
§token_id: TokenIDThe token’s kind or category (e.g. identifier, operator, number).
value: TokenValueThe associated value for the token, if applicable.
span: Option<Span>The line number in the input source where the token occurs.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CalcToken
impl RefUnwindSafe for CalcToken
impl Send for CalcToken
impl Sync for CalcToken
impl Unpin for CalcToken
impl UnwindSafe for CalcToken
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more