提供语法规则球拍

Provide syntax-rule Racket

如何在球拍中提供语法规则?

我有与此类似的代码:

(define-syntax SELECT 
  (syntax-rules (FROM WHERE star)
    [(SELECT colnames FROM relnames)
     ...]
    [(SELECT colnames FROM relnames WHERE . expression)
     ...]))

如何使用提供语句来提供 FROM WHERE 和星标?

这是我提供的方式SELECT:

(provide SELECT)

这是一种方法。首先定义字面量(如果在 SELECT 之外使用,则给出一个很好的错误消息),然后提供它们。

#lang racket
(provide SELECT FROM WHERE)

(define-syntax FROM  (λ (stx) (raise-syntax-error 'FROM  "literal FROM used outside SELECT"  stx)))
(define-syntax WHERE (λ (stx) (raise-syntax-error 'WHERE "literal WHERE used outside SELECT" stx)))

(define-syntax SELECT 
  (syntax-rules (FROM WHERE star)
    [(SELECT colnames FROM relnames)                    ...]
    [(SELECT colnames FROM relnames WHERE . expression) ...]))