hello,
how do i access the pattern variable var at compile time (phase 1?)
additional to an answer, could you point me to the right part of the
documentation? i really couldn't find it.
#lang racket
(define inp (open-input-string "12+34"))
(define-syntax (terminal stx)
(syntax-case stx ()
((_ name rx)
(if (pregexp? (syntax->datum #'rx))
#'(define (name)
(regexp-try-match rx inp))
#'(error "Pregexp expected.")))))
(define-syntax (prod stx)
(syntax-case stx ()
((_ prod-name (name var))
(cond ((procedure? (syntax->datum #'var)) #'1)
((procedure? #'var) #'2)
((procedure? 'var) #'2)
((procedure? #''var) #'3)
((procedure? #''var) #'4)
((procedure? (syntax 'var)) #'5)
((pregexp? #'var) #'0)
(else #'(raise-syntax-error 'PROD-ARGUMENTS "Pregexp oder
Procedure expected."))))))
(terminal digit #px"\\d")
(prod term (op1 digit))
thanks for your help! :-)
--
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].
For more options, visit https://groups.google.com/d/optout.