From bc1eb42af459115aad06dd019783c22b3c592a0f Mon Sep 17 00:00:00 2001 From: able Date: Tue, 13 Apr 2021 18:01:19 -0500 Subject: [PATCH] variable things added --- src/main.rs | 4 ++++ src/variables.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/variables.rs diff --git a/src/main.rs b/src/main.rs index 5d8f61a7..73bcfea7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,11 +2,14 @@ mod base_55; mod parser; mod scanner; mod tokens; +mod variables; use clap::{App, Arg}; use scanner::Scanner; fn main() { + variables::test(); + let matches = App::new("AbleScript") .version(env!("CARGO_PKG_VERSION")) .author("Able ") @@ -20,6 +23,7 @@ fn main() { .takes_value(true), ) .get_matches(); + match matches.value_of("file") { Some(file_path) => { // Read file diff --git a/src/variables.rs b/src/variables.rs new file mode 100644 index 00000000..df9cd067 --- /dev/null +++ b/src/variables.rs @@ -0,0 +1,32 @@ +use std::collections::HashMap; + +#[derive(Debug)] +enum Value { + Str(String), + Int(i32), + Bool(bool), + //TODO(Able): Add abool and other variable types +} + +#[derive(Debug)] +pub struct Variable { + melo: bool, + value: Value, +} +pub fn test() { + let mut map = HashMap::new(); + let a = Variable { + melo: false, + value: Value::Str("1".to_string()), + }; + let b = Variable { + melo: false, + value: Value::Int(2), + }; + map.insert("a", a); + map.insert("b", b); + + for (key, value) in &map { + println!("{}: {:?}", key, value); + } +}