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

16 lines
415 B
Racket

#lang brag
top : (/NEWLINE+ [line])* /NEWLINE*
line : [lookbehind] pat [lookahead]
pat : repeat+ | choice
lookbehind : /"(" /"?" /"<" /"=" pat /")"
lookahead : /"(" /"?" /"=" pat /")"
choice : pat (/"|" pat)+
repeat : repeatable [("*" | "+") ["?"] | "?"]
6 years ago
@repeatable : group | any | start | end | literal | chars
group : /"(" pat /")"
any : /"."
start : /"^"
end : /"$"
6 years ago
literal : LITERAL
chars : /"[" literal* /"]"