diff --git a/examples-output.txt b/examples-output.txt new file mode 100644 index 0000000..4be1e5f --- /dev/null +++ b/examples-output.txt @@ -0,0 +1,55 @@ +fddl examples.fddl +Func +Identifier("main") +LeftParen +RightParen +LeftBrace +Comment(" print statement") +Print +LeftParen +StringLiteral("hello, world in fddl") +RightParen +Semicolon +Comment(" variable declaration") +Let +Identifier("y") +Equal +Number(5.0) +Semicolon +Comment(" if statement") +If +LeftParen +Identifier("x") +Greater +Number(10.0) +RightParen +LeftBrace +Print +LeftParen +StringLiteral("x is greater than 10") +RightParen +Semicolon +RightBrace +Comment(" while loop") +While +LeftParen +Identifier("x") +Less +Number(100.0) +RightParen +LeftBrace +Print +LeftParen +Identifier("x") +RightParen +Semicolon +Let +Identifier("x") +Equal +Identifier("x") +Plus +Number(1.0) +Semicolon +RightBrace +RightBrace +EOF diff --git a/index.html b/index.html index 6a6d3dd..310d869 100644 --- a/index.html +++ b/index.html @@ -61,22 +61,25 @@

To parse a fddl script:

cargo run path/to/script.fddl
-

Examples

-

Your basic "hello, world":

+

Examples:

func main() {
-    print("hello, world in fddl");
-}
-

Defining a function inside a module, squaring a number:

-
# This is a sample module
-
-module math {
-
-    // Computes the square of a number
-    func square(x) => x ^ 2;
-}
-
-sym number = 5;
-print(`The square of $number is ${math.square($number)}`);
+ // print statement + print("hello, world in fddl"); + + // variable declaration + let y = 5; + + // if statement + if (x > 10) { + print("x is greater than 10"); + } + + // while loop + while (x < 100) { + print(x); + let x = x + 1; + } + }

At least for right now. I still want to do something odd.

Running the Project

@@ -86,6 +89,7 @@ print(`The square of $number is ${math.square($number)}`); cargo test cargo run

Again, cargo run only starts the REPL for testing.

+

running fddl examples.fddl (from the git repo) produces the following.

Goals and Projections:

@@ -98,11 +102,12 @@ cargo run

Parser:

Compiler:

Comments: