(guarantee-environment environment #f)
environment)))
(atom-delimiters
- (environment-lookup environment '*PARSER-ATOM-DELIMITERS*))
+ (repl-environment-value environment '*PARSER-ATOM-DELIMITERS*))
(constituents
- (environment-lookup environment '*PARSER-CONSTITUENTS*)))
+ (repl-environment-value environment '*PARSER-CONSTITUENTS*)))
(guarantee-char-set atom-delimiters #f)
(guarantee-char-set constituents #f)
- (make-db (environment-lookup environment '*PARSER-ASSOCIATE-POSITIONS?*)
+ (make-db (repl-environment-value environment '*PARSER-ASSOCIATE-POSITIONS?*)
atom-delimiters
(overridable-value
port environment '*PARSER-CANONICALIZE-SYMBOLS?*)
(overridable-value
port environment '*PARSER-ENABLE-FILE-ATTRIBUTES-PARSING?*)
(overridable-value port environment '*PARSER-KEYWORD-STYLE*)
- (environment-lookup environment '*PARSER-RADIX*)
- (environment-lookup environment '*PARSER-TABLE*)
+ (repl-environment-value environment '*PARSER-RADIX*)
+ (repl-environment-value environment '*PARSER-TABLE*)
(make-shared-objects)
(port/operation port 'DISCRETIONARY-WRITE-CHAR)
(position-operation port environment)
(port/operation port 'READ-CHAR)
'())))
+(define (repl-environment-value environment name)
+ (environment-lookup-or
+ environment name
+ (lambda ()
+ (environment-lookup-or
+ (->environment '(USER)) name
+ (lambda ()
+ (environment-lookup environment name))))))
+
(define (overridable-value port environment name)
;; Check the port property list for the name, and then the
;; environment. This way a port can override the default.
- (port/get-property port name (environment-lookup environment name)))
+ (let* ((nope "no-overridden-value")
+ (v (port/get-property port name nope)))
+ (if (eq? v nope)
+ (repl-environment-value environment name)
+ v)))
(define (position-operation port environment)
(let ((default (lambda (port) port #f)))
- (if (environment-lookup environment '*PARSER-ASSOCIATE-POSITIONS?*)
+ (if (repl-environment-value environment '*PARSER-ASSOCIATE-POSITIONS?*)
(or (port/operation port 'POSITION)
default)
default)))
(define hook/repl-eval)
(define (default/repl-eval s-expression environment repl)
- (%repl-scode-eval (syntax s-expression environment) environment repl))
+ (if (and (pair? s-expression)
+ (eq? 'UNQUOTE (car s-expression)))
+ (let ((env (->environment '(user))))
+ (%repl-scode-eval (syntax (cadr s-expression) env) env repl))
+ (%repl-scode-eval (syntax s-expression environment) environment repl)))
(define (repl-scode-eval scode #!optional environment repl)
(receive (environment repl) (optional-er environment repl 'REPL-SCODE-EVAL)
environment-has-parent?
environment-lambda
environment-lookup
+ environment-lookup-or
environment-lookup-macro
environment-macro-names
environment-parent
(export (runtime unparser)
char-set/atom-delimiters
char-set/number-leaders
- char-set/symbol-quotes)
+ char-set/symbol-quotes
+ repl-environment-value)
(initialization (initialize-package!)))
(define-package (runtime parser file-attributes)
(error:macro-binding environment name))
(else value))))
+(define (environment-lookup-or environment name no-value)
+ (case (environment-reference-type environment name)
+ ((UNBOUND UNASSIGNED) (no-value))
+ ((MACRO) (error:macro-binding environment name))
+ (else (environment-lookup environment name))))
+
(define (environment-lookup-macro environment name)
(and (eq? 'MACRO (environment-reference-type environment name))
(let ((value (environment-safe-lookup environment name)))
(*dispatch-table*
(unparser-table/dispatch-vector
(let ((table
- (environment-lookup environment '*UNPARSER-TABLE*)))
+ (repl-environment-value environment '*UNPARSER-TABLE*)))
(guarantee-unparser-table table #f)
table))))
(*unparse-object object)))
(unparse-symbol-name (symbol-name symbol))))
(define (unparse-keyword-name s)
- (case (environment-lookup *environment* '*PARSER-KEYWORD-STYLE*)
+ (case (repl-environment-value *environment* '*PARSER-KEYWORD-STYLE*)
((PREFIX)
(*unparse-char #\:)
(unparse-symbol-name s))
(define (unparse-symbol-name s)
(if (or (string-find-next-char-in-set
s
- (if (environment-lookup *environment*
- '*PARSER-CANONICALIZE-SYMBOLS?*)
+ (if (repl-environment-value *environment*
+ '*PARSER-CANONICALIZE-SYMBOLS?*)
canon-symbol-quoted
non-canon-symbol-quoted))
(fix:= (string-length s) 0)
(char=? (string-ref string 0) #\#))
(define (looks-like-keyword? string)
- (case (environment-lookup *environment* '*PARSER-KEYWORD-STYLE*)
+ (case (repl-environment-value *environment* '*PARSER-KEYWORD-STYLE*)
((PREFIX)
(char=? (string-ref string 0) #\:))
((SUFFIX)