~ubuntu-branches/ubuntu/saucy/ess/saucy

« back to all changes in this revision

Viewing changes to lisp/ess-stan-d.el

  • Committer: Package Import Robot
  • Author(s): Dirk Eddelbuettel
  • Date: 2013-05-17 13:54:28 UTC
  • Revision ID: package-import@ubuntu.com-20130517135428-6bcx2dgg1bigd8vf
Tags: 13.05-2
lisp/ess-stan-d.el: Comment-out the file which should not have been in
the release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
;;; ess-stan-d.el --- ESS[STAN] dialect
 
1
n;;; ess-stan-d.el --- ESS[STAN] dialect
2
2
 
3
3
;; Copyright (C) 2008-2013 ESS Core Team
4
4
 
24
24
 
25
25
;;; Code:
26
26
 
27
 
(require 'ess-bugs-l)
28
 
(require 'ess-utils)
29
 
(require 'ess-inf)
30
 
 
31
 
(setq auto-mode-alist
32
 
      (append '(("\\.[sS][tT][aA][nN]\\'" . ess-stan-mode)) auto-mode-alist))
33
 
 
34
 
(defvar ess-stan-command "stan" "Default STAN program in PATH.")
35
 
(make-local-variable 'ess-stan-command)
36
 
 
37
 
(defvar ess-stan-monitor '("") "Default list of variables to monitor.")
38
 
(make-local-variable 'ess-stan-monitor)
39
 
 
40
 
(defvar ess-stan-thin 1 "Default thinning parameter.")
41
 
(make-local-variable 'ess-stan-thin)
42
 
 
43
 
(defvar ess-stan-chains 1 "Default number of chains.")
44
 
(make-local-variable 'ess-stan-chains)
45
 
 
46
 
(defvar ess-stan-burnin 10000 "Default burn-in.")
47
 
(make-local-variable 'ess-stan-burnin)
48
 
 
49
 
(defvar ess-stan-update 10000 "Default number of updates after burnin.")
50
 
(make-local-variable 'ess-stan-update)
51
 
 
52
 
(defvar ess-stan-system t "Default whether STAN recognizes the system command.")
53
 
 
54
 
(defvar stan-blocks
55
 
  '("data" "transformed data" 
56
 
    "parameters" "transformed parameters" 
57
 
    "model" "generated quantities")
58
 
  "Model blocks in Stan")
59
 
(defvar stan-types
60
 
  '("int" "real" "vector" "ordered" "positive_ordered" "simplex" "row_vector" 
61
 
    "matrix" "corr_matrix" "cov_matrix")
62
 
  "Types in Stan")
63
 
(defvar stan-type-bounds
64
 
  '("lower" "upper")
65
 
  "Types in Stan")
66
 
(defvar stan-distributions
67
 
  '("bernoulli" "bernoulli_logit" "beta_binomial" 
68
 
    "beta" "binomial" "categorical" "cauchy" "chi_square" "dirichlet"
69
 
    "double_exponential" "exponential" "gamma" "hypergeometric" 
70
 
    "inv_chi_square" "inv_gamma" 
71
 
    "inv_wishart" "lkj_corr_cholesky" "lkj_corr" "lkj_cov"
72
 
    "logistic" "lognormal" 
73
 
    "multi_normal_cholesky" "multi_normal" "multi_student_t"
74
 
    "multinomial" "neg_binomial" "normal" 
75
 
    "ordered_logistic"
76
 
    "pareto" "poisson" "poisson_log" "scaled_inv_chi_square" 
77
 
    "student_t" "uniform"
78
 
    "weibull" "wishart")
79
 
  "Distributions in Stan (see index)")
80
 
(defvar stan-cdfs
81
 
  '("bernoulli_cdf" "beta_binomial_cdf" "beta_cdf" "binomial_cdf" 
82
 
    "exponential_cdf" "inv_chi_square_cdf" "inv_gamma_cdf" "logistic_cdf" 
83
 
    "lognormal_cdf" "neg_binomial_cdf" "normal_cdf" "pareto_cdf" 
84
 
    "poisson_cdf" "scaled_inv_chi_square_cdf" "student_t_cdf")
85
 
  "CDFs in Stan (see index)")
86
 
(defvar stan-functions
87
 
  '("Phi" "Phi_approx" "abs" "acos" "acosh" "asin"
88
 
    "asinh" "atan" "atan2" "atanh" "binary_log_loss"
89
 
    "binomial_coefficient_log" "block" "cbrt" "ceil" "cholesky_decompose" 
90
 
    "col" "cols" "cos" "cosh" "crossprod" "cumulative_sum" "determinant" 
91
 
    "diag_matrix" "diag_post_multiply" "diag_pre_multiply" "diagonal" 
92
 
    "dims" "dot_product" "dot_self" "e" 
93
 
    "eigenvalues_sym" "eigenvectors_sym" "epsilon"
94
 
    "erf" "erfc" "exp" "exp2" "expm1" 
95
 
    "fabs" "fdim" "floor" "fma" "fmax" 
96
 
    "fmin" "fmod" "hypot" "if_else" 
97
 
    "int_step" "inv_cloglog" "inv_logit" "inverse" "lbeta" 
98
 
    "lgamma" "lmgamma" "log" "log10" "log1m" "log1m_inv_logit"
99
 
    "log1p" "log1p_exp" "log2" "log_determinant" "log_inv_logit"
100
 
    "log_sum_exp" "logit" 
101
 
    "max" "mdivide_left_tri_low" "mdivide_right_tri_low" "mean" 
102
 
    "min" "multiply_log" "multiply_lower_tri_self_transpose" 
103
 
    "negative_epsilon" "negative_infinity"
104
 
    "not_a_number" "pi" "positive_infinity" "pow" "prod" 
105
 
    "round" "row" "rows" "sd" "sin" "singular_values" 
106
 
    "sinh" "size" "softmax" "sqrt" "sqrt2" 
107
 
    "square" "step" "sum" "tan" "tanh" 
108
 
    "tcrossprod" "tgamma" "trace" "trunc" "variance")
109
 
  "Functions in Stan (excluding distributions and cdfs)")
110
 
(defvar stan-keywords
111
 
  '("for")
112
 
  "Keywords in Stan")
113
 
 
114
 
(defvar ess-stan-font-lock-keywords
115
 
 (list
116
 
     (cons "#.*\n"                        font-lock-comment-face)  
117
 
     ;; Stan model blocks. Look for start of line before and open brace after.
118
 
     (cons (concat "^[[:space:]]*\\(" (regexp-opt stan-blocks 'words) "\\)\\s-*{") 1 font-lock-keyword-face)
119
 
     ;; Stan types. Look for it to come after the start of a line or semicolon.
120
 
     (cons (concat "\\(^\\|;\\)\\s-*" (regexp-opt stan-types 'words)) 2 font-lock-constant-face)
121
 
     ;; Stan type bounds. Look for them after either '<' or ','
122
 
     (cons (concat "\\(<\\|,\\)\\s-*" (regexp-opt stan-type-bounds 'words)) 2 font-lock-constant-face)
123
 
     ;; Stan variables. Look for it to come after the types, anything, then '>'
124
 
     (cons (concat "\\(^\\|;\\)\\s-*" (regexp-opt stan-types 'words) "\\s-*\\(\\w*\\)") 3 font-lock-variable-name-face)
125
 
     (cons (concat "\\(^\\|;\\)\\s-*" (regexp-opt stan-types 'words) "<.*>\\s-*\\(\\w*\\)") 3 font-lock-variable-name-face)
126
 
     ;; Stan functions.
127
 
     (cons (regexp-opt stan-functions 'words) . font-lock-function-name-face)
128
 
     ;; Stan distributions. Look for distribution after '~'
129
 
     (cons (concat "~[[:space:]]*" (regexp-opt stan-distributions 'words)) 1 font-lock-function-constant-face)
130
 
     ;; Stan distributions. Look for distribution_log after '<-'
131
 
     (cons (concat "<-\\s-*\\(\\<" (regexp-opt stan-distributions) "_log\\>\\)") 1 font-lock-constant-face)
132
 
     ;; Stan distributions. Look for cdfs after '<-'
133
 
     (cons (concat "<-[[:space:]]*" (regexp-opt stan-cdfs 'words)) 1 font-lock-constant-face)
134
 
     ;; Stan keywords.
135
 
     (cons (regexp-opt stan-keywords 'words) . font-lock-keyword-face)
136
 
     )
137
 
  "Stan-mode font lock defaults"
138
 
  )
139
 
 
140
 
 
141
 
 
142
 
(defun ess-stan-mode ()
143
 
  "ESS[STAN]: Major mode for STAN."
144
 
  (interactive)
145
 
  (kill-all-local-variables)
146
 
  (ess-setq-vars-local '((comment-start . "#")))
147
 
  (setq major-mode 'ess-stan-mode)
148
 
  (setq mode-name "ESS[STAN]")
149
 
  (use-local-map ess-bugs-mode-map)
150
 
  (setq font-lock-auto-fontify t)
151
 
  (make-local-variable 'font-lock-defaults)
152
 
  (setq font-lock-defaults '(ess-stan-font-lock-keywords nil t))
153
 
  (setq ess-language "S") ; mimic S for ess-smart-underscore
154
 
  (run-hooks 'ess-bugs-mode-hook)
155
 
 
156
 
  (if (not (w32-shell-dos-semantics))
157
 
      (add-hook 'comint-output-filter-functions 'ess-bugs-exit-notify-sh))
158
 
  )
159
 
 
160
 
(setq features (delete 'ess-bugs-d features))
161
 
(provide 'ess-stan-d)
162
 
 
163
 
;;; ess-stan-d.el ends here
164
 
 
165
 
 
166
 
 
167
 
;; ;; Stan mode for v1.2.0 of the language
168
 
 
169
 
 
170
 
;; (define-derived-mode 
171
 
;;   stan-mode   ; variant
172
 
;;   c++-mode    ; parent
173
 
;;   "stan-mode" ; name
174
 
;;   "Stan mode is a mode for editing Stan models" ; doc string
175
 
;;   ;; keyword-args
176
 
;;   ;; body
177
 
;;   ;; comments: '#', '//', or '/*' '*/' pair
178
 
;;   (modify-syntax-entry ?# "< b" stan-mode-syntax-table)
179
 
;;   (modify-syntax-entry ?_ "w" stan-mode-syntax-table)
180
 
;;   (modify-syntax-entry ?\' "_" stan-mode-syntax-table)
181
 
;;   (setq font-lock-defaults stan-font-lock-defaults)   ; stan fonts
182
 
;;   )
183
 
 
184
 
 
185
 
;; (add-to-list 'auto-mode-alist 
186
 
;;           '("\\.stan\\'" . stan-mode))
187
 
 
188
 
;; (provide 'stan-mode)
 
27
;; (require 'ess-bugs-l)
 
28
;; (require 'ess-utils)
 
29
;; (require 'ess-inf)
 
30
 
 
31
;; (setq auto-mode-alist
 
32
;;       (append '(("\\.[sS][tT][aA][nN]\\'" . ess-stan-mode)) auto-mode-alist))
 
33
 
 
34
;; (defvar ess-stan-command "stan" "Default STAN program in PATH.")
 
35
;; (make-local-variable 'ess-stan-command)
 
36
 
 
37
;; (defvar ess-stan-monitor '("") "Default list of variables to monitor.")
 
38
;; (make-local-variable 'ess-stan-monitor)
 
39
 
 
40
;; (defvar ess-stan-thin 1 "Default thinning parameter.")
 
41
;; (make-local-variable 'ess-stan-thin)
 
42
 
 
43
;; (defvar ess-stan-chains 1 "Default number of chains.")
 
44
;; (make-local-variable 'ess-stan-chains)
 
45
 
 
46
;; (defvar ess-stan-burnin 10000 "Default burn-in.")
 
47
;; (make-local-variable 'ess-stan-burnin)
 
48
 
 
49
;; (defvar ess-stan-update 10000 "Default number of updates after burnin.")
 
50
;; (make-local-variable 'ess-stan-update)
 
51
 
 
52
;; (defvar ess-stan-system t "Default whether STAN recognizes the system command.")
 
53
 
 
54
;; (defvar stan-blocks
 
55
;;   '("data" "transformed data" 
 
56
;;     "parameters" "transformed parameters" 
 
57
;;     "model" "generated quantities")
 
58
;;   "Model blocks in Stan")
 
59
;; (defvar stan-types
 
60
;;   '("int" "real" "vector" "ordered" "positive_ordered" "simplex" "row_vector" 
 
61
;;     "matrix" "corr_matrix" "cov_matrix")
 
62
;;   "Types in Stan")
 
63
;; (defvar stan-type-bounds
 
64
;;   '("lower" "upper")
 
65
;;   "Types in Stan")
 
66
;; (defvar stan-distributions
 
67
;;   '("bernoulli" "bernoulli_logit" "beta_binomial" 
 
68
;;     "beta" "binomial" "categorical" "cauchy" "chi_square" "dirichlet"
 
69
;;     "double_exponential" "exponential" "gamma" "hypergeometric" 
 
70
;;     "inv_chi_square" "inv_gamma" 
 
71
;;     "inv_wishart" "lkj_corr_cholesky" "lkj_corr" "lkj_cov"
 
72
;;     "logistic" "lognormal" 
 
73
;;     "multi_normal_cholesky" "multi_normal" "multi_student_t"
 
74
;;     "multinomial" "neg_binomial" "normal" 
 
75
;;     "ordered_logistic"
 
76
;;     "pareto" "poisson" "poisson_log" "scaled_inv_chi_square" 
 
77
;;     "student_t" "uniform"
 
78
;;     "weibull" "wishart")
 
79
;;   "Distributions in Stan (see index)")
 
80
;; (defvar stan-cdfs
 
81
;;   '("bernoulli_cdf" "beta_binomial_cdf" "beta_cdf" "binomial_cdf" 
 
82
;;     "exponential_cdf" "inv_chi_square_cdf" "inv_gamma_cdf" "logistic_cdf" 
 
83
;;     "lognormal_cdf" "neg_binomial_cdf" "normal_cdf" "pareto_cdf" 
 
84
;;     "poisson_cdf" "scaled_inv_chi_square_cdf" "student_t_cdf")
 
85
;;   "CDFs in Stan (see index)")
 
86
;; (defvar stan-functions
 
87
;;   '("Phi" "Phi_approx" "abs" "acos" "acosh" "asin"
 
88
;;     "asinh" "atan" "atan2" "atanh" "binary_log_loss"
 
89
;;     "binomial_coefficient_log" "block" "cbrt" "ceil" "cholesky_decompose" 
 
90
;;     "col" "cols" "cos" "cosh" "crossprod" "cumulative_sum" "determinant" 
 
91
;;     "diag_matrix" "diag_post_multiply" "diag_pre_multiply" "diagonal" 
 
92
;;     "dims" "dot_product" "dot_self" "e" 
 
93
;;     "eigenvalues_sym" "eigenvectors_sym" "epsilon"
 
94
;;     "erf" "erfc" "exp" "exp2" "expm1" 
 
95
;;     "fabs" "fdim" "floor" "fma" "fmax" 
 
96
;;     "fmin" "fmod" "hypot" "if_else" 
 
97
;;     "int_step" "inv_cloglog" "inv_logit" "inverse" "lbeta" 
 
98
;;     "lgamma" "lmgamma" "log" "log10" "log1m" "log1m_inv_logit"
 
99
;;     "log1p" "log1p_exp" "log2" "log_determinant" "log_inv_logit"
 
100
;;     "log_sum_exp" "logit" 
 
101
;;     "max" "mdivide_left_tri_low" "mdivide_right_tri_low" "mean" 
 
102
;;     "min" "multiply_log" "multiply_lower_tri_self_transpose" 
 
103
;;     "negative_epsilon" "negative_infinity"
 
104
;;     "not_a_number" "pi" "positive_infinity" "pow" "prod" 
 
105
;;     "round" "row" "rows" "sd" "sin" "singular_values" 
 
106
;;     "sinh" "size" "softmax" "sqrt" "sqrt2" 
 
107
;;     "square" "step" "sum" "tan" "tanh" 
 
108
;;     "tcrossprod" "tgamma" "trace" "trunc" "variance")
 
109
;;   "Functions in Stan (excluding distributions and cdfs)")
 
110
;; (defvar stan-keywords
 
111
;;   '("for")
 
112
;;   "Keywords in Stan")
 
113
 
 
114
;; (defvar ess-stan-font-lock-keywords
 
115
;;  (list
 
116
;;      (cons "#.*\n"                        font-lock-comment-face)  
 
117
;;      ;; Stan model blocks. Look for start of line before and open brace after.
 
118
;;      (cons (concat "^[[:space:]]*\\(" (regexp-opt stan-blocks 'words) "\\)\\s-*{") 1 font-lock-keyword-face)
 
119
;;      ;; Stan types. Look for it to come after the start of a line or semicolon.
 
120
;;      (cons (concat "\\(^\\|;\\)\\s-*" (regexp-opt stan-types 'words)) 2 font-lock-constant-face)
 
121
;;      ;; Stan type bounds. Look for them after either '<' or ','
 
122
;;      (cons (concat "\\(<\\|,\\)\\s-*" (regexp-opt stan-type-bounds 'words)) 2 font-lock-constant-face)
 
123
;;      ;; Stan variables. Look for it to come after the types, anything, then '>'
 
124
;;      (cons (concat "\\(^\\|;\\)\\s-*" (regexp-opt stan-types 'words) "\\s-*\\(\\w*\\)") 3 font-lock-variable-name-face)
 
125
;;      (cons (concat "\\(^\\|;\\)\\s-*" (regexp-opt stan-types 'words) "<.*>\\s-*\\(\\w*\\)") 3 font-lock-variable-name-face)
 
126
;;      ;; Stan functions.
 
127
;;      (cons (regexp-opt stan-functions 'words) . font-lock-function-name-face)
 
128
;;      ;; Stan distributions. Look for distribution after '~'
 
129
;;      (cons (concat "~[[:space:]]*" (regexp-opt stan-distributions 'words)) 1 font-lock-function-constant-face)
 
130
;;      ;; Stan distributions. Look for distribution_log after '<-'
 
131
;;      (cons (concat "<-\\s-*\\(\\<" (regexp-opt stan-distributions) "_log\\>\\)") 1 font-lock-constant-face)
 
132
;;      ;; Stan distributions. Look for cdfs after '<-'
 
133
;;      (cons (concat "<-[[:space:]]*" (regexp-opt stan-cdfs 'words)) 1 font-lock-constant-face)
 
134
;;      ;; Stan keywords.
 
135
;;      (cons (regexp-opt stan-keywords 'words) . font-lock-keyword-face)
 
136
;;      )
 
137
;;   "Stan-mode font lock defaults"
 
138
;;   )
 
139
 
 
140
 
 
141
 
 
142
;; (defun ess-stan-mode ()
 
143
;;   "ESS[STAN]: Major mode for STAN."
 
144
;;   (interactive)
 
145
;;   (kill-all-local-variables)
 
146
;;   (ess-setq-vars-local '((comment-start . "#")))
 
147
;;   (setq major-mode 'ess-stan-mode)
 
148
;;   (setq mode-name "ESS[STAN]")
 
149
;;   (use-local-map ess-bugs-mode-map)
 
150
;;   (setq font-lock-auto-fontify t)
 
151
;;   (make-local-variable 'font-lock-defaults)
 
152
;;   (setq font-lock-defaults '(ess-stan-font-lock-keywords nil t))
 
153
;;   (setq ess-language "S") ; mimic S for ess-smart-underscore
 
154
;;   (run-hooks 'ess-bugs-mode-hook)
 
155
 
 
156
;;   (if (not (w32-shell-dos-semantics))
 
157
;;       (add-hook 'comint-output-filter-functions 'ess-bugs-exit-notify-sh))
 
158
;;   )
 
159
 
 
160
;; (setq features (delete 'ess-bugs-d features))
 
161
;; (provide 'ess-stan-d)
 
162
 
 
163
;; ;;; ess-stan-d.el ends here
 
164
 
 
165
 
 
166
 
 
167
;; ;; ;; Stan mode for v1.2.0 of the language
 
168
 
 
169
 
 
170
;; ;; (define-derived-mode 
 
171
;; ;;   stan-mode   ; variant
 
172
;; ;;   c++-mode    ; parent
 
173
;; ;;   "stan-mode" ; name
 
174
;; ;;   "Stan mode is a mode for editing Stan models" ; doc string
 
175
;; ;;   ;; keyword-args
 
176
;; ;;   ;; body
 
177
;; ;;   ;; comments: '#', '//', or '/*' '*/' pair
 
178
;; ;;   (modify-syntax-entry ?# "< b" stan-mode-syntax-table)
 
179
;; ;;   (modify-syntax-entry ?_ "w" stan-mode-syntax-table)
 
180
;; ;;   (modify-syntax-entry ?\' "_" stan-mode-syntax-table)
 
181
;; ;;   (setq font-lock-defaults stan-font-lock-defaults)   ; stan fonts
 
182
;; ;;   )
 
183
 
 
184
 
 
185
;; ;; (add-to-list 'auto-mode-alist 
 
186
;; ;;        '("\\.stan\\'" . stan-mode))
 
187
 
 
188
;; ;; (provide 'stan-mode)