annotate lisp/progmodes/ebnf-ebx.el @ 77998:71120e9b162d

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