Added try-order-point< and try-order-point>
This commit is contained in:
parent
16290d0fcc
commit
dc5e7b12d2
5
main.rkt
5
main.rkt
|
@ -24,6 +24,8 @@
|
|||
~order-point
|
||||
order-point<
|
||||
order-point>
|
||||
try-order-point<
|
||||
try-order-point>
|
||||
~mixin
|
||||
~post-check
|
||||
~post-fail
|
||||
|
@ -38,4 +40,5 @@
|
|||
aggregate-global-counter
|
||||
(for-template define-syntax/parse+simple)
|
||||
define/syntax-parse+simple
|
||||
try-attribute)
|
||||
try-attribute
|
||||
if-attribute)
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
phc-toolkit/untyped
|
||||
racket/list
|
||||
racket/pretty)
|
||||
"parameters.rkt")
|
||||
"parameters.rkt"
|
||||
"try-attribute.rkt")
|
||||
|
||||
(provide define-eh-alternative-mixin
|
||||
~seq-no-order
|
||||
|
@ -36,6 +37,8 @@
|
|||
~order-point
|
||||
order-point<
|
||||
order-point>
|
||||
try-order-point<
|
||||
try-order-point>
|
||||
(expander-out eh-mixin))
|
||||
|
||||
(define-expander-type eh-mixin)
|
||||
|
@ -159,4 +162,10 @@
|
|||
|
||||
(define-syntax-rule (order-point> a b)
|
||||
(and (attribute a) (attribute b)
|
||||
(> (attribute a) (attribute b))))
|
||||
(> (attribute a) (attribute b))))
|
||||
|
||||
(define-syntax-rule (try-order-point< a b)
|
||||
(if-attribute a (if-attribute b (order-point< a b) #f) #f))
|
||||
|
||||
(define-syntax-rule (try-order-point> a b)
|
||||
(if-attribute a (if-attribute b (order-point> a b) #f) #f))
|
|
@ -136,21 +136,61 @@
|
|||
#:grammar
|
||||
[(a #,tribute-name)
|
||||
(b #,tribute-name)]]{
|
||||
|
||||
Returns @racket[#t] when the first element matched by
|
||||
@racket[(~order-point a #,ntax-pattern ...)] occurs before the first element
|
||||
matched by @racket[(~order-point b #,ntax-pattern ...)]. Otherwise, returns
|
||||
@racket[#f].}
|
||||
@racket[#f].
|
||||
|
||||
This operation does not fail if @racket[a] or @racket[b] are bound to
|
||||
@racket[#f] (i.e. their corresponding @racket[_syntax-pattern ...] did not
|
||||
match). Instead, in both cases, it returns @racket[#f].}
|
||||
|
||||
@defform[(order-point> a b)
|
||||
#:grammar
|
||||
[(a #,tribute-name)
|
||||
(b #,tribute-name)]]{
|
||||
|
||||
Returns @racket[#t] when the first element matched by
|
||||
@racket[(~order-point a #,ntax-pattern ...)] occurs after the first element
|
||||
matched by @racket[(~order-point b #,ntax-pattern ...)]. Otherwise, returns
|
||||
@racket[#f].}
|
||||
@racket[#f].
|
||||
|
||||
This operation does not fail if @racket[a] or @racket[b] are bound to
|
||||
@racket[#f] (i.e. their corresponding @racket[_syntax-pattern ...] did not
|
||||
match). Instead, in both cases, it returns @racket[#f].}
|
||||
|
||||
@defform[(try-order-point< a b)
|
||||
#:grammar
|
||||
[(a #,tribute-name)
|
||||
(b #,tribute-name)]]{
|
||||
|
||||
Like @racket[order-point<], except that it does not fail if @racket[a] or
|
||||
@racket[b] are not attributes, or if they are bound to @racket[#f]. Instead, in
|
||||
all those cases, it returns @racket[#f].
|
||||
|
||||
It can be used as follows:
|
||||
|
||||
@racketblock[
|
||||
(~post-fail "a must appear after b"
|
||||
#:when (try-order-point< a b))]
|
||||
|
||||
The same caveats as for @racket[try-attribute] apply.}
|
||||
|
||||
@defform[(try-order-point> a b)
|
||||
#:grammar
|
||||
[(a #,tribute-name)
|
||||
(b #,tribute-name)]]{
|
||||
|
||||
Like @racket[order-point>], except that it does not fail if @racket[a] or
|
||||
@racket[b] are not attributes, or if they are bound to @racket[#f]. Instead, in
|
||||
all those cases, it returns @racket[#f].
|
||||
|
||||
It can be used as follows:
|
||||
|
||||
@racketblock[
|
||||
(~post-fail "a must appear before b"
|
||||
#:when (try-order-point> a b))]
|
||||
|
||||
The same caveats as for @racket[try-attribute] apply.}
|
||||
|
||||
@defform[(~mixin #,-alternative-mixin)]{
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user