Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
459 changes: 459 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "wokelang"
version = "0.1.0"
edition = "2021"
description = "A human-centered, consent-driven programming language"
license = "MIT"
repository = "https://github.com/hyperpolymath/wokelang"

[lib]
name = "wokelang"
path = "src/lib.rs"

[[bin]]
name = "woke"
path = "src/main.rs"

[dependencies]
logos = "0.14"
thiserror = "1.0"
miette = { version = "7.0", features = ["fancy"] }

[dev-dependencies]
pretty_assertions = "1.4"

[profile.release]
lto = true
opt-level = "z"
strip = true

[profile.release-wasm]
inherits = "release"
opt-level = "s"
92 changes: 92 additions & 0 deletions examples/demo.woke
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// WokeLang Demo - showing interpreter capabilities

thanks to {
"You" -> "For trying WokeLang!";
}

to greet(name: String) -> String {
hello "Starting greeting";
remember message = "Hello, " + name + "!";
give back message;
goodbye "Greeting complete";
}

to factorial(n: Int) -> Int {
when n <= 1 {
give back 1;
}
give back n * factorial(n - 1);
}

to fizzbuzz(n: Int) {
repeat n times {
remember i = n;
when i % 15 == 0 {
print("FizzBuzz");
} otherwise {
when i % 3 == 0 {
print("Fizz");
} otherwise {
when i % 5 == 0 {
print("Buzz");
} otherwise {
print(i);
}
}
}
}
}

to main() {
// Basic output
print("Welcome to WokeLang!");
print("");

// Function calls
remember greeting = greet("World");
print(greeting);
print("");

// Arithmetic and loops
print("Counting to 5:");
remember count = 0;
repeat 5 times {
count = count + 1;
print(count);
}
print("");

// Conditionals
remember x = 10;
when x > 5 {
print("x is greater than 5");
} otherwise {
print("x is 5 or less");
}
print("");

// Pattern matching
remember mood = "happy";
decide based on mood {
"happy" -> { print("Celebrating!"); }
"sad" -> { print("Sending comfort..."); }
_ -> { print("Acknowledged."); }
}
print("");

// Recursive function
print("Factorial of 5:");
remember fact = factorial(5);
print(fact);
print("");

// Arrays
remember numbers = [1, 2, 3, 4, 5];
print("Array:");
print(numbers);
print("Length:");
print(len(numbers));

print("");
print("WokeLang demo complete!");
}
47 changes: 47 additions & 0 deletions examples/hello.woke
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// A simple WokeLang program demonstrating key features

thanks to {
"Rust Community" → "For the amazing language tooling";
"You" → "For trying WokeLang";
}

@enthusiastic
to greet(name: String) → String {
hello "Starting the greeting ritual";

remember message = "Hello, " + name + "!";

give back message;

goodbye "Greeting complete";
}

to main() {
// Consent-based camera access
only if okay "camera_access" {
remember photo = takePhoto();
}

// Safe error handling
attempt safely {
remember result = riskyOperation();
} or reassure "Don't worry, we handled that gracefully";

// Loop with natural language
repeat 3 times {
greet("World");
}

// Pattern matching
decide based on mood {
"happy" → { celebrate(); }
"sad" → { comfort(); }
_ → { acknowledge(); }
}
}

// Worker for background tasks
worker dataProcessor {
remember data = fetchData();
processInBackground(data);
}
Loading
Loading