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/pythonesque-demo/grammar.rkt

15 lines
414 B
Racket

#lang brag
6 years ago
top : statement*
@statement : func-def | expr | return | if
func-def : /"def" var /"(" ids /")" /":" block
6 years ago
/ids : [var (/"," var)*]
6 years ago
block : /INDENT statement* /DEDENT
@expr : comparison
6 years ago
comparison : [comparison "<"] value
6 years ago
@value : var | INT | func-app | STRING
func-app : var /"(" exprs /")"
@exprs : [expr (/"," expr)*]
return : /"return" expr
if : /"if" expr /":" block [/"else" /":" block]
6 years ago
@var : ID