如何在球拍中提供语法规则?
我的代码类似于:
(define-syntax SELECT
(syntax-rules (FROM WHERE star)
[(SELECT colnames FROM relnames)
...]
[(SELECT colnames FROM relnames WHERE . expression)
...]))
如何使用provide语句提供FROM WHERE和star?
这就是我提供SELECT的方式:
(provide SELECT)
答案 0 :(得分:2)
这是一种方法。首先定义文字(如果在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) ...]))