www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 8ea555aaee7cb358be6556e29765b02a7bc13972
parent 97dfccd487497c6c5cd006b9f9fda3fb7c06e8ca
Author: Matthew Flatt <mflatt@racket-lang.org>
Date:   Mon, 16 Mar 2015 17:30:28 -0600

fix interaction of `local-expand` use and defn context

Since `parser` works in an expression context, it's simplest
to force an expression context.

Diffstat:
Mmacro-debugger-text-lib/macro-debugger/model/yacc-ext.rkt | 9++++++++-
Mmacro-debugger-text-lib/macro-debugger/util/stxobj.rkt | 34+++++-----------------------------
2 files changed, 13 insertions(+), 30 deletions(-)

diff --git a/macro-debugger-text-lib/macro-debugger/model/yacc-ext.rkt b/macro-debugger-text-lib/macro-debugger/model/yacc-ext.rkt @@ -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))) diff --git a/macro-debugger-text-lib/macro-debugger/util/stxobj.rkt b/macro-debugger-text-lib/macro-debugger/util/stxobj.rkt @@ -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)))