Base initial commit
Still WIP, working on object system still, which in Rust, makes me want to kill myself Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
67
src/token.rs
Normal file
67
src/token.rs
Normal file
@@ -0,0 +1,67 @@
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum TokenKind {
|
||||
// Keywords
|
||||
Return,
|
||||
If,
|
||||
Else,
|
||||
True,
|
||||
False,
|
||||
Nil,
|
||||
|
||||
// Expressions
|
||||
Name,
|
||||
Number,
|
||||
String,
|
||||
|
||||
// Binary operators
|
||||
Plus,
|
||||
Minus,
|
||||
Star,
|
||||
Slash,
|
||||
|
||||
// Unary operators (not already covered)
|
||||
Bang,
|
||||
|
||||
// Boolean operators
|
||||
And,
|
||||
Or,
|
||||
|
||||
// Comparison
|
||||
BangEq,
|
||||
EqEq,
|
||||
Greater,
|
||||
GreaterEq,
|
||||
Less,
|
||||
LessEq,
|
||||
|
||||
// Braces, parens, etc
|
||||
LParen,
|
||||
RParen,
|
||||
LBrace,
|
||||
RBrace,
|
||||
LBracket,
|
||||
RBracket,
|
||||
|
||||
// Assignment
|
||||
Eq,
|
||||
|
||||
// Dot, comma
|
||||
Dot,
|
||||
Comma,
|
||||
Arrow,
|
||||
Colon,
|
||||
|
||||
// Line end
|
||||
Eol,
|
||||
|
||||
// File end
|
||||
Eof,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Token {
|
||||
pub line: usize,
|
||||
//pub index: usize,
|
||||
pub text: String,
|
||||
pub kind: TokenKind,
|
||||
}
|
||||
Reference in New Issue
Block a user