mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Relocating source list to (scheme base)
This commit is contained in:
parent
f4ac3c7cb7
commit
858cac4eee
3 changed files with 15 additions and 11 deletions
|
@ -680,7 +680,7 @@
|
|||
(define (read-file filename)
|
||||
(call-with-input-file filename
|
||||
(lambda (port)
|
||||
(read-all port))))
|
||||
(read-all/source port filename))))
|
||||
|
||||
;; Compile and emit:
|
||||
(define (run-compiler args cc? cc-prog cc-exec cc-lib cc-so cc-prog-linker-opts append-dirs prepend-dirs)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
(define-library (scheme base)
|
||||
(import (scheme cyclone common))
|
||||
(export
|
||||
*source-loc-lis*
|
||||
syntax-error/loc
|
||||
member
|
||||
assoc
|
||||
cons-source
|
||||
|
@ -232,6 +234,18 @@
|
|||
fast-string=?
|
||||
)
|
||||
(begin
|
||||
(define *source-loc-lis* '())
|
||||
(define (syntax-error/loc reason expr)
|
||||
(let ((loc-vec (assoc expr *source-loc-lis*)))
|
||||
(error "Syntax error at "
|
||||
(vector-ref (assoc loc-vec *source-loc-lis*) 0)
|
||||
":"
|
||||
(vector-ref (assoc loc-vec *source-loc-lis*) 1)
|
||||
":"
|
||||
(vector-ref (assoc loc-vec *source-loc-lis*) 2)
|
||||
reason
|
||||
expr)))
|
||||
|
||||
;; Features implemented by this Scheme
|
||||
(define (features)
|
||||
(cons
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
read
|
||||
read-all
|
||||
read-all/source
|
||||
*source-loc-lis*
|
||||
read-test
|
||||
include
|
||||
include-ci)
|
||||
(inline
|
||||
|
@ -28,7 +26,6 @@
|
|||
(define *sym-dot* (string->symbol "."))
|
||||
(define *sym-unquote-splicing* (string->symbol ",@"))
|
||||
(define *sym-datum-comment* (string->symbol "#;"))
|
||||
(define *source-loc-lis* '())
|
||||
|
||||
(define-syntax include
|
||||
(er-macro-transformer
|
||||
|
@ -84,12 +81,6 @@
|
|||
(define (read-all/source port filename)
|
||||
(read-all port store-source-info! filename))
|
||||
|
||||
;; TODO: assume the source-loc-lis needs to be part of (scheme base) so that those macros can use them
|
||||
(define-syntax read-test
|
||||
(er-macro-transformer
|
||||
(lambda (expr rename compare)
|
||||
(error "read test error" (assoc expr *source-loc-lis*) *source-loc-lis*))))
|
||||
|
||||
;; read-all -> port -> [objects]
|
||||
(define (read-all . args)
|
||||
(let* ((fp (if (null? args)
|
||||
|
@ -176,7 +167,6 @@
|
|||
|
||||
(define (store-source-info! obj filename line col)
|
||||
(set! *source-loc-lis*
|
||||
;; TODO: not good enough, need to index by file and obj
|
||||
(cons (cons obj (vector filename line col))
|
||||
*source-loc-lis*)))
|
||||
;; TODO: where to store? Need to use a hashtable but also needs to
|
||||
|
|
Loading…
Add table
Reference in a new issue