#lang scheme/base
(require (planet dherman/parameter:1)
(only-in srfi/1/list lset-adjoin))
(provide (except-out (all-defined-out) default-keywords keyword-guard add-keyword remove-keyword (struct-out config)))
(define default-keywords
'(break case catch const continue
debugger default delete do else enum
false finally for function if instanceof in
let
new null return switch this throw true
try typeof var void while with))
(define (keyword-guard kw)
(lambda (v)
(if v (add-keyword kw) (remove-keyword kw))))
(define (add-keyword kw)
(lexical-keywords (lset-adjoin eq? (lexical-keywords) kw)))
(define (remove-keyword kw)
(lexical-keywords (filter (lambda (k)
(not (eq? k kw)))
(lexical-keywords))))
(define current-debug-port (make-parameter (current-error-port)))
(define-parameter-set config current-config
(allow-anonymous-function-source-elements? #t)
(infer-do-while-semicolon? #f)
(enable-extended-catch-statements? #f)
(allow-nested-function-declarations? #f)
(proper-tail-recursion? #f)
(stack-limit #f)
(allow-eval-aliasing? #f)
(code-representation 'standard)
(lexical-keywords default-keywords)
(enable-let-expressions? #t (keyword-guard 'let))
(debug-destination 'error-port)
(debug-scope-resolution? #f)
(debug-unbound-references? #f))
(define default-config (current-config))
(define (default-config? c)
(equal? c default-config))
(define ecma-strict?
(make-pseudo-parameter (lambda ()
(not (or (allow-anonymous-function-source-elements?)
(infer-do-while-semicolon?)
(enable-extended-catch-statements?)
(allow-nested-function-declarations?))))
(lambda (b)
(let ([non-strict? (not b)])
(allow-anonymous-function-source-elements? non-strict?)
(infer-do-while-semicolon? non-strict?)
(enable-extended-catch-statements? non-strict?)
(allow-nested-function-declarations? non-strict?)))))