Add syntax/parse/lib/function-header library.
This commit is contained in:
parent
af6c39611d
commit
ca365d17c1
26
racket/collects/syntax/parse/lib/function-header.rkt
Normal file
26
racket/collects/syntax/parse/lib/function-header.rkt
Normal file
|
@ -0,0 +1,26 @@
|
|||
#lang racket/base
|
||||
|
||||
(require "../../parse.rkt"
|
||||
"../experimental/template.rkt")
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
(define-syntax-class function-header
|
||||
(pattern ((~or header:function-header name:id) . args:args)
|
||||
#:attr params
|
||||
(template ((?@ . (?? header.params ()))
|
||||
. args.params))))
|
||||
|
||||
(define-syntax-class args
|
||||
(pattern (arg:arg ...)
|
||||
#:attr params #'(arg.name ...))
|
||||
(pattern (arg:arg ... . rest:id)
|
||||
#:attr params #'(arg.name ... rest)))
|
||||
|
||||
(define-splicing-syntax-class arg
|
||||
#:attributes (name)
|
||||
(pattern name:id)
|
||||
(pattern [name:id default])
|
||||
(pattern (~seq kw:keyword name:id))
|
||||
(pattern (~seq kw:keyword [name:id default])))
|
||||
|
Loading…
Reference in New Issue
Block a user