From 1e701f73abb24657260f2ba599a5139fa3d1a14c Mon Sep 17 00:00:00 2001 From: able Date: Sun, 11 Apr 2021 11:47:35 -0500 Subject: [PATCH] added base 55 --- Cargo.lock | 110 ++++++++++++++++++++++++++++++++ Cargo.toml | 1 + able-lang-test/hello_world.able | 2 +- src/base_55.rs | 61 ++++++++++++++++++ src/file_load.rs | 3 - src/main.rs | 43 +++++++------ src/prompt.rs | 20 ------ src/scanner.rs | 15 ----- src/tokens.rs | 59 ++++------------- 9 files changed, 210 insertions(+), 104 deletions(-) create mode 100644 src/base_55.rs delete mode 100644 src/file_load.rs delete mode 100644 src/prompt.rs diff --git a/Cargo.lock b/Cargo.lock index 769f7f3..4274890 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,115 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "able-lang" version = "0.1.0" +dependencies = [ + "clap", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index e00d093..b550ba2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap="*" diff --git a/able-lang-test/hello_world.able b/able-lang-test/hello_world.able index e7b775d..d32b8b8 100644 --- a/able-lang-test/hello_world.able +++ b/able-lang-test/hello_world.able @@ -1,2 +1,2 @@ var hello = "world"; -print hello; +hello print; diff --git a/src/base_55.rs b/src/base_55.rs new file mode 100644 index 0000000..60486da --- /dev/null +++ b/src/base_55.rs @@ -0,0 +1,61 @@ +pub fn h78() { + let x = 'b'; + match x.char() { + ' ' => 0, + 'a' => 1, + 'b' => 2, + 'c' => 3, + 'd' => 4, + 'e' => 5, + 'f' => 6, + 'g' => 7, + 'h' => 8, + 'i' => 9, + 'j' => 10, + 'k' => 11, + 'l' => 12, + 'm' => 13, + 'n' => 14, + 'o' => 15, + 'p' => 16, + 'q' => 17, + 'r' => 18, + 'S' => 19, + 't' => 20, + 'u' => 21, + 'v' => 22, + 'w' => 23, + 'x' => 24, + 'y' => 25, + 'z' => 26, + 'A' => 1 + 26, + 'B' => 2 + 26, + 'C' => 3 + 26, + 'D' => 4 + 26, + 'E' => 5 + 26, + 'F' => 6 + 26, + 'G' => 7 + 26, + 'H' => 8 + 26, + 'I' => 9 + 26, + 'J' => 10 + 26, + 'K' => 11 + 26, + 'L' => 12 + 26, + 'M' => 13 + 26, + 'N' => 14 + 26, + 'O' => 15 + 26, + 'P' => 16 + 26, + 'Q' => 17 + 26, + 'R' => 18 + 26, + 'S' => 19 + 26, + 'T' => 20 + 26, + 'U' => 21 + 26, + 'V' => 22 + 26, + 'W' => 23 + 26, + 'X' => 24 + 26, + 'Y' => 25 + 26, + 'Z' => 26 + 26, + '/' => 53, + '\\' => 54, + '.' => 55, + } +} diff --git a/src/file_load.rs b/src/file_load.rs deleted file mode 100644 index 9df50f3..0000000 --- a/src/file_load.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn run_file(filepath: &String) { - println!("{}{}", filepath, PI); -} diff --git a/src/main.rs b/src/main.rs index d024d28..b3c8ea2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,22 +1,29 @@ -use std::env; -pub use std::f64::consts::{ - PI, // For the heretics among us - TAU, -}; - -mod file_load; -mod prompt; -mod tokens; +extern crate clap; +use clap::{App, Arg}; fn main() { - let mut args: Vec = 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(); + let matches = App::new("My Super Program") + .version("1.0") + .author("Able ") + .about("Does awesome things") + .arg( + Arg::with_name("file") + .short("f") + .long("file") + .value_name("FILE") + .help("Sets a custom config file") + .takes_value(true), + ) + .get_matches(); + + match matches.value_of("file") { + Some(file_path) => { + println!("{}", file_path); + // Start parsing that file + } + None => { + println!("hi"); + //start the prompt + } } } diff --git a/src/prompt.rs b/src/prompt.rs deleted file mode 100644 index 515ccd5..0000000 --- a/src/prompt.rs +++ /dev/null @@ -1,20 +0,0 @@ -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); -} diff --git a/src/scanner.rs b/src/scanner.rs index 9d1d942..e69de29 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -1,15 +0,0 @@ -mod tokens; -pub struct Scanner { - pub start: u64, - pub current: u64, - pub line: u64, -} - -pub fn scan() { - let tokens: Vec = vec![]; - - scan_token(); - - // -} -fn scan_token() {} diff --git a/src/tokens.rs b/src/tokens.rs index 414c182..1e24f71 100644 --- a/src/tokens.rs +++ b/src/tokens.rs @@ -1,48 +1,13 @@ -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, +pub enum tokens { + LEFT_PARENTHESIS, // ( + RIGHT_PARENTHESIS, // ) + LEFT_BRACKET, // [ + RIGHT_BRACKET, // ] + LEFT_BRACE, // { + RIGHT_BRACE, // } + CHAR, // Base52 based character + VARIABLE, // Variable bro + BOOLEAN, // True, False + ABOOLEAN, // Always, Sometimes, Never + PRINT, // Prints the preceding things }