Mercurial > hg > mpdl-group
comparison software/eXist/mpdl-modules/src/de/mpg/mpiwg/berlin/mpdl/lt/analyzer/lang/MpdlNormalizerLexIT.java @ 9:1ec29fdd0db8
neue .lex Dateien f?r Normalisierung / externe Objekte update
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 22 Feb 2011 16:03:45 +0100 |
parents | |
children | 5df60f24e997 |
comparison
equal
deleted
inserted
replaced
8:d2a1c14fde31 | 9:1ec29fdd0db8 |
---|---|
1 /* The following code was generated by JFlex 1.4.3 on 22.02.11 12:03 */ | |
2 | |
3 /* | |
4 * Normalization rules for Italian text | |
5 * [this is a JFlex specification] | |
6 * | |
7 * Wolfgang Schmidle | |
8 * version 0.96 | |
9 * 2011-02-21 | |
10 * | |
11 */ | |
12 | |
13 package de.mpg.mpiwg.berlin.mpdl.lt.analyzer.lang; | |
14 | |
15 | |
16 /** | |
17 * This class is a scanner generated by | |
18 * <a href="http://www.jflex.de/">JFlex</a> 1.4.3 | |
19 * on 22.02.11 12:03 from the specification file | |
20 * <tt>MpdlNormalizerLexIT.lex</tt> | |
21 */ | |
22 public class MpdlNormalizerLexIT { | |
23 | |
24 /** This character denotes the end of file */ | |
25 public static final int YYEOF = -1; | |
26 | |
27 /** initial size of the lookahead buffer */ | |
28 private static final int ZZ_BUFFERSIZE = 16384; | |
29 | |
30 /** lexical states */ | |
31 public static final int SEARCH = 6; | |
32 public static final int DICT = 4; | |
33 public static final int YYINITIAL = 0; | |
34 public static final int DISP = 2; | |
35 | |
36 /** | |
37 * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l | |
38 * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l | |
39 * at the beginning of a line | |
40 * l is of the form l = 2*k, k a non negative integer | |
41 */ | |
42 private static final int ZZ_LEXSTATE[] = { | |
43 0, 0, 1, 2, 3, 4, 5, 6 | |
44 }; | |
45 | |
46 /** | |
47 * Translates characters to character classes | |
48 */ | |
49 private static final String ZZ_CMAP_PACKED = | |
50 "\12\0\1\5\42\0\1\4\22\0\1\51\1\1\3\2\1\1\3\2"+ | |
51 "\1\40\1\0\1\2\1\3\2\2\1\41\1\2\1\47\1\3\1\2"+ | |
52 "\1\37\1\44\1\50\2\2\1\0\1\2\6\0\1\43\3\2\1\11"+ | |
53 "\2\2\1\42\1\6\1\35\1\2\1\3\1\2\1\7\1\36\1\13"+ | |
54 "\1\45\1\12\1\2\1\10\1\15\1\46\2\2\1\0\1\2\62\0"+ | |
55 "\1\4\22\0\1\16\5\0\1\32\1\0\1\17\3\0\1\20\5\0"+ | |
56 "\1\21\6\0\1\22\5\0\1\30\1\23\5\0\1\31\1\0\1\24"+ | |
57 "\3\0\1\25\5\0\1\26\6\0\1\27\37\0\1\1\70\0\1\34"+ | |
58 "\1\33\53\0\1\14\ufe80\0"; | |
59 | |
60 /** | |
61 * Translates characters to character classes | |
62 */ | |
63 private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); | |
64 | |
65 /** | |
66 * Translates DFA states to action switch labels. | |
67 */ | |
68 private static final int [] ZZ_ACTION = zzUnpackAction(); | |
69 | |
70 private static final String ZZ_ACTION_PACKED_0 = | |
71 "\11\0\1\1\1\2\2\3\1\4\1\5\1\2\1\3"+ | |
72 "\1\6\1\2\1\7\1\10\1\11\1\12\1\13\5\3"+ | |
73 "\1\14\1\2\1\3\1\6\1\2\1\15\1\16\1\17"+ | |
74 "\1\20\1\21\1\22\1\23\1\24\1\25\1\26\1\27"+ | |
75 "\1\30\4\0\1\31\1\32\1\0\1\33\1\0\1\34"+ | |
76 "\1\35\1\0\1\36\1\37\1\40\4\0\1\41\5\0"+ | |
77 "\1\42\1\43\2\0\1\44\1\0\1\45\5\0\1\44"+ | |
78 "\1\46\3\0\1\47"; | |
79 | |
80 private static int [] zzUnpackAction() { | |
81 int [] result = new int[89]; | |
82 int offset = 0; | |
83 offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); | |
84 return result; | |
85 } | |
86 | |
87 private static int zzUnpackAction(String packed, int offset, int [] result) { | |
88 int i = 0; /* index in packed string */ | |
89 int j = offset; /* index in unpacked array */ | |
90 int l = packed.length(); | |
91 while (i < l) { | |
92 int count = packed.charAt(i++); | |
93 int value = packed.charAt(i++); | |
94 do result[j++] = value; while (--count > 0); | |
95 } | |
96 return j; | |
97 } | |
98 | |
99 | |
100 /** | |
101 * Translates a state to a row index in the transition table | |
102 */ | |
103 private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); | |
104 | |
105 private static final String ZZ_ROWMAP_PACKED_0 = | |
106 "\0\0\0\52\0\124\0\176\0\250\0\322\0\374\0\u0126"+ | |
107 "\0\u0150\0\0\0\0\0\0\0\u017a\0\0\0\0\0\u01a4"+ | |
108 "\0\u01ce\0\0\0\u01f8\0\0\0\0\0\0\0\0\0\0"+ | |
109 "\0\u0222\0\u024c\0\u0276\0\u02a0\0\u02ca\0\0\0\u02f4\0\u031e"+ | |
110 "\0\u0348\0\u0372\0\u039c\0\0\0\0\0\0\0\0\0\0"+ | |
111 "\0\0\0\0\0\0\0\0\0\0\0\0\0\u03c6\0\u03f0"+ | |
112 "\0\u041a\0\0\0\0\0\0\0\u0444\0\0\0\u046e\0\0"+ | |
113 "\0\0\0\u0498\0\0\0\0\0\0\0\u04c2\0\u04ec\0\u0516"+ | |
114 "\0\u0540\0\0\0\u056a\0\u0594\0\u05be\0\u05e8\0\u0612\0\0"+ | |
115 "\0\0\0\u063c\0\u031e\0\u0666\0\u0690\0\0\0\u06ba\0\u06e4"+ | |
116 "\0\u070e\0\0\0\u0738\0\0\0\0\0\u0762\0\u078c\0\u07b6"+ | |
117 "\0\0"; | |
118 | |
119 private static int [] zzUnpackRowMap() { | |
120 int [] result = new int[89]; | |
121 int offset = 0; | |
122 offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); | |
123 return result; | |
124 } | |
125 | |
126 private static int zzUnpackRowMap(String packed, int offset, int [] result) { | |
127 int i = 0; /* index in packed string */ | |
128 int j = offset; /* index in unpacked array */ | |
129 int l = packed.length(); | |
130 while (i < l) { | |
131 int high = packed.charAt(i++) << 16; | |
132 result[j++] = high | packed.charAt(i++); | |
133 } | |
134 return j; | |
135 } | |
136 | |
137 /** | |
138 * The transition table of the DFA | |
139 */ | |
140 private static final int [] ZZ_TRANS = zzUnpackTrans(); | |
141 | |
142 private static final String ZZ_TRANS_PACKED_0 = | |
143 "\52\0\1\12\1\13\1\14\1\15\1\16\1\17\1\20"+ | |
144 "\1\14\1\21\1\13\1\15\1\14\1\22\1\23\5\12"+ | |
145 "\2\13\1\12\2\13\1\24\1\25\1\26\1\27\1\30"+ | |
146 "\1\12\1\13\1\31\2\13\1\14\1\13\1\23\1\32"+ | |
147 "\1\33\1\34\1\35\1\36\1\12\1\13\1\14\1\15"+ | |
148 "\1\16\1\17\1\37\1\14\1\21\1\13\1\15\1\40"+ | |
149 "\1\41\1\42\5\12\2\13\1\12\2\13\1\24\1\25"+ | |
150 "\1\26\1\27\1\30\1\12\1\13\1\31\2\13\1\43"+ | |
151 "\1\13\1\42\1\32\1\33\1\34\1\35\1\36\1\12"+ | |
152 "\1\13\1\14\1\15\1\16\1\44\1\20\1\14\1\21"+ | |
153 "\1\13\1\15\1\14\1\22\1\23\1\45\1\46\1\47"+ | |
154 "\1\50\1\51\1\52\1\53\1\54\1\55\1\56\1\24"+ | |
155 "\1\25\1\26\1\27\1\30\1\12\1\13\1\31\2\13"+ | |
156 "\1\14\1\13\1\23\1\32\1\33\1\34\1\35\1\36"+ | |
157 "\1\12\1\13\1\14\1\15\1\16\1\44\1\37\1\14"+ | |
158 "\1\21\1\13\1\15\1\40\1\41\1\42\1\45\1\46"+ | |
159 "\1\47\1\50\1\51\1\52\1\53\1\54\1\55\1\56"+ | |
160 "\1\24\1\25\1\26\1\27\1\30\1\12\1\13\1\31"+ | |
161 "\2\13\1\43\1\13\1\42\1\32\1\33\1\34\1\35"+ | |
162 "\1\36\1\12\1\13\1\14\1\15\1\16\1\17\1\20"+ | |
163 "\1\14\1\21\1\13\1\15\1\14\1\22\1\23\1\45"+ | |
164 "\1\46\1\47\1\50\1\51\1\52\1\53\1\54\1\55"+ | |
165 "\1\56\1\24\1\25\1\26\1\27\1\30\1\12\1\13"+ | |
166 "\1\31\2\13\1\14\1\13\1\23\1\32\1\33\1\34"+ | |
167 "\1\35\1\36\1\12\1\13\1\14\1\15\1\16\1\17"+ | |
168 "\1\37\1\14\1\21\1\13\1\15\1\40\1\41\1\42"+ | |
169 "\1\45\1\46\1\47\1\50\1\51\1\52\1\53\1\54"+ | |
170 "\1\55\1\56\1\24\1\25\1\26\1\27\1\30\1\12"+ | |
171 "\1\13\1\31\2\13\1\43\1\13\1\42\1\32\1\33"+ | |
172 "\1\34\1\35\1\36\6\0\1\57\4\0\1\60\1\61"+ | |
173 "\41\0\1\62\113\0\1\63\1\0\1\63\36\0\1\64"+ | |
174 "\22\0\1\65\44\0\1\66\4\0\1\66\2\0\1\66"+ | |
175 "\3\0\1\66\5\0\2\66\1\0\2\66\1\0\3\66"+ | |
176 "\2\0\1\66\1\0\2\66\1\0\2\66\45\0\1\67"+ | |
177 "\57\0\1\70\5\0\2\71\1\72\2\0\2\71\1\0"+ | |
178 "\3\71\13\0\1\71\6\0\1\71\2\0\1\71\2\0"+ | |
179 "\4\71\47\0\1\73\1\0\1\74\3\0\2\75\1\76"+ | |
180 "\2\0\2\75\1\0\3\75\13\0\1\75\6\0\1\75"+ | |
181 "\2\0\1\75\2\0\4\75\10\0\1\77\25\0\1\64"+ | |
182 "\25\0\1\100\51\0\1\100\3\0\1\101\35\0\1\102"+ | |
183 "\4\0\1\102\2\0\1\102\3\0\1\102\5\0\2\102"+ | |
184 "\1\0\2\102\1\0\3\102\2\0\1\102\1\0\2\102"+ | |
185 "\1\0\2\102\43\0\1\103\4\0\1\104\15\0\1\105"+ | |
186 "\53\0\1\106\51\0\1\106\3\0\1\107\72\0\1\110"+ | |
187 "\54\0\1\111\12\0\2\71\3\0\2\71\1\0\3\71"+ | |
188 "\13\0\1\71\6\0\1\71\2\0\1\71\2\0\4\71"+ | |
189 "\3\0\2\75\3\0\2\75\1\0\3\75\13\0\1\75"+ | |
190 "\6\0\1\75\2\0\1\75\2\0\4\75\5\0\1\112"+ | |
191 "\3\0\1\113\53\0\1\114\43\0\1\115\6\0\1\113"+ | |
192 "\43\0\1\116\51\0\1\116\1\117\1\120\46\0\1\121"+ | |
193 "\3\0\1\60\53\0\1\122\43\0\1\123\6\0\1\60"+ | |
194 "\46\0\1\113\45\0\1\124\60\0\1\113\43\0\1\125"+ | |
195 "\50\0\1\126\2\0\1\127\52\0\1\60\54\0\1\60"+ | |
196 "\45\0\1\127\100\0\1\130\20\0\1\131\44\0"; | |
197 | |
198 private static int [] zzUnpackTrans() { | |
199 int [] result = new int[2016]; | |
200 int offset = 0; | |
201 offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); | |
202 return result; | |
203 } | |
204 | |
205 private static int zzUnpackTrans(String packed, int offset, int [] result) { | |
206 int i = 0; /* index in packed string */ | |
207 int j = offset; /* index in unpacked array */ | |
208 int l = packed.length(); | |
209 while (i < l) { | |
210 int count = packed.charAt(i++); | |
211 int value = packed.charAt(i++); | |
212 value--; | |
213 do result[j++] = value; while (--count > 0); | |
214 } | |
215 return j; | |
216 } | |
217 | |
218 | |
219 /* error codes */ | |
220 private static final int ZZ_UNKNOWN_ERROR = 0; | |
221 private static final int ZZ_NO_MATCH = 1; | |
222 private static final int ZZ_PUSHBACK_2BIG = 2; | |
223 | |
224 /* error messages for the codes above */ | |
225 private static final String ZZ_ERROR_MSG[] = { | |
226 "Unkown internal scanner error", | |
227 "Error: could not match input", | |
228 "Error: pushback value was too large" | |
229 }; | |
230 | |
231 /** | |
232 * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code> | |
233 */ | |
234 private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); | |
235 | |
236 private static final String ZZ_ATTRIBUTE_PACKED_0 = | |
237 "\1\10\7\0\1\1\3\11\1\1\2\11\2\1\1\11"+ | |
238 "\1\1\5\11\5\1\1\11\5\1\13\11\3\0\3\11"+ | |
239 "\1\0\1\11\1\0\2\11\1\0\3\11\4\0\1\11"+ | |
240 "\5\0\2\11\2\0\1\1\1\0\1\11\3\0\1\11"+ | |
241 "\1\0\2\11\3\0\1\11"; | |
242 | |
243 private static int [] zzUnpackAttribute() { | |
244 int [] result = new int[89]; | |
245 int offset = 0; | |
246 offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); | |
247 return result; | |
248 } | |
249 | |
250 private static int zzUnpackAttribute(String packed, int offset, int [] result) { | |
251 int i = 0; /* index in packed string */ | |
252 int j = offset; /* index in unpacked array */ | |
253 int l = packed.length(); | |
254 while (i < l) { | |
255 int count = packed.charAt(i++); | |
256 int value = packed.charAt(i++); | |
257 do result[j++] = value; while (--count > 0); | |
258 } | |
259 return j; | |
260 } | |
261 | |
262 /** the input device */ | |
263 private java.io.Reader zzReader; | |
264 | |
265 /** the current state of the DFA */ | |
266 private int zzState; | |
267 | |
268 /** the current lexical state */ | |
269 private int zzLexicalState = YYINITIAL; | |
270 | |
271 /** this buffer contains the current text to be matched and is | |
272 the source of the yytext() string */ | |
273 private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; | |
274 | |
275 /** the textposition at the last accepting state */ | |
276 private int zzMarkedPos; | |
277 | |
278 /** the current text position in the buffer */ | |
279 private int zzCurrentPos; | |
280 | |
281 /** startRead marks the beginning of the yytext() string in the buffer */ | |
282 private int zzStartRead; | |
283 | |
284 /** endRead marks the last character in the buffer, that has been read | |
285 from input */ | |
286 private int zzEndRead; | |
287 | |
288 /** number of newlines encountered up to the start of the matched text */ | |
289 private int yyline; | |
290 | |
291 /** the number of characters up to the start of the matched text */ | |
292 private int yychar; | |
293 | |
294 /** | |
295 * the number of characters from the last newline up to the start of the | |
296 * matched text | |
297 */ | |
298 private int yycolumn; | |
299 | |
300 /** | |
301 * zzAtBOL == true <=> the scanner is currently at the beginning of a line | |
302 */ | |
303 private boolean zzAtBOL = true; | |
304 | |
305 /** zzAtEOF == true <=> the scanner is at the EOF */ | |
306 private boolean zzAtEOF; | |
307 | |
308 /** denotes if the user-EOF-code has already been executed */ | |
309 private boolean zzEOFDone; | |
310 | |
311 /** For the backwards DFA of general lookahead statements */ | |
312 private boolean [] zzFin = new boolean [ZZ_BUFFERSIZE+1]; | |
313 | |
314 /* user code: */ | |
315 private static final int CONS = 1; | |
316 private static final int VOWEL = 2; | |
317 private int cv = 0; // consonant = 1, vowel = 2, everything else = 0 | |
318 | |
319 private String original = ""; | |
320 private String normalized = ""; | |
321 private int problem = 0; | |
322 | |
323 private void add (String norm) { | |
324 original += yytext(); | |
325 normalized += norm; | |
326 } | |
327 | |
328 | |
329 /** | |
330 * Creates a new scanner | |
331 * There is also a java.io.InputStream version of this constructor. | |
332 * | |
333 * @param in the java.io.Reader to read input from. | |
334 */ | |
335 public MpdlNormalizerLexIT(java.io.Reader in) { | |
336 this.zzReader = in; | |
337 } | |
338 | |
339 /** | |
340 * Creates a new scanner. | |
341 * There is also java.io.Reader version of this constructor. | |
342 * | |
343 * @param in the java.io.Inputstream to read input from. | |
344 */ | |
345 public MpdlNormalizerLexIT(java.io.InputStream in) { | |
346 this(new java.io.InputStreamReader(in)); | |
347 } | |
348 | |
349 /** | |
350 * Unpacks the compressed character translation table. | |
351 * | |
352 * @param packed the packed character translation table | |
353 * @return the unpacked character translation table | |
354 */ | |
355 private static char [] zzUnpackCMap(String packed) { | |
356 char [] map = new char[0x10000]; | |
357 int i = 0; /* index in packed string */ | |
358 int j = 0; /* index in unpacked array */ | |
359 while (i < 168) { | |
360 int count = packed.charAt(i++); | |
361 char value = packed.charAt(i++); | |
362 do map[j++] = value; while (--count > 0); | |
363 } | |
364 return map; | |
365 } | |
366 | |
367 | |
368 /** | |
369 * Refills the input buffer. | |
370 * | |
371 * @return <code>false</code>, iff there was new input. | |
372 * | |
373 * @exception java.io.IOException if any I/O-Error occurs | |
374 */ | |
375 private boolean zzRefill() throws java.io.IOException { | |
376 | |
377 /* first: make room (if you can) */ | |
378 if (zzStartRead > 0) { | |
379 System.arraycopy(zzBuffer, zzStartRead, | |
380 zzBuffer, 0, | |
381 zzEndRead-zzStartRead); | |
382 | |
383 /* translate stored positions */ | |
384 zzEndRead-= zzStartRead; | |
385 zzCurrentPos-= zzStartRead; | |
386 zzMarkedPos-= zzStartRead; | |
387 zzStartRead = 0; | |
388 } | |
389 | |
390 /* is the buffer big enough? */ | |
391 if (zzCurrentPos >= zzBuffer.length) { | |
392 /* if not: blow it up */ | |
393 char newBuffer[] = new char[zzCurrentPos*2]; | |
394 System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); | |
395 zzBuffer = newBuffer; | |
396 } | |
397 | |
398 /* finally: fill the buffer with new input */ | |
399 int numRead = zzReader.read(zzBuffer, zzEndRead, | |
400 zzBuffer.length-zzEndRead); | |
401 | |
402 if (numRead > 0) { | |
403 zzEndRead+= numRead; | |
404 return false; | |
405 } | |
406 // unlikely but not impossible: read 0 characters, but not at end of stream | |
407 if (numRead == 0) { | |
408 int c = zzReader.read(); | |
409 if (c == -1) { | |
410 return true; | |
411 } else { | |
412 zzBuffer[zzEndRead++] = (char) c; | |
413 return false; | |
414 } | |
415 } | |
416 | |
417 // numRead < 0 | |
418 return true; | |
419 } | |
420 | |
421 | |
422 /** | |
423 * Closes the input stream. | |
424 */ | |
425 public final void yyclose() throws java.io.IOException { | |
426 zzAtEOF = true; /* indicate end of file */ | |
427 zzEndRead = zzStartRead; /* invalidate buffer */ | |
428 | |
429 if (zzReader != null) | |
430 zzReader.close(); | |
431 } | |
432 | |
433 | |
434 /** | |
435 * Resets the scanner to read from a new input stream. | |
436 * Does not close the old reader. | |
437 * | |
438 * All internal variables are reset, the old input stream | |
439 * <b>cannot</b> be reused (internal buffer is discarded and lost). | |
440 * Lexical state is set to <tt>ZZ_INITIAL</tt>. | |
441 * | |
442 * @param reader the new input stream | |
443 */ | |
444 public final void yyreset(java.io.Reader reader) { | |
445 zzReader = reader; | |
446 zzAtBOL = true; | |
447 zzAtEOF = false; | |
448 zzEOFDone = false; | |
449 zzEndRead = zzStartRead = 0; | |
450 zzCurrentPos = zzMarkedPos = 0; | |
451 yyline = yychar = yycolumn = 0; | |
452 zzLexicalState = YYINITIAL; | |
453 } | |
454 | |
455 | |
456 /** | |
457 * Returns the current lexical state. | |
458 */ | |
459 public final int yystate() { | |
460 return zzLexicalState; | |
461 } | |
462 | |
463 | |
464 /** | |
465 * Enters a new lexical state | |
466 * | |
467 * @param newState the new lexical state | |
468 */ | |
469 public final void yybegin(int newState) { | |
470 zzLexicalState = newState; | |
471 } | |
472 | |
473 | |
474 /** | |
475 * Returns the text matched by the current regular expression. | |
476 */ | |
477 public final String yytext() { | |
478 return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); | |
479 } | |
480 | |
481 | |
482 /** | |
483 * Returns the character at position <tt>pos</tt> from the | |
484 * matched text. | |
485 * | |
486 * It is equivalent to yytext().charAt(pos), but faster | |
487 * | |
488 * @param pos the position of the character to fetch. | |
489 * A value from 0 to yylength()-1. | |
490 * | |
491 * @return the character at position pos | |
492 */ | |
493 public final char yycharat(int pos) { | |
494 return zzBuffer[zzStartRead+pos]; | |
495 } | |
496 | |
497 | |
498 /** | |
499 * Returns the length of the matched text region. | |
500 */ | |
501 public final int yylength() { | |
502 return zzMarkedPos-zzStartRead; | |
503 } | |
504 | |
505 | |
506 /** | |
507 * Reports an error that occured while scanning. | |
508 * | |
509 * In a wellformed scanner (no or only correct usage of | |
510 * yypushback(int) and a match-all fallback rule) this method | |
511 * will only be called with things that "Can't Possibly Happen". | |
512 * If this method is called, something is seriously wrong | |
513 * (e.g. a JFlex bug producing a faulty scanner etc.). | |
514 * | |
515 * Usual syntax/scanner level error handling should be done | |
516 * in error fallback rules. | |
517 * | |
518 * @param errorCode the code of the errormessage to display | |
519 */ | |
520 private void zzScanError(int errorCode) { | |
521 String message; | |
522 try { | |
523 message = ZZ_ERROR_MSG[errorCode]; | |
524 } | |
525 catch (ArrayIndexOutOfBoundsException e) { | |
526 message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; | |
527 } | |
528 | |
529 throw new Error(message); | |
530 } | |
531 | |
532 | |
533 /** | |
534 * Pushes the specified amount of characters back into the input stream. | |
535 * | |
536 * They will be read again by then next call of the scanning method | |
537 * | |
538 * @param number the number of characters to be read again. | |
539 * This number must not be greater than yylength()! | |
540 */ | |
541 public void yypushback(int number) { | |
542 if ( number > yylength() ) | |
543 zzScanError(ZZ_PUSHBACK_2BIG); | |
544 | |
545 zzMarkedPos -= number; | |
546 } | |
547 | |
548 | |
549 /** | |
550 * Resumes scanning until the next regular expression is matched, | |
551 * the end of input is encountered or an I/O-Error occurs. | |
552 * | |
553 * @return the next token | |
554 * @exception java.io.IOException if any I/O-Error occurs | |
555 */ | |
556 public java.lang.String yylex() throws java.io.IOException { | |
557 int zzInput; | |
558 int zzAction; | |
559 | |
560 // cached fields: | |
561 int zzCurrentPosL; | |
562 int zzMarkedPosL; | |
563 int zzEndReadL = zzEndRead; | |
564 char [] zzBufferL = zzBuffer; | |
565 char [] zzCMapL = ZZ_CMAP; | |
566 | |
567 int [] zzTransL = ZZ_TRANS; | |
568 int [] zzRowMapL = ZZ_ROWMAP; | |
569 int [] zzAttrL = ZZ_ATTRIBUTE; | |
570 | |
571 while (true) { | |
572 zzMarkedPosL = zzMarkedPos; | |
573 | |
574 if (zzMarkedPosL > zzStartRead) { | |
575 switch (zzBufferL[zzMarkedPosL-1]) { | |
576 case '\n': | |
577 case '\u000B': | |
578 case '\u000C': | |
579 case '\u0085': | |
580 case '\u2028': | |
581 case '\u2029': | |
582 zzAtBOL = true; | |
583 break; | |
584 case '\r': | |
585 if (zzMarkedPosL < zzEndReadL) | |
586 zzAtBOL = zzBufferL[zzMarkedPosL] != '\n'; | |
587 else if (zzAtEOF) | |
588 zzAtBOL = false; | |
589 else { | |
590 boolean eof = zzRefill(); | |
591 zzMarkedPosL = zzMarkedPos; | |
592 zzEndReadL = zzEndRead; | |
593 zzBufferL = zzBuffer; | |
594 if (eof) | |
595 zzAtBOL = false; | |
596 else | |
597 zzAtBOL = zzBufferL[zzMarkedPosL] != '\n'; | |
598 } | |
599 break; | |
600 default: | |
601 zzAtBOL = false; | |
602 } | |
603 } | |
604 zzAction = -1; | |
605 | |
606 zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; | |
607 | |
608 if (zzAtBOL) | |
609 zzState = ZZ_LEXSTATE[zzLexicalState+1]; | |
610 else | |
611 zzState = ZZ_LEXSTATE[zzLexicalState]; | |
612 | |
613 | |
614 zzForAction: { | |
615 while (true) { | |
616 | |
617 if (zzCurrentPosL < zzEndReadL) | |
618 zzInput = zzBufferL[zzCurrentPosL++]; | |
619 else if (zzAtEOF) { | |
620 zzInput = YYEOF; | |
621 break zzForAction; | |
622 } | |
623 else { | |
624 // store back cached positions | |
625 zzCurrentPos = zzCurrentPosL; | |
626 zzMarkedPos = zzMarkedPosL; | |
627 boolean eof = zzRefill(); | |
628 // get translated positions and possibly new buffer | |
629 zzCurrentPosL = zzCurrentPos; | |
630 zzMarkedPosL = zzMarkedPos; | |
631 zzBufferL = zzBuffer; | |
632 zzEndReadL = zzEndRead; | |
633 if (eof) { | |
634 zzInput = YYEOF; | |
635 break zzForAction; | |
636 } | |
637 else { | |
638 zzInput = zzBufferL[zzCurrentPosL++]; | |
639 } | |
640 } | |
641 int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; | |
642 if (zzNext == -1) break zzForAction; | |
643 zzState = zzNext; | |
644 | |
645 int zzAttributes = zzAttrL[zzState]; | |
646 if ( (zzAttributes & 1) == 1 ) { | |
647 zzAction = zzState; | |
648 zzMarkedPosL = zzCurrentPosL; | |
649 if ( (zzAttributes & 8) == 8 ) break zzForAction; | |
650 } | |
651 | |
652 } | |
653 } | |
654 | |
655 // store back cached position | |
656 zzMarkedPos = zzMarkedPosL; | |
657 | |
658 switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { | |
659 case 32: | |
660 // lookahead expression with fixed base length | |
661 zzMarkedPos = zzStartRead + 1; | |
662 { cv = CONS; add("U"); | |
663 } | |
664 case 40: break; | |
665 case 15: | |
666 { add("Á"); | |
667 } | |
668 case 41: break; | |
669 case 39: | |
670 // lookahead expression with fixed lookahead length | |
671 yypushback(1); | |
672 { add(yytext()); | |
673 } | |
674 case 42: break; | |
675 case 38: | |
676 // lookahead expression with fixed base length | |
677 zzMarkedPos = zzStartRead + 3; | |
678 { add(yytext()); | |
679 } | |
680 case 43: break; | |
681 case 37: | |
682 // lookahead expression with fixed base length | |
683 zzMarkedPos = zzStartRead + 2; | |
684 { add(yytext()); | |
685 } | |
686 case 44: break; | |
687 case 4: | |
688 { add(yytext()); | |
689 } | |
690 case 45: break; | |
691 case 22: | |
692 { add("í"); | |
693 } | |
694 case 46: break; | |
695 case 9: | |
696 { cv = VOWEL; add("AE"); | |
697 } | |
698 case 47: break; | |
699 case 5: | |
700 { switch (problem) { | |
701 case 1: return original; | |
702 default: return normalized; | |
703 } | |
704 } | |
705 case 48: break; | |
706 case 29: | |
707 // lookahead expression with fixed base length | |
708 zzMarkedPos = zzStartRead + 1; | |
709 { cv = CONS; add("u"); | |
710 } | |
711 case 49: break; | |
712 case 20: | |
713 { add("á"); | |
714 } | |
715 case 50: break; | |
716 case 1: | |
717 { cv = 0; add(yytext()); | |
718 } | |
719 case 51: break; | |
720 case 33: | |
721 // lookahead expression with fixed base length | |
722 zzMarkedPos = zzStartRead + 1; | |
723 { cv = VOWEL; add(yytext().replaceAll("u", "v").replaceAll("U", "V")); | |
724 } | |
725 case 52: break; | |
726 case 34: | |
727 { cv = VOWEL; add("zio"); | |
728 } | |
729 case 53: break; | |
730 case 11: | |
731 { cv = VOWEL; add("OE"); | |
732 } | |
733 case 54: break; | |
734 case 19: | |
735 { add("Ú"); | |
736 } | |
737 case 55: break; | |
738 case 36: | |
739 // general lookahead, find correct zzMarkedPos | |
740 { int zzFState = 7; | |
741 int zzFPos = zzStartRead; | |
742 if (zzFin.length <= zzBufferL.length) { zzFin = new boolean[zzBufferL.length+1]; } | |
743 boolean zzFinL[] = zzFin; | |
744 while (zzFState != -1 && zzFPos < zzMarkedPos) { | |
745 if ((zzAttrL[zzFState] & 1) == 1) { zzFinL[zzFPos] = true; } | |
746 zzInput = zzBufferL[zzFPos++]; | |
747 zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ]; | |
748 } | |
749 if (zzFState != -1 && (zzAttrL[zzFState] & 1) == 1) { zzFinL[zzFPos] = true; } | |
750 | |
751 zzFState = 8; | |
752 zzFPos = zzMarkedPos; | |
753 while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) { | |
754 zzInput = zzBufferL[--zzFPos]; | |
755 zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ]; | |
756 }; | |
757 zzMarkedPos = zzFPos; | |
758 } | |
759 { cv = VOWEL; add(yytext().replace("ſ", "s")); | |
760 } | |
761 case 56: break; | |
762 case 3: | |
763 { cv = CONS; add(yytext()); | |
764 } | |
765 case 57: break; | |
766 case 31: | |
767 { cv = CONS; add("QU"); | |
768 } | |
769 case 58: break; | |
770 case 16: | |
771 { add("É"); | |
772 } | |
773 case 59: break; | |
774 case 27: | |
775 // lookahead expression with fixed base length | |
776 zzMarkedPos = zzStartRead + 1; | |
777 { switch(cv) { | |
778 case VOWEL: add(yytext().replace("u", "v").replace("U", "V")); break; | |
779 default: cv = VOWEL; add(yytext()); break; | |
780 } | |
781 } | |
782 case 60: break; | |
783 case 7: | |
784 { cv = CONS; add("ss"); | |
785 } | |
786 case 61: break; | |
787 case 6: | |
788 { cv = CONS; add("s"); | |
789 } | |
790 case 62: break; | |
791 case 35: | |
792 { cv = VOWEL; add("ZIO"); | |
793 } | |
794 case 63: break; | |
795 case 2: | |
796 { cv = VOWEL; add(yytext()); | |
797 } | |
798 case 64: break; | |
799 case 18: | |
800 { add("Ó"); | |
801 } | |
802 case 65: break; | |
803 case 24: | |
804 { add("ú"); | |
805 } | |
806 case 66: break; | |
807 case 30: | |
808 { cv = CONS; add("Qu"); | |
809 } | |
810 case 67: break; | |
811 case 21: | |
812 { add("é"); | |
813 } | |
814 case 68: break; | |
815 case 8: | |
816 { cv = VOWEL; add("ae"); | |
817 } | |
818 case 69: break; | |
819 case 14: | |
820 { switch (problem) { | |
821 case 1: return ""; | |
822 default: return normalized; | |
823 } | |
824 } | |
825 case 70: break; | |
826 case 13: | |
827 { add(""); | |
828 } | |
829 case 71: break; | |
830 case 23: | |
831 { add("ó"); | |
832 } | |
833 case 72: break; | |
834 case 10: | |
835 { cv = VOWEL; add("oe"); | |
836 } | |
837 case 73: break; | |
838 case 28: | |
839 { cv = CONS; add("qu"); | |
840 } | |
841 case 74: break; | |
842 case 12: | |
843 { problem = 1; add(yytext()); | |
844 } | |
845 case 75: break; | |
846 case 25: | |
847 { switch(cv) { | |
848 case CONS: add(yytext().replace("v", "u").replace("V", "U")); break; | |
849 default: cv = CONS; add(yytext()); break; | |
850 } | |
851 } | |
852 case 76: break; | |
853 case 26: | |
854 { cv = VOWEL; add("ii"); | |
855 } | |
856 case 77: break; | |
857 case 17: | |
858 { add("Í"); | |
859 } | |
860 case 78: break; | |
861 default: | |
862 if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { | |
863 zzAtEOF = true; | |
864 return null; | |
865 } | |
866 else { | |
867 zzScanError(ZZ_NO_MATCH); | |
868 } | |
869 } | |
870 } | |
871 } | |
872 | |
873 | |
874 } |