You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
beautiful-racket/beautiful-racket-demo/precalc-demo/grammar.rkt

11 lines
297 B
Racket

7 years ago
#lang brag
7 years ago
top : (func-def | func-app)*
7 years ago
func-def : /"fun" var /"(" vars /")" /"=" expr
7 years ago
/vars : [var (/"," var)*]
7 years ago
@expr : sum
sum : [sum ("+" | "-")] product
product : [product ("*" | "/")] value
@value : var | INT | func-app | /"(" expr /")"
7 years ago
func-app : var /"(" [expr (/"," expr)*] /")"
7 years ago
@var : ID