AbleLang is coming together boys :) and girls and enby pals

pull/11/head
able 2021-04-08 16:11:20 -05:00
commit cc66d0b63a
9 changed files with 125 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

5
Cargo.lock generated Normal file
View File

@ -0,0 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "able-lang"
version = "0.1.0"

9
Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "able-lang"
version = "0.1.0"
authors = ["able <abl3theabove@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -0,0 +1,2 @@
var hello = "world";
print hello;

3
src/file_load.rs Normal file
View File

@ -0,0 +1,3 @@
pub fn run_file(filepath: &String) {
println!("{}{}", filepath, PI);
}

22
src/main.rs Normal file
View File

@ -0,0 +1,22 @@
use std::env;
pub use std::f64::consts::{
PI, // For the heretics among us
TAU,
};
mod file_load;
mod prompt;
mod tokens;
fn main() {
let mut args: Vec<String> = env::args().collect();
args.remove(0);
if args.len() > 1 {
println!("Usage: alang [script]");
} else if args.len() == 1 {
let filepath = &args[0];
file_load::run_file(filepath);
} else {
prompt::prompt();
}
}

20
src/prompt.rs Normal file
View File

@ -0,0 +1,20 @@
use std::io::{stdin, stdout, Write};
pub fn prompt() {
loop {
print! {"> "};
stdout().flush().unwrap();
let mut input = String::new();
stdin().read_line(&mut input).unwrap();
if input.trim() == "quit" {
break;
} else {
run(input);
}
}
}
fn run(s: String) {
println!("{}", s);
}

15
src/scanner.rs Normal file
View File

@ -0,0 +1,15 @@
mod tokens;
pub struct Scanner {
pub start: u64,
pub current: u64,
pub line: u64,
}
pub fn scan() {
let tokens: Vec<tokens::Token> = vec![];
scan_token();
//
}
fn scan_token() {}

48
src/tokens.rs Normal file
View File

@ -0,0 +1,48 @@
pub enum Token {
// Single-character tokens.
LEFT_PAREN, //
RIGHT_PAREN,
LEFT_BRACE,
RIGHT_BRACE,
COMMA,
DOT,
MINUS,
PLUS,
SEMICOLON,
SLASH,
STAR,
// One or two character tokens.
BANG,
BANG_EQUAL,
EQUAL,
EQUAL_EQUAL,
GREATER,
GREATER_EQUAL,
LESS,
LESS_EQUAL,
// Literals.
IDENTIFIER,
STRING,
NUMBER,
// Keywords.
AND,
CLASS,
ELSE,
FALSE,
FUN,
FOR,
IF,
NIL,
OR,
PRINT,
RETURN,
SUPER,
THIS,
TRUE,
VAR,
WHILE,
EOF,
}