annotate lisp/progmodes/ebnf-ebx.el @ 72143:c72f78a4a1c1

*** empty log message ***
author Nick Roberts <nickrob@snap.net.nz>
date Thu, 27 Jul 2006 12:17:38 +0000
parents dc49655f57ae
children 8c9e156de392 4b3d39451150
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
68773
dc49655f57ae Update copyright for 2006.
Nick Roberts <nickrob@snap.net.nz>
parents: 64699
diff changeset
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
dc49655f57ae Update copyright for 2006.
Nick Roberts <nickrob@snap.net.nz>
parents: 64699
diff changeset
4 ;; Free Sofware 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>
54714
fc6e53c00fcf ebnf2ps 4.2
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 54667
diff changeset
8 ;; Time-stamp: <2004/04/03 16:45:34 vinicius>
54623
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
9 ;; Keywords: wp, ebnf, PostScript
54714
fc6e53c00fcf ebnf2ps 4.2
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 54667
diff changeset
10 ;; Version: 1.1
54623
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
11
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
13
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
17 ;; any later version.
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
18
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
22 ;; GNU General Public License for more details.
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
23
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63633
diff changeset
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63633
diff changeset
27 ;; Boston, MA 02110-1301, USA.
54623
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 ;;; Commentary:
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
30
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
31 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
32 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
33 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
34 ;; This is part of ebnf2ps package.
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
35 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
36 ;; 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
37 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
38 ;; See ebnf2ps.el for documentation.
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 ;; EBNFX Syntax
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
42 ;; ------------
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
43 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
44 ;; See the URL:
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
45 ;; `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
46 ;; (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
47 ;;
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 ;; rule ::= symbol '::=' expression
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
50 ;; /* 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
51 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
52 ;; expression ::= concatenation ('|' concatenation)*
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
53 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
54 ;; concatenation ::= exception*
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
55 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
56 ;; exception ::= term ('-' term)?
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
57 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
58 ;; term ::= factor ('*' | '+' | '?')?
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
59 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
60 ;; factor ::= hex-char+
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
61 ;; | '[' '^'? ( char ( '-' char )? )+ ']'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
62 ;; | '"' 'string' '"'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
63 ;; | "'" "string" "'"
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
64 ;; | '(' expression ')'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
65 ;; | symbol
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
66 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
67 ;; 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
68 ;; ('upper or lower case letter' | '-' | '_')*
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
69 ;; /* 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
70 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
71 ;; 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
72 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
73 ;; 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
74 ;; /* 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
75 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
76 ;; any-char ::= char | 'newline' | 'tab'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
77 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
78 ;; 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
79 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
80 ;; comment ::= '/*' ( any-char - '*/' ) '*/'
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 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
83 ;; 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
84 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
85 ;; 6 Notation
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
86 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
87 ;; 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
88 ;; 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
89 ;; one symbol, in the form
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
90 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
91 ;; symbol ::= expression
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
92 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
93 ;; 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
94 ;; 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
95 ;; Literal strings are quoted.
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 ;; 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
98 ;; 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
99 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
100 ;; #xN
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
101 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
102 ;; 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
103 ;; 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
104 ;; 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
105 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
106 ;; [a-zA-Z], [#xN-#xN]
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
107 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
108 ;; 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
109 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
110 ;; [abc], [#xN#xN#xN]
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 ;; 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
113 ;; 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
114 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
115 ;; [^a-z], [^#xN-#xN]
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
116 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
117 ;; 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
118 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
119 ;; [^abc], [^#xN#xN#xN]
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
120 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
121 ;; 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
122 ;; 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
123 ;; brackets.
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
124 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
125 ;; "string"
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
126 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
127 ;; 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
128 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
129 ;; 'string'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
130 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
131 ;; 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
132 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
133 ;; 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
134 ;; 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
135 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
136 ;; (expression)
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 ;; 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
139 ;; list.
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
140 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
141 ;; A?
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
142 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
143 ;; 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
144 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
145 ;; A B
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 ;; 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
148 ;; 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
149 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
150 ;; A | B
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
151 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
152 ;; matches A or B.
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
153 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
154 ;; A - B
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
155 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
156 ;; 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
157 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
158 ;; A+
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 ;; 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
161 ;; 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
162 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
163 ;; A*
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 ;; 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
166 ;; 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
167 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
168 ;; 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
169 ;;
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 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
172 ;; comment.
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
173 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
174 ;; [ wfc: ... ]
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 ;; 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
177 ;; 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
178 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
179 ;; [ vc: ... ]
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 ;; 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
182 ;; documents associated with a production.
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 ;; 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
186 ;; -------------------------------------------
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
187 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
188 ;; 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
189 ;; 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
190 ;; 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
191 ;; 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
192 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
193 ;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
194 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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 ;;; Code:
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 (require 'ebnf-otz)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
200
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 (defvar ebnf-ebx-lex nil
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
203 "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
204
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 ;; Syntactic analyzer
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
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
210 ;;; rulelist ::= rule+
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
211
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
212 (defun ebnf-ebx-parser (start)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
213 "EBNFX parser."
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
214 (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
215 (bias (1- start))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
216 (origin (point))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
217 rule-list token rule)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
218 (goto-char start)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
219 (setq token (ebnf-ebx-lex))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
220 (and (eq token 'end-of-input)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
221 (error "Invalid EBNFX file format"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
222 (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
223 (setq token (ebnf-ebx-lex)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
224 (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
225 (ebnf-message-float
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
226 "Parsing...%s%%"
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
227 (/ (* (- (point) bias) 100.0) total))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
228 (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
229 rule (cdr token)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
230 token (car token))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
231 (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
232 (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
233 (goto-char origin)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
234 rule-list))
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 ;;; rule ::= symbol '::=' expression
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
238
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
239
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
240 (defun ebnf-ebx-rule (token)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
241 (let ((name ebnf-ebx-lex)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
242 (action ebnf-action)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
243 elements)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
244 (setq ebnf-action nil)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
245 (or (eq token 'non-terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
246 (error "Invalid rule name"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
247 (setq token (ebnf-ebx-lex))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
248 (or (eq token 'production)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
249 (error "Invalid rule: missing `::='"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
250 (setq elements (ebnf-ebx-expression))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
251 (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
252 (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
253 (setq elements (cdr elements))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
254 (ebnf-eps-add-production name)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
255 (cons (ebnf-ebx-lex)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
256 (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
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 ;; expression ::= concatenation ('|' concatenation)*
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
260
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
261
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
262 (defun ebnf-ebx-expression ()
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
263 (let (body concatenation)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
264 (while (eq (car (setq concatenation
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
265 (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
266 'alternative)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
267 (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
268 (ebnf-token-alternative body concatenation)))
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 ;; concatenation ::= exception*
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
272
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
273
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
274 (defun ebnf-ebx-concatenation (token)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
275 (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
276 seq)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
277 (or (setq token (car term)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
278 term (cdr term))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
279 (error "Empty element"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
280 (setq seq (cons term seq))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
281 (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
282 token (car term)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
283 term (cdr term))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
284 (setq seq (cons term seq)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
285 (cons token
54714
fc6e53c00fcf ebnf2ps 4.2
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 54667
diff changeset
286 (ebnf-token-sequence seq))))
54623
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 ;;; exception ::= term ('-' term)?
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
290
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
291
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
292 (defun ebnf-ebx-exception (token)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
293 (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
294 (if (eq (car term) 'exception)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
295 (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
296 (cons (car except)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
297 (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
298 term)))
63633
2bca9aad87e8 (ebnf-ebx-lex): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents: 60917
diff changeset
299
54623
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 ;;; term ::= factor ('*' | '+' | '?')?
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
303
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
304
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
305 (defun ebnf-ebx-term (token)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
306 (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
307 (when factor
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
308 (setq token (ebnf-ebx-lex))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
309 (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
310 (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
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 'one-or-more)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
313 (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
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 ((eq token 'optional)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
316 (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
317 token (ebnf-ebx-lex)))))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
318 (cons token factor)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
319
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
320
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
321 ;;; factor ::= hex-char+
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
322 ;;; | '[' '^'? ( char ( '-' char )? )+ ']'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
323 ;;; | '"' 'string' '"'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
324 ;;; | "'" "string" "'"
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
325 ;;; | '(' expression ')'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
326 ;;; | symbol
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
327 ;;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
328 ;;; 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
329 ;;; ('upper or lower case letter' | '-' | '_')*
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
330 ;;; /* 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
331 ;;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
332 ;;; 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
333 ;;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
334 ;;; 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
335 ;;; /* 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
336 ;;;
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
337 ;;; any-char ::= char | 'newline' | 'tab'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
338
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
339
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
340 (defun ebnf-ebx-factor (token)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
341 (cond
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
342 ;; terminal
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
343 ((eq token 'terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
344 (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
345 ;; non-terminal
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
346 ((eq token 'non-terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
347 (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
348 ;; group
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
349 ((eq token 'begin-group)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
350 (let ((body (ebnf-ebx-expression)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
351 (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
352 (error "Missing `)'"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
353 (cdr body)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
354 ;; no element
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
355 (t
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
356 nil)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
357 ))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
358
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
359
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 ;; Lexical analyzer
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
362
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 (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
365 "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
366
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
367
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
368 (defun ebnf-ebx-initialize ()
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
369 "Initialize EBNFX token table."
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
370 ;; 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
371 (let ((char ?\101))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
372 ;; printable character: A-Z
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
373 (while (< char ?\133)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
374 (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
375 (setq char (1+ char)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
376 ;; printable character: a-z
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
377 (setq char ?\141)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
378 (while (< char ?\173)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
379 (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
380 (setq char (1+ char)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
381 ;; European 8-bit accentuated characters:
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
382 (setq char ?\240)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
383 (while (< char ?\400)
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 char 'non-terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
385 (setq char (1+ char)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
386 ;; Override end of line 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 ?\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
388 (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
389 ;; Override space characters:
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
390 (aset ebnf-ebx-token-table ?\013 'space) ; [VT] vertical tab
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 ?\t 'space) ; [HT] horizontal tab
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
392 (aset ebnf-ebx-token-table ?\ 'space) ; [SP] space
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
393 ;; Override form feed character:
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 ?\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
395 ;; Override other lexical characters:
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 ?# 'hash)
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 ?\" 'double-quote)
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 ?\' 'single-quote)
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 ?\( 'begin-group)
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 ?\) 'end-group)
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 ?- 'exception)
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 ?: 'colon)
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 ?\[ 'begin-square)
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 ?| 'alternative)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
405 (aset ebnf-ebx-token-table ?* 'zero-or-more)
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 ?+ 'one-or-more)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
407 (aset ebnf-ebx-token-table ?\? 'optional)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
408 ;; Override comment character:
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
409 (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
410
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
411
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
412 ;; 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
413 (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
414 (ebnf-range-regexp "-_A-Za-z" ?\240 ?\377))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
415 (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
416 (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
417
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 (defun ebnf-ebx-lex ()
63633
2bca9aad87e8 (ebnf-ebx-lex): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents: 60917
diff changeset
420 "Lexical analyzer for EBNFX.
54623
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
421
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
422 Return a lexical token.
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
423
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
424 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
425 (if (>= (point) ebnf-limit)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
426 'end-of-input
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
427 (let (token)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
428 ;; skip spaces and comments
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
429 (while (if (> (following-char) 255)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
430 (progn
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
431 (setq token 'error)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
432 nil)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
433 (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
434 (cond
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
435 ((eq token 'space)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
436 (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
437 (< (point) ebnf-limit))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
438 ((eq token 'comment)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
439 (ebnf-ebx-skip-comment))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
440 ((eq token 'form-feed)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
441 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
442 (setq ebnf-action 'form-feed))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
443 ((eq token 'end-of-rule)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
444 (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
445 ((and (eq token 'begin-square)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
446 (let ((case-fold-search t))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
447 (looking-at "\\[\\(wfc\\|vc\\):")))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
448 (ebnf-ebx-skip-constraint))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
449 (t nil)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
450 )))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
451 (cond
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
452 ;; end of input
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
453 ((>= (point) ebnf-limit)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
454 'end-of-input)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
455 ;; error
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
456 ((eq token 'error)
60917
87f9bb9d3718 * progmodes/ebnf-abn.el, progmodes/ebnf-bnf.el,
Werner LEMBERG <wl@gnu.org>
parents: 54714
diff changeset
457 (error "Invalid character"))
54623
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
458 ;; end of rule
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
459 ((eq token 'end-of-rule)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
460 'end-of-rule)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
461 ;; 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
462 ((eq token 'hash)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
463 (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
464 'terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
465 ;; terminal: "string"
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
466 ((eq token 'double-quote)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
467 (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
468 'terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
469 ;; terminal: 'string'
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
470 ((eq token 'single-quote)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
471 (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
472 'terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
473 ;; terminal: [ ^? ( char ( - char )? )+ ]
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
474 ((eq token 'begin-square)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
475 (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
476 'terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
477 ;; non-terminal: NAME
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
478 ((eq token 'non-terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
479 (setq ebnf-ebx-lex
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
480 (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
481 'non-terminal)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
482 ;; colon: ::=
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
483 ((eq token 'colon)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
484 (or (looking-at "::=")
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
485 (error "Missing `::=' token"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
486 (forward-char 3)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
487 'production)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
488 ;; miscellaneous: (, ), *, +, ?, |, -
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
489 (t
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
490 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
491 token)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
492 ))))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
493
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
494
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
495 ;; 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
496 (defconst ebnf-ebx-constraint-chars
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
497 (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
498
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
499
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
500 (defun ebnf-ebx-skip-constraint ()
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
501 (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
502 (error "Invalid character"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
503 (or (= (following-char) ?\])
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
504 (error "Missing end of constraint `]'"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
505 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
506 t)
63633
2bca9aad87e8 (ebnf-ebx-lex): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents: 60917
diff changeset
507
54623
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
508
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
509
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
510 (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
511 (let (eor-p)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
512 (while (progn
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
513 ;; 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
514 (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
515 eor-p))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
516 ;; skip spaces
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
517 (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
518 ;; skip comments
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
519 (and (= (following-char) ?/)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
520 (ebnf-ebx-skip-comment))))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
521 (not eor-p)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
522
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
523
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
524 ;; 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
525 (defconst ebnf-ebx-comment-chars
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
526 (ebnf-range-regexp "^\000-\010\016-\037\\*" ?\177 ?\237))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
527 (defconst ebnf-ebx-filename-chars
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
528 (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
529
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
530
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
531 (defun ebnf-ebx-skip-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 (or (= (following-char) ?*)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
534 (error "Invalid beginning of comment"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
535 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
536 (cond
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
537 ;; open 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-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
540 ;; close EPS file
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
541 ((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
542 (ebnf-eps-remove-context (ebnf-ebx-eps-filename)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
543 ;; any other action in comment
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
544 (t
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
545 (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
546 )
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
547 (while (progn
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
548 (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
549 (or (= (following-char) ?*)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
550 (error "Missing end of comment"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
551 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
552 (and (/= (following-char) ?/)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
553 (< (point) ebnf-limit))))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
554 ;; 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
555 (and (>= (point) ebnf-limit)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
556 (error "Missing end of comment"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
557 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
558 t)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
559
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
560
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
561 (defun ebnf-ebx-eps-filename ()
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
562 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
563 (let (fname nchar)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
564 (while (progn
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
565 (setq fname
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
566 (concat fname
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
567 (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
568 (and (< (point) ebnf-limit)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
569 (> (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
570 (< (point) ebnf-limit)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
571 (/= (following-char) ?/)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
572 (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
573 nchar nil))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
574 (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
575 fname
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
576 (and (< (point) ebnf-limit)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
577 (= (following-char) ?/)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
578 (setq nchar (1- nchar)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
579 (concat fname (make-string nchar ?*)))))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
580
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
581
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
582 ;; 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
583 (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
584 (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
585 (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
586 (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
587
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
588
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
589 (defun ebnf-ebx-string (delim)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
590 (buffer-substring-no-properties
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
591 (progn
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
592 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
593 (point))
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 (skip-chars-forward (if (= delim ?\")
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
596 ebnf-ebx-double-string-chars
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
597 ebnf-ebx-single-string-chars)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
598 ebnf-limit)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
599 (or (= (following-char) delim)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
600 (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
601 (prog1
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
602 (point)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
603 (forward-char)))))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
604
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
605
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
606 (defun ebnf-ebx-character ()
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
607 ;; #x [0-9A-Fa-f]+
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
608 (buffer-substring-no-properties
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
609 (point)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
610 (progn
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
611 (ebnf-ebx-hex-character)
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
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
614
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
615 (defun ebnf-ebx-range ()
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
616 ;; [ ^? ( char ( - char )? )+ ]
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
617 (buffer-substring-no-properties
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
618 (point)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
619 (progn
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
620 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
621 (and (= (following-char) ?^)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
622 (forward-char))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
623 (and (= (following-char) ?-)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
624 (forward-char))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
625 (while (progn
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
626 (ebnf-ebx-any-character)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
627 (when (= (following-char) ?-)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
628 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
629 (ebnf-ebx-any-character))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
630 (and (/= (following-char) ?\])
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
631 (< (point) ebnf-limit))))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
632 (and (>= (point) ebnf-limit)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
633 (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
634 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
635 (point))))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
636
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
637
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
638 (defun ebnf-ebx-any-character ()
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
639 (let ((char (following-char)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
640 (cond ((= char ?#)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
641 (ebnf-ebx-hex-character t))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
642 ((or (and (<= ?\ char) (<= char ?\")) ; #
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
643 (and (<= ?$ char) (<= char ?,)) ; -
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
644 (and (<= ?. char) (<= char ?\\)) ; ]
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
645 (and (<= ?^ char) (<= char ?~))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
646 (and (<= ?\240 char) (<= char ?\377)))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
647 (forward-char))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
648 (t
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
649 (error "Invalid character `%c'" char)))))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
650
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
651
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
652 (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
653 ;; #x [0-9A-Fa-f]+
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
654 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
655 (if (/= (following-char) ?x)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
656 (or no-error
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
657 (error "Invalid hexadecimal character"))
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
658 (forward-char)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
659 (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
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
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
662
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
663 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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 (provide 'ebnf-ebx)
d6b491b74eae Parser for EBNF used to specify XML (EBNFX)
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
667
54667
6e794586bfc8 Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54623
diff changeset
668 ;;; 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
669 ;;; ebnf-ebx.el ends here