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

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