update
This commit is contained in:
@@ -19,3 +19,8 @@ target
|
|||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
|
||||||
|
# Added by cargo
|
||||||
|
|
||||||
|
/target
|
||||||
|
|||||||
Generated
+7
@@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rust-interpreter"
|
||||||
|
version = "0.1.0"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "rust-interpreter"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
struct Lexer {
|
||||||
|
input: String,
|
||||||
|
position: Option<i32>,
|
||||||
|
read_pos: Option<i32>,
|
||||||
|
ch: Option<i8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new(input_str: String) -> Lexer {
|
||||||
|
let l: Lexer = Lexer {
|
||||||
|
input: input_str,
|
||||||
|
position: None,
|
||||||
|
read_pos: None,
|
||||||
|
ch: None,
|
||||||
|
};
|
||||||
|
l
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_char(l: Lexer) {
|
||||||
|
let read_pos = usize::try_from(l.read_pos.unwrap());
|
||||||
|
if read_pos >= l.input.len() {
|
||||||
|
l.ch = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
mod lexer;
|
||||||
|
mod token;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
struct Token {
|
||||||
|
type_: String,
|
||||||
|
literal: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
const ILLEGAL: &str = "ILLEGAL";
|
||||||
|
const EOF: &str = "EOF";
|
||||||
|
const IDENT: &str = "IDENT";
|
||||||
|
const INT: &str = "INT";
|
||||||
|
const ASSIGN: &str = "=";
|
||||||
|
const PLUS: &str = "+";
|
||||||
|
const COMMA: &str = ",";
|
||||||
|
const SEMICOLON: &str = ";";
|
||||||
|
const LPAREN: &str = "(";
|
||||||
|
const RPAREN: &str = ")";
|
||||||
|
const LBRACE: &str = "{";
|
||||||
|
const RBRACE: &str = "}";
|
||||||
|
const FUNCTION: &str = "FUNCTION";
|
||||||
|
const LET: &str = "LET";
|
||||||
Reference in New Issue
Block a user