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
|
; - alternatives are ordered
|
||||||
|
|
||||||
function-kind = "proc" / "iter"
|
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)
|
proc-decl-args = symbol-type-pair *("," symbol-type-pair)
|
||||||
symbol-type-pair = ident ":" ident
|
symbol-type-pair = ident ":" ident
|
||||||
|
|
||||||
symbol-decl = ("var" / "let" / "const") ident-type-expr ; "Variable" declaration
|
|
||||||
ident-type-expr = ident [":" ident] ["=" expr]
|
ident-type-expr = ident [":" ident] ["=" expr]
|
||||||
|
symbol-decl = ("var" / "let" / "const") ident-type-expr ; "Variable" declaration
|
||||||
|
|
||||||
function-call = ident-qualified "(" [funcargs] ")"
|
function-call = ident-qualified "(" [funcargs] ")"
|
||||||
funcargs = expr-list
|
funcargs = expr-list
|
||||||
|
|
||||||
array-literal = "[" expr-list "]"
|
array-literal = "[" expr-list "]"
|
||||||
|
|
||||||
expr-list = expr *("," expr) [","] ; Allows a trailling comma
|
expr-list = expr *("," expr) [","] ; Allows a trailling comma
|
||||||
expr = number
|
expr = number
|
||||||
/ array-literal
|
/ array-literal
|
||||||
/ function-call
|
/ function-call
|
||||||
|
/ string-literal
|
||||||
|
|
||||||
pragma = "#" "[" "]" ; TODO
|
pragma-directive = ident *("," ident) [","]
|
||||||
decorated-decl = pragma (proc-decl / symbol-decl)
|
pragma = "#" "[" pragma-directive "]"
|
||||||
|
decorated-decl = pragma (proc-decl / symbol-decl)
|
||||||
|
|
||||||
; Statements
|
; Statements
|
||||||
while-stmt = "while" expr *stmt "end"
|
while-stmt = "while" expr *stmt "end"
|
||||||
if-expr = "if" expr *stmt "end"
|
if-expr = "if" expr *stmt "end"
|
||||||
break-expr = "break" *expr
|
break-expr = "break" [expr]
|
||||||
return-stmt = "return" *expr
|
return-stmt = "return" [expr]
|
||||||
yield-stmt = "yield" *expr
|
yield-stmt = "yield" [expr]
|
||||||
|
discard-stmt = "discard" expr
|
||||||
loop-control = "next" / break-expr
|
loop-control = "next" / break-expr
|
||||||
stmt = proc-decl
|
stmt = proc-decl
|
||||||
|
/ symbol-decl
|
||||||
/ expr
|
/ expr
|
||||||
/ loop-control
|
/ loop-control
|
||||||
/ if-expr
|
/ if-expr
|
||||||
/ while-stmt
|
/ while-stmt
|
||||||
/ return-stmt
|
/ return-stmt
|
||||||
/ yield-stmt
|
/ yield-stmt
|
||||||
|
/ discard-stmt
|
||||||
|
|
||||||
ident = (ALPHA / "_") *(ALPHA / DIGIT / "_" / "?" / "!")
|
ident = (ALPHA / "_") *(ALPHA / DIGIT / "_" / "?" / "!")
|
||||||
; Identifier accounting for namespacing: std:io.print, aaa:bbb:ccc
|
; Identifier accounting for namespacing: std:io.print, aaa:bbb:ccc
|
||||||
|
|
Loading…
Add table
Reference in a new issue