refac scriptish
parent
37bc753b27
commit
944c543db7
@ -0,0 +1,24 @@
|
||||
#lang brag
|
||||
|
||||
top : @statement*
|
||||
statement : (var | expr | return) /";" | if | while
|
||||
var : /"var" id /"=" expr
|
||||
@expr : comparison
|
||||
comparison : [comparison ("!=" | "==")] add-or-sub
|
||||
add-or-sub : [@add-or-sub /"+"] value
|
||||
@value : id | INTEGER | STRING | object
|
||||
| fun | app | increment
|
||||
increment : id /"++"
|
||||
object : /"{" @kvs /"}"
|
||||
kvs : [kv (/"," kv)*]
|
||||
/kv : expr /":" expr
|
||||
fun : /"function" /"(" ids /")" @block
|
||||
/ids : [id (/"," id)*]
|
||||
@id : ID | deref
|
||||
deref : DEREF
|
||||
block : /"{" @statement* /"}"
|
||||
return : /"return" expr
|
||||
app : id /"(" @exprs /")"
|
||||
exprs : [expr (/"," expr)*]
|
||||
if : /"if" /"(" expr /")" @block ["else" @block]
|
||||
while : /"while" /"(" expr /")" @block
|
@ -1,24 +0,0 @@
|
||||
#lang brag
|
||||
|
||||
top : @statement*
|
||||
statement : (assignment | expr | return) /";" | if | while
|
||||
assignment : /"var" id /"=" expr
|
||||
@expr : comparison
|
||||
comparison : [comparison ("!=" | "==")] sumlike
|
||||
sumlike : [@sumlike /"+"] value
|
||||
@value : id | INTEGER | STRING | object
|
||||
| func-def | func-app | increment
|
||||
increment : id /"++"
|
||||
object : /"{" @kvs /"}"
|
||||
kvs : [kv (/"," kv)*]
|
||||
/kv : expr /":" expr
|
||||
func-def : /"function" /"(" ids /")" @block
|
||||
/ids : [id (/"," id)*]
|
||||
@id : ID | dotted-id
|
||||
dotted-id : DOTTED-ID
|
||||
block : /"{" @statement* /"}"
|
||||
return : /"return" expr
|
||||
func-app : id /"(" @exprs /")"
|
||||
exprs : [expr (/"," expr)*]
|
||||
if : /"if" /"(" expr /")" @block
|
||||
while : /"while" /"(" expr /")" @block
|
Loading…
Reference in New Issue