Token-related definitions
This commit is contained in:
parent
dcbb2681c1
commit
987118be8b
2 changed files with 66 additions and 3 deletions
src
55
src/tokens.rs
Normal file
55
src/tokens.rs
Normal file
|
@ -0,0 +1,55 @@
|
|||
/// The type of a token. May also contain its litteral value.
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum TokenType {
|
||||
LeftParen,
|
||||
RightParen,
|
||||
LeftBrace,
|
||||
RightBrace,
|
||||
Comma,
|
||||
Dot,
|
||||
Minus,
|
||||
Plus,
|
||||
Semicolon,
|
||||
Slash,
|
||||
Star,
|
||||
|
||||
Bang,
|
||||
BangEqual,
|
||||
Equal,
|
||||
EqualEqual,
|
||||
Greater,
|
||||
GreaterEqual,
|
||||
Less,
|
||||
LessEqual,
|
||||
|
||||
Identifier(String),
|
||||
String(String),
|
||||
Number(f64),
|
||||
|
||||
And,
|
||||
Class,
|
||||
Else,
|
||||
False,
|
||||
Fun,
|
||||
For,
|
||||
If,
|
||||
Nil,
|
||||
Or,
|
||||
Print,
|
||||
Return,
|
||||
Super,
|
||||
This,
|
||||
True,
|
||||
Var,
|
||||
While,
|
||||
|
||||
EOF,
|
||||
}
|
||||
|
||||
/// Full information about a token.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Token {
|
||||
pub token_type: TokenType,
|
||||
pub lexeme: String,
|
||||
pub line: usize,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue