Skip to content

Commit cbdc77e

Browse files
Added namespaces & imports.
Added namespaces & imports. Added a basic CLI for running a file as main.
1 parent 96e099a commit cbdc77e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+900
-215
lines changed

.idea/codeStyles/Project.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.lock

+244
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
name = "evilang"
33
version = "0.1.0"
44
edition = "2021"
5+
authors = ["Aryan Chudasama"]
56

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

89
[dependencies]
910
anyhow = { version = "1.0.71", features = ["backtrace"] }
1011
backtrace = "0.3.68"
12+
clap = { version = "4.3.21", features = ["derive"] }
1113
const-str = "0.5.6"
1214
debug-ignore = "1.0.5"
1315
delegate = "0.10.0"

resources/tests/import_test/main.evil

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import "./sub/sub_file_1.evil" as sub_f1;
2+
import "./sub/sub_2/sub_2_file_1.evil" as sub2_f1;
3+
import "./sub/point.evil" as point;
4+
5+
push_res_stack(sub_f1.value == "sub.sub_file_1");
6+
push_res_stack(sub2_f1.main_adj.main_adj_val == "main_adj_v");
7+
8+
push_res_stack(point.Point.ORIGIN->calc() == 0);
9+
10+
let p = new point.Point(10, 12);
11+
push_res_stack(p->calc() == 22);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let main_adj_val = "main_adj_v";
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Point {
2+
fn constructor(this, x, y) {
3+
this.x = x;
4+
this.y = y;
5+
}
6+
7+
fn calc(this) {
8+
return this.x + this.y;
9+
}
10+
}
11+
12+
namespace Point {
13+
let ORIGIN = new Point(0, 0);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "../../main_adj.evil" as main_adj;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let value = "sub.sub_file_1";

src/cli/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use clap::Parser;
2+
3+
#[derive(Parser, Debug)]
4+
#[command(author, version, about, long_about = None)]
5+
pub struct CliArguments {
6+
#[arg(long, short, help = "File to execute", value_name = "FILE")]
7+
pub file: Option<String>,
8+
}

src/evilang_files/main.evil

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import "./sub/sub_file_1.evil" as sub_f1;
2+
import "./sub/sub_2/sub_2_file_1.evil" as sub2_f1;
3+
4+
push_res_stack(sub_f1.value);
5+
push_res_stack(sub2_f1.main_adj.main_adj_val);

src/evilang_files/main_adj.evil

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let main_adj_val = "main_adj_v";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "../../main_adj.evil" as main_adj;

src/evilang_files/sub/sub_file_1.evil

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let value = "sub.sub_file_1";

0 commit comments

Comments
 (0)