#lang scheme/base
(require (planet dherman/parameter:1:3)
(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
(let ([keywords '(break case catch const continue default delete do
else finally for function if instanceof in
new return switch this throw try typeof
var void while with)]
[null-literal '(null)]
[boolean-literals '(true false)]
[future-keywords '(abstract boolean byte char class const debugger double
enum export extends final float goto implements import
int interface long native package private protected public
short static super synchronized throws transient volatile)]
[extended-keywords '(let)])
(append keywords null-literal boolean-literals future-keywords extended-keywords)))
(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?)))))