Skip to content

Commit

Permalink
Fix last function in the wltr file not executing
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectricS01 committed Apr 9, 2024
1 parent 502b779 commit a150ead
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 84 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@ name: Rust

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.56
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.60

- name: Build
run: cargo +1.56 build --verbose
- name: Run tests
run: cargo + 1.56 test --verbose
- name: Build
run: cargo +1.60 build --verbose
- name: Run tests
run: cargo + 1.60 test --verbose
81 changes: 22 additions & 59 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "walterlang"
version = "0.2.0"
version = "0.2.1"
authors = ["ElectricS01<[email protected]>"]
edition = "2021"
rust-version = "1.56"
rust-version = "1.60"
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]
home = "0.5.9"
home = "0.4.2"
regex = "1.7.3"
10 changes: 9 additions & 1 deletion example.wltr
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ Um print Print 1 Ok Um print Print 2 Ok
Um print 6. Ok
Set MultilineVar to This is a
multiline variable Ok
Um print MultilineVar
Um print MultilineVar Ok

// Test functions
Um print 7. Ok
Set TestFunction to
Um print This is a function Ok
Ok

TestFunction

18 changes: 9 additions & 9 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 26/3/2024
// Modified 9/4/2024
// Created by ElectricS01

use home::home_dir;
Expand All @@ -9,8 +9,7 @@ use std::collections::HashMap;
use std::env;
use std::fs;
use std::fs::OpenOptions;
use std::io;
use std::io::Write;
use std::io::{self, Write};
use std::path::Path;

fn main() {
Expand Down Expand Up @@ -120,12 +119,7 @@ fn execute(debug: bool, contents: String, vars: &mut HashMap<String, String>) {
for _i in 0..line.len() {
if line[0].trim().is_empty() {
break;
} else if "Um" == &*line[0] || "Set" == &*line[0] {
if function == "Um" {
um(read_buffer.split(' ').collect(), vars);
} else if function == "Set" {
set(read_buffer.split(' ').collect(), vars);
}
} else if ("Um" == &*line[0] || "Set" == &*line[0]) && function == String::new() {
read_buffer = String::new();
function = line[0].to_string();
} else if "Ok" == &*line[0] && function != "" {
Expand All @@ -152,6 +146,12 @@ fn execute(debug: bool, contents: String, vars: &mut HashMap<String, String>) {
read_buffer += "\n"
}
}

if function == "Um" {
um(read_buffer.split(' ').collect(), vars);
} else if function == "Set" {
set(read_buffer.split(' ').collect(), vars);
}
}

fn set(line: Vec<&str>, vars: &mut HashMap<String, String>) {
Expand Down

0 comments on commit a150ead

Please sign in to comment.