fix rule naming in grammar spec
I forgot that ABNF rule names don't accept underscores...
This commit is contained in:
parent
47dfde6b3b
commit
0f27e9965a
1 changed files with 27 additions and 27 deletions
|
@ -1,45 +1,45 @@
|
|||
; Rutile's grammar formal definition in ABNF
|
||||
; NOTE: terminal strings are case sensitive here
|
||||
|
||||
function_kind = "proc" / "iter"
|
||||
proc_decl = function_kind "(" [proc_decl_args] ")" [ident] *stmt 'end'
|
||||
proc_decl_args = symbol_type_pair *("," symbol_type_pair)
|
||||
symbol_type_pair = ident ":" ident
|
||||
function-kind = "proc" / "iter"
|
||||
proc-decl = function-kind "(" [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
|
||||
ident-type-expr = ident [":" ident] ["=" expr]
|
||||
|
||||
function_call = ident_qualified "(" [funcargs] ")"
|
||||
funcargs = expr_list
|
||||
function-call = ident-qualified "(" [funcargs] ")"
|
||||
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 =/ array_literal
|
||||
expr =/ function_call
|
||||
expr =/ array-literal
|
||||
expr =/ function-call
|
||||
|
||||
pragma = "#" "[" "]" ; TODO
|
||||
decorated_decl = pragma (proc_decl / symbol_decl)
|
||||
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
|
||||
loop_control = "next" / break_expr
|
||||
stmt = proc_decl
|
||||
while-stmt = "while" expr *stmt "end"
|
||||
if-expr = "if" expr *stmt "end"
|
||||
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 =/ loop-control
|
||||
stmt =/ if-expr
|
||||
stmt =/ while-stmt
|
||||
stmt =/ return-stmt
|
||||
stmt =/ yield-stmt
|
||||
|
||||
ident = (ALPHA / "_") *(ALPHA / DIGIT / "_" / "?" / "!")
|
||||
; Identifier accounting for namespacing: std:io.print, aaa:bbb:ccc
|
||||
ident_qualified = (ALPHA / "_") *(ALPHA / DIGIT / "_" / "?" / "!" / ":" / ".")
|
||||
ident-qualified = (ALPHA / "_") *(ALPHA / DIGIT / "_" / "?" / "!" / ":" / ".")
|
||||
|
||||
number = 1*DIGIT ; Decimal
|
||||
/ "0b" 1*("0" / "1") ; Binary
|
||||
|
@ -49,4 +49,4 @@ number = 1*DIGIT ; Decimal
|
|||
byte = %x00-FF
|
||||
escape = "\" ("\" / DQUOTE / "0" / "a" / "b" / "n" / "r" / "t" / ("x" 1*2HEXDIGIT))
|
||||
character = byte / escape
|
||||
string_literal = DQUOTE *character DQUOTE
|
||||
string-literal = DQUOTE *character DQUOTE
|
||||
|
|
Loading…
Add table
Reference in a new issue