update grammar
This commit is contained in:
parent
41589320de
commit
b2c4a55544
1 changed files with 13 additions and 8 deletions
|
@ -4,40 +4,45 @@
|
|||
; - alternatives are ordered
|
||||
|
||||
function-kind = "proc" / "iter"
|
||||
proc-decl = function-kind "(" [proc-decl-args] ")" ":" [ident] *stmt 'end'
|
||||
proc-decl = function-kind ident ["*"] "(" [proc-decl-args] ")" [":" ident] *stmt 'end'
|
||||
proc-decl-args = symbol-type-pair *("," symbol-type-pair)
|
||||
symbol-type-pair = ident ":" ident
|
||||
|
||||
symbol-decl = ("var" / "let" / "const") ident-type-expr ; "Variable" declaration
|
||||
ident-type-expr = ident [":" ident] ["=" expr]
|
||||
symbol-decl = ("var" / "let" / "const") ident-type-expr ; "Variable" declaration
|
||||
|
||||
function-call = ident-qualified "(" [funcargs] ")"
|
||||
funcargs = expr-list
|
||||
|
||||
array-literal = "[" expr-list "]"
|
||||
|
||||
expr-list = expr *("," expr) [","] ; Allows a trailling comma
|
||||
expr-list = expr *("," expr) [","] ; Allows a trailling comma
|
||||
expr = number
|
||||
/ array-literal
|
||||
/ function-call
|
||||
/ string-literal
|
||||
|
||||
pragma = "#" "[" "]" ; TODO
|
||||
decorated-decl = pragma (proc-decl / symbol-decl)
|
||||
pragma-directive = ident *("," ident) [","]
|
||||
pragma = "#" "[" pragma-directive "]"
|
||||
decorated-decl = pragma (proc-decl / symbol-decl)
|
||||
|
||||
; Statements
|
||||
while-stmt = "while" expr *stmt "end"
|
||||
if-expr = "if" expr *stmt "end"
|
||||
break-expr = "break" *expr
|
||||
return-stmt = "return" *expr
|
||||
yield-stmt = "yield" *expr
|
||||
break-expr = "break" [expr]
|
||||
return-stmt = "return" [expr]
|
||||
yield-stmt = "yield" [expr]
|
||||
discard-stmt = "discard" expr
|
||||
loop-control = "next" / break-expr
|
||||
stmt = proc-decl
|
||||
/ symbol-decl
|
||||
/ expr
|
||||
/ loop-control
|
||||
/ if-expr
|
||||
/ while-stmt
|
||||
/ return-stmt
|
||||
/ yield-stmt
|
||||
/ discard-stmt
|
||||
|
||||
ident = (ALPHA / "_") *(ALPHA / DIGIT / "_" / "?" / "!")
|
||||
; Identifier accounting for namespacing: std:io.print, aaa:bbb:ccc
|
||||
|
|
Loading…
Add table
Reference in a new issue