Mercurial > emacs
annotate lisp/progmodes/ebnf-ebx.el @ 110308:74362068fc07
Remove some obsolete files from etc/.
* emacs.bash, emacs.csh, ms-kermit: Remove obsolete files (use
emacsclient -a instead of the first two).
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 10 Sep 2010 19:06:11 -0700 |
parents | 280c8ae2476d |
children | 417b1e4d63cd |
rev | line source |
---|---|
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
1 ;;; ebnf-ebx.el --- parser for EBNF used to specify XML (EBNFX) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
2 |
106815 | 3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
75347 | 4 ;; Free Software Foundation, Inc. |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
5 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
6 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
7 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
8 ;; Keywords: wp, ebnf, PostScript |
82143
81c81019e0c6
New: Header/Footer comment & Log messages
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78234
diff
changeset
|
9 ;; Version: 1.2 |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
10 ;; Package: ebnf2ps |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
11 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
12 ;; This file is part of GNU Emacs. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
13 |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
15 ;; it under the terms of the GNU General Public License as published by |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
17 ;; (at your option) any later version. |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
18 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
19 ;; GNU Emacs is distributed in the hope that it will be useful, |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
22 ;; GNU General Public License for more details. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
23 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
24 ;; You should have received a copy of the GNU General Public License |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
26 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
27 ;;; Commentary: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
28 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
29 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
30 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
31 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
32 ;; This is part of ebnf2ps package. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
33 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
34 ;; This package defines a parser for EBNF used to specify XML (EBNFX). |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
35 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
36 ;; See ebnf2ps.el for documentation. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
37 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
38 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
39 ;; EBNFX Syntax |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
40 ;; ------------ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
41 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
42 ;; See the URL: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
43 ;; `http://www.w3.org/TR/2004/REC-xml-20040204/#sec-notation' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
44 ;; (Extensible Markup Language (XML) 1.0 (Third Edition)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
45 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
46 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
47 ;; rule ::= symbol '::=' expression |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
48 ;; /* rules are separated by at least one blank line. */ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
49 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
50 ;; expression ::= concatenation ('|' concatenation)* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
51 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
52 ;; concatenation ::= exception* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
53 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
54 ;; exception ::= term ('-' term)? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
55 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
56 ;; term ::= factor ('*' | '+' | '?')? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
57 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
58 ;; factor ::= hex-char+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
59 ;; | '[' '^'? ( char ( '-' char )? )+ ']' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
60 ;; | '"' 'string' '"' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
61 ;; | "'" "string" "'" |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
62 ;; | '(' expression ')' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
63 ;; | symbol |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
64 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
65 ;; symbol ::= 'upper or lower case letter' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
66 ;; ('upper or lower case letter' | '-' | '_')* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
67 ;; /* upper and lower 8-bit accentuated characters are included */ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
68 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
69 ;; hex-char ::= '#x' [0-9A-Fa-f]+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
70 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
71 ;; char ::= hex-char | 'any character except control characters' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
72 ;; /* 8-bit accentuated characters are included */ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
73 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
74 ;; any-char ::= char | 'newline' | 'tab' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
75 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
76 ;; ignore ::= '[' ('wfc' | 'WFC' | 'vc' | 'VC') ':' ( any-char - ']' )* ']' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
77 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
78 ;; comment ::= '/*' ( any-char - '*/' ) '*/' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
79 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
80 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
81 ;; Below is the Notation section extracted from the URL cited above. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
82 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
83 ;; 6 Notation |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
84 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
85 ;; The formal grammar of XML is given in this specification using a simple |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
86 ;; Extended Backus-Naur Form (EBNF) notation. Each rule in the grammar defines |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
87 ;; one symbol, in the form |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
88 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
89 ;; symbol ::= expression |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
90 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
91 ;; Symbols are written with an initial capital letter if they are the start |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
92 ;; symbol of a regular language, otherwise with an initial lowercase letter. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
93 ;; Literal strings are quoted. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
94 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
95 ;; Within the expression on the right-hand side of a rule, the following |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
96 ;; expressions are used to match strings of one or more characters: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
97 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
98 ;; #xN |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
99 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
100 ;; where N is a hexadecimal integer, the expression matches the character |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
101 ;; whose number (code point) in ISO/IEC 10646 is N. The number of leading |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
102 ;; zeros in the #xN form is insignificant. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
103 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
104 ;; [a-zA-Z], [#xN-#xN] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
105 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
106 ;; matches any Char with a value in the range(s) indicated (inclusive). |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
107 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
108 ;; [abc], [#xN#xN#xN] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
109 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
110 ;; matches any Char with a value among the characters enumerated. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
111 ;; Enumerations and ranges can be mixed in one set of brackets. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
112 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
113 ;; [^a-z], [^#xN-#xN] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
114 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
115 ;; matches any Char with a value outside the range indicated. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
116 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
117 ;; [^abc], [^#xN#xN#xN] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
118 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
119 ;; matches any Char with a value not among the characters given. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
120 ;; Enumerations and ranges of forbidden values can be mixed in one set of |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
121 ;; brackets. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
122 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
123 ;; "string" |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
124 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
125 ;; matches a literal string matching that given inside the double quotes. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
126 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
127 ;; 'string' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
128 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
129 ;; matches a literal string matching that given inside the single quotes. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
130 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
131 ;; These symbols may be combined to match more complex patterns as follows, |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
132 ;; where A and B represent simple expressions: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
133 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
134 ;; (expression) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
135 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
136 ;; expression is treated as a unit and may be combined as described in this |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
137 ;; list. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
138 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
139 ;; A? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
140 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
141 ;; matches A or nothing; optional A. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
142 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
143 ;; A B |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
144 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
145 ;; matches A followed by B. This operator has higher precedence than |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
146 ;; alternation; thus A B | C D is identical to (A B) | (C D). |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
147 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
148 ;; A | B |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
149 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
150 ;; matches A or B. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
151 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
152 ;; A - B |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
153 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
154 ;; matches any string that matches A but does not match B. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
155 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
156 ;; A+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
157 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
158 ;; matches one or more occurrences of A. Concatenation has higher |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
159 ;; precedence than alternation; thus A+ | B+ is identical to (A+) | (B+). |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
160 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
161 ;; A* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
162 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
163 ;; matches zero or more occurrences of A. Concatenation has higher |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
164 ;; precedence than alternation; thus A* | B* is identical to (A*) | (B*). |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
165 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
166 ;; Other notations used in the productions are: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
167 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
168 ;; /* ... */ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
169 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
170 ;; comment. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
171 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
172 ;; [ wfc: ... ] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
173 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
174 ;; well-formedness constraint; this identifies by name a constraint on |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
175 ;; well-formed documents associated with a production. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
176 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
177 ;; [ vc: ... ] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
178 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
179 ;; validity constraint; this identifies by name a constraint on valid |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
180 ;; documents associated with a production. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
181 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
182 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
183 ;; Differences Between EBNFX And ebnf2ps EBNFX |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
184 ;; ------------------------------------------- |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
185 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
186 ;; Besides the characters that EBNFX accepts, ebnf2ps EBNFX accepts also the |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
187 ;; underscore (_) and minus (-) for rule name and european 8-bit accentuated |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
188 ;; characters (from \240 to \377) for rule name, string and comment. Also |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
189 ;; rule name can start with upper case letter. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
190 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
191 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
192 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
193 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
194 ;;; Code: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
195 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
196 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
197 (require 'ebnf-otz) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
198 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
199 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
200 (defvar ebnf-ebx-lex nil |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
201 "Value returned by `ebnf-ebx-lex' function.") |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
202 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
203 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
205 ;; Syntactic analyzer |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
206 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
207 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
208 ;;; rulelist ::= rule+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
209 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
210 (defun ebnf-ebx-parser (start) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
211 "EBNFX parser." |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
212 (let ((total (+ (- ebnf-limit start) 1)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
213 (bias (1- start)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
214 (origin (point)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
215 rule-list token rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
216 (goto-char start) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
217 (setq token (ebnf-ebx-lex)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
218 (and (eq token 'end-of-input) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
219 (error "Invalid EBNFX file format")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
220 (and (eq token 'end-of-rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
221 (setq token (ebnf-ebx-lex))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
222 (while (not (eq token 'end-of-input)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
223 (ebnf-message-float |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
224 "Parsing...%s%%" |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
225 (/ (* (- (point) bias) 100.0) total)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
226 (setq token (ebnf-ebx-rule token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
227 rule (cdr token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
228 token (car token)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
229 (or (ebnf-add-empty-rule-list rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
230 (setq rule-list (cons rule rule-list)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
231 (goto-char origin) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
232 rule-list)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
233 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
234 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
235 ;;; rule ::= symbol '::=' expression |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
236 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
237 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
238 (defun ebnf-ebx-rule (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
239 (let ((name ebnf-ebx-lex) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
240 (action ebnf-action) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
241 elements) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
242 (setq ebnf-action nil) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
243 (or (eq token 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
244 (error "Invalid rule name")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
245 (setq token (ebnf-ebx-lex)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
246 (or (eq token 'production) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
247 (error "Invalid rule: missing `::='")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
248 (setq elements (ebnf-ebx-expression)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
249 (or (memq (car elements) '(end-of-rule end-of-input)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
250 (error "Invalid rule: there is no end of rule")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
251 (setq elements (cdr elements)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
252 (ebnf-eps-add-production name) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
253 (cons (ebnf-ebx-lex) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
254 (ebnf-make-production name elements action)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
255 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
256 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
257 ;; expression ::= concatenation ('|' concatenation)* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
258 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
259 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
260 (defun ebnf-ebx-expression () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
261 (let (body concatenation) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
262 (while (eq (car (setq concatenation |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
263 (ebnf-ebx-concatenation (ebnf-ebx-lex)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
264 'alternative) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
265 (setq body (cons (cdr concatenation) body))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
266 (ebnf-token-alternative body concatenation))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
267 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
268 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
269 ;; concatenation ::= exception* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
270 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
271 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
272 (defun ebnf-ebx-concatenation (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
273 (let ((term (ebnf-ebx-exception token)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
274 seq) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
275 (or (setq token (car term) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
276 term (cdr term)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
277 (error "Empty element")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
278 (setq seq (cons term seq)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
279 (while (setq term (ebnf-ebx-exception token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
280 token (car term) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
281 term (cdr term)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
282 (setq seq (cons term seq))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
283 (cons token |
54714 | 284 (ebnf-token-sequence seq)))) |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
285 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
286 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
287 ;;; exception ::= term ('-' term)? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
288 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
289 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
290 (defun ebnf-ebx-exception (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
291 (let ((term (ebnf-ebx-term token))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
292 (if (eq (car term) 'exception) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
293 (let ((except (ebnf-ebx-term (ebnf-ebx-lex)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
294 (cons (car except) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
295 (ebnf-make-except (cdr term) (cdr except)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
296 term))) |
63633
2bca9aad87e8
(ebnf-ebx-lex): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
60917
diff
changeset
|
297 |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
298 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
299 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
300 ;;; term ::= factor ('*' | '+' | '?')? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
301 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
302 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
303 (defun ebnf-ebx-term (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
304 (let ((factor (ebnf-ebx-factor token))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
305 (when factor |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
306 (setq token (ebnf-ebx-lex)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
307 (cond ((eq token 'zero-or-more) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
308 (setq factor (ebnf-make-zero-or-more factor) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
309 token (ebnf-ebx-lex))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
310 ((eq token 'one-or-more) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
311 (setq factor (ebnf-make-one-or-more factor) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
312 token (ebnf-ebx-lex))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
313 ((eq token 'optional) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
314 (setq factor (ebnf-token-optional factor) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
315 token (ebnf-ebx-lex))))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
316 (cons token factor))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
317 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
318 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
319 ;;; factor ::= hex-char+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
320 ;;; | '[' '^'? ( char ( '-' char )? )+ ']' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
321 ;;; | '"' 'string' '"' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
322 ;;; | "'" "string" "'" |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
323 ;;; | '(' expression ')' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
324 ;;; | symbol |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
325 ;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
326 ;;; symbol ::= 'upper or lower case letter' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
327 ;;; ('upper or lower case letter' | '-' | '_')* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
328 ;;; /* upper and lower 8-bit accentuated characters are included */ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
329 ;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
330 ;;; hex-char ::= '#x' [0-9A-Fa-f]+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
331 ;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
332 ;;; char ::= hex-char | 'any character except control characters' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
333 ;;; /* 8-bit accentuated characters are included */ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
334 ;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
335 ;;; any-char ::= char | 'newline' | 'tab' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
336 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
337 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
338 (defun ebnf-ebx-factor (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
339 (cond |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
340 ;; terminal |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
341 ((eq token 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
342 (ebnf-make-terminal ebnf-ebx-lex)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
343 ;; non-terminal |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
344 ((eq token 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
345 (ebnf-make-non-terminal ebnf-ebx-lex)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
346 ;; group |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
347 ((eq token 'begin-group) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
348 (let ((body (ebnf-ebx-expression))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
349 (or (eq (car body) 'end-group) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
350 (error "Missing `)'")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
351 (cdr body))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
352 ;; no element |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
353 (t |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
354 nil) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
355 )) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
356 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
357 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
358 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
359 ;; Lexical analyzer |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
360 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
361 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
362 (defconst ebnf-ebx-token-table (make-vector 256 'error) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
363 "Vector used to map characters to a lexical token.") |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
364 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
365 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
366 (defun ebnf-ebx-initialize () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
367 "Initialize EBNFX token table." |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
368 ;; control character & control 8-bit character are set to `error' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
369 (let ((char ?\101)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
370 ;; printable character: A-Z |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
371 (while (< char ?\133) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
372 (aset ebnf-ebx-token-table char 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
373 (setq char (1+ char))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
374 ;; printable character: a-z |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
375 (setq char ?\141) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
376 (while (< char ?\173) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
377 (aset ebnf-ebx-token-table char 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
378 (setq char (1+ char))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
379 ;; European 8-bit accentuated characters: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
380 (setq char ?\240) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
381 (while (< char ?\400) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
382 (aset ebnf-ebx-token-table char 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
383 (setq char (1+ char))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
384 ;; Override end of line characters: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
385 (aset ebnf-ebx-token-table ?\n 'end-of-rule) ; [NL] linefeed |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
386 (aset ebnf-ebx-token-table ?\r 'end-of-rule) ; [CR] carriage return |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
387 ;; Override space characters: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
388 (aset ebnf-ebx-token-table ?\013 'space) ; [VT] vertical tab |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
389 (aset ebnf-ebx-token-table ?\t 'space) ; [HT] horizontal tab |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
390 (aset ebnf-ebx-token-table ?\ 'space) ; [SP] space |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
391 ;; Override form feed character: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
392 (aset ebnf-ebx-token-table ?\f 'form-feed) ; [FF] form feed |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
393 ;; Override other lexical characters: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
394 (aset ebnf-ebx-token-table ?# 'hash) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
395 (aset ebnf-ebx-token-table ?\" 'double-quote) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
396 (aset ebnf-ebx-token-table ?\' 'single-quote) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
397 (aset ebnf-ebx-token-table ?\( 'begin-group) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
398 (aset ebnf-ebx-token-table ?\) 'end-group) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
399 (aset ebnf-ebx-token-table ?- 'exception) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
400 (aset ebnf-ebx-token-table ?: 'colon) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
401 (aset ebnf-ebx-token-table ?\[ 'begin-square) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
402 (aset ebnf-ebx-token-table ?| 'alternative) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
403 (aset ebnf-ebx-token-table ?* 'zero-or-more) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
404 (aset ebnf-ebx-token-table ?+ 'one-or-more) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
405 (aset ebnf-ebx-token-table ?\? 'optional) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
406 ;; Override comment character: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
407 (aset ebnf-ebx-token-table ?/ 'comment))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
408 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
409 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
410 ;; replace the range "\240-\377" (see `ebnf-range-regexp'). |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
411 (defconst ebnf-ebx-non-terminal-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
412 (ebnf-range-regexp "-_A-Za-z" ?\240 ?\377)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
413 (defconst ebnf-ebx-non-terminal-letter-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
414 (ebnf-range-regexp "A-Za-z" ?\240 ?\377)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
415 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
416 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
417 (defun ebnf-ebx-lex () |
63633
2bca9aad87e8
(ebnf-ebx-lex): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
60917
diff
changeset
|
418 "Lexical analyzer for EBNFX. |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
419 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
420 Return a lexical token. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
421 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
422 See documentation for variable `ebnf-ebx-lex'." |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
423 (if (>= (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
424 'end-of-input |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
425 (let (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
426 ;; skip spaces and comments |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
427 (while (if (> (following-char) 255) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
428 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
429 (setq token 'error) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
430 nil) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
431 (setq token (aref ebnf-ebx-token-table (following-char))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
432 (cond |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
433 ((eq token 'space) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
434 (skip-chars-forward " \013\t" ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
435 (< (point) ebnf-limit)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
436 ((eq token 'comment) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
437 (ebnf-ebx-skip-comment)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
438 ((eq token 'form-feed) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
439 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
440 (setq ebnf-action 'form-feed)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
441 ((eq token 'end-of-rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
442 (ebnf-ebx-skip-end-of-rule)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
443 ((and (eq token 'begin-square) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
444 (let ((case-fold-search t)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
445 (looking-at "\\[\\(wfc\\|vc\\):"))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
446 (ebnf-ebx-skip-constraint)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
447 (t nil) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
448 ))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
449 (cond |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
450 ;; end of input |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
451 ((>= (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
452 'end-of-input) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
453 ;; error |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
454 ((eq token 'error) |
60917
87f9bb9d3718
* progmodes/ebnf-abn.el, progmodes/ebnf-bnf.el,
Werner LEMBERG <wl@gnu.org>
parents:
54714
diff
changeset
|
455 (error "Invalid character")) |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
456 ;; end of rule |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
457 ((eq token 'end-of-rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
458 'end-of-rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
459 ;; terminal: #x [0-9A-Fa-f]+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
460 ((eq token 'hash) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
461 (setq ebnf-ebx-lex (ebnf-ebx-character)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
462 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
463 ;; terminal: "string" |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
464 ((eq token 'double-quote) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
465 (setq ebnf-ebx-lex (ebnf-ebx-string ?\")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
466 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
467 ;; terminal: 'string' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
468 ((eq token 'single-quote) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
469 (setq ebnf-ebx-lex (ebnf-ebx-string ?\')) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
470 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
471 ;; terminal: [ ^? ( char ( - char )? )+ ] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
472 ((eq token 'begin-square) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
473 (setq ebnf-ebx-lex (ebnf-ebx-range)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
474 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
475 ;; non-terminal: NAME |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
476 ((eq token 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
477 (setq ebnf-ebx-lex |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
478 (ebnf-buffer-substring ebnf-ebx-non-terminal-chars)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
479 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
480 ;; colon: ::= |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
481 ((eq token 'colon) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
482 (or (looking-at "::=") |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
483 (error "Missing `::=' token")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
484 (forward-char 3) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
485 'production) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
486 ;; miscellaneous: (, ), *, +, ?, |, - |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
487 (t |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
488 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
489 token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
490 )))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
491 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
492 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
493 ;; replace the range "\177-\237" (see `ebnf-range-regexp'). |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
494 (defconst ebnf-ebx-constraint-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
495 (ebnf-range-regexp "^\000-\010\016-\037]" ?\177 ?\237)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
496 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
497 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
498 (defun ebnf-ebx-skip-constraint () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
499 (or (> (skip-chars-forward ebnf-ebx-constraint-chars ebnf-limit) 0) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
500 (error "Invalid character")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
501 (or (= (following-char) ?\]) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
502 (error "Missing end of constraint `]'")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
503 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
504 t) |
63633
2bca9aad87e8
(ebnf-ebx-lex): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
60917
diff
changeset
|
505 |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
506 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
507 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
508 (defun ebnf-ebx-skip-end-of-rule () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
509 (let (eor-p) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
510 (while (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
511 ;; end of rule ==> 2 or more consecutive end of lines |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
512 (setq eor-p (or (> (skip-chars-forward "\r\n" ebnf-limit) 1) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
513 eor-p)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
514 ;; skip spaces |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
515 (skip-chars-forward " \013\t" ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
516 ;; skip comments |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
517 (and (= (following-char) ?/) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
518 (ebnf-ebx-skip-comment)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
519 (not eor-p))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
520 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
521 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
522 ;; replace the range "\177-\237" (see `ebnf-range-regexp'). |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
523 (defconst ebnf-ebx-comment-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
524 (ebnf-range-regexp "^\000-\010\016-\037\\*" ?\177 ?\237)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
525 (defconst ebnf-ebx-filename-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
526 (ebnf-range-regexp "^\000-\037\\*" ?\177 ?\237)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
527 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
528 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
529 (defun ebnf-ebx-skip-comment () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
530 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
531 (or (= (following-char) ?*) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
532 (error "Invalid beginning of comment")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
533 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
534 (cond |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
535 ;; open EPS file |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
536 ((and ebnf-eps-executing (= (following-char) ?\[)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
537 (ebnf-eps-add-context (ebnf-ebx-eps-filename))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
538 ;; close EPS file |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
539 ((and ebnf-eps-executing (= (following-char) ?\])) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
540 (ebnf-eps-remove-context (ebnf-ebx-eps-filename))) |
82143
81c81019e0c6
New: Header/Footer comment & Log messages
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78234
diff
changeset
|
541 ;; EPS header |
81c81019e0c6
New: Header/Footer comment & Log messages
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78234
diff
changeset
|
542 ((and ebnf-eps-executing (= (following-char) ?H)) |
81c81019e0c6
New: Header/Footer comment & Log messages
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78234
diff
changeset
|
543 (ebnf-eps-header-comment (ebnf-ebx-eps-filename))) |
81c81019e0c6
New: Header/Footer comment & Log messages
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78234
diff
changeset
|
544 ;; EPS footer |
81c81019e0c6
New: Header/Footer comment & Log messages
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78234
diff
changeset
|
545 ((and ebnf-eps-executing (= (following-char) ?F)) |
81c81019e0c6
New: Header/Footer comment & Log messages
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78234
diff
changeset
|
546 (ebnf-eps-footer-comment (ebnf-ebx-eps-filename))) |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
547 ;; any other action in comment |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
548 (t |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
549 (setq ebnf-action (aref ebnf-comment-table (following-char)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
550 ) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
551 (while (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
552 (skip-chars-forward ebnf-ebx-comment-chars ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
553 (or (= (following-char) ?*) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
554 (error "Missing end of comment")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
555 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
556 (and (/= (following-char) ?/) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
557 (< (point) ebnf-limit)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
558 ;; check for a valid end of comment |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
559 (and (>= (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
560 (error "Missing end of comment")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
561 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
562 t) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
563 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
564 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
565 (defun ebnf-ebx-eps-filename () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
566 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
567 (let (fname nchar) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
568 (while (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
569 (setq fname |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
570 (concat fname |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
571 (ebnf-buffer-substring ebnf-ebx-filename-chars))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
572 (and (< (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
573 (> (setq nchar (skip-chars-forward "*" ebnf-limit)) 0) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
574 (< (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
575 (/= (following-char) ?/))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
576 (setq fname (concat fname (make-string nchar ?*)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
577 nchar nil)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
578 (if (or (not nchar) (= nchar 0)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
579 fname |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
580 (and (< (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
581 (= (following-char) ?/) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
582 (setq nchar (1- nchar))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
583 (concat fname (make-string nchar ?*))))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
584 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
585 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
586 ;; replace the range "\240-\377" (see `ebnf-range-regexp'). |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
587 (defconst ebnf-ebx-double-string-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
588 (ebnf-range-regexp "\t -!#-~" ?\240 ?\377)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
589 (defconst ebnf-ebx-single-string-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
590 (ebnf-range-regexp "\t -&(-~" ?\240 ?\377)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
591 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
592 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
593 (defun ebnf-ebx-string (delim) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
594 (buffer-substring-no-properties |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
595 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
596 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
597 (point)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
598 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
599 (skip-chars-forward (if (= delim ?\") |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
600 ebnf-ebx-double-string-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
601 ebnf-ebx-single-string-chars) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
602 ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
603 (or (= (following-char) delim) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
604 (error "Missing string delimiter `%c'" delim)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
605 (prog1 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
606 (point) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
607 (forward-char))))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
608 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
609 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
610 (defun ebnf-ebx-character () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
611 ;; #x [0-9A-Fa-f]+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
612 (buffer-substring-no-properties |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
613 (point) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
614 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
615 (ebnf-ebx-hex-character) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
616 (point)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
617 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
618 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
619 (defun ebnf-ebx-range () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
620 ;; [ ^? ( char ( - char )? )+ ] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
621 (buffer-substring-no-properties |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
622 (point) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
623 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
624 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
625 (and (= (following-char) ?^) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
626 (forward-char)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
627 (and (= (following-char) ?-) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
628 (forward-char)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
629 (while (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
630 (ebnf-ebx-any-character) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
631 (when (= (following-char) ?-) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
632 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
633 (ebnf-ebx-any-character)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
634 (and (/= (following-char) ?\]) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
635 (< (point) ebnf-limit)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
636 (and (>= (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
637 (error "Missing end of character range `]'")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
638 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
639 (point)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
640 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
641 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
642 (defun ebnf-ebx-any-character () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
643 (let ((char (following-char))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
644 (cond ((= char ?#) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
645 (ebnf-ebx-hex-character t)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
646 ((or (and (<= ?\ char) (<= char ?\")) ; # |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
647 (and (<= ?$ char) (<= char ?,)) ; - |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
648 (and (<= ?. char) (<= char ?\\)) ; ] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
649 (and (<= ?^ char) (<= char ?~)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
650 (and (<= ?\240 char) (<= char ?\377))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
651 (forward-char)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
652 (t |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
653 (error "Invalid character `%c'" char))))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
654 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
655 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
656 (defun ebnf-ebx-hex-character (&optional no-error) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
657 ;; #x [0-9A-Fa-f]+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
658 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
659 (if (/= (following-char) ?x) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
660 (or no-error |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
661 (error "Invalid hexadecimal character")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
662 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
663 (or (> (skip-chars-forward "0-9A-Fa-f" ebnf-limit) 0) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
664 (error "Invalid hexadecimal character")))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
665 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
666 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
667 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
668 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
669 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
670 (provide 'ebnf-ebx) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
671 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
672 ;; arch-tag: bfe2f95b-66bc-4dc6-8b7e-b7831e68f5fb |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
673 ;;; ebnf-ebx.el ends here |