forked from AbleScript/ablescript
added base 55
This commit is contained in:
parent
cc66d0b63a
commit
1e701f73ab
110
Cargo.lock
generated
110
Cargo.lock
generated
|
@ -1,5 +1,115 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "able-lang"
|
name = "able-lang"
|
||||||
version = "0.1.0"
|
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"
|
||||||
|
|
|
@ -7,3 +7,4 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap="*"
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
var hello = "world";
|
var hello = "world";
|
||||||
print hello;
|
hello print;
|
||||||
|
|
61
src/base_55.rs
Normal file
61
src/base_55.rs
Normal file
|
@ -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,
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
pub fn run_file(filepath: &String) {
|
|
||||||
println!("{}{}", filepath, PI);
|
|
||||||
}
|
|
43
src/main.rs
43
src/main.rs
|
@ -1,22 +1,29 @@
|
||||||
use std::env;
|
extern crate clap;
|
||||||
pub use std::f64::consts::{
|
use clap::{App, Arg};
|
||||||
PI, // For the heretics among us
|
|
||||||
TAU,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod file_load;
|
|
||||||
mod prompt;
|
|
||||||
mod tokens;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut args: Vec<String> = env::args().collect();
|
let matches = App::new("My Super Program")
|
||||||
args.remove(0);
|
.version("1.0")
|
||||||
if args.len() > 1 {
|
.author("Able <abl3theabove@gmail.com>")
|
||||||
println!("Usage: alang [script]");
|
.about("Does awesome things")
|
||||||
} else if args.len() == 1 {
|
.arg(
|
||||||
let filepath = &args[0];
|
Arg::with_name("file")
|
||||||
file_load::run_file(filepath);
|
.short("f")
|
||||||
} else {
|
.long("file")
|
||||||
prompt::prompt();
|
.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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
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() {}
|
|
|
@ -1,48 +1,13 @@
|
||||||
pub enum Token {
|
pub enum tokens {
|
||||||
// Single-character tokens.
|
LEFT_PARENTHESIS, // (
|
||||||
LEFT_PAREN, //
|
RIGHT_PARENTHESIS, // )
|
||||||
RIGHT_PAREN,
|
LEFT_BRACKET, // [
|
||||||
LEFT_BRACE,
|
RIGHT_BRACKET, // ]
|
||||||
RIGHT_BRACE,
|
LEFT_BRACE, // {
|
||||||
COMMA,
|
RIGHT_BRACE, // }
|
||||||
DOT,
|
CHAR, // Base52 based character
|
||||||
MINUS,
|
VARIABLE, // Variable bro
|
||||||
PLUS,
|
BOOLEAN, // True, False
|
||||||
SEMICOLON,
|
ABOOLEAN, // Always, Sometimes, Never
|
||||||
SLASH,
|
PRINT, // Prints the preceding things
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue