(module config mzscheme
  (require (planet "" ("dherman" "list.plt" 1 0))
           (lib ""))

  (define (ecma-strict? flag)
    (allow-anonymous-function-source-elements? (not flag))
    (infer-do-while-semicolon? (not flag))
    (enable-extended-catch-statements? (not flag))
    (allow-nested-function-declarations? (not flag)))

  ;; Turn on this flag to allow anonymous function expressions to appear in
  ;; SourceElement contexts. Named functions in SourceElement contexts are
  ;; always considered declarations. (Not ECMA-compliant).
  (define allow-anonymous-function-source-elements? (make-parameter #t))

  ;; Allow do-while statements to omit the semicolon (not ECMA-compliant)?
  (define infer-do-while-semicolon? (make-parameter #f))

  ;; Allow Mozilla-style extended catch statements with guard expressions
  ;; (not ECMA-compliant)?
  (define enable-extended-catch-statements? (make-parameter #f))

  ;; Allow function declarations to appear nested inside of statements
  ;; (not ECMA-compliant)?
  (define allow-nested-function-declarations? (make-parameter #f))

  ;; Turn on this flag to enable proper tail recursion.
  (define proper-tail-recursion? (make-parameter #f))

  ;; Set this to a positive integer to set an artificial limit to the number
  ;; of allowed nested function calls.
  (define stack-limit (make-parameter #f))

  ;; Turn on this flag to allow `eval' to be used in contexts other than as
  ;; a function call. Uses of `eval' in any of these other contexts will
  ;; not inherit the lexical environment of their application site.
  (define allow-eval-aliasing? (make-parameter #f))

  ;; Choose from either 'standard (i.e., the standard syntax for JavaScript)
  ;; or 'sexp (an S-expression syntax).
  (define code-representation (make-parameter 'standard))

  ;; The current set of lexical keywords.
  (define lexical-keywords (make-parameter '(break case catch const continue
                                             debugger default delete do else enum
                                             false finally for function if instanceof in
                                             new null return switch this throw true
                                             try typeof var void while with)))

  (define make-keyword-parameter
    (opt-lambda (kw [init #f])
      (let ([p (make-parameter #f
                 (lambda (b)
                   (if b
                       (lexical-keywords (lset-adjoin eq? (lexical-keywords) kw))
                       (lexical-keywords (lset-difference eq? (lexical-keywords) (list kw))))))])
        (when init
          (p #t))

  ;; Enable the `let' expression, which introduces a new lexical scope block
  ;; (as opposed to implicitly hoisted variables)?
  (define let-expression? (make-keyword-parameter 'let #t))

  (provide (all-defined-except make-keyword-parameter)))