mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Issue #2 expression fix, updated readme.
This commit is contained in:
@@ -61,6 +61,12 @@ var number = 123;
|
||||
var floatingPointNumber = 1.23;
|
||||
var string = "string";
|
||||
var array = [1, 2, 3];
|
||||
|
||||
// accessing array elements:
|
||||
var one = array[0];
|
||||
|
||||
// accessing using a statement:
|
||||
var zwo = array[33/3-2];
|
||||
```
|
||||
|
||||
### Control structures
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var array = [1, 2, 3];
|
||||
var x = array[0];
|
||||
|
||||
if array[1] == 2 {
|
||||
if array[(1-1)+10/10] == 2 {
|
||||
foo();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
array = [1,2,3];
|
||||
x = (array select 0);
|
||||
if ((array select 1)==2) then {
|
||||
if ((array select (1-1)+10/10)==2) then {
|
||||
[] call foo;
|
||||
};
|
||||
|
||||
@@ -424,7 +424,7 @@ func parseIdentifier() string {
|
||||
output += "("+get().token
|
||||
next()
|
||||
expect("[")
|
||||
output += " select "+parseExpression(false)+")"
|
||||
output += " select ("+parseExpression(false)+"))"
|
||||
expect("]")
|
||||
} else if accept("!") || accept("-") {
|
||||
output = get().token
|
||||
|
||||
@@ -131,7 +131,7 @@ func TestParserWaitUntil(t *testing.T) {
|
||||
|
||||
func TestParserArray(t *testing.T) {
|
||||
got := getCompiled(t, "test/parser_array.asl")
|
||||
want := "x = [1,2,3];\ny = (x select 1);\n"
|
||||
want := "x = [1,2,3];\ny = (x select (1));\n"
|
||||
|
||||
equal(t, got, want)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user