rcalc/rcalc/token.rs
1/// Describes a Token scanned by the Lexer.
2///
3/// As there as a limited number of Tokens, all Token types
4/// are easily enumerated, consisting largely of
5///
6/// - Data types (Integer)
7/// - Operands (Plus, Minus, Multiply, Divide, Exponent)
8/// - Controls (Lparen, Rparen, EOF)
9///
10/// For the Parser and Interpereter to adequately process Tokens, Tokens must be cloneable and
11/// equatable.
12///
13/// # Examples
14///
15/// All tokens except those representing data types are symbolic; only data types must hold a
16/// value.
17///
18/// ```
19/// # mod rcalc;
20/// # use rcalc::Token;
21/// let plus = Token::PLUS;
22/// let num = Token::NUMBER(23);
23/// ```
24#[derive(Clone, Debug, PartialEq)]
25pub enum Token {
26 // Data types
27 NUMBER(usize),
28
29 // Operands
30 PLUS,
31 MINUS,
32 MULTIPLY,
33 DIVIDE,
34 DIVIDEINT,
35 MODULO,
36 EXPONENT,
37 FACTORIAL,
38
39 // Containers
40 LPAREN,
41 RPAREN,
42
43 // Controls
44 EOF,
45 NONE,
46}