Initialize Aster project with basic structure, including Cargo configuration, lexer, parser, interpreter, and AST definitions. Add a sample script and README documentation. Implement basic error handling and environment management for variable storage.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// lexer/token.rs
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum TokenKind {
|
||||
// 单字符
|
||||
LeftParen, RightParen,
|
||||
LeftBrace, RightBrace,
|
||||
Comma, Semicolon,
|
||||
|
||||
// 运算符
|
||||
Plus, Minus, Star, Slash,
|
||||
Bang,
|
||||
Equal,
|
||||
Greater, GreaterEqual,
|
||||
Less, LessEqual,
|
||||
EqualEqual, BangEqual,
|
||||
AndAnd, OrOr,
|
||||
|
||||
// 字面量
|
||||
Identifier(String),
|
||||
Number(f64),
|
||||
String(String),
|
||||
|
||||
// 关键字
|
||||
Let,
|
||||
Fn,
|
||||
If,
|
||||
Else,
|
||||
While,
|
||||
Return,
|
||||
True,
|
||||
False,
|
||||
Nil,
|
||||
|
||||
EOF,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Token {
|
||||
pub kind: TokenKind,
|
||||
pub line: usize,
|
||||
pub column: usize,
|
||||
}
|
||||
Reference in New Issue
Block a user