aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-09-21 12:41:48 +0200
committerHimbeer <himbeer@disroot.org>2024-09-21 12:41:48 +0200
commit24d452f027826d29455634f9f29ccda71b92f0d1 (patch)
treed7a0e6158b32df8ec3e4e750e1c6d0bd8ed7ebd3 /doc
parent30a62e11d09f48d4a847ad6e2dbbd778e7be59a8 (diff)
Merge array and slice grammar definitions
This makes it possible for the parser to distinguish between them without unlexing more than one token.
Diffstat (limited to 'doc')
-rw-r--r--doc/grammar.txt12
1 files changed, 5 insertions, 7 deletions
diff --git a/doc/grammar.txt b/doc/grammar.txt
index 486fefd..bd42658 100644
--- a/doc/grammar.txt
+++ b/doc/grammar.txt
@@ -51,8 +51,8 @@ call := path "(" ( expression ), ")"
defer := "defer" call
type := "*" type | "?" type | "!" type
- | integer | float | struct | enum | union
- | array | slice
+ | bool | integer | float | struct | enum | union
+ | array
| path
numtype := integer | float
integer := "int8" | "uint8"
@@ -61,11 +61,10 @@ integer := "int8" | "uint8"
| "int64" | "uint64"
| "int" | "uint"
float := "float32" | "float64"
-array := "[" expression "]" type
-slice := "[]" type
+array := "[" [ expression ] "]" type
struct := "struct" "{" fields "}"
enum := "enum" [ integer ] [ "=" expression ] "{" ( NAME ), "}"
-union := "union" [ type ] "{" fields "}"
+union := "union" [ type ] "{" ( type ), "}"
fields := ( NAME type ),
expression := disjunction
@@ -84,9 +83,8 @@ unaryprefix := [ "-" | "!" | "~" ] unarypostfix
unarypostfix := primary [ "*" | "?" | "!" ]
primary := grouping | literal | call | path
grouping := "(" expression ")"
-literal := bool | string | number | arrayelems | sliceelems
+literal := bool | string | number | arrayelems
bool := "true" | "false"
string := STRING*
number := NUMBER ( numtype )
arrayelems := array "{" ( expression ), "}"
-sliceelems := slice "{" ( expression ), "}"