comparison lisp/progmodes/ebnf-iso.el @ 89909:68c22ea6027c

Sync to HEAD
author Kenichi Handa <handa@m17n.org>
date Fri, 16 Apr 2004 12:51:06 +0000
parents 375f2633d815
children 4da4a09e8b1b
comparison
equal deleted inserted replaced
89908:ee1402f7b568 89909:68c22ea6027c
1 ;;; ebnf-iso.el --- parser for ISO EBNF 1 ;;; ebnf-iso.el --- parser for ISO EBNF
2 2
3 ;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
4 4 ;; Free Software Foundation, Inc.
5 ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> 5
6 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 6 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
7 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8 ;; Time-stamp: <2004/04/03 16:48:52 vinicius>
7 ;; Keywords: wp, ebnf, PostScript 9 ;; Keywords: wp, ebnf, PostScript
8 ;; Time-stamp: <2003-02-10 10:26:32 jbarranquero> 10 ;; Version: 1.8
9 ;; Version: 1.6
10 11
11 ;; This file is part of GNU Emacs. 12 ;; This file is part of GNU Emacs.
12 13
13 ;; GNU Emacs is free software; you can redistribute it and/or modify 14 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by 15 ;; it under the terms of the GNU General Public License as published by
110 ;; ------------------------------------------------- 111 ;; -------------------------------------------------
111 ;; 112 ;;
112 ;; ISO EBNF accepts the characters given by <character> production above, 113 ;; ISO EBNF accepts the characters given by <character> production above,
113 ;; HORIZONTAL TAB (^I), VERTICAL TAB (^K), NEWLINE (^J or ^M) and FORM FEED 114 ;; HORIZONTAL TAB (^I), VERTICAL TAB (^K), NEWLINE (^J or ^M) and FORM FEED
114 ;; (^L), any other characters are illegal. But ebnf2ps accepts also the 115 ;; (^L), any other characters are illegal. But ebnf2ps accepts also the
115 ;; european 8-bit accentuated characters (from \240 to \377). 116 ;; european 8-bit accentuated characters (from \240 to \377) and underscore
117 ;; (_).
116 ;; 118 ;;
117 ;; 119 ;;
118 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 120 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
119 121
120 ;;; Code: 122 ;;; Code:
125 127
126 (defvar ebnf-iso-lex nil 128 (defvar ebnf-iso-lex nil
127 "Value returned by `ebnf-iso-lex' function.") 129 "Value returned by `ebnf-iso-lex' function.")
128 130
129 131
130 (defconst ebnf-no-meta-identifier nil) 132 (defvar ebnf-no-meta-identifier nil
133 "Used by `ebnf-iso-term' and `ebnf-iso-lex' functions.")
131 134
132 135
133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 136 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
134 ;; Syntactic analyzer 137 ;; Syntactic analyzer
135 138
198 token (car term) 201 token (car term)
199 term (cdr term)) 202 term (cdr term))
200 (eq token 'catenate)) 203 (eq token 'catenate))
201 (setq seq (cons term seq))) 204 (setq seq (cons term seq)))
202 (cons token 205 (cons token
203 (cond 206 (ebnf-token-sequence (if term
204 ;; null sequence 207 (cons term seq)
205 ((null seq) 208 seq)))))
206 term)
207 ;; sequence with only one element
208 ((and (null term) (= (length seq) 1))
209 (car seq))
210 ;; a real sequence
211 (t
212 (ebnf-make-sequence (nreverse (cons term seq))))
213 ))))
214 209
215 210
216 ;;; term = factor, ['-', exception]; 211 ;;; term = factor, ['-', exception];
217 ;;; 212 ;;;
218 ;;; exception = factor (* without <meta identifier> *); 213 ;;; exception = factor (* without <meta identifier> *);
343 (aset table ?\t 'space) ; [HT] horizontal tab 338 (aset table ?\t 'space) ; [HT] horizontal tab
344 (aset table ?\ 'space) ; [SP] space 339 (aset table ?\ 'space) ; [SP] space
345 ;; Override form feed character: 340 ;; Override form feed character:
346 (aset table ?\f 'form-feed) ; [FF] form feed 341 (aset table ?\f 'form-feed) ; [FF] form feed
347 ;; Override other lexical characters: 342 ;; Override other lexical characters:
343 (aset table ?_ 'non-terminal)
348 (aset table ?\" 'double-terminal) 344 (aset table ?\" 'double-terminal)
349 (aset table ?\' 'single-terminal) 345 (aset table ?\' 'single-terminal)
350 (aset table ?\? 'special) 346 (aset table ?\? 'special)
351 (aset table ?* 'repeat) 347 (aset table ?* 'repeat)
352 (aset table ?, 'catenate) 348 (aset table ?, 'catenate)
387 (aset ebnf-iso-token-table ?. 'character))) 383 (aset ebnf-iso-token-table ?. 'character)))
388 384
389 385
390 ;; replace the range "\240-\377" (see `ebnf-range-regexp'). 386 ;; replace the range "\240-\377" (see `ebnf-range-regexp').
391 (defconst ebnf-iso-non-terminal-chars 387 (defconst ebnf-iso-non-terminal-chars
392 (ebnf-range-regexp " 0-9A-Za-z" ?\240 ?\377)) 388 (ebnf-range-regexp " 0-9A-Za-z_" ?\240 ?\377))
393 389
394 390
395 (defun ebnf-iso-lex () 391 (defun ebnf-iso-lex ()
396 "Lexical analyser for ISO EBNF. 392 "Lexical analyser for ISO EBNF.
397 393
436 ((eq token 'integer) 432 ((eq token 'integer)
437 (setq ebnf-iso-lex (ebnf-buffer-substring "0-9")) 433 (setq ebnf-iso-lex (ebnf-buffer-substring "0-9"))
438 'integer) 434 'integer)
439 ;; special: ?special? 435 ;; special: ?special?
440 ((eq token 'special) 436 ((eq token 'special)
441 (setq ebnf-iso-lex (concat "?" 437 (setq ebnf-iso-lex (concat (and ebnf-special-show-delimiter "?")
442 (ebnf-string " ->@-~" ?\? "special") 438 (ebnf-string " ->@-~" ?\? "special")
443 "?")) 439 (and ebnf-special-show-delimiter "?")))
444 'special) 440 'special)
445 ;; terminal: "string" 441 ;; terminal: "string"
446 ((eq token 'double-terminal) 442 ((eq token 'double-terminal)
447 (setq ebnf-iso-lex (ebnf-string " !#-~" ?\" "terminal")) 443 (setq ebnf-iso-lex (ebnf-string " !#-~" ?\" "terminal"))
448 'terminal) 444 'terminal)
610 606
611 607
612 (provide 'ebnf-iso) 608 (provide 'ebnf-iso)
613 609
614 610
611 ;;; arch-tag: 03315eef-8f64-404a-bf9d-256d42442ee3
615 ;;; ebnf-iso.el ends here 612 ;;; ebnf-iso.el ends here