Remove temporary test directories
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
[Package]
|
|
||||||
Name = "enums"
|
|
||||||
Version = "0.1.0"
|
|
||||||
Type = "bin"
|
|
||||||
|
|
||||||
[Build]
|
|
||||||
Output = "Bin"
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
// Enums - Enumeration types
|
|
||||||
import Std::Io::{PrintLine, PrintInt};
|
|
||||||
|
|
||||||
|
|
||||||
enum Color {
|
|
||||||
Red,
|
|
||||||
Green,
|
|
||||||
Blue
|
|
||||||
}
|
|
||||||
|
|
||||||
func ColorName(c: Color) -> String {
|
|
||||||
if c == Color::Red {
|
|
||||||
return "Red";
|
|
||||||
}
|
|
||||||
if c == Color::Green {
|
|
||||||
return "Green";
|
|
||||||
}
|
|
||||||
if c == Color::Blue {
|
|
||||||
return "Blue";
|
|
||||||
}
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let myColor: Color = Color::Green;
|
|
||||||
|
|
||||||
PrintLine("My color is:");
|
|
||||||
PrintLine(ColorName(myColor));
|
|
||||||
PrintLine("Color value:");
|
|
||||||
PrintInt(myColor as int);
|
|
||||||
PrintLine("");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[Package]
|
|
||||||
Name = "factorial"
|
|
||||||
Version = "0.1.0"
|
|
||||||
Type = "bin"
|
|
||||||
|
|
||||||
[Build]
|
|
||||||
Output = "Bin"
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
// Factorial - Recursive function
|
|
||||||
import Std::Io::{PrintLine, PrintInt};
|
|
||||||
|
|
||||||
|
|
||||||
func Factorial(n: int) -> int {
|
|
||||||
if n <= 1 {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return n * Factorial(n - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
PrintLine("Factorials:");
|
|
||||||
|
|
||||||
var i: int = 1;
|
|
||||||
while i <= 10 {
|
|
||||||
let fact: int = Factorial(i);
|
|
||||||
PrintInt(i);
|
|
||||||
PrintLine("! = ");
|
|
||||||
PrintInt(fact);
|
|
||||||
PrintLine("");
|
|
||||||
i = i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[Package]
|
|
||||||
Name = "fib"
|
|
||||||
Version = "0.1.0"
|
|
||||||
Type = "bin"
|
|
||||||
|
|
||||||
[Build]
|
|
||||||
Output = "Bin"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
// Fibonacci - Recursive function with while loop
|
|
||||||
import Std::Io::{PrintLine, PrintInt};
|
|
||||||
|
|
||||||
|
|
||||||
func Fibonacci(n: int) -> int {
|
|
||||||
if n <= 1 {
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
return Fibonacci(n - 1) + Fibonacci(n - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
PrintLine("Fibonacci sequence:");
|
|
||||||
|
|
||||||
var i: int = 0;
|
|
||||||
while i < 10 {
|
|
||||||
let fib: int = Fibonacci(i);
|
|
||||||
PrintInt(fib);
|
|
||||||
PrintLine("");
|
|
||||||
i = i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
import Std::Json;
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let j: JsonValue = Json_Parse("{\"name\":\"Bux\",\"count\":42}");
|
|
||||||
PrintLine(Json_Stringify(j));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
import Std::Json;
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let s: String = "{\"user\":{\"name\":\"Bux\",\"active\":true,\"score\":99.5,\"tags\":[\"fast\",\"safe\",null],\"meta\":{\"v\":1}}}";
|
|
||||||
let j: JsonValue = Json_Parse(s);
|
|
||||||
PrintLine(Json_Stringify(j));
|
|
||||||
|
|
||||||
let user: JsonValue = Json_ObjectGet(j, "user");
|
|
||||||
PrintLine(Json_AsString(Json_ObjectGet(user, "name")));
|
|
||||||
if Json_AsBool(Json_ObjectGet(user, "active")) {
|
|
||||||
PrintLine("yes");
|
|
||||||
} else {
|
|
||||||
PrintLine("no");
|
|
||||||
}
|
|
||||||
|
|
||||||
let tags: JsonValue = Json_ObjectGet(user, "tags");
|
|
||||||
PrintLine(Json_AsString(Json_ArrayGet(tags, 0)));
|
|
||||||
PrintLine(Json_AsString(Json_ArrayGet(tags, 1)));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
struct JsonValue {
|
|
||||||
tag: int,
|
|
||||||
strVal: String,
|
|
||||||
numVal: float64
|
|
||||||
}
|
|
||||||
|
|
||||||
extern func bux_alloc(size: uint) -> *void;
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let cap: uint = 4;
|
|
||||||
let data: *JsonValue = bux_alloc(cap * 32) as *JsonValue;
|
|
||||||
data[0] = JsonValue { tag: 1, strVal: "first", numVal: 1.0 };
|
|
||||||
data[1] = JsonValue { tag: 2, strVal: "second", numVal: 2.0 };
|
|
||||||
PrintLine(data[0].strVal);
|
|
||||||
PrintLine(data[1].strVal);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
struct JsonValue {
|
|
||||||
tag: int,
|
|
||||||
strVal: String,
|
|
||||||
numVal: float64
|
|
||||||
}
|
|
||||||
|
|
||||||
extern func bux_alloc(size: uint) -> *void;
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let cap: uint = 4;
|
|
||||||
let data: *JsonValue = bux_alloc(cap * sizeof(JsonValue)) as *JsonValue;
|
|
||||||
data[0] = JsonValue { tag: 1, strVal: "first", numVal: 1.0 };
|
|
||||||
PrintLine(data[0].strVal);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
struct JsonValue {
|
|
||||||
tag: int,
|
|
||||||
strVal: String,
|
|
||||||
numVal: float64
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
var a: JsonValue = JsonValue { tag: 1, strVal: "hello", numVal: 3.14 };
|
|
||||||
var b: JsonValue = a;
|
|
||||||
b.strVal = "world";
|
|
||||||
PrintLine(a.strVal);
|
|
||||||
PrintLine(b.strVal);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
import Std::Array::{Array};
|
|
||||||
|
|
||||||
enum JsonValue {
|
|
||||||
JsonNull,
|
|
||||||
JsonBool(bool),
|
|
||||||
JsonNumber(float64),
|
|
||||||
JsonString(String),
|
|
||||||
JsonArray(Array<JsonValue>),
|
|
||||||
JsonObject(Map<String, JsonValue>)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: JsonNull };
|
|
||||||
PrintLine("ok");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
import Std::Array::{Array};
|
|
||||||
import Std::Map::{Map};
|
|
||||||
|
|
||||||
enum JsonValue {
|
|
||||||
JsonNull,
|
|
||||||
JsonBool(bool),
|
|
||||||
JsonNumber(float64),
|
|
||||||
JsonString(String),
|
|
||||||
JsonArray(Array<*JsonValue>),
|
|
||||||
JsonObject(Map<String, *JsonValue>)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: JsonNull };
|
|
||||||
PrintLine("ok");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
enum JsonValue {
|
|
||||||
JsonNull,
|
|
||||||
JsonBool(bool),
|
|
||||||
JsonNumber(float64),
|
|
||||||
JsonString(String)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: JsonNull };
|
|
||||||
PrintLine("ok");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
enum JsonValue {
|
|
||||||
JsonNull,
|
|
||||||
JsonBool(bool),
|
|
||||||
JsonNumber(float64),
|
|
||||||
JsonString(String)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: JsonValue_JsonNull };
|
|
||||||
PrintLine("ok");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
import Std::Array::{Array};
|
|
||||||
import Std::Map::{Map};
|
|
||||||
|
|
||||||
enum JsonValue {
|
|
||||||
JsonNull,
|
|
||||||
JsonBool(bool),
|
|
||||||
JsonNumber(float64),
|
|
||||||
JsonString(String),
|
|
||||||
JsonArray(Array<JsonValue>),
|
|
||||||
JsonObject(Map<String, JsonValue>)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: JsonValue_JsonNull };
|
|
||||||
PrintLine("ok");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
struct JsonArray {
|
|
||||||
data: **JsonValue,
|
|
||||||
len: uint,
|
|
||||||
cap: uint
|
|
||||||
}
|
|
||||||
|
|
||||||
struct JsonObjectEntry {
|
|
||||||
key: String,
|
|
||||||
value: *JsonValue
|
|
||||||
}
|
|
||||||
|
|
||||||
struct JsonObject {
|
|
||||||
data: *JsonObjectEntry,
|
|
||||||
len: uint,
|
|
||||||
cap: uint
|
|
||||||
}
|
|
||||||
|
|
||||||
enum JsonValue {
|
|
||||||
JsonNull,
|
|
||||||
JsonBool(bool),
|
|
||||||
JsonNumber(float64),
|
|
||||||
JsonString(String),
|
|
||||||
JsonArray(JsonArray),
|
|
||||||
JsonObject(JsonObject)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: JsonValue_JsonNull };
|
|
||||||
PrintLine("ok");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
struct JsonValue {
|
|
||||||
tag: int,
|
|
||||||
strVal: String,
|
|
||||||
next: *JsonValue
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: 0, strVal: "hello", next: null };
|
|
||||||
PrintLine(v.strVal);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
struct JsonArray {
|
|
||||||
data: *JsonValue,
|
|
||||||
len: uint,
|
|
||||||
cap: uint
|
|
||||||
}
|
|
||||||
|
|
||||||
enum JsonValue {
|
|
||||||
JsonNull,
|
|
||||||
JsonBool(bool),
|
|
||||||
JsonNumber(float64),
|
|
||||||
JsonString(String),
|
|
||||||
JsonArrayPtr(*JsonArray)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: JsonValue_JsonNull };
|
|
||||||
PrintLine("ok");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
struct JsonValue {
|
|
||||||
tag: int,
|
|
||||||
boolVal: bool,
|
|
||||||
numVal: float64,
|
|
||||||
strVal: String,
|
|
||||||
arrData: *JsonValue,
|
|
||||||
arrLen: uint,
|
|
||||||
objKeys: *String,
|
|
||||||
objValues: *JsonValue,
|
|
||||||
objLen: uint
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: 0, boolVal: false, numVal: 0.0, strVal: "hello", arrData: null, arrLen: 0, objKeys: null, objValues: null, objLen: 0 };
|
|
||||||
PrintLine(v.strVal);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[Package]
|
|
||||||
Name = "hello"
|
|
||||||
Version = "0.1.0"
|
|
||||||
Type = "bin"
|
|
||||||
|
|
||||||
[Build]
|
|
||||||
Output = "Bin"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
// Hello World - Basic Bux program
|
|
||||||
import Std::Io::{PrintLine, PrintInt};
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
PrintLine("Hello, Bux!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import Std::Io::{PrintLine, PrintInt};
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let s: String = "hello";
|
|
||||||
let c: char8 = s[0];
|
|
||||||
PrintInt(c as int);
|
|
||||||
PrintLine("");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[Package]
|
|
||||||
Name = "strings"
|
|
||||||
Version = "0.1.0"
|
|
||||||
Type = "bin"
|
|
||||||
|
|
||||||
[Build]
|
|
||||||
Output = "Bin"
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
// Strings - String manipulation with Std::String
|
|
||||||
import Std::Io::{PrintLine, PrintInt};
|
|
||||||
import Std::String::{String_Len, String_Eq, String_Concat};
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let hello: String = "Hello";
|
|
||||||
let world: String = "World";
|
|
||||||
|
|
||||||
PrintLine("String operations:");
|
|
||||||
|
|
||||||
// Length
|
|
||||||
PrintLine("Length of 'Hello':");
|
|
||||||
PrintInt(String_Len(hello));
|
|
||||||
PrintLine("");
|
|
||||||
|
|
||||||
// Concatenation
|
|
||||||
let greeting: String = String_Concat(hello, ", ");
|
|
||||||
let greeting2: String = String_Concat(greeting, world);
|
|
||||||
let full: String = String_Concat(greeting2, "!");
|
|
||||||
|
|
||||||
PrintLine("Concatenated:");
|
|
||||||
PrintLine(full);
|
|
||||||
|
|
||||||
// Equality
|
|
||||||
if String_Eq(hello, "Hello") {
|
|
||||||
PrintLine("'Hello' equals 'Hello'");
|
|
||||||
}
|
|
||||||
|
|
||||||
if !String_Eq(hello, world) {
|
|
||||||
PrintLine("'Hello' does not equal 'World'");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
[Package]
|
|
||||||
Name = "structs"
|
|
||||||
Version = "0.1.0"
|
|
||||||
Type = "bin"
|
|
||||||
|
|
||||||
[Build]
|
|
||||||
Output = "Bin"
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
// Structs - Basic struct usage
|
|
||||||
import Std::Io::{PrintLine, PrintInt};
|
|
||||||
|
|
||||||
|
|
||||||
struct Point {
|
|
||||||
x: int;
|
|
||||||
y: int;
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddPoints(a: Point, b: Point) -> Point {
|
|
||||||
let result: Point = Point { x: a.x + b.x, y: a.y + b.y };
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let p1: Point = Point { x: 10, y: 20 };
|
|
||||||
let p2: Point = Point { x: 5, y: 15 };
|
|
||||||
let sum: Point = AddPoints(p1, p2);
|
|
||||||
|
|
||||||
PrintLine("Point sum:");
|
|
||||||
PrintLine("x = ");
|
|
||||||
PrintInt(sum.x);
|
|
||||||
PrintLine("");
|
|
||||||
PrintLine("y = ");
|
|
||||||
PrintInt(sum.y);
|
|
||||||
PrintLine("");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
[Package]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import Std::Io::{PrintLine};
|
|
||||||
|
|
||||||
union JsonData {
|
|
||||||
boolVal: bool,
|
|
||||||
numVal: float64,
|
|
||||||
strVal: String
|
|
||||||
}
|
|
||||||
|
|
||||||
struct JsonValue {
|
|
||||||
tag: int,
|
|
||||||
data: JsonData
|
|
||||||
}
|
|
||||||
|
|
||||||
func Main() -> int {
|
|
||||||
let v: JsonValue = JsonValue { tag: 0, data: JsonData { strVal: "hello" } };
|
|
||||||
PrintLine(v.data.strVal);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user