diff options
-rw-r--r-- | doc/lang.txt | 6 | ||||
-rw-r--r-- | lib/crypto/x25519.myr | 16 | ||||
-rw-r--r-- | parse/gram.y | 4 | ||||
-rw-r--r-- | test/arraylit.myr | 6 |
4 files changed, 18 insertions, 14 deletions
diff --git a/doc/lang.txt b/doc/lang.txt index 4b7c482..0a38c00 100644 --- a/doc/lang.txt +++ b/doc/lang.txt @@ -998,7 +998,7 @@ TABLE OF CONTENTS: tuplit: "(" tuplelts ")" structelts: ("." ident "=" expr)+ - arrayelts: (expr ":" expr | expr)* + arrayelts: ("." "[" expr "]" "=" expr | expr)* tupelts: expr ("," expr)* [","] Sequence literals are used to initialize either a structure @@ -1026,7 +1026,7 @@ TABLE OF CONTENTS: An unindexed initializer sequence is simply a comma separated list of values. An indexed initializer sequence contains a - '#number=value' comma separated sequence, which indicates the + '.[index]=value' comma separated sequence, which indicates the index of the array into which the value is inserted. A named initializer sequence contains a comma separated list of '.name=value' pairs. @@ -1039,7 +1039,7 @@ TABLE OF CONTENTS: [.a = 42, .b="str"] Example: Array literal: - [1,2,3], [2:3, 1:2, 0:1], [] + [1,2,3], [.[2] = 3, .[1] = 2, .[0] = 1], [] Example: Tuple literals: (1,), (1,'b',"three") diff --git a/lib/crypto/x25519.myr b/lib/crypto/x25519.myr index e4178e6..d267338 100644 --- a/lib/crypto/x25519.myr +++ b/lib/crypto/x25519.myr @@ -477,14 +477,14 @@ const fmonty = {x2, z2, x3, z3, x, z, xprime, zprime, qmqp * q: a point of the curve (short form) */ const cmult = {resultx, resultz, n, q - var a : felem[19] = [0:0, 18:0] - var b : felem[19] = [0:1, 18:0] - var c : felem[19] = [0:1, 18:0] - var d : felem[19] = [0:0, 18:0] - var e : felem[19] = [0:0, 18:0] - var f : felem[19] = [0:1, 18:0] - var g : felem[19] = [0:0, 18:0] - var h : felem[19] = [0:1, 18:0] + var a : felem[19] = [.[0] = 0, .[18] = 0] + var b : felem[19] = [.[0] = 1, .[18] = 0] + var c : felem[19] = [.[0] = 1, .[18] = 0] + var d : felem[19] = [.[0] = 0, .[18] = 0] + var e : felem[19] = [.[0] = 0, .[18] = 0] + var f : felem[19] = [.[0] = 1, .[18] = 0] + var g : felem[19] = [.[0] = 0, .[18] = 0] + var h : felem[19] = [.[0] = 1, .[18] = 0] var nqpqx = a[:] var nqpqz = b[:] var nqx = c[:] diff --git a/parse/gram.y b/parse/gram.y index 5836b0c..749d7a5 100644 --- a/parse/gram.y +++ b/parse/gram.y @@ -963,8 +963,8 @@ arrayelts ; arrayelt: expr optendlns {$$ = $1;} - | expr Tcolon expr optendlns { - $$ = mkidxinit($2->loc, $1, $3); + | Tdot Tosqbrac expr Tcsqbrac Tasn expr optendlns { + $$ = mkidxinit($1->loc, $3, $6); } ; diff --git a/test/arraylit.myr b/test/arraylit.myr index e37e772..93a90ee 100644 --- a/test/arraylit.myr +++ b/test/arraylit.myr @@ -2,6 +2,10 @@ use std /* checks we can make indexed array literals. exits with 3. */ const main = { - var a = [0: 1, 2: 3, 1: 2] + var a = [ + .[0] = 1, + .[2] = 3, + .[1] = 2, + ] std.exit(a[2]) } |