\documentclass{article} \title{Constructing the Interface for a New Statistical Language in ESS} \author{A.J. Rossini \\ Biostatistics \\ University of Washington} \begin{document} \maketitle \begin{abstract} Methods and templates for constructing a template for a new language and dialects are provided. \end{abstract} \section{New Languages} \label{sec:language} The essl-*.el files provide specifications for language support for ESS. Currently, there are 4 major language families supported: \begin{itemize} \item S (including S-PLUS and R) \item SAS \item XLispStat \item Stata \end{itemize} The essl-*.el file provides the following information: \begin{itemize} \item Language dependent indentation functions \item non-dialect customizations \end{itemize} <>= ;-*- mode: emacs-lisp -*- ;;; essl-.el --- Support for editing source ;; Copyright (C) 1999 by A.J. Rossini ;; Author: Your Name Here ;; Maintainer: A.J. Rossini ;; Created: xx Aug 2000 ;; Modified: $Date: 1999/09/08 07:52:13 $ ;; Version: $Revision: 1.1 $ ;; RCS: $Id: NewLanguage.nw,v 1.1 1999/09/08 07:52:13 ess Exp $ ;; This file is part of ESS (Emacs Speaks Statistics). ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;; Code for general editing ;;; Code: ; Requires and autoloads ; Configuration variables (defun LANG-comment-indent () "Indentation for comments." ) ;; The below might have additional (defun LANG-indent-line () "Indent current line as LANG code. Return the amount the indentation changed by." ) ;; For constructing the symbol-table, consider using ;; (defvar S-syntax-table nil "Syntax table for S code.") (if S-syntax-table nil (setq S-syntax-table (make-syntax-table)) (modify-syntax-entry ?\\ "\\" S-syntax-table) (modify-syntax-entry ?+ "." S-syntax-table) (modify-syntax-entry ?- "." S-syntax-table) (modify-syntax-entry ?= "." S-syntax-table) (modify-syntax-entry ?% "." S-syntax-table) (modify-syntax-entry ?< "." S-syntax-table) (modify-syntax-entry ?> "." S-syntax-table) (modify-syntax-entry ?& "." S-syntax-table) (modify-syntax-entry ?| "." S-syntax-table) (modify-syntax-entry ?\' "\"" S-syntax-table) (modify-syntax-entry ?# "<" S-syntax-table) ; open comment (modify-syntax-entry ?\n ">" S-syntax-table) ; close comment ;;(modify-syntax-entry ?. "w" S-syntax-table) ; "." used in S obj names (modify-syntax-entry ?. "_" S-syntax-table) ; see above/below, ; plus consider separation. (modify-syntax-entry ?$ "_" S-syntax-table) ; foo.bar$hack is 1 symbol (modify-syntax-entry ?_ "." S-syntax-table) (modify-syntax-entry ?* "." S-syntax-table) (modify-syntax-entry ?< "." S-syntax-table) (modify-syntax-entry ?> "." S-syntax-table) (modify-syntax-entry ?/ "." S-syntax-table)) (defvar S-editing-alist '((paragraph-start . (concat "^$\\|" page-delimiter)) (paragraph-separate . (concat "^$\\|" page-delimiter)) (paragraph-ignore-fill-prefix . t) (require-final-newline . t) (comment-start . "#") (comment-start-skip . "#+ *") (comment-column . 40) ;;(comment-indent-function . 'S-comment-indent) ;;(ess-comment-indent . 'S-comment-indent) ;;(ess-indent-line . 'S-indent-line) ;;(ess-calculate-indent . 'S-calculate-indent) (indent-line-function . 'S-indent-line) (parse-sexp-ignore-comments . t) (ess-set-style . ess-default-style) (ess-local-process-name . nil) ;;(ess-keep-dump-files . 'ask) (ess-mode-syntax-table . S-syntax-table) (font-lock-defaults . '(ess-mode-font-lock-keywords nil nil ((?\. . "w"))))) "General options for editing S, S+, and R source files.") ;;; Changes from S to S-PLUS 3.x. (standard S3 should be in essl-s!). (defconst S+-help-sec-keys-alist '((?a . "ARGUMENTS:") (?b . "BACKGROUND:") (?B . "BUGS:") (?d . "DESCRIPTION:") (?D . "DETAILS:") (?e . "EXAMPLES:") (?n . "NOTE:") (?O . "OPTIONAL ARGUMENTS:") (?R . "REQUIRED ARGUMENTS:") (?r . "REFERENCES:") (?s . "SEE ALSO:") (?S . "SIDE EFFECTS:") (?u . "USAGE:") (?v . "VALUE:")) "Alist of (key . string) pairs for use in section searching.") ;;; `key' indicates the keystroke to use to search for the section heading ;;; `string' in an S help file. `string' is used as part of a ;;; regexp-search, and so specials should be quoted. ;; S ver.3 (NOT S-Plus) (defconst S3-help-sec-keys-alist '((?a . "ARGUMENTS:") (?b . "BACKGROUND:") (?B . "BUGS:") (?d . "DESCRIPTION:") (?D . "DETAILS:") (?e . "EXAMPLES:") (?n . "NOTE:") (?r . "REFERENCES:") (?s . "SEE ALSO:") (?S . "SIDE EFFECTS:") (?u . "USAGE:") (?v . "VALUE:")) "Help section keys for S ver.3.") (defconst S4-help-sec-keys-alist '((?a . "ARGUMENTS:") (?b . "BACKGROUND:") (?B . "BUGS:") (?d . "DESCRIPTION:") (?D . "DETAILS:") (?e . "EXAMPLES:") (?n . "NOTE:") (?r . "REFERENCES:") (?s . "SEE ALSO:") (?S . "SIDE EFFECTS:") (?u . "USAGE:") (?v . "VALUE:")) "Help section keys for S4.") (defconst R-help-sec-keys-alist '((?a . "\\s *Arguments:") (?d . "\\s *Description:") (?e . "\\s *Examples:") (?n . "\\s *Note:") (?r . "\\s *References:") (?s . "\\s *See Also:") (?v . "\\s *Value[s]?") ; )) ;; "Alist of (key . string) pairs for use in section searching." (defconst ess-help-S+-sec-regex "^[A-Z. ---]+:$" "Reg(ular) Ex(pression) of section headers in help file") (defconst ess-help-R-sec-regex "^\\s *[A-Z[a-z. ---]+:$") ;; Put any other functions here. (provide 'essl-s) ; Local variables section ;;; This file is automatically placed in Outline minor mode. ;;; The file is structured as follows: ;;; Chapters: ^L ; ;;; Sections: ;;*;; ;;; Subsections: ;;;*;;; ;;; Components: defuns, defvars, defconsts ;;; Random code beginning with a ;;;;* comment ;;; Local variables: ;;; mode: emacs-lisp ;;; outline-minor-mode: nil ;;; mode: outline-minor ;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*" ;;; End: ;;; essl-s.el ends here @ section{Dialect Construction} <>= ;;; -*- mode: emacs-lisp -*- ;;; essd-NEWDIALECT.el --- NEWDIALECT customization ;; Copyright (C) 1999 A. J. Rossini ;; Author: DIALECT AUTHOR ;; Maintainer: A.J. Rossini ;; Created: ;; Modified: $Date: 1999/09/08 07:52:13 $ ;; Version: $Revision: 1.1 $ ;; RCS: $Id: NewLanguage.nw,v 1.1 1999/09/08 07:52:13 ess Exp $ ;; ;; Keywords: start up, configuration. ;; This file is part of ESS. ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;;; This file defines all the S-PLUS 3.x customizations for ess-mode. ;;; Requires and Autoloads: (require 'essl-NEWLANGUAGE) (autoload 'inferior-ess "ess-inf" "Run an ESS process") (autoload 'ess-mode "ess-mode" "Edit an ESS process") ; Code: (defvar S+3-dialect-name "S+3" "Name of 'dialect' for S-PLUS 3.x.");easily changeable in a user's .emacs (defvar S+3-customize-alist '((ess-local-customize-alist . 'S+3-customize-alist) (ess-language . "S") (ess-dialect . S+3-dialect-name) (ess-suffix . "S") (ess-loop-timeout . 500000 ) (ess-dump-filename-template . (concat (user-login-name) ".%s." ess-suffix)) (ess-mode-editing-alist . S-editing-alist) (ess-mode-syntax-table . S-syntax-table) (ess-help-sec-regex . ess-help-S+-sec-regex) (ess-help-sec-keys-alist . S+-help-sec-keys-alist) (ess-object-name-db-file . "ess-s+3-namedb.el" ) (ess-retr-lastvalue-command . ".Last.value <- get(\".ess.lvsave\",frame=0)\n") (ess-save-lastvalue-command . "assign(\".ess.lvsave\",.Last.value,frame=0)\n") (inferior-ess-program . inferior-S+3-program-name) (inferior-ess-objects-command . "objects(%d)\n") (inferior-ess-help-command . "help(\"%s\",pager=\"cat\",window=F)\n") (inferior-ess-exit-command . "q()\n") (inferior-ess-primary-prompt . "[a-zA-Z0-9() ]*> ?") (inferior-ess-secondary-prompt . "+ ?") (inferior-ess-start-file . nil) ;"~/.ess-S+3") (inferior-ess-start-args . "")) "Variables to customize for NEWDIALECT") (defun NEWDIALECT (&optional proc-name) "Call 'NEWDIALECT'." (interactive) (setq ess-customize-alist S+3-customize-alist) (ess-write-to-dribble-buffer (format "\n(S+3): ess-dialect=%s, buf=%s\n" ess-dialect (current-buffer))) (inferior-ess)) (defun NEWDIALECT-mode (&optional proc-name) "Major mode for editing NEWDIALECT source. See ess-mode for more help." (interactive) (setq ess-customize-alist S+3-customize-alist) (ess-mode S+3-customize-alist proc-name)) (defun NEWDIALECT-transcript-mode () "NEWDIALECT transcript mode." (interactive) (ess-transcript-mode S+3-customize-alist)) ; Provide package (provide 'essd-sp3) ; Local variables section ;;; This file is automatically placed in Outline minor mode. ;;; The file is structured as follows: ;;; Chapters: ^L ; ;;; Sections: ;;*;; ;;; Subsections: ;;;*;;; ;;; Components: defuns, defvars, defconsts ;;; Random code beginning with a ;;;;* comment ;;; Local variables: ;;; mode: emacs-lisp ;;; outline-minor-mode: nil ;;; mode: outline-minor ;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*" ;;; End: ;;; essd-NEWDIALECT ends here @ \end{document}