Skip to content

Commit

Permalink
0.1.2 Debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectricS01 committed Mar 22, 2024
1 parent 950dc62 commit cbf428c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
30 changes: 9 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[package]
name = "walterlang"
version = "0.1.1"
version = "0.1.2"
authors = ["ElectricS01<[email protected]>"]
edition = "2021"
rust-version = "1.56"
description = "WalterLang, an interpreted typeless language built with Rust"
repository = "https://github.com/ElectricS01/WalterLang"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
regex = "1.10.3"
regex = "1.7.3"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The official repo for the WalterLang, an interpreted typeless language built wit
### Feature Checklist
- [x] Comments
- [ ] Multi-line comments
- [ ] `-d` Debug mode
- [x] `-d` Debug mode
- [x] Parsing a file name
- [ ] WalterShell

24 changes: 21 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// main.rs
// Created 12/2/2024
// Modified 19/3/2024
// Modified 22/3/2024
// Created by ElectricS01

use regex::Regex;
Expand All @@ -10,8 +10,18 @@ use std::fs;
use std::path::Path;

fn main() {
let args: Vec<String> = env::args().collect();
let mut args: Vec<String> = env::args().collect();

let file_path;
let debug;

let index = args.iter().position(|n| n == &"-d".to_string());
if index.is_some() {
args.remove(index.expect("Could not find index of debug tag"));
debug = true;
} else {
debug = false;
}

if args.len() < 2 {
if Path::new("example.wltr").exists() {
Expand All @@ -28,7 +38,11 @@ fn main() {
let contents = fs::read_to_string(file_path).expect("Failed to read the file");

let multi_comment_regex = Regex::new(r"///.*?///").unwrap();
let comment_regex = Regex::new(r"[^\/]\/\/[^\/]+.*$").unwrap();
let comment_regex = Regex::new(r"[^/]//[^/]+.*$").unwrap();

if debug == true {
println!("{}", contents);
}

let mut vars: HashMap<String, String> = HashMap::new();

Expand All @@ -48,6 +62,10 @@ fn main() {
}

for line in trimmed_contents.lines() {
if debug == true {
println!("line: {}", line);
}

let mut line: Vec<&str> = line.split(' ').collect();

for _i in 0..line.len() - 1 {
Expand Down

0 comments on commit cbf428c

Please sign in to comment.