diff --git a/ToDo.md b/ToDo.md index 0230b72..a8cabc7 100644 --- a/ToDo.md +++ b/ToDo.md @@ -4,7 +4,7 @@ * special cases (like if ... exitWith) * sqf: ... sqf whitespace * solution for build in commands which do not require left values -* pretty/minified printing +* ~~pretty/minified printing~~ * usage * recursive compiling * concurrent compiling diff --git a/in/simple.asl b/in/simple.asl index 994f4a7..26978df 100644 --- a/in/simple.asl +++ b/in/simple.asl @@ -2,4 +2,4 @@ func foo(a, b) { return a > b; } -var x = foo(); +var x = foo(1, 2); diff --git a/src/asl/parser.go b/src/asl/parser.go index 13f42a1..52e5bf6 100644 --- a/src/asl/parser.go +++ b/src/asl/parser.go @@ -151,7 +151,6 @@ func parseFor() { expect(";") appendOut("}, {", false) parseExpression(true) - expect(";") appendOut("}] do {", true) expect("{") parseBlock() diff --git a/src/asl/parser_test.go b/src/asl/parser_test.go index e198c89..812ceb3 100644 --- a/src/asl/parser_test.go +++ b/src/asl/parser_test.go @@ -1,5 +1,85 @@ package asl import ( - + "testing" + "io/ioutil" ) + +func TestParserDeclaration(t *testing.T) { + got := getCompiled(t, "test/tokenizer_var.asl") + want := "x = 1;\n" + + equal(t, got, want) +} + +func TestParserAssignment(t *testing.T) { + got := getCompiled(t, "test/parser_assignment.asl") + want := "x = 1;\n" + + equal(t, got, want) +} + +func TestParserIf(t *testing.T) { + got := getCompiled(t, "test/tokenizer_if.asl") + want := "if (a []") + fmt.Println("-v (optional) shows asl version") + fmt.Println("-r (optional) recursivly compile all asl files in folder") + fmt.Println("-pretty (optional) activates pretty printing") + fmt.Println(" file or directory to compile") + fmt.Println(" (optional) output file/folder, if not set, files will be created alongside their asl files") } func main() { diff --git a/test/parser_assign_result.asl b/test/parser_assign_result.asl new file mode 100644 index 0000000..c6803a7 --- /dev/null +++ b/test/parser_assign_result.asl @@ -0,0 +1,2 @@ +var x = foo(1, 2, 3); +y = bar(1, 2, 3); diff --git a/test/parser_assignment.asl b/test/parser_assignment.asl new file mode 100644 index 0000000..7ea4737 --- /dev/null +++ b/test/parser_assignment.asl @@ -0,0 +1 @@ +x = 1; \ No newline at end of file