Use pre operations for ~before and ~after. Documented that. Bugfix ~before ~after and their try- variants
This commit is contained in:
parent
75fa5aea07
commit
15ceea43fc
|
@ -279,40 +279,40 @@
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ other message pat …)
|
[(_ other message pat …)
|
||||||
(and (identifier? #'other)
|
(and (identifier? #'other)
|
||||||
(string? (syntax-e #'message))
|
(string? (syntax-e #'message)))
|
||||||
#'{~order-point pt
|
#'{~order-point pt
|
||||||
{~seq pat …}
|
{~seq pat …}
|
||||||
{~post-fail message #:when (order-point> pt other)}})])))
|
{~pre-fail message #:when (order-point> pt other)}}])))
|
||||||
|
|
||||||
(define-eh-mixin-expander ~after
|
(define-eh-mixin-expander ~after
|
||||||
(λ (stx)
|
(λ (stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ other message pat …)
|
[(_ other message pat …)
|
||||||
(and (identifier? #'other)
|
(and (identifier? #'other)
|
||||||
(string? (syntax-e #'message))
|
(string? (syntax-e #'message)))
|
||||||
#'{~order-point pt
|
#'{~order-point pt
|
||||||
{~seq pat …}
|
{~seq pat …}
|
||||||
{~post-fail message #:when (order-point< pt other)}})])))
|
{~pre-fail message #:when (order-point< pt other)}}])))
|
||||||
|
|
||||||
(define-eh-mixin-expander ~try-before
|
(define-eh-mixin-expander ~try-before
|
||||||
(λ (stx)
|
(λ (stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ other message pat …)
|
[(_ other message pat …)
|
||||||
(and (identifier? #'other)
|
(and (identifier? #'other)
|
||||||
(string? (syntax-e #'message))
|
(string? (syntax-e #'message)))
|
||||||
#'{~order-point pt
|
#'{~order-point pt
|
||||||
{~seq pat …}
|
{~seq pat …}
|
||||||
{~post-fail message #:when (try-order-point> pt other)}})])))
|
{~pre-fail message #:when (try-order-point> pt other)}}])))
|
||||||
|
|
||||||
(define-eh-mixin-expander ~try-after
|
(define-eh-mixin-expander ~try-after
|
||||||
(λ (stx)
|
(λ (stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ other message pat …)
|
[(_ other message pat …)
|
||||||
(and (identifier? #'other)
|
(and (identifier? #'other)
|
||||||
(string? (syntax-e #'message))
|
(string? (syntax-e #'message)))
|
||||||
#'{~order-point pt
|
#'{~order-point pt
|
||||||
{~seq pat …}
|
{~seq pat …}
|
||||||
{~post-fail message #:when (try-order-point< pt other)}})])))
|
{~pre-fail message #:when (try-order-point< pt other)}}])))
|
||||||
|
|
||||||
(define-syntax ~omitable-lifted-rest
|
(define-syntax ~omitable-lifted-rest
|
||||||
(pattern-expander
|
(pattern-expander
|
||||||
|
|
|
@ -146,7 +146,10 @@
|
||||||
auto-detects if the @racket[other] order-point is not defined as part of the
|
auto-detects if the @racket[other] order-point is not defined as part of the
|
||||||
current @racket[~no-order]. Do not rely on comparisons with order points
|
current @racket[~no-order]. Do not rely on comparisons with order points
|
||||||
somehow defined outside the current @racket[~no-order], as that behaviour may
|
somehow defined outside the current @racket[~no-order], as that behaviour may
|
||||||
change in the future.}
|
change in the future.
|
||||||
|
|
||||||
|
This is implemented as a @seclink["Pre__global_and_post_operations"]{pre
|
||||||
|
operation}.}
|
||||||
|
|
||||||
@defform[#:kind "eh-mixin-expander"
|
@defform[#:kind "eh-mixin-expander"
|
||||||
(~after other message pat ...)]{
|
(~after other message pat ...)]{
|
||||||
|
@ -161,7 +164,10 @@
|
||||||
auto-detects if the @racket[other] order-point is not defined as part of the
|
auto-detects if the @racket[other] order-point is not defined as part of the
|
||||||
current @racket[~no-order]. Do not rely on comparisons with order points
|
current @racket[~no-order]. Do not rely on comparisons with order points
|
||||||
somehow defined outside the current @racket[~no-order], as that behaviour may
|
somehow defined outside the current @racket[~no-order], as that behaviour may
|
||||||
change in the future.}
|
change in the future.
|
||||||
|
|
||||||
|
This is implemented as a @seclink["Pre__global_and_post_operations"]{pre
|
||||||
|
operation}.}
|
||||||
|
|
||||||
@defform[#:kind "eh-mixin-expander"
|
@defform[#:kind "eh-mixin-expander"
|
||||||
(~try-before other message pat ...)]{
|
(~try-before other message pat ...)]{
|
||||||
|
@ -177,7 +183,10 @@
|
||||||
|
|
||||||
Note: Hopefully @racket[~before] will be modified in the future so that it
|
Note: Hopefully @racket[~before] will be modified in the future so that it
|
||||||
auto-detects if the @racket[other] order-point is missing. This form will then
|
auto-detects if the @racket[other] order-point is missing. This form will then
|
||||||
be removed.}
|
be removed.
|
||||||
|
|
||||||
|
This is implemented as a @seclink["Pre__global_and_post_operations"]{pre
|
||||||
|
operation}.}
|
||||||
|
|
||||||
@defform[#:kind "eh-mixin-expander"
|
@defform[#:kind "eh-mixin-expander"
|
||||||
(~try-after other message pat ...)]{
|
(~try-after other message pat ...)]{
|
||||||
|
@ -192,5 +201,8 @@
|
||||||
|
|
||||||
Note: Hopefully @racket[~after] will be modified in the future so that it
|
Note: Hopefully @racket[~after] will be modified in the future so that it
|
||||||
auto-detects if the @racket[other] order-point is missing. This form will then
|
auto-detects if the @racket[other] order-point is missing. This form will then
|
||||||
be removed.}
|
be removed.
|
||||||
|
|
||||||
|
This is implemented as a @seclink["Pre__global_and_post_operations"]{pre
|
||||||
|
operation}.}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#lang scribble/manual
|
#lang scribble/manual
|
||||||
|
|
||||||
@title{Post operations and global operations}
|
@title{Pre, global and post operations}
|
||||||
|
|
||||||
Pre operations happen before the @racket[~!] backtracking cut, so they can
|
Pre operations happen before the @racket[~!] backtracking cut, so they can
|
||||||
affect what combination of alternative clauses the parser will choose. Post
|
affect what combination of alternative clauses the parser will choose. Post
|
||||||
|
|
Loading…
Reference in New Issue
Block a user