update grammar
This commit is contained in:
parent
0f27e9965a
commit
ad64813a67
1 changed files with 17 additions and 15 deletions
|
@ -1,8 +1,10 @@
|
|||
; Rutile's grammar formal definition in ABNF
|
||||
; NOTE: terminal strings are case sensitive here
|
||||
; NOTES:
|
||||
; - terminal strings are by default case sensitive
|
||||
; - alternatives are ordered
|
||||
|
||||
function-kind = "proc" / "iter"
|
||||
proc-decl = function-kind "(" [proc-decl-args] ")" [ident] *stmt 'end'
|
||||
proc-decl = function-kind "(" [proc-decl-args] ")" ":" [ident] *stmt 'end'
|
||||
proc-decl-args = symbol-type-pair *("," symbol-type-pair)
|
||||
symbol-type-pair = ident ":" ident
|
||||
|
||||
|
@ -15,9 +17,9 @@ funcargs = expr-list
|
|||
array-literal = "[" expr-list "]"
|
||||
|
||||
expr-list = expr *("," expr) [","] ; Allows a trailling comma
|
||||
expr = number
|
||||
expr =/ array-literal
|
||||
expr =/ function-call
|
||||
expr = number
|
||||
/ array-literal
|
||||
/ function-call
|
||||
|
||||
pragma = "#" "[" "]" ; TODO
|
||||
decorated-decl = pragma (proc-decl / symbol-decl)
|
||||
|
@ -29,24 +31,24 @@ break-expr = "break" *expr
|
|||
return-stmt = "return" *expr
|
||||
yield-stmt = "yield" *expr
|
||||
loop-control = "next" / break-expr
|
||||
stmt = proc-decl
|
||||
stmt =/ expr
|
||||
stmt =/ loop-control
|
||||
stmt =/ if-expr
|
||||
stmt =/ while-stmt
|
||||
stmt =/ return-stmt
|
||||
stmt =/ yield-stmt
|
||||
stmt = proc-decl
|
||||
/ expr
|
||||
/ loop-control
|
||||
/ if-expr
|
||||
/ while-stmt
|
||||
/ return-stmt
|
||||
/ yield-stmt
|
||||
|
||||
ident = (ALPHA / "_") *(ALPHA / DIGIT / "_" / "?" / "!")
|
||||
; Identifier accounting for namespacing: std:io.print, aaa:bbb:ccc
|
||||
ident-qualified = (ALPHA / "_") *(ALPHA / DIGIT / "_" / "?" / "!" / ":" / ".")
|
||||
|
||||
OCTDIGIT = %x30-37
|
||||
number = 1*DIGIT ; Decimal
|
||||
/ "0b" 1*("0" / "1") ; Binary
|
||||
/ "0o" 1*(0-8) ; Octal
|
||||
/ "0o" 1*OCTDIGIT ; Octal
|
||||
/ "0x" 1*HEXDIGIT ; Hexadecimal
|
||||
|
||||
byte = %x00-FF
|
||||
escape = "\" ("\" / DQUOTE / "0" / "a" / "b" / "n" / "r" / "t" / ("x" 1*2HEXDIGIT))
|
||||
character = byte / escape
|
||||
character = OCTET / escape
|
||||
string-literal = DQUOTE *character DQUOTE
|
||||
|
|
Loading…
Add table
Reference in a new issue