#lang scheme/base
(require "../ns-tx.ss")
(provide (all-defined-out))
(define-struct op-static (prototype))
(define (op-arity op)
(length (op-static-prototype op)))
(define (op-check-syntax ins)
(syntax-case ins ()
((rator rand ...)
(if (not (identifier? #'rator))
(raise-syntax-error #f "operator is not an identifier" ins #'rator)
(let* ((id (ns-prefixed #'(op info) #'rator))
(op (syntax-local-value id (lambda () #f))))
(unless op
(raise-syntax-error #f "undefined operator" ins))
(unless (= (op-arity op)
(length (syntax->list #'(rand ...))))
(raise-syntax-error #f (format "incorrect arity. expected ~a"
(op-static-prototype op)) ins)))))))