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<
|
order-point<
|
||||||
order-point>
|
order-point>
|
||||||
|
try-order-point<
|
||||||
|
try-order-point>
|
||||||
~mixin
|
~mixin
|
||||||
~post-check
|
~post-check
|
||||||
~post-fail
|
~post-fail
|
||||||
|
@ -38,4 +40,5 @@
|
||||||
aggregate-global-counter
|
aggregate-global-counter
|
||||||
(for-template define-syntax/parse+simple)
|
(for-template define-syntax/parse+simple)
|
||||||
define/syntax-parse+simple
|
define/syntax-parse+simple
|
||||||
try-attribute)
|
try-attribute
|
||||||
|
if-attribute)
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
phc-toolkit/untyped
|
phc-toolkit/untyped
|
||||||
racket/list
|
racket/list
|
||||||
racket/pretty)
|
racket/pretty)
|
||||||
"parameters.rkt")
|
"parameters.rkt"
|
||||||
|
"try-attribute.rkt")
|
||||||
|
|
||||||
(provide define-eh-alternative-mixin
|
(provide define-eh-alternative-mixin
|
||||||
~seq-no-order
|
~seq-no-order
|
||||||
|
@ -36,6 +37,8 @@
|
||||||
~order-point
|
~order-point
|
||||||
order-point<
|
order-point<
|
||||||
order-point>
|
order-point>
|
||||||
|
try-order-point<
|
||||||
|
try-order-point>
|
||||||
(expander-out eh-mixin))
|
(expander-out eh-mixin))
|
||||||
|
|
||||||
(define-expander-type eh-mixin)
|
(define-expander-type eh-mixin)
|
||||||
|
@ -160,3 +163,9 @@
|
||||||
(define-syntax-rule (order-point> a b)
|
(define-syntax-rule (order-point> a b)
|
||||||
(and (attribute a) (attribute 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
|
#:grammar
|
||||||
[(a #,tribute-name)
|
[(a #,tribute-name)
|
||||||
(b #,tribute-name)]]{
|
(b #,tribute-name)]]{
|
||||||
|
|
||||||
Returns @racket[#t] when the first element matched by
|
Returns @racket[#t] when the first element matched by
|
||||||
@racket[(~order-point a #,ntax-pattern ...)] occurs before the first element
|
@racket[(~order-point a #,ntax-pattern ...)] occurs before the first element
|
||||||
matched by @racket[(~order-point b #,ntax-pattern ...)]. Otherwise, returns
|
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)
|
@defform[(order-point> a b)
|
||||||
#:grammar
|
#:grammar
|
||||||
[(a #,tribute-name)
|
[(a #,tribute-name)
|
||||||
(b #,tribute-name)]]{
|
(b #,tribute-name)]]{
|
||||||
|
|
||||||
Returns @racket[#t] when the first element matched by
|
Returns @racket[#t] when the first element matched by
|
||||||
@racket[(~order-point a #,ntax-pattern ...)] occurs after the first element
|
@racket[(~order-point a #,ntax-pattern ...)] occurs after the first element
|
||||||
matched by @racket[(~order-point b #,ntax-pattern ...)]. Otherwise, returns
|
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)]{
|
@defform[(~mixin #,-alternative-mixin)]{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user