fix interaction of local-expand
use and defn context
Since `parser` works in an expression context, it's simplest to force an expression context.
This commit is contained in:
parent
97dfccd487
commit
8ea555aaee
|
@ -19,7 +19,7 @@
|
|||
(lambda (stx)
|
||||
(raise-syntax-error #f "definitions keyword used out of context" stx)))
|
||||
|
||||
(define-syntax (parser stx)
|
||||
(define-syntax (parser* stx)
|
||||
(syntax-case stx ()
|
||||
[(parser form ...)
|
||||
(let ([stop-list (list #'begin #'options #'productions #'definitions)]
|
||||
|
@ -47,3 +47,10 @@
|
|||
#'(let ()
|
||||
def ...
|
||||
(#%expression (yacc:parser opt ... (grammar prod ...))))))]))
|
||||
|
||||
(define-syntax-rule (parser . content)
|
||||
;; Ensure that local expansion doesn't add
|
||||
;; marks due to use of a macro in the enclosing
|
||||
;; binding scope:
|
||||
(let ()
|
||||
(parser* . content)))
|
||||
|
|
|
@ -1,32 +1,8 @@
|
|||
#lang racket/base
|
||||
(require (rename-in racket/contract/base [-> c:->])
|
||||
ffi/unsafe)
|
||||
|
||||
(define lib (ffi-lib #f))
|
||||
(provide get-marks)
|
||||
|
||||
(define get-marks
|
||||
(get-ffi-obj "scheme_stx_extract_marks" lib
|
||||
(_fun _scheme -> _scheme)))
|
||||
|
||||
#|
|
||||
(define (simplify-marks marklist)
|
||||
(simplify* (sort marklist <)))
|
||||
|
||||
(define (simplify* marklist)
|
||||
(cond [(null? marklist) marklist]
|
||||
[(null? (cdr marklist)) marklist]
|
||||
[(= (car marklist) (cadr marklist))
|
||||
(simplify* (cddr marklist))]
|
||||
[else
|
||||
(let ([result (simplify* (cdr marklist))])
|
||||
(if (eq? result (cdr marklist))
|
||||
marklist
|
||||
(cons (car marklist) result)))]))
|
||||
|
||||
(provide simplify-marks)
|
||||
|#
|
||||
|
||||
(provide/contract
|
||||
[get-marks
|
||||
;; syntax? check needed for safety!
|
||||
(c:-> syntax? any)])
|
||||
(define (get-marks stx)
|
||||
(define info (syntax-debug-info stx))
|
||||
(for ([e (in-list (hash-ref info 'context))])
|
||||
(vector-ref e 0)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user