Mercurial > emacs
annotate lisp/progmodes/ebnf-ebx.el @ 104400:ed5d844496e7 CEDET_BASE
(ns_get_color): fix typo in last change
author | Adrian Robert <Adrian.B.Robert@gmail.com> |
---|---|
date | Fri, 21 Aug 2009 19:36:50 +0000 |
parents | a9dc0e7c3f2b |
children | 1d1d5d9bd884 |
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 |
100908 | 3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
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 |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
10 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
11 ;; 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
|
12 |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; 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
|
14 ;; 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
|
15 ;; 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
|
16 ;; (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
|
17 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
18 ;; 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
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
23 ;; 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
|
24 ;; 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
|
25 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
26 ;;; Commentary: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
27 |
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 ;; 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
|
32 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
33 ;; 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
|
34 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
35 ;; See ebnf2ps.el for documentation. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
36 ;; |
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 ;; EBNFX Syntax |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
39 ;; ------------ |
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 ;; See the URL: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
42 ;; `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
|
43 ;; (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
|
44 ;; |
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 ;; rule ::= symbol '::=' expression |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
47 ;; /* 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
|
48 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
49 ;; expression ::= concatenation ('|' concatenation)* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
50 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
51 ;; concatenation ::= exception* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
52 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
53 ;; exception ::= term ('-' term)? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
54 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
55 ;; term ::= factor ('*' | '+' | '?')? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
56 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
57 ;; factor ::= hex-char+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
58 ;; | '[' '^'? ( char ( '-' char )? )+ ']' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
59 ;; | '"' 'string' '"' |
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 ;; | '(' expression ')' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
62 ;; | symbol |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
63 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
64 ;; 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
|
65 ;; ('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 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
|
67 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
68 ;; 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
|
69 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
70 ;; 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
|
71 ;; /* 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
|
72 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
73 ;; any-char ::= char | 'newline' | 'tab' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
74 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
75 ;; 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
|
76 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
77 ;; comment ::= '/*' ( any-char - '*/' ) '*/' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
78 ;; |
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 ;; 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
|
81 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
82 ;; 6 Notation |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
83 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
84 ;; 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
|
85 ;; 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
|
86 ;; one symbol, in the form |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
87 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
88 ;; symbol ::= expression |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
89 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
90 ;; 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
|
91 ;; 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
|
92 ;; Literal strings are quoted. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
93 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
94 ;; 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
|
95 ;; 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
|
96 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
97 ;; #xN |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
98 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
99 ;; 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
|
100 ;; 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
|
101 ;; 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
|
102 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
103 ;; [a-zA-Z], [#xN-#xN] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
104 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
105 ;; 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
|
106 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
107 ;; [abc], [#xN#xN#xN] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
108 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
109 ;; 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
|
110 ;; 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
|
111 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
112 ;; [^a-z], [^#xN-#xN] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
113 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
114 ;; 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
|
115 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
116 ;; [^abc], [^#xN#xN#xN] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
117 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
118 ;; 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
|
119 ;; 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
|
120 ;; brackets. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
121 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
122 ;; "string" |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
123 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
124 ;; 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
|
125 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
126 ;; 'string' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
127 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
128 ;; 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
|
129 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
130 ;; 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
|
131 ;; 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
|
132 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
133 ;; (expression) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
134 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
135 ;; 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
|
136 ;; list. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
137 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
138 ;; A? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
139 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
140 ;; 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
|
141 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
142 ;; A B |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
143 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
144 ;; 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
|
145 ;; 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
|
146 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
147 ;; A | B |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
148 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
149 ;; matches A or B. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
150 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
151 ;; A - B |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
152 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
153 ;; 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
|
154 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
155 ;; A+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
156 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
157 ;; 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
|
158 ;; 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
|
159 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
160 ;; A* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
161 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
162 ;; 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
|
163 ;; 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
|
164 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
165 ;; 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
|
166 ;; |
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 ;; comment. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
170 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
171 ;; [ wfc: ... ] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
172 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
173 ;; 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
|
174 ;; 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
|
175 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
176 ;; [ vc: ... ] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
177 ;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
178 ;; 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
|
179 ;; documents associated with a production. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
180 ;; |
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 ;; 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
|
183 ;; ------------------------------------------- |
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 ;; 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
|
186 ;; 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
|
187 ;; 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
|
188 ;; 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
|
189 ;; |
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 ;;; Code: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
194 |
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 (require 'ebnf-otz) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
197 |
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 (defvar ebnf-ebx-lex nil |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
200 "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
|
201 |
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 ;; Syntactic analyzer |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
205 |
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 ;;; rulelist ::= rule+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
208 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
209 (defun ebnf-ebx-parser (start) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
210 "EBNFX parser." |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
211 (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
|
212 (bias (1- start)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
213 (origin (point)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
214 rule-list token rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
215 (goto-char start) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
216 (setq token (ebnf-ebx-lex)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
217 (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
|
218 (error "Invalid EBNFX file format")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
219 (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
|
220 (setq token (ebnf-ebx-lex))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
221 (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
|
222 (ebnf-message-float |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
223 "Parsing...%s%%" |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
224 (/ (* (- (point) bias) 100.0) total)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
225 (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
|
226 rule (cdr token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
227 token (car token)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
228 (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
|
229 (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
|
230 (goto-char origin) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
231 rule-list)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
232 |
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 ;;; rule ::= symbol '::=' expression |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
235 |
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 (defun ebnf-ebx-rule (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
238 (let ((name ebnf-ebx-lex) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
239 (action ebnf-action) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
240 elements) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
241 (setq ebnf-action nil) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
242 (or (eq token 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
243 (error "Invalid rule name")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
244 (setq token (ebnf-ebx-lex)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
245 (or (eq token 'production) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
246 (error "Invalid rule: missing `::='")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
247 (setq elements (ebnf-ebx-expression)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
248 (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
|
249 (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
|
250 (setq elements (cdr elements)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
251 (ebnf-eps-add-production name) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
252 (cons (ebnf-ebx-lex) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
253 (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
|
254 |
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 ;; expression ::= concatenation ('|' concatenation)* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
257 |
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 (defun ebnf-ebx-expression () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
260 (let (body concatenation) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
261 (while (eq (car (setq concatenation |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
262 (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
|
263 'alternative) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
264 (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
|
265 (ebnf-token-alternative body concatenation))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
266 |
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 ;; concatenation ::= exception* |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
269 |
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 (defun ebnf-ebx-concatenation (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
272 (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
|
273 seq) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
274 (or (setq token (car term) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
275 term (cdr term)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
276 (error "Empty element")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
277 (setq seq (cons term seq)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
278 (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
|
279 token (car term) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
280 term (cdr term)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
281 (setq seq (cons term seq))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
282 (cons token |
54714 | 283 (ebnf-token-sequence seq)))) |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
284 |
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 ;;; exception ::= term ('-' term)? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
287 |
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 (defun ebnf-ebx-exception (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
290 (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
|
291 (if (eq (car term) 'exception) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
292 (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
|
293 (cons (car except) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
294 (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
|
295 term))) |
63633
2bca9aad87e8
(ebnf-ebx-lex): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
60917
diff
changeset
|
296 |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
297 |
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 ;;; term ::= factor ('*' | '+' | '?')? |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
300 |
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 (defun ebnf-ebx-term (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
303 (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
|
304 (when factor |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
305 (setq token (ebnf-ebx-lex)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
306 (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
|
307 (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
|
308 token (ebnf-ebx-lex))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
309 ((eq token 'one-or-more) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
310 (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
|
311 token (ebnf-ebx-lex))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
312 ((eq token 'optional) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
313 (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
|
314 token (ebnf-ebx-lex))))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
315 (cons token factor))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
316 |
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 ;;; factor ::= hex-char+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
319 ;;; | '[' '^'? ( char ( '-' char )? )+ ']' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
320 ;;; | '"' 'string' '"' |
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 ;;; | '(' expression ')' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
323 ;;; | symbol |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
324 ;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
325 ;;; 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
|
326 ;;; ('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 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
|
328 ;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
329 ;;; 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
|
330 ;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
331 ;;; 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
|
332 ;;; /* 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
|
333 ;;; |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
334 ;;; any-char ::= char | 'newline' | 'tab' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
335 |
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 (defun ebnf-ebx-factor (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
338 (cond |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
339 ;; terminal |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
340 ((eq token 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
341 (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
|
342 ;; non-terminal |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
343 ((eq token 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
344 (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
|
345 ;; group |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
346 ((eq token 'begin-group) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
347 (let ((body (ebnf-ebx-expression))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
348 (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
|
349 (error "Missing `)'")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
350 (cdr body))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
351 ;; no element |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
352 (t |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
353 nil) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
354 )) |
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 ;; Lexical analyzer |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
359 |
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 (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
|
362 "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
|
363 |
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 (defun ebnf-ebx-initialize () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
366 "Initialize EBNFX token table." |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
367 ;; 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
|
368 (let ((char ?\101)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
369 ;; printable character: A-Z |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
370 (while (< char ?\133) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
371 (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
|
372 (setq char (1+ char))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
373 ;; printable character: a-z |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
374 (setq char ?\141) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
375 (while (< char ?\173) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
376 (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
|
377 (setq char (1+ char))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
378 ;; European 8-bit accentuated characters: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
379 (setq char ?\240) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
380 (while (< char ?\400) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
381 (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
|
382 (setq char (1+ char))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
383 ;; Override end of line characters: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
384 (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
|
385 (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
|
386 ;; Override space characters: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
387 (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
|
388 (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
|
389 (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
|
390 ;; Override form feed character: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
391 (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
|
392 ;; Override other lexical characters: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
393 (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
|
394 (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
|
395 (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
|
396 (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
|
397 (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
|
398 (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
|
399 (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
|
400 (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
|
401 (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
|
402 (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
|
403 (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
|
404 (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
|
405 ;; Override comment character: |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
406 (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
|
407 |
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 ;; 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
|
410 (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
|
411 (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
|
412 (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
|
413 (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
|
414 |
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 (defun ebnf-ebx-lex () |
63633
2bca9aad87e8
(ebnf-ebx-lex): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
60917
diff
changeset
|
417 "Lexical analyzer for EBNFX. |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
418 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
419 Return a lexical token. |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
420 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
421 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
|
422 (if (>= (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
423 'end-of-input |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
424 (let (token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
425 ;; skip spaces and comments |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
426 (while (if (> (following-char) 255) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
427 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
428 (setq token 'error) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
429 nil) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
430 (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
|
431 (cond |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
432 ((eq token 'space) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
433 (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
|
434 (< (point) ebnf-limit)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
435 ((eq token 'comment) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
436 (ebnf-ebx-skip-comment)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
437 ((eq token 'form-feed) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
438 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
439 (setq ebnf-action 'form-feed)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
440 ((eq token 'end-of-rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
441 (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
|
442 ((and (eq token 'begin-square) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
443 (let ((case-fold-search t)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
444 (looking-at "\\[\\(wfc\\|vc\\):"))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
445 (ebnf-ebx-skip-constraint)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
446 (t nil) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
447 ))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
448 (cond |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
449 ;; end of input |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
450 ((>= (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
451 'end-of-input) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
452 ;; error |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
453 ((eq token 'error) |
60917
87f9bb9d3718
* progmodes/ebnf-abn.el, progmodes/ebnf-bnf.el,
Werner LEMBERG <wl@gnu.org>
parents:
54714
diff
changeset
|
454 (error "Invalid character")) |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
455 ;; end of rule |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
456 ((eq token 'end-of-rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
457 'end-of-rule) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
458 ;; 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
|
459 ((eq token 'hash) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
460 (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
|
461 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
462 ;; terminal: "string" |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
463 ((eq token 'double-quote) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
464 (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
|
465 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
466 ;; terminal: 'string' |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
467 ((eq token 'single-quote) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
468 (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
|
469 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
470 ;; terminal: [ ^? ( char ( - char )? )+ ] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
471 ((eq token 'begin-square) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
472 (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
|
473 'terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
474 ;; non-terminal: NAME |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
475 ((eq token 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
476 (setq ebnf-ebx-lex |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
477 (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
|
478 'non-terminal) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
479 ;; colon: ::= |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
480 ((eq token 'colon) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
481 (or (looking-at "::=") |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
482 (error "Missing `::=' token")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
483 (forward-char 3) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
484 'production) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
485 ;; miscellaneous: (, ), *, +, ?, |, - |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
486 (t |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
487 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
488 token) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
489 )))) |
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 ;; 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
|
493 (defconst ebnf-ebx-constraint-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
494 (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
|
495 |
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 (defun ebnf-ebx-skip-constraint () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
498 (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
|
499 (error "Invalid character")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
500 (or (= (following-char) ?\]) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
501 (error "Missing end of constraint `]'")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
502 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
503 t) |
63633
2bca9aad87e8
(ebnf-ebx-lex): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
60917
diff
changeset
|
504 |
54623
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
505 |
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 (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
|
508 (let (eor-p) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
509 (while (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
510 ;; 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
|
511 (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
|
512 eor-p)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
513 ;; skip spaces |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
514 (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
|
515 ;; skip comments |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
516 (and (= (following-char) ?/) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
517 (ebnf-ebx-skip-comment)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
518 (not eor-p))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
519 |
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 ;; 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
|
522 (defconst ebnf-ebx-comment-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
523 (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
|
524 (defconst ebnf-ebx-filename-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
525 (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
|
526 |
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 (defun ebnf-ebx-skip-comment () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
529 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
530 (or (= (following-char) ?*) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
531 (error "Invalid beginning of comment")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
532 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
533 (cond |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
534 ;; open EPS file |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
535 ((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
|
536 (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
|
537 ;; close EPS file |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
538 ((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
|
539 (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
|
540 ;; EPS header |
81c81019e0c6
New: Header/Footer comment & Log messages
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78234
diff
changeset
|
541 ((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
|
542 (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
|
543 ;; EPS footer |
81c81019e0c6
New: Header/Footer comment & Log messages
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78234
diff
changeset
|
544 ((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
|
545 (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
|
546 ;; any other action in comment |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
547 (t |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
548 (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
|
549 ) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
550 (while (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
551 (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
|
552 (or (= (following-char) ?*) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
553 (error "Missing end of comment")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
554 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
555 (and (/= (following-char) ?/) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
556 (< (point) ebnf-limit)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
557 ;; 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
|
558 (and (>= (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
559 (error "Missing end of comment")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
560 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
561 t) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
562 |
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 (defun ebnf-ebx-eps-filename () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
565 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
566 (let (fname nchar) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
567 (while (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
568 (setq fname |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
569 (concat fname |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
570 (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
|
571 (and (< (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
572 (> (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
|
573 (< (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
574 (/= (following-char) ?/))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
575 (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
|
576 nchar nil)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
577 (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
|
578 fname |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
579 (and (< (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
580 (= (following-char) ?/) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
581 (setq nchar (1- nchar))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
582 (concat fname (make-string nchar ?*))))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
583 |
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 ;; 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
|
586 (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
|
587 (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
|
588 (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
|
589 (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
|
590 |
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 (defun ebnf-ebx-string (delim) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
593 (buffer-substring-no-properties |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
594 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
595 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
596 (point)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
597 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
598 (skip-chars-forward (if (= delim ?\") |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
599 ebnf-ebx-double-string-chars |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
600 ebnf-ebx-single-string-chars) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
601 ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
602 (or (= (following-char) delim) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
603 (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
|
604 (prog1 |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
605 (point) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
606 (forward-char))))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
607 |
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 (defun ebnf-ebx-character () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
610 ;; #x [0-9A-Fa-f]+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
611 (buffer-substring-no-properties |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
612 (point) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
613 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
614 (ebnf-ebx-hex-character) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
615 (point)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
616 |
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 (defun ebnf-ebx-range () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
619 ;; [ ^? ( char ( - char )? )+ ] |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
620 (buffer-substring-no-properties |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
621 (point) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
622 (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
623 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
624 (and (= (following-char) ?^) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
625 (forward-char)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
626 (and (= (following-char) ?-) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
627 (forward-char)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
628 (while (progn |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
629 (ebnf-ebx-any-character) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
630 (when (= (following-char) ?-) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
631 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
632 (ebnf-ebx-any-character)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
633 (and (/= (following-char) ?\]) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
634 (< (point) ebnf-limit)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
635 (and (>= (point) ebnf-limit) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
636 (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
|
637 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
638 (point)))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
639 |
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 (defun ebnf-ebx-any-character () |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
642 (let ((char (following-char))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
643 (cond ((= char ?#) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
644 (ebnf-ebx-hex-character t)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
645 ((or (and (<= ?\ char) (<= char ?\")) ; # |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
646 (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 (<= ?\240 char) (<= char ?\377))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
650 (forward-char)) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
651 (t |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
652 (error "Invalid character `%c'" char))))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
653 |
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 (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
|
656 ;; #x [0-9A-Fa-f]+ |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
657 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
658 (if (/= (following-char) ?x) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
659 (or no-error |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
660 (error "Invalid hexadecimal character")) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
661 (forward-char) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
662 (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
|
663 (error "Invalid hexadecimal character")))) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
664 |
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 (provide 'ebnf-ebx) |
d6b491b74eae
Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff
changeset
|
670 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
671 ;; 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
|
672 ;;; ebnf-ebx.el ends here |