I'm trying to learn how to write syntax classes. My intended macro expresses a 
set of Racket versions, either as inclusive intervals or as exact versions. In 
an interval, "*" remove a bound.

- (version "6.5") means exactly version "6.5", as does (version ("6.5" "6.5"))

- (versions ("7.0" "7.7.0.5")) means the inclusive interval between version 7.0 
and 7.7.0.5
- (versions ("7.0" "7.7.0.5") "6.5"): union of the above two items
- (versions ("6.0" "*")): all Racket versions >= 6.0
- (versions "*"), (versions ("*" "*")): all Racket versions

I was able to define the syntax class without much issue:

(define-syntax-class racket-version-selection

#:attributes (min max)

(pattern (min:string max:string))

(pattern (~and (~var v string)

(~bind [min #'v]

[max #'v]))))

Now I want each attribute-bound expression V to satisfy (or (valid-version? V) 
(equal? V "*")). Where I'm stuck is how I can use #:declare with (expr/c) here. 
From what I understand, expr/c does not really mean much because it accepts an 
expression (as in the expr syntax-class), not attributes.

The only way I can think to fix this is to perform an additional syntax-parse 
so that I can use the attributes in an expression for expr/c to consume. But is 
it possible to do everything I'm thinking of in just one syntax class?

~slg

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/syiNcw0zJpSyA16fO8OkClrQmXFOC4qZEwrBm3JwETX-bGJGlALnP6Apn4ttCbIzMZUoobO7AT4MyRDm9ID0oUA648nXXSAZ1nvaCaj2NbI%3D%40sagegerard.com.

Reply via email to