Re: [racket-users] Using expr/c within one syntax class?

2020-12-18 Thread Ryan Culpepper
Right, I would generally recommend against using `raise-syntax-error` within syntax classes. syntax-parse has heuristics to convert the "most specific" pattern failure into a syntax error, and it's usually better to work within that framework (as your code using `~fail` does). To make that work, yo

Re: [racket-users] Using expr/c within one syntax class?

2020-12-17 Thread Sage Gerard
Fantastic, thank you for getting me on my way. I followed your advice where I do not use string-producing expressions and ended up with a follow up question. New syntax classes are below for those reading. (define (unbounded? v) (equal? "*" v)) (define-syntax-class racket-version-or-* (pattern

Re: [racket-users] Using expr/c within one syntax class?

2020-12-17 Thread Ryan Culpepper
Based on what you have written so far, the `versions` macro has no sub-expressions, so you shouldn't use `expr/c` at all. It requires version bounds to be in the form of literal strings. So you could describe the macro using a grammar as follows: Expression ::= | (versions Version ...) Ve

Re: [racket-users] Using expr/c within one syntax class?

2020-12-16 Thread Sage Gerard
Typos: - "*" remove a bound ==> "*" removes a bound - All examples should read (versions ...), not (version ...) ~slg ‐‐‐ Original Message ‐‐‐ On Wednesday, December 16, 2020 6:27 PM, Sage Gerard wrote: > I'm trying to learn how to write syntax classes. My intended macro expresses >

[racket-users] Using expr/c within one syntax class?

2020-12-16 Thread Sage Gerard
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