Initial Commit
[packages] / xemacs-packages / prog-modes / simula.el
1 ;;; simula.el --- SIMULA 87 code editing commands for Emacs
2
3 ;; Copyright (C) 1992 Free Software Foundation, Inc.
4
5 ;; Author: Hans Henrik Eriksen <hhe@ifi.uio.no>
6 ;; Maintainer: simula-mode@ifi.uio.no
7 ;; Version: 0.992
8 ;; Adapted-By: ESR
9 ;; Keywords: languages
10
11 ;; This file is part of XEmacs.
12
13 ;; XEmacs is free software; you can redistribute it and/or modify it
14 ;; under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; XEmacs is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with XEmacs; see the file COPYING.  If not, write to the 
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Synched up with: FSF 19.30.
29
30 ;;; Commentary:
31
32 ;; A major mode for editing the Simula language.  It knows about Simula
33 ;; syntax and standard indentation commands.  It also provides convenient
34 ;; abbrevs for Simula keywords.
35 ;;
36 ;; Hans Henrik Eriksen (the author) may be reached at:
37 ;;         Institutt for informatikk,
38 ;;         Universitetet i Oslo
39
40 ;;; Code:
41
42 (provide 'simula-mode)
43
44 (defgroup simula nil
45   "SIMULA 87 code editing commands for Emacs."
46   :group 'languages)
47
48
49 (defcustom simula-tab-always-indent nil
50   "*Non-nil means TAB in SIMULA mode should always reindent the current line.
51 Otherwise TAB indents only when point is within
52 the run of whitespace at the beginning of the line."
53   :type 'boolean
54   :group 'simula)
55
56 (defcustom simula-indent-level 3
57   "*Indentation of SIMULA statements with respect to containing block."
58   :type 'integer
59   :group 'simula)
60
61 (defcustom simula-substatement-offset 3
62   "*Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE."
63   :type 'integer
64   :group 'simula)
65
66 (defcustom simula-continued-statement-offset 3
67   "*Extra indentation for lines not starting a statement or substatement.
68 If value is a list, each line in a multipleline continued statement
69 will have the car of the list extra indentation with respect to
70 the previous line of the statement."
71   :type 'integer
72   :group 'simula)
73
74 (defcustom simula-label-offset -4711
75   "*Offset of SIMULA label lines relative to usual indentation."
76   :type 'integer
77   :group 'simula)
78
79 (defcustom simula-if-indent '(0 . 0)
80   "*Extra indentation of THEN and ELSE with respect to the starting IF.
81 Value is a cons cell, the car is extra THEN indentation and the cdr
82 extra ELSE indentation.  IF after ELSE is indented as the starting IF."
83   :type '(cons (integer :tag "THEN")
84                (integer :tag "ELSE"))
85   :group 'simula)
86
87 (defcustom simula-inspect-indent '(0 . 0)
88   "*Extra indentation of WHEN and OTHERWISE with respect to the INSPECT.
89 Value is a cons cell, the car is extra WHEN indentation
90 and the cdr extra OTHERWISE indentation."
91   :type '(cons (integer :tag "WHEN")
92                (integer :tag "OTHERWISE"))
93   :group 'simula)
94
95 (defcustom simula-electric-indent nil
96   "*Non-nil means `simula-indent-line' function may reindent previous line."
97   :type 'boolean
98   :group 'simula)
99
100 (defcustom simula-abbrev-keyword 'upcase
101   "*Specify how to convert case for SIMULA keywords.
102 Value is one of the symbols `upcase', `downcase', `capitalize',
103 \(as in) `abbrev-table' or nil if they should not be changed."
104   :type '(choice (const upcase) (const downcase) (const capitalize)
105                  (const abbrev-table) (const nil))
106   :group 'simula)
107
108 (defcustom simula-abbrev-stdproc 'abbrev-table
109   "*Specify how to convert case for standard SIMULA procedure and class names.
110 Value is one of the symbols `upcase', `downcase', `capitalize',
111 \(as in) `abbrev-table', or nil if they should not be changed."
112   :type '(choice (const upcase) (const downcase) (const capitalize)
113                  (const abbrev-table) (const nil))
114   :group 'simula)
115
116 (defcustom simula-abbrev-file nil
117   "*File with extra abbrev definitions for use in SIMULA mode.
118 These are used together with the standard abbrev definitions for SIMULA.
119 Please note that the standard definitions are required
120 for SIMULA mode to function correctly."
121   :type '(choice (const :tag "None")
122                  file)
123   :group 'simula)
124
125 (defvar simula-mode-syntax-table nil
126   "Syntax table in SIMULA mode buffers.")
127
128 (if simula-mode-syntax-table
129     ()
130   (setq simula-mode-syntax-table  (copy-syntax-table nil))
131   (modify-syntax-entry ?!  "<"    simula-mode-syntax-table)
132   (modify-syntax-entry ?$  "."    simula-mode-syntax-table)
133   (modify-syntax-entry ?%  "."    simula-mode-syntax-table)
134   (modify-syntax-entry ?'  "\""   simula-mode-syntax-table)
135   (modify-syntax-entry ?\( "()"   simula-mode-syntax-table)
136   (modify-syntax-entry ?\) ")("   simula-mode-syntax-table)
137   (modify-syntax-entry ?\; ">"    simula-mode-syntax-table)
138   (modify-syntax-entry ?\[ "."    simula-mode-syntax-table)
139   (modify-syntax-entry ?\\ "."    simula-mode-syntax-table)
140   (modify-syntax-entry ?\] "."    simula-mode-syntax-table)
141   (modify-syntax-entry ?_  "w"    simula-mode-syntax-table)
142   (modify-syntax-entry ?\| "."    simula-mode-syntax-table)
143   (modify-syntax-entry ?\{ "."    simula-mode-syntax-table)
144   (modify-syntax-entry ?\} "."    simula-mode-syntax-table))
145
146 (defvar simula-mode-map ()
147   "Keymap used in SIMULA mode.")
148
149 (if simula-mode-map
150     ()
151   (setq simula-mode-map (make-sparse-keymap))
152   (define-key simula-mode-map "\C-c\C-u"   'simula-backward-up-level)
153   (define-key simula-mode-map "\C-c\C-p"   'simula-previous-statement)
154   (define-key simula-mode-map "\C-c\C-d"   'simula-forward-down-level)
155   (define-key simula-mode-map "\C-c\C-n"   'simula-next-statement)
156   ;(define-key simula-mode-map "\C-c\C-g"   'simula-goto-definition)
157   ;(define-key simula-mode-map "\C-c\C-h"   'simula-standard-help)
158   (define-key simula-mode-map ":"          'simula-electric-label)
159   (define-key simula-mode-map "\t"         'simula-indent-command))
160
161 (defvar simula-mode-abbrev-table nil
162   "Abbrev table in SIMULA mode buffers")
163
164 ;;;###autoload
165 (defun simula-mode ()
166   "Major mode for editing SIMULA code.
167 \\{simula-mode-map}
168 Variables controlling indentation style:
169  simula-tab-always-indent
170     Non-nil means TAB in SIMULA mode should always reindent the current line,
171     regardless of where in the line point is when the TAB command is used.
172  simula-indent-level
173     Indentation of SIMULA statements with respect to containing block.
174  simula-substatement-offset
175     Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.
176  simula-continued-statement-offset 3
177     Extra indentation for lines not starting a statement or substatement,
178     e.g. a nested FOR-loop.  If value is a list, each line in a multiple-
179     line continued statement will have the car of the list extra indentation
180     with respect to the previous line of the statement.
181  simula-label-offset -4711
182     Offset of SIMULA label lines relative to usual indentation.
183  simula-if-indent '(0 . 0)
184     Extra indentation of THEN and ELSE with respect to the starting IF.
185     Value is a cons cell, the car is extra THEN indentation and the cdr
186     extra ELSE indentation.  IF after ELSE is indented as the starting IF.
187  simula-inspect-indent '(0 . 0)
188     Extra indentation of WHEN and OTHERWISE with respect to the
189     corresponding INSPECT.  Value is a cons cell, the car is
190     extra WHEN indentation and the cdr extra OTHERWISE indentation.
191  simula-electric-indent nil
192     If this variable is non-nil, `simula-indent-line'
193     will check the previous line to see if it has to be reindented.
194  simula-abbrev-keyword 'upcase
195     Determine how SIMULA keywords will be expanded.  Value is one of
196     the symbols `upcase', `downcase', `capitalize', (as in) `abbrev-table',
197     or nil if they should not be changed.
198  simula-abbrev-stdproc 'abbrev-table
199     Determine how standard SIMULA procedure and class names will be
200     expanded. Value is one of the symbols `upcase', `downcase', `capitalize',
201     (as in) `abbrev-table', or nil if they should not be changed.
202
203 Turning on SIMULA mode calls the value of the variable simula-mode-hook
204 with no arguments, if that value is non-nil
205
206 Warning: simula-mode-hook should not read in an abbrev file without calling
207 the function simula-install-standard-abbrevs afterwards, preferably not
208 at all."
209   (interactive)
210   (kill-all-local-variables)
211   (use-local-map simula-mode-map)
212   (setq major-mode 'simula-mode)
213   (setq mode-name "SIMULA")
214   (make-local-variable 'comment-column)
215   (setq comment-column 40)
216   (make-local-variable 'end-comment-column)
217   (setq end-comment-column 75)
218   (set-syntax-table simula-mode-syntax-table)
219   (make-local-variable 'paragraph-start)
220   (setq paragraph-start "[ \t]*$\\|\\f")
221   (make-local-variable 'paragraph-separate)
222   (setq paragraph-separate paragraph-start)
223   (make-local-variable 'indent-line-function)
224   (setq indent-line-function 'simula-indent-line)
225   (make-local-variable 'require-final-newline)
226   (setq require-final-newline t)
227   (make-local-variable 'comment-start)
228   (setq comment-start "! ")
229   (make-local-variable 'comment-end)
230   (setq comment-end " ;")
231   (make-local-variable 'comment-start-skip)
232   (setq comment-start-skip "!+ *")
233   (make-local-variable 'parse-sexp-ignore-comments)
234   (setq parse-sexp-ignore-comments nil)
235   (make-local-variable 'comment-multi-line)
236   (setq comment-multi-line t)
237   (if simula-mode-abbrev-table
238       ()
239     (if simula-abbrev-file
240         (read-abbrev-file simula-abbrev-file)
241       (define-abbrev-table 'simula-mode-abbrev-table ()))
242     (let (abbrevs-changed)
243       (simula-install-standard-abbrevs)))
244   (setq local-abbrev-table simula-mode-abbrev-table)
245   (abbrev-mode 1)
246   (run-hooks 'simula-mode-hook))
247
248
249
250 (defun simula-indent-line ()
251   "Indent this line as SIMULA code.
252 If `simula-electric-indent' is non-nil, indent previous line if necessary."
253   (let ((origin (- (point-max) (point)))
254         (indent (simula-calculate-indent))
255         (case-fold-search t))
256     (unwind-protect
257         (progn
258           ;;
259           ;; manually expand abbrev on last line, if any
260           ;;
261           (end-of-line 0)
262           (expand-abbrev)
263           ;; now maybe we should reindent that line
264           (if simula-electric-indent
265               (progn
266                 (beginning-of-line)
267                 (skip-chars-forward " \t\f")
268                 (if (and
269                      (looking-at
270                       "\\(end\\|if\\|then\\|else\\|when\\|otherwise\\)\\>")
271                      (not (simula-context)))
272                     ;; yes - reindent
273                     (let ((post-indent (simula-calculate-indent)))
274                       (if (eq (current-indentation) post-indent)
275                           ()
276                         (delete-horizontal-space)
277                         (indent-to post-indent)))))))
278       (goto-char (- (point-max) origin))
279       (if (eq (current-indentation) indent)
280           (back-to-indentation)
281         (delete-horizontal-space)
282         (indent-to indent)))))
283
284
285 (defun simula-indent-command (&optional whole-exp)
286   "Indent current line as SIMULA code, or insert TAB character.
287 If `simula-tab-always-indent' is non-nil, always indent current line.
288 Otherwise, indent only if point is before any non-whitespace
289 character on the line.
290
291 A numeric argument, regardless of its value, means indent rigidly
292 all the lines of the SIMULA statement after point so that this line
293 becomes properly indented.
294 The relative indentation among the lines of the statement are preserved."
295   (interactive "P")
296   (let ((case-fold-search t))
297     (if (or whole-exp simula-tab-always-indent
298             (save-excursion
299               (skip-chars-backward " \t\f")
300               (bolp)))
301         ;; reindent current line
302         (let ((indent (save-excursion
303                         (beginning-of-line)
304                         (simula-calculate-indent)))
305               (current (current-indentation))
306               (origin (- (point-max) (point)))
307               (bol (save-excursion
308                      (skip-chars-backward " \t\f")
309                      (bolp)))
310               beg end)
311           (unwind-protect
312               (if (eq current indent)
313                   (if (save-excursion
314                         (skip-chars-backward " \t\f")
315                         (bolp))
316                       (back-to-indentation))
317                 (beginning-of-line)
318                 (delete-horizontal-space)
319                 (indent-to indent))
320             (if (not bol)
321                 (goto-char (- (point-max) origin))))
322           (setq origin (point))
323           (if whole-exp
324               (save-excursion
325                 (beginning-of-line 2)
326                 (setq beg (point))
327                 (goto-char origin)
328                 (simula-next-statement 1)
329                 (setq end (point))
330                 (if (and (> end beg) (not (eq indent current)))
331                     (indent-code-rigidly beg end (- indent current) "%")))))
332       (insert-tab))))
333
334
335 (defun simula-context ()
336   "Returns value according to syntactic SIMULA context of point.
337     0    point inside COMMENT comment
338     1    point on SIMULA-compiler directive line
339     2    point inside END comment
340     3    point inside string
341     4    point inside character constant
342   nil    otherwise."
343   ;; first, find out if this is a compiler directive line
344   (if (save-excursion
345         (beginning-of-line)
346         (eq (following-char) ?%))
347       ;; YES - return 1
348       1
349     (save-excursion
350       ;; The current line is NOT a compiler directive line.
351       ;; Now, the strategy is to search backward to find a semicolon
352       ;; that is NOT inside a string. The point after semicolon MUST be
353       ;; outside a comment, since semicolons are comment-ending and
354       ;; comments are non-recursive. We take advantage of the fact
355       ;; that strings MUST end on the same line as they started, so
356       ;; that we can easily decide whether we are inside a string or not.
357       (let (return-value (origin (point)))
358         (skip-chars-backward "^;" (point-min))
359         ;; found semicolon or beginning of buffer
360         (let (loopvalue (saved-point origin))
361           (while (and (not (bobp))
362                       (if (progn
363                             (beginning-of-line)
364                             ;; compiler directive line? If so, cont searching..
365                             (eq (following-char) ?%))
366                           t
367                         (while (< (point) saved-point)
368                           (skip-chars-forward "^;\"'")
369                           (forward-char 1)
370                           (cond
371                            ((eq (preceding-char) ?\;)
372                             (setq saved-point (point)))
373                            ((eq (preceding-char) ?\")
374                             (skip-chars-forward "^\";")
375                             (if (eq (following-char) ?\;)
376                                 (setq saved-point (point) loopvalue t)
377                               (forward-char 1)))
378                            (t
379                             (if (eq (following-char) ?')
380                                 (forward-char 1))
381                             (skip-chars-forward "^';")
382                             (if (eq (following-char) ?\;)
383                                 (setq saved-point (point) loopvalue t)
384                               (forward-char 1)))))
385                         loopvalue))
386             (backward-char 1)
387             (skip-chars-backward "^;")
388             (setq saved-point (point) loopvalue nil)))
389         ;; Now we are CERTAIN that we are outside comments and strings.
390         ;; The job now is to search forward again towards the origin
391         ;; skipping directives, comments and strings correctly,
392         ;; so that we know what context we are in when we find the origin.
393         (while (and
394                 (< (point) origin)
395                 (re-search-forward
396                  "\\<end\\>\\|!\\|\"\\|'\\|^%\\|\\<comment\\>" origin 'move))
397           (cond
398            ((memq (preceding-char) '(?d ?D))
399             (setq return-value 2)
400             (while (and (memq (preceding-char) '(?d ?D)) (not return-value))
401               (while (and (re-search-forward
402                            ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>\\|^%"
403                            origin 'move)
404                           (eq (preceding-char) ?%))
405                 (beginning-of-line 2)))
406             (if (looking-at "[ \t\n\f]*\\(;\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>\\)")
407                 (setq return-value nil)))
408            ((memq (preceding-char) '(?! ?t ?T))
409             ; skip comment
410             (setq return-value 0)
411             (skip-chars-forward "^%;" origin)
412             (while (and return-value (< (point) origin))
413               (if (eq (following-char) ?\;)
414                   (setq return-value nil)
415                 (if (bolp)
416                     (beginning-of-line 2)       ; skip directive inside comment
417                   (forward-char 1))             ; or single '%'
418                 (skip-chars-forward "^%;" origin))))
419            ((eq (preceding-char) ?\")
420             (if (not (search-forward "\"" origin 'move))
421                 (setq return-value 3)))
422            ((eq (preceding-char) ?\')
423             (if (or (eq (point) origin) (eobp))
424                 (setq return-value 4)
425               (forward-char 1)
426               (if (not (search-forward "'" origin 'move))
427                   (setq return-value 4))))
428            ;; compiler directive line - skip
429            (t (beginning-of-line 2))))
430         return-value)
431       )))
432
433
434 (defun simula-electric-label ()
435   "If this is a label that starts the line, reindent the line."
436   (interactive)
437   (expand-abbrev)
438   (insert ?:)
439   (let ((origin (- (point-max) (point)))
440         (case-fold-search t)
441         ;; don't mix a label with an assignment operator := :-
442         ;; therefore look at next typed character...
443         (next-char (if (fboundp 'next-command-event)
444                        (event-to-character (setq unread-command-events
445                                                  (list (next-command-event))))
446                        ;; FSFmacs
447                        (setq unread-command-events (list (read-event)))))
448         ;(com-char last-command-char) -- unused
449         )
450     (unwind-protect
451         ;; Problem: find out if character just read is a command char
452         ;; that would insert something after ':' making it a label.
453         ;; At least \n, \r (and maybe \t) falls into this category.
454         ;; This is a real crock, it depends on traditional keymap
455         ;; bindings, that is, printing characters doing self-insert,
456         ;; and no other command sequence inserting '-' or '='.
457         ;; simula-electric-label can be easily fooled...
458         (if (and (not (memq next-char '(?= ?-)))
459                  (or (memq next-char '(?\n ?\r))
460                      (and (eq next-char ?\t)
461                           simula-tab-always-indent)
462                      (not (memq (following-char) '(?= ?-))))
463                  (not (simula-context))
464                  ;; label?
465                  (progn
466                    (backward-char 1)
467                    (skip-chars-backward " \t\f")
468                    (skip-chars-backward "a-zA-Z0-9_")
469                    (if (looking-at "virtual\\>")
470                        nil
471                      (skip-chars-backward " \t\f")
472                      (bolp))))
473             (let ((amount (simula-calculate-indent)))
474               (delete-horizontal-space)
475               (indent-to amount)))
476       (goto-char (- (point-max) origin)))))
477         
478
479 (defun simula-backward-up-level (count)
480   "Move backward up COUNT block levels.
481 If COUNT is negative, move forward up block level instead."
482   (interactive "p")
483   (let ((origin (point))
484         (case-fold-search t))
485     (condition-case ()
486         (if (> count 0)
487             (while (> count 0)
488               (re-search-backward "\\<begin\\>\\|\\<end\\>")
489               (if (not (simula-context))
490                   (setq count (if (memq (following-char) '(?b ?B))
491                                   (1- count)
492                                 (1+ count)))))
493           (while (< count 0)
494             (re-search-forward "\\<begin\\>\\|\\<end\\>")
495             (backward-word 1)
496             (if (not (simula-context))
497                 (setq count (if (memq (following-char) '(?e ?E))
498                                 (1+ count)
499                               (1- count))))
500             (backward-word -1)))
501       ;; If block level not found, jump back to origin and signal an error
502       (error (progn
503                (goto-char origin)
504                (error "No higher block level")))
505       (quit (progn
506               (goto-char origin)
507               (signal 'quit nil))))))
508
509
510 (defun simula-forward-down-level (count)
511   "Move forward down COUNT block levels.
512 If COUNT is negative, move backward down block level instead."
513   (interactive "p")
514   ;; When we search for a deeper block level, we must never
515   ;; get out of the block where we started -> count >= start-count
516   (let ((start-count count)
517         (origin (point))
518         (case-fold-search t))
519     (condition-case ()
520         (if (< count 0)
521             (while (< count 0)
522               (re-search-backward "\\<begin\\>\\|\\<end\\>")
523               (if (not (simula-context))
524                   (setq count (if (memq (following-char) '(?e ?E))
525                                   (1+ count)
526                                 (1- count))))
527               (if (< count start-count) (signal 'error nil)))
528           (while (> count 0)
529             (re-search-forward "\\<begin\\>\\|\\<end\\>")
530             (backward-word 1)
531             (if (not (simula-context))
532                 (setq count (if (memq (following-char) '(?b ?B))
533                                 (1- count)
534                               (1+ count))))
535             (backward-word -1)
536             ;; deeper level has to be found within starting block
537             (if (> count start-count) (signal 'error nil))))
538       ;; If block level not found, jump back to origin and signal an error
539       (error (progn
540                (goto-char origin)
541                (error "No containing block level")))
542       (quit (progn
543               (goto-char origin)
544               (signal 'quit nil))))))
545
546      
547 (defun simula-previous-statement (count)
548   "Move backward COUNT statements.
549 If COUNT is negative, move forward instead."
550   (interactive "p")
551   (if (< count 0)
552       (simula-next-statement (- count))
553     (let (status
554           (case-fold-search t)
555           (origin (point)))
556       (condition-case ()
557           (progn
558             (simula-skip-comment-backward)
559             (if (memq (preceding-char) '(?n ?N))
560                 (progn
561                   (backward-word 1)
562                   (if (not (looking-at "\\<begin\\>"))
563                       (backward-word -1)))
564               (if (eq (preceding-char) ?\;)
565                   (backward-char 1)))
566             (while (and (natnump (setq count (1- count)))
567                         (setq status (simula-search-backward
568                                       ";\\|\\<begin\\>" nil 'move))))
569             (if status
570                 (progn
571                   (if (eq (following-char) ?\;)
572                       (forward-char 1)
573                     (backward-word -1))))
574             (simula-skip-comment-forward))
575         (error (progn (goto-char origin)
576                       (error "Incomplete statement (too many ENDs)")))
577         (quit (progn (goto-char origin) (signal 'quit nil)))))))
578
579
580 (defun simula-next-statement (count)
581   "Move forward COUNT statements.
582 If COUNT is negative, move backward instead."
583   (interactive "p")
584   (if (< count 0)
585       (simula-previous-statement (- count))
586     (let (status
587           (case-fold-search t)
588           (origin (point)))
589       (condition-case ()
590           (progn
591             (simula-skip-comment-forward)
592             (if (looking-at "\\<end\\>") (forward-word 1))
593             (while (and (natnump (setq count (1- count)))
594                         (setq status (simula-search-forward
595                                       ";\\|\\<end\\>" (point-max) 'move))))
596             (if (and status (/= (preceding-char) ?\;))
597                 (progn
598                   (backward-word 1)
599                   (simula-skip-comment-backward))))
600         (error (progn (goto-char origin)
601                       (error "Incomplete statement (too few ENDs)")))
602         (quit (progn (goto-char origin) (signal 'quit nil)))))))
603
604
605 (defun simula-skip-comment-backward ()
606   "Search towards bob to find first char that is outside a comment."
607   (interactive)
608   (catch 'simula-out
609     (let (context)
610       (while t
611         (skip-chars-backward " \t\n\f")
612         (if (eq (preceding-char) ?\;)
613             (save-excursion
614               (backward-char 1)
615               (setq context (simula-context)))
616           (setq context (simula-context)))
617         (cond
618          ((memq context '(nil 3 4))
619           ;; check to see if we found a label
620           (if (and (eq (preceding-char) ?:)
621                    (not (memq (following-char) '(?- ?=)))
622                    (save-excursion
623                      (skip-chars-backward ": \t\fa-zA-Z0-9_")
624                      (not (looking-at "virtual\\>"))))
625               (skip-chars-backward ": \t\fa-zA-Z0-9_")
626             (throw 'simula-out nil)))
627          ((eq context 0)
628           ;; since we are inside a comment, it must start somewhere!
629           (while (and (re-search-backward "!\\|\\<comment\\>")
630                       (memq (simula-context) '(0 1)))))
631          ((eq context 1)
632           (end-of-line 0)
633           (if (bobp)
634               (throw 'simula-out nil)))
635          ((eq context 2)
636           ;; an END-comment must belong to an END
637           (re-search-backward "\\<end\\>")
638           (forward-word 1)
639           (throw 'simula-out nil))
640          ;; should be impossible to get here..
641          )))))
642
643
644 (defun simula-skip-comment-forward ()
645   "Search towards eob to find first char that is outside a comment."
646   ;; this function assumes we start with point .outside a comment
647   (interactive)
648   (catch 'simula-out
649     (while t
650       (skip-chars-forward " \t\n\f")
651       (cond
652        ((looking-at "!\\|\\<comment\\>")
653         (search-forward ";" nil 'move))
654        ((and (bolp) (eq (following-char) ?%))
655         (beginning-of-line 2))
656        ((and (looking-at "[a-z0-9_]*[ \t\f]*:[^-=]")
657              (not (looking-at "virtual\\>")))
658         (skip-chars-forward "a-zA-Z0-9_ \t\f:"))
659        (t
660         (throw 'simula-out t))))))
661
662
663 (defun simula-forward-up-level ()
664   (let ((continue-loop t)
665         (origin (point))
666         (case-fold-search t)
667         return-value
668         temp)
669     (while continue-loop
670       (if (re-search-backward "\\<begin\\>\\|\\<end\\>" (point-min) 'move)
671           (setq temp (simula-context)
672               return-value (and (memq (preceding-char) '(?d ?D))
673                                 (memq temp '(nil 2)))
674               continue-loop (and (not return-value)
675                                  (simula-forward-up-level)))
676         (setq continue-loop nil)))
677     (if return-value
678         t
679       (goto-char origin)
680       nil)))
681
682
683 (defun simula-calculate-indent ()
684   (save-excursion
685     (let ((where (simula-context))
686           (origin (point))
687           (indent 0)
688           continued
689           start-line
690           temp
691           found-end
692           prev-cont)
693       (cond
694        ((eq where 0)
695         ;;
696         ;; Comment.
697         ;; If comment started on previous non-blank line, indent to the
698         ;; column where the comment started, else indent as that line.
699         ;;
700         (skip-chars-backward " \t\n\f")
701         (while (and (not (bolp)) (eq (simula-context) 0))
702           (re-search-backward "^\\|!\\|\\<comment\\>"))
703         (skip-chars-forward " \t\n\f")
704         (prog1
705             (current-column)
706           (goto-char origin)))
707        ;;
708        ;; Detect missing string delimiters
709        ;;
710        ((eq where 3)
711         (error "Inside string"))
712        ((eq where 4)
713         (error "Inside character constant"))
714        ;;
715        ;; check to see if inside ()'s
716        ;;
717        ((setq temp (simula-inside-parens))
718         temp)
719        ;;
720        ;; Calculate non-comment indentation
721        (t
722         ;; first, find out if this line starts with something that needs
723         ;; special indentation (END/IF/THEN/ELSE/WHEN/OTHERWISE or label)
724         ;;
725         (skip-chars-forward " \t\f")
726         (cond
727          ;;
728          ;; END
729          ;;
730          ((looking-at "end\\>")
731           (setq indent (- simula-indent-level)
732                 found-end t))
733          ;;
734          ;; IF/THEN/ELSE
735          ;;
736          ((looking-at "if\\>\\|then\\>\\|else\\>")
737           ;; search for the *starting* IF
738           (cond
739            ((memq (following-char) '(?T ?t))
740             (setq indent (car simula-if-indent)))
741            ((memq (following-char) '(?E ?e))
742             (setq indent (cdr simula-if-indent)))
743            (t
744             (forward-word 1)
745             (setq indent 0)))
746           (simula-find-if))
747          ;;
748          ;; WHEN/OTHERWISE
749          ;;
750          ((looking-at "when\\>\\|otherwise\\>")
751           ;; search for corresponding INSPECT
752           (if (memq (following-char) '(?W ?w))
753               (setq indent (car simula-inspect-indent))
754             (setq indent (cdr simula-inspect-indent)))
755           (simula-find-inspect))
756          ;;
757          ;; label:
758          ;;
759          ((and (not (looking-at "virtual\\>"))
760                (looking-at "[a-z0-9_]*[ \t\f]*:[^-=]"))
761           (setq indent simula-label-offset)))
762         ;; find line with non-comment text
763         (simula-skip-comment-backward)
764         (if (and found-end
765                  (not (eq (preceding-char) ?\;))
766                  (if (memq (preceding-char) '(?N ?n))
767                      (save-excursion
768                        (backward-word 1)
769                        (not (looking-at "begin\\>")))
770                    t))
771             (progn
772               (simula-previous-statement 1)
773               (simula-skip-comment-backward)))
774         (setq start-line
775               (save-excursion (beginning-of-line) (point))
776               ;; - perhaps this is a continued statement
777               continued
778               (save-excursion
779                 (and (not (bobp))
780                      ;; (not found-end)
781                      (if (eq (char-syntax (preceding-char)) ?w)
782                          (progn
783                            (backward-word 1)
784                            (not (looking-at
785                                  "begin\\|then\\|else\\|when\\|otherwise\\|do"
786                                  )))
787                        (not (memq (preceding-char) '(?: ?\;)))))))
788         ;;
789         ;; MAIN calculation loop - count BEGIN/DO etc.
790         ;;
791         (while (not (bolp))
792           (if (re-search-backward
793                ";\\|\\<\\(begin\\|end\\|if\\|else\\|then\\|when\\|otherwise\\|do\\)\\>"
794                start-line 'move)
795               (if (simula-context)
796                   ();; found something in a comment/string - ignore
797                 (setq temp (following-char))
798                 (cond
799                  ((eq temp ?\;)
800                   (simula-previous-statement 1))
801                  ((looking-at "begin\\>")
802                   (setq indent (+ indent simula-indent-level)))
803                  ((looking-at "end\\>")
804                   (forward-word 1)
805                   (simula-previous-statement 1))
806                  ((looking-at "do\\>")
807                   (setq indent (+ indent simula-substatement-offset))
808                   (simula-find-do-match))
809                  ((looking-at "\\(if\\|then\\|else\\)\\>")
810                   (if (memq temp '(?I ?i))
811                       (forward-word 1)
812                     (setq indent (+ indent
813                                     simula-substatement-offset
814                                     (if (memq temp '(?T ?t))
815                                         (car simula-if-indent)
816                                       (cdr simula-if-indent)))))
817                   (simula-find-if))
818                  ((looking-at "\\<when\\>\\|\\<otherwise\\>")
819                   (setq indent (+ indent
820                                   simula-substatement-offset
821                                   (if (memq temp '(?W ?w))
822                                       (car simula-if-indent)
823                                     (cdr simula-if-indent))))
824                   (simula-find-inspect)))
825                 ;; found the start of a [sub]statement
826                 ;; add indentation for continued statement
827                 (if continued
828                     (setq indent
829                           (+ indent
830                              (if (listp simula-continued-statement-offset)
831                                  (car simula-continued-statement-offset)
832                                simula-continued-statement-offset))))
833                 (setq start-line
834                       (save-excursion (beginning-of-line) (point))
835                       continued nil))
836             ;; search failed .. point is at beginning of line
837             ;; determine if we should continue searching
838             ;; (at or before comment or label)
839             ;; temp = t means finished
840             (setq temp
841                   (and (not (simula-context))                   
842                        (save-excursion
843                          (skip-chars-forward " \t\f")
844                          (or (looking-at "virtual")
845                              (not
846                               (looking-at
847                                "!\\|comment\\>\\|[a-z0-9_]*[ \t\f]*:[^-=]")))))
848                   prev-cont continued)
849             ;; if we are finished, find current line's indentation
850             (if temp
851                 (setq indent (+ indent (current-indentation))))
852             ;; find next line with non-comment SIMULA text
853             ;; maybe indent extra if statement continues
854             (simula-skip-comment-backward)
855             (setq continued
856                   (and (not (bobp))
857                        (if (eq (char-syntax (preceding-char)) ?w)
858                            (save-excursion
859                              (backward-word 1)
860                              (not (looking-at
861                                    "begin\\|then\\|else\\|when\\|otherwise\\|do")))
862                          (not (memq (preceding-char) '(?: ?\;))))))
863             ;; if we the state of the continued-variable
864             ;; changed, add indentation for continued statement
865             (if (or (and prev-cont (not continued))
866                     (and continued
867                          (listp simula-continued-statement-offset)))
868                 (setq indent
869                       (+ indent
870                          (if (listp simula-continued-statement-offset)
871                              (car simula-continued-statement-offset)
872                            simula-continued-statement-offset))))
873             ;; while ends if point is at beginning of line at loop test
874             (if (not temp)
875                 (setq start-line (save-excursion (beginning-of-line) (point)))
876               (beginning-of-line))))
877         ;;
878         ;; return indentation
879         ;;
880         indent)))))
881
882
883 (defun simula-find-if ()
884   "Find starting IF of a IF-THEN[-ELSE[-IF-THEN...]] statement."
885   (catch 'simula-out
886     (while t
887       (if (and (simula-search-backward "\\<if\\>\\|;\\|\\<begin\\>"nil t)
888                (memq (following-char) '(?I ?i)))
889           (save-excursion
890             ;;
891             ;; find out if this IF was really the start of the IF statement
892             ;;
893             (simula-skip-comment-backward)
894             (if (and (eq (char-syntax (preceding-char)) ?w)
895                      (progn
896                        (backward-word 1)
897                        (looking-at "else\\>")))
898                 ()
899               (throw 'simula-out t)))
900         (if (not (looking-at "\\<if\\>"))
901             (error "Missing IF or misplaced BEGIN or ';' (can't find IF)")
902           ;;
903           ;; we were at the starting IF in the first place..
904           ;;
905           (throw 'simula-out t))))))
906
907
908 (defun simula-find-inspect ()
909   "Find INSPECT matching WHEN or OTHERWISE."
910   (catch 'simula-out
911     (let ((level 0))
912       ;;
913       ;; INSPECTs can be nested, have to find the corresponding one
914       ;;
915       (while t
916         (if (and (simula-search-backward "\\<inspect\\>\\|\\<otherwise\\>\\|;"
917                                           nil t)
918                  (/= (following-char) ?\;))
919             (if (memq (following-char) '(?O ?o))
920                 (setq level (1+ level))
921               (if (zerop level)
922                   (throw 'simula-out t)
923                 (setq level (1- level))))
924           (error "Missing INSPECT or misplaced ';' (can't find INSPECT)"))))))
925
926
927 (defun simula-find-do-match ()
928   "Find keyword matching DO: FOR, WHILE, INSPECT or WHEN"
929   (while (and (re-search-backward
930                "\\<\\(do\\|for\\|while\\|inspect\\|when\\|end\\|begin\\)\\>\\|;"
931                nil 'move)
932               (simula-context)))
933   (if (and (looking-at "\\<\\(for\\|while\\|inspect\\|when\\)\\>")
934            (not (simula-context)))
935       () ;; found match
936     (error "No matching FOR, WHILE or INSPECT for DO, or misplaced ';'")))
937
938
939 (defun simula-inside-parens ()
940   "Return position after `(' on line if inside parentheses, nil otherwise."
941   (save-excursion
942     (let ((parlevel 0))
943       (catch 'simula-out
944         (while t
945           (if (re-search-backward "(\\|)\\|;" nil t)
946               (if (eq (simula-context) nil)
947                   ;; found something - check it out
948                   (cond
949                    ((eq (following-char) ?\;)
950                     (if (zerop parlevel)
951                         (throw 'simula-out nil)
952                       (error "Parenthesis mismatch or misplaced ';'")))
953                    ((eq (following-char) ?\()
954                     (if (zerop parlevel)
955                         (throw 'simula-out (1+ (current-column)))
956                       (setq parlevel (1- parlevel))))
957                    (t (setq parlevel (1+ parlevel))))
958                 );; nothing - inside comment or string
959             ;; search failed
960             (throw 'simula-out nil)))))))
961
962
963 (defun simula-goto-definition ()
964   "Goto point of definition of variable, procedure or class."
965   (interactive))
966
967
968 (defun simula-expand-stdproc ()
969   (if (or (not simula-abbrev-stdproc) (simula-context))
970       (unexpand-abbrev)
971     (cond
972      ((eq simula-abbrev-stdproc 'upcase) (upcase-word -1))
973      ((eq simula-abbrev-stdproc 'downcase) (downcase-word -1))
974      ((eq simula-abbrev-stdproc 'capitalize) (capitalize-word -1)))))
975
976
977 (defun simula-expand-keyword ()
978   (if (or (not simula-abbrev-keyword) (simula-context))
979       (unexpand-abbrev)
980     (cond
981      ((eq simula-abbrev-keyword 'upcase) (upcase-word -1))
982      ((eq simula-abbrev-keyword 'downcase) (downcase-word -1))
983      ((eq simula-abbrev-keyword 'capitalize) (capitalize-word -1)))))
984
985
986 (defun simula-electric-keyword ()
987   "Expand SIMULA keyword.  If it starts the line, reindent."
988   ;; redisplay
989   (let ((show-char (eq this-command 'self-insert-command)))
990     ;; If the abbrev expansion results in reindentation, the user may have
991     ;; to wait some time before the character he typed is displayed
992     ;; (the char causing the expansion is inserted AFTER the hook function
993     ;; is called). This is annoying in case of normal characters.
994     ;; However, if the user pressed a key bound to newline, it is better
995     ;; to have the line inserted after the begin-end match.
996     (if show-char
997         (progn
998           (insert-char last-command-char 1)
999           (sit-for 0)
1000           (backward-char 1)))
1001     (if (let ((where (simula-context))
1002               (case-fold-search t))
1003           (if where
1004               (if (and (eq where 2) (eq (char-syntax (preceding-char)) ?w))
1005                   (save-excursion
1006                     (backward-word 1)
1007                     (not (looking-at "end\\>"))))))
1008         (unexpand-abbrev)
1009       (cond
1010        ((not simula-abbrev-keyword) (unexpand-abbrev))
1011        ((eq simula-abbrev-keyword 'upcase) (upcase-word -1))
1012        ((eq simula-abbrev-keyword 'downcase) (downcase-word -1))
1013        ((eq simula-abbrev-keyword 'capitalize) (capitalize-word -1)))
1014       (let ((pos (- (point-max) (point)))
1015             (case-fold-search t)
1016             )
1017         (condition-case nil
1018             (progn
1019               ;; check if the expanded word is on the beginning of the line.
1020               (if (and (eq (char-syntax (preceding-char)) ?w)
1021                        (progn
1022                          (backward-word 1)
1023                          (if (looking-at "end\\>")
1024                              (save-excursion
1025                                (simula-backward-up-level 1)
1026                                (if (pos-visible-in-window-p)
1027                                    (sit-for 1)
1028                                  (message
1029                                   (concat "Matches "
1030                                           (buffer-substring
1031                                            (point)
1032                                            (+ (point) (window-width))))))))
1033                          (skip-chars-backward " \t\f")
1034                          (bolp)))
1035                   (let ((indent (simula-calculate-indent)))
1036                     (if (eq indent (current-indentation))
1037                         ()
1038                       (delete-horizontal-space)
1039                       (indent-to indent)))
1040                 (skip-chars-forward " \t\f"))
1041               ;; check for END - blow whistles and ring bells
1042
1043               (goto-char (- (point-max) pos))
1044               (if show-char
1045                   (delete-char 1)))
1046           (quit (goto-char (- (point-max) pos))))))))
1047
1048
1049 (defun simula-search-backward (string &optional limit move)
1050   (setq string (concat string "\\|\\<end\\>"))
1051   (let (level)
1052     (catch 'simula-out
1053       (while (re-search-backward string limit move)
1054         (if (simula-context)
1055             ()
1056           (if (looking-at "\\<end\\>")
1057               (progn
1058                 (setq level 0)
1059                 (while (natnump level)
1060                   (re-search-backward "\\<begin\\>\\|\\<end\\>")
1061                   (if (simula-context)
1062                       ()
1063                     (setq level (if (memq (following-char) '(?b ?B))
1064                                     (1- level)
1065                                   (1+ level))))))
1066             (throw 'simula-out t)))))))
1067
1068
1069 (defun simula-search-forward (string &optional limit move)
1070   (setq string (concat string "\\|\\<begin\\>"))
1071   (let (level)
1072     (catch 'exit
1073       (while (re-search-forward string limit move)
1074         (goto-char (match-beginning 0))
1075         (if (simula-context)
1076             (goto-char (1- (match-end 0)))
1077           (if (looking-at "\\<begin\\>")
1078               (progn
1079                 (goto-char (1- (match-end 0)))
1080                 (setq level 0)
1081                 (while (natnump level)
1082                   (re-search-forward "\\<begin\\>\\|\\<end\\>")
1083                   (backward-word 1)
1084                   (if (not (simula-context))
1085                       (setq level (if (memq (following-char) '(?e ?E))
1086                                       (1- level)
1087                                     (1+ level))))
1088                   (backward-word -1)))
1089             (goto-char (1- (match-end 0)))
1090             (throw 'exit t)))))))
1091
1092   
1093 (defun simula-install-standard-abbrevs ()
1094   "Define Simula keywords, procedures and classes in local abbrev table."
1095   ;; procedure and class names are as of the SIMULA 87 standard.
1096   (interactive)
1097   (mapcar (function (lambda (args)
1098                       (apply 'define-abbrev simula-mode-abbrev-table args)))
1099           '(("abs" "Abs" simula-expand-stdproc)
1100             ("accum" "Accum" simula-expand-stdproc)
1101             ("activate" "ACTIVATE" simula-expand-keyword)
1102             ("addepsilon" "AddEpsilon" simula-expand-stdproc)
1103             ("after" "AFTER" simula-expand-keyword)
1104             ("and" "AND" simula-expand-keyword)
1105             ("arccos" "ArcCos" simula-expand-stdproc)
1106             ("arcsin" "ArcSin" simula-expand-stdproc)
1107             ("arctan" "ArcTan" simula-expand-stdproc)
1108             ("arctan2" "ArcTan2" simula-expand-stdproc)
1109             ("array" "ARRAY" simula-expand-keyword)
1110             ("at" "AT" simula-expand-keyword)
1111             ("before" "BEFORE" simula-expand-keyword)
1112             ("begin" "BEGIN" simula-expand-keyword)
1113             ("blanks" "Blanks" simula-expand-stdproc)
1114             ("boolean" "BOOLEAN" simula-expand-keyword)
1115             ("breakoutimage" "BreakOutImage" simula-expand-stdproc)
1116             ("bytefile" "ByteFile" simula-expand-stdproc)
1117             ("call" "Call" simula-expand-stdproc)
1118             ("cancel" "Cancel" simula-expand-stdproc)
1119             ("cardinal" "Cardinal" simula-expand-stdproc)
1120             ("char" "Char" simula-expand-stdproc)
1121             ("character" "CHARACTER" simula-expand-keyword)
1122             ("checkpoint" "CheckPoint" simula-expand-stdproc)
1123             ("class" "CLASS" simula-expand-keyword)
1124             ("clear" "Clear" simula-expand-stdproc)
1125             ("clocktime" "ClockTime" simula-expand-stdproc)
1126             ("close" "Close" simula-expand-stdproc)
1127             ("comment" "COMMENT" simula-expand-keyword)
1128             ("constant" "Constant" simula-expand-stdproc)
1129             ("copy" "Copy" simula-expand-stdproc)
1130             ("cos" "Cos" simula-expand-stdproc)
1131             ("cosh" "CosH" simula-expand-stdproc)
1132             ("cotan" "CoTan" simula-expand-stdproc)
1133             ("cputime" "CpuTime" simula-expand-stdproc)
1134             ("current" "Current" simula-expand-stdproc)
1135             ("datetime" "DateTime" simula-expand-stdproc)
1136             ("decimalmark" "DecimalMark" simula-expand-stdproc)
1137             ("delay" "DELAY" simula-expand-keyword)
1138             ("deleteimage" "DeleteImage" simula-expand-stdproc)
1139             ("detach" "Detach" simula-expand-stdproc)
1140             ("digit" "Digit" simula-expand-stdproc)
1141             ("directbytefile" "DirectByteFile" simula-expand-stdproc)
1142             ("directfile" "DirectFile" simula-expand-stdproc)
1143             ("discrete" "Discrete" simula-expand-stdproc)
1144             ("do" "DO" simula-expand-keyword)
1145             ("downcase" "Downcase" simula-expand-stdproc)
1146             ("draw" "Draw" simula-expand-stdproc)
1147             ("eject" "Eject" simula-expand-stdproc)
1148             ("else" "ELSE" simula-electric-keyword)
1149             ("empty" "Empty" simula-expand-stdproc)
1150             ("end" "END" simula-electric-keyword)
1151             ("endfile" "Endfile" simula-expand-stdproc)
1152             ("entier" "Entier" simula-expand-stdproc)
1153             ("eq" "EQ" simula-expand-keyword)
1154             ("eqv" "EQV" simula-expand-keyword)
1155             ("erlang" "Erlang" simula-expand-stdproc)
1156             ("error" "Error" simula-expand-stdproc)
1157             ("evtime" "EvTime" simula-expand-stdproc)
1158             ("exp" "Exp" simula-expand-stdproc)
1159             ("external" "EXTERNAL" simula-expand-keyword)
1160             ("false" "FALSE" simula-expand-keyword)
1161             ("field" "Field" simula-expand-stdproc)
1162             ("file" "File" simula-expand-stdproc)
1163             ("first" "First" simula-expand-stdproc)
1164             ("follow" "Follow" simula-expand-stdproc)
1165             ("for" "FOR" simula-expand-keyword)
1166             ("ge" "GE" simula-expand-keyword)
1167             ("getchar" "GetChar" simula-expand-stdproc)
1168             ("getfrac" "GetFrac" simula-expand-stdproc)
1169             ("getint" "GetInt" simula-expand-stdproc)
1170             ("getreal" "GetReal" simula-expand-stdproc)
1171             ("go" "GO" simula-expand-keyword)
1172             ("goto" "GOTO" simula-expand-keyword)
1173             ("gt" "GT" simula-expand-keyword)
1174             ("head" "Head" simula-expand-stdproc)
1175             ("hidden" "HIDDEN" simula-expand-keyword)
1176             ("histd" "HistD" simula-expand-stdproc)
1177             ("histo" "Histo" simula-expand-stdproc)
1178             ("hold" "Hold" simula-expand-stdproc)
1179             ("idle" "Idle" simula-expand-stdproc)
1180             ("if" "IF" simula-expand-keyword)
1181             ("image" "Image" simula-expand-stdproc)
1182             ("imagefile" "ImageFile" simula-expand-stdproc)
1183             ("imp" "IMP" simula-expand-keyword)
1184             ("in" "IN" simula-expand-keyword)
1185             ("inbyte" "InByte" simula-expand-stdproc)
1186             ("inbytefile" "InByteFile" simula-expand-stdproc)
1187             ("inchar" "InChar" simula-expand-stdproc)
1188             ("infile" "InFile" simula-expand-stdproc)
1189             ("infrac" "InFrac" simula-expand-stdproc)
1190             ("inimage" "InImage" simula-expand-stdproc)
1191             ("inint" "InInt" simula-expand-stdproc)
1192             ("inner" "INNER" simula-expand-keyword)
1193             ("inreal" "InReal" simula-expand-stdproc)
1194             ("inrecord" "InRecord" simula-expand-stdproc)
1195             ("inspect" "INSPECT" simula-expand-keyword)
1196             ("integer" "INTEGER" simula-expand-keyword)
1197             ("intext" "InText" simula-expand-stdproc)
1198             ("into" "Into" simula-expand-stdproc)
1199             ("is" "IS" simula-expand-keyword)
1200             ("isochar" "ISOChar" simula-expand-stdproc)
1201             ("isopen" "IsOpen" simula-expand-stdproc)
1202             ("isorank" "ISORank" simula-expand-stdproc)
1203             ("label" "LABEL" simula-expand-keyword)
1204             ("last" "Last" simula-expand-stdproc)
1205             ("lastitem" "LastItem" simula-expand-stdproc)
1206             ("lastloc" "LastLoc" simula-expand-stdproc)
1207             ("le" "LE" simula-expand-keyword)
1208             ("length" "Length" simula-expand-stdproc)
1209             ("letter" "Letter" simula-expand-stdproc)
1210             ("line" "Line" simula-expand-stdproc)
1211             ("linear" "Linear" simula-expand-stdproc)
1212             ("linesperpage" "LinesPerPage" simula-expand-stdproc)
1213             ("link" "Link" simula-expand-stdproc)
1214             ("linkage" "Linkage" simula-expand-stdproc)
1215             ("ln" "Ln" simula-expand-stdproc)
1216             ("locate" "Locate" simula-expand-stdproc)
1217             ("location" "Location" simula-expand-stdproc)
1218             ("lock" "Lock" simula-expand-stdproc)
1219             ("locked" "Locked" simula-expand-stdproc)
1220             ("log10" "Log10" simula-expand-stdproc)
1221             ("long" "LONG" simula-expand-keyword)
1222             ("lowcase" "LowCase" simula-expand-stdproc)
1223             ("lowerbound" "LowerBound" simula-expand-stdproc)
1224             ("lowten" "LowTen" simula-expand-stdproc)
1225             ("lt" "LT" simula-expand-keyword)
1226             ("main" "Main" simula-expand-stdproc)
1227             ("max" "Max" simula-expand-stdproc)
1228             ("maxint" "MaxInt" simula-expand-stdproc)
1229             ("maxlongreal" "MaxLongReal" simula-expand-stdproc)
1230             ("maxloc" "MaxLoc" simula-expand-stdproc)
1231             ("maxrank" "MaxRank" simula-expand-stdproc)
1232             ("maxreal" "MaxReal" simula-expand-stdproc)
1233             ("min" "Min" simula-expand-stdproc)
1234             ("minint" "MinInt" simula-expand-stdproc)
1235             ("minlongreal" "MinLongReal" simula-expand-stdproc)
1236             ("minrank" "MinRank" simula-expand-stdproc)
1237             ("minreal" "MinReal" simula-expand-stdproc)
1238             ("mod" "Mod" simula-expand-stdproc)
1239             ("more" "More" simula-expand-stdproc)
1240             ("name" "NAME" simula-expand-keyword)
1241             ("ne" "NE" simula-expand-keyword)
1242             ("negexp" "NegExp" simula-expand-stdproc)
1243             ("new" "NEW" simula-expand-keyword)
1244             ("nextev" "NextEv" simula-expand-stdproc)
1245             ("none" "NONE" simula-expand-keyword)
1246             ("normal" "Normal" simula-expand-stdproc)
1247             ("not" "NOT" simula-expand-keyword)
1248             ("notext" "NOTEXT" simula-expand-keyword)
1249             ("open" "Open" simula-expand-stdproc)
1250             ("or" "OR" simula-expand-keyword)
1251             ("otherwise" "OTHERWISE" simula-electric-keyword)
1252             ("out" "Out" simula-expand-stdproc)
1253             ("outbyte" "OutByte" simula-expand-stdproc)
1254             ("outbytefile" "OutByteFile" simula-expand-stdproc)
1255             ("outchar" "OutChar" simula-expand-stdproc)
1256             ("outfile" "OutFile" simula-expand-stdproc)
1257             ("outfix" "OutFix" simula-expand-stdproc)
1258             ("outfrac" "OutFrac" simula-expand-stdproc)
1259             ("outimage" "OutImage" simula-expand-stdproc)
1260             ("outint" "OutInt" simula-expand-stdproc)
1261             ("outreal" "OutReal" simula-expand-stdproc)
1262             ("outrecord" "OutRecord" simula-expand-stdproc)
1263             ("outtext" "OutText" simula-expand-stdproc)
1264             ("page" "Page" simula-expand-stdproc)
1265             ("passivate" "Passivate" simula-expand-stdproc)
1266             ("poisson" "Poisson" simula-expand-stdproc)
1267             ("pos" "Pos" simula-expand-stdproc)
1268             ("precede" "Precede" simula-expand-stdproc)
1269             ("pred" "Pred" simula-expand-stdproc)
1270             ("prev" "Prev" simula-expand-stdproc)
1271             ("printfile" "PrintFile" simula-expand-stdproc)
1272             ("prior" "PRIOR" simula-expand-keyword)
1273             ("procedure" "PROCEDURE" simula-expand-keyword)
1274             ("process" "Process" simula-expand-stdproc)
1275             ("protected" "PROTECTED" simula-expand-keyword)
1276             ("putchar" "PutChar" simula-expand-stdproc)
1277             ("putfix" "PutFix" simula-expand-stdproc)
1278             ("putfrac" "PutFrac" simula-expand-stdproc)
1279             ("putint" "PutInt" simula-expand-stdproc)
1280             ("putreal" "PutReal" simula-expand-stdproc)
1281             ("qua" "QUA" simula-expand-keyword)
1282             ("randint" "RandInt" simula-expand-stdproc)
1283             ("rank" "Rank" simula-expand-stdproc)
1284             ("reactivate" "REACTIVATE" simula-expand-keyword)
1285             ("real" "REAL" simula-expand-keyword)
1286             ("ref" "REF" simula-expand-keyword)
1287             ("resume" "Resume" simula-expand-stdproc)
1288             ("setaccess" "SetAccess" simula-expand-stdproc)
1289             ("setpos" "SetPos" simula-expand-stdproc)
1290             ("short" "SHORT" simula-expand-keyword)
1291             ("sign" "Sign" simula-expand-stdproc)
1292             ("simset" "SimSet" simula-expand-stdproc)
1293             ("simulaid" "SimulaId" simula-expand-stdproc)
1294             ("simulation" "Simulation" simula-expand-stdproc)
1295             ("sin" "Sin" simula-expand-stdproc)
1296             ("sinh" "SinH" simula-expand-stdproc)
1297             ("sourceline" "SourceLine" simula-expand-stdproc)
1298             ("spacing" "Spacing" simula-expand-stdproc)
1299             ("sqrt" "Sqrt" simula-expand-stdproc)
1300             ("start" "Start" simula-expand-stdproc)
1301             ("step" "STEP" simula-expand-keyword)
1302             ("strip" "Strip" simula-expand-stdproc)
1303             ("sub" "Sub" simula-expand-stdproc)
1304             ("subepsilon" "SubEpsilon" simula-expand-stdproc)
1305             ("suc" "Suc" simula-expand-stdproc)
1306             ("switch" "SWITCH" simula-expand-keyword)
1307             ("sysin" "SysIn" simula-expand-stdproc)
1308             ("sysout" "SysOut" simula-expand-stdproc)
1309             ("tan" "Tan" simula-expand-stdproc)
1310             ("tanh" "TanH" simula-expand-stdproc)
1311             ("terminate_program" "Terminate_Program" simula-expand-stdproc)
1312             ("terminated" "Terminated" simula-expand-stdproc)
1313             ("text" "TEXT" simula-expand-keyword)
1314             ("then" "THEN" simula-electric-keyword)
1315             ("this" "THIS" simula-expand-keyword)
1316             ("time" "Time" simula-expand-stdproc)
1317             ("to" "TO" simula-expand-keyword)
1318             ("true" "TRUE" simula-expand-keyword)
1319             ("uniform" "Uniform" simula-expand-stdproc)
1320             ("unlock" "Unlock" simula-expand-stdproc)
1321             ("until" "UNTIL" simula-expand-keyword)
1322             ("upcase" "Upcase" simula-expand-stdproc)
1323             ("upperbound" "UpperBound" simula-expand-stdproc)
1324             ("value" "VALUE" simula-expand-keyword)
1325             ("virtual" "VIRTUAL" simula-expand-keyword)
1326             ("wait" "Wait" simula-expand-stdproc)
1327             ("when" "WHEN" simula-electric-keyword)
1328             ("while" "WHILE" simula-expand-keyword))))
1329
1330 ;;; simula.el ends here