001: /* The following code was generated by JFlex 1.3.5 on 7/11/04 2:35 PM */
002:
003: package com.bluecast.xml;
004:
005: import java.io.*;
006: import com.bluecast.io.*;
007:
008: /*
009: * $Id: XMLDeclParser.flex,v 1.3 2004/07/08 08:03:04 yuvalo Exp $
010: *
011: * (C) Copyright 2002-2004 by Yuval Oren. All rights reserved.
012: *
013: * Licensed under the Apache License, Version 2.0 (the "License");
014: * you may not use this file except in compliance with the License.
015: * You may obtain a copy of the License at
016: *
017: * http://www.apache.org/licenses/LICENSE-2.0
018: *
019: * Unless required by applicable law or agreed to in writing, software
020: * distributed under the License is distributed on an "AS IS" BASIS,
021: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
022: * See the License for the specific language governing permissions and
023: * limitations under the License.
024: */
025:
026: /**
027: * Parses an XML declaration (<?xml...?>). The parse() method returns
028: * SUCCESS if a declaration was parsed, or NO_DECLARATION if none was found.
029: */
030:
031: /* This JFlex source file should be compiled with Yuval's "skeleton2" skeleton. */
032:
033: /**
034: * This class is a scanner generated by
035: * <a href="http://www.jflex.de/">JFlex</a> 1.3.5
036: * on 7/11/04 2:35 PM from the specification file
037: * <tt>file:/C:/Library/Projects/piccolo/src/com/bluecast/xml/XMLDeclParser.flex</tt>
038: */
039: final class XMLDeclParser {
040:
041: /** This character denotes the end of file */
042: final public static int YYEOF = -1;
043:
044: /** initial size of the lookahead buffer */
045: final private static int YY_BUFFERSIZE = 0;
046:
047: /** lexical states */
048: final public static int GOT_ENCODING = 5;
049: final public static int ENCODING = 4;
050: final public static int XML_DECL = 1;
051: final public static int YYINITIAL = 0;
052: final public static int STANDALONE = 6;
053: final public static int GOT_VERSION = 3;
054: final public static int VERSION = 2;
055: final public static int GOT_STANDALONE = 7;
056:
057: /**
058: * Translates characters to character classes
059: */
060: final private static String yycmap_packed = "\11\0\1\1\1\1\2\0\1\1\22\0\1\1\1\0\1\22\4\0"
061: + "\1\26\5\0\1\40\1\24\1\0\1\25\1\23\3\5\1\50\1\46"
062: + "\1\5\1\41\1\51\1\3\1\0\1\6\1\2\1\34\1\7\1\0"
063: + "\1\43\1\4\1\44\2\4\1\37\2\4\1\45\5\4\1\47\3\4"
064: + "\1\42\1\36\1\35\5\4\4\0\1\5\1\0\1\33\1\4\1\27"
065: + "\1\30\1\14\1\4\1\31\1\4\1\17\2\4\1\12\1\11\1\21"
066: + "\1\20\2\4\1\15\1\16\1\32\1\4\1\13\1\4\1\10\1\52"
067: + "\1\4\uff85\0";
068:
069: /**
070: * Translates characters to character classes
071: */
072: final private static char[] yycmap = yy_unpack_cmap(yycmap_packed);
073:
074: /**
075: * Translates a state to a row index in the transition table
076: */
077: final private static int yy_rowMap[] = { 0, 43, 86, 129, 172, 215,
078: 258, 301, 344, 387, 344, 430, 473, 516, 559, 602, 645, 688,
079: 731, 774, 817, 860, 903, 430, 473, 946, 989, 1032, 344,
080: 1075, 1118, 1161, 1204, 602, 1247, 1290, 1333, 1376, 1419,
081: 1462, 1505, 1548, 731, 1591, 1634, 1677, 1720, 860, 1763,
082: 1806, 1849, 1892, 344, 1935, 1978, 344, 2021, 2064, 2107,
083: 2150, 2193, 2236, 2279, 2322, 2365, 2408, 2451, 2494, 2537,
084: 2580, 2623, 2666, 2709, 2752, 2795, 2838, 2881, 2924, 2967,
085: 3010, 3053, 3096, 344, 3139, 3182, 3225, 3268, 3311, 3354,
086: 344, 3397, 3440, 3483, 3526, 3569, 3612, 3655, 3698, 3741,
087: 3784, 344, 3225, 3827, 3870, 3913, 3956, 344, 3999, 4042,
088: 4085, 4128, 4171, 4214, 4257, 4300, 344, 344, 4343, 4386,
089: 4429, 4472, 4515, 4558, 4601, 4644, 4687, 4730, 4773, 4816,
090: 4859, 4902, 4945, 4988, 5031, 5074, 5117, 5160, 344 };
091:
092: /**
093: * The packed transition table of the DFA (part 0)
094: */
095: final private static String yy_packed0 = "\6\11\1\12\44\11\1\13\1\14\5\13\1\15\65\13"
096: + "\1\16\3\13\1\17\25\13\1\20\5\13\1\15\65\13"
097: + "\1\21\3\13\1\22\25\13\1\23\5\13\1\15\65\13"
098: + "\1\24\3\13\1\25\25\13\1\26\5\13\1\15\43\13"
099: + "\62\0\1\27\44\0\1\30\5\0\1\31\3\0\1\32"
100: + "\1\33\1\0\1\34\70\0\1\35\21\0\3\36\2\0"
101: + "\12\36\1\0\1\37\2\36\1\0\5\36\1\0\16\36"
102: + "\3\0\3\40\2\0\12\40\1\0\1\41\2\40\1\0"
103: + "\5\40\1\0\16\40\1\0\1\42\5\0\1\31\4\0"
104: + "\1\33\1\0\1\34\40\0\1\43\3\0\12\43\5\0"
105: + "\5\43\1\0\1\44\2\43\2\0\1\43\1\45\1\43"
106: + "\1\46\1\0\1\43\2\0\1\43\4\0\1\47\3\0"
107: + "\12\47\5\0\5\47\1\0\1\50\2\47\2\0\1\47"
108: + "\1\51\1\47\1\52\1\0\1\47\2\0\1\47\1\0"
109: + "\1\53\5\0\1\31\6\0\1\34\55\0\1\54\30\0"
110: + "\1\55\21\0\1\56\30\0\1\57\1\0\1\60\5\0"
111: + "\1\31\53\0\1\61\56\0\1\62\57\0\1\63\63\0"
112: + "\1\64\23\0\3\36\2\0\12\36\1\65\3\36\1\0"
113: + "\5\36\1\0\16\36\3\0\3\36\2\0\12\36\1\65"
114: + "\1\36\1\66\1\36\1\0\5\36\1\0\16\36\3\0"
115: + "\3\40\2\0\12\40\1\0\3\40\1\65\5\40\1\0"
116: + "\16\40\3\0\3\40\2\0\12\40\1\0\1\40\1\67"
117: + "\1\40\1\65\5\40\1\0\16\40\4\0\2\43\2\0"
118: + "\12\43\1\70\3\43\1\0\5\43\1\0\16\43\4\0"
119: + "\2\43\2\0\12\43\1\70\3\43\1\0\5\43\1\0"
120: + "\1\43\1\71\3\43\1\72\10\43\4\0\2\43\2\0"
121: + "\12\43\1\70\3\43\1\0\5\43\1\0\5\43\1\73"
122: + "\10\43\4\0\2\43\2\0\12\43\1\70\3\43\1\0"
123: + "\5\43\1\0\5\43\1\74\10\43\4\0\2\47\2\0"
124: + "\12\47\1\0\3\47\1\70\5\47\1\0\16\47\4\0"
125: + "\2\47\2\0\12\47\1\0\3\47\1\70\5\47\1\0"
126: + "\1\47\1\75\3\47\1\76\10\47\4\0\2\47\2\0"
127: + "\12\47\1\0\3\47\1\70\5\47\1\0\5\47\1\77"
128: + "\10\47\4\0\2\47\2\0\12\47\1\0\3\47\1\70"
129: + "\5\47\1\0\5\47\1\100\10\47\20\0\1\101\46\0"
130: + "\1\102\56\0\1\103\46\0\1\104\47\0\1\105\56\0"
131: + "\1\106\64\0\1\107\56\0\1\110\22\0\3\36\2\0"
132: + "\12\36\1\65\2\36\1\111\1\0\5\36\1\0\16\36"
133: + "\3\0\3\40\2\0\12\40\1\0\2\40\1\112\1\65"
134: + "\5\40\1\0\16\40\4\0\2\43\2\0\12\43\1\70"
135: + "\3\43\1\0\5\43\1\0\2\43\1\113\13\43\4\0"
136: + "\2\43\2\0\12\43\1\70\3\43\1\0\5\43\1\0"
137: + "\3\43\1\114\12\43\4\0\2\43\2\0\12\43\1\70"
138: + "\3\43\1\0\5\43\1\0\7\43\1\115\6\43\4\0"
139: + "\2\43\2\0\12\43\1\70\3\43\1\0\5\43\1\0"
140: + "\12\43\1\116\3\43\4\0\2\47\2\0\12\47\1\0"
141: + "\3\47\1\70\5\47\1\0\2\47\1\117\13\47\4\0"
142: + "\2\47\2\0\12\47\1\0\3\47\1\70\5\47\1\0"
143: + "\3\47\1\120\12\47\4\0\2\47\2\0\12\47\1\0"
144: + "\3\47\1\70\5\47\1\0\7\47\1\121\6\47\4\0"
145: + "\2\47\2\0\12\47\1\0\3\47\1\70\5\47\1\0"
146: + "\12\47\1\122\3\47\22\0\1\123\46\0\1\124\62\0"
147: + "\1\123\42\0\1\125\46\0\1\126\56\0\1\127\54\0"
148: + "\1\130\53\0\1\131\34\0\3\36\2\0\12\36\1\132"
149: + "\3\36\1\0\5\36\1\0\16\36\3\0\3\40\2\0"
150: + "\12\40\1\0\3\40\1\132\5\40\1\0\16\40\4\0"
151: + "\2\43\2\0\12\43\1\70\1\133\2\43\1\0\5\43"
152: + "\1\0\3\43\1\134\1\135\11\43\4\0\2\43\2\0"
153: + "\12\43\1\70\3\43\1\0\5\43\1\0\6\43\1\45"
154: + "\7\43\4\0\2\43\2\0\12\43\1\70\3\43\1\0"
155: + "\5\43\1\0\10\43\1\136\5\43\4\0\2\43\2\0"
156: + "\12\43\1\70\3\43\1\0\5\43\1\0\3\43\1\137"
157: + "\12\43\4\0\2\47\2\0\12\47\1\0\1\140\2\47"
158: + "\1\70\5\47\1\0\3\47\1\141\1\142\11\47\4\0"
159: + "\2\47\2\0\12\47\1\0\3\47\1\70\5\47\1\0"
160: + "\6\47\1\51\7\47\4\0\2\47\2\0\12\47\1\0"
161: + "\3\47\1\70\5\47\1\0\10\47\1\143\5\47\4\0"
162: + "\2\47\2\0\12\47\1\0\3\47\1\70\5\47\1\0"
163: + "\3\47\1\144\12\47\22\0\1\145\56\0\1\145\25\0"
164: + "\1\146\70\0\1\147\63\0\1\150\52\0\1\151\26\0"
165: + "\2\43\2\0\12\43\1\70\3\43\1\0\5\43\1\0"
166: + "\11\43\1\152\4\43\4\0\2\43\2\0\12\43\1\70"
167: + "\1\133\2\43\1\0\5\43\1\0\4\43\1\135\11\43"
168: + "\4\0\2\43\2\0\12\43\1\153\3\43\1\0\5\43"
169: + "\1\0\16\43\4\0\2\43\2\0\12\43\1\70\3\43"
170: + "\1\0\5\43\1\0\10\43\1\154\5\43\4\0\2\43"
171: + "\2\0\12\43\1\70\3\43\1\0\5\43\1\0\4\43"
172: + "\1\155\11\43\4\0\2\47\2\0\12\47\1\0\3\47"
173: + "\1\70\5\47\1\0\11\47\1\156\4\47\4\0\2\47"
174: + "\2\0\12\47\1\0\1\140\2\47\1\70\5\47\1\0"
175: + "\4\47\1\142\11\47\4\0\2\47\2\0\12\47\1\0"
176: + "\3\47\1\153\5\47\1\0\16\47\4\0\2\47\2\0"
177: + "\12\47\1\0\3\47\1\70\5\47\1\0\10\47\1\157"
178: + "\5\47\4\0\2\47\2\0\12\47\1\0\3\47\1\70"
179: + "\5\47\1\0\4\47\1\160\11\47\20\0\1\161\51\0"
180: + "\1\162\66\0\1\163\23\0\2\43\2\0\12\43\1\164"
181: + "\3\43\1\0\5\43\1\0\16\43\4\0\2\43\2\0"
182: + "\12\43\1\165\3\43\1\0\5\43\1\0\16\43\4\0"
183: + "\2\43\2\0\12\43\1\70\3\43\1\0\5\43\1\0"
184: + "\4\43\1\166\11\43\4\0\2\47\2\0\12\47\1\0"
185: + "\3\47\1\164\5\47\1\0\16\47\4\0\2\47\2\0"
186: + "\12\47\1\0\3\47\1\165\5\47\1\0\16\47\4\0"
187: + "\2\47\2\0\12\47\1\0\3\47\1\70\5\47\1\0"
188: + "\4\47\1\167\11\47\21\0\1\170\52\0\1\171\43\0"
189: + "\1\172\44\0\2\43\2\0\12\43\1\70\3\43\1\0"
190: + "\5\43\1\0\13\43\1\173\2\43\4\0\2\47\2\0"
191: + "\12\47\1\0\3\47\1\70\5\47\1\0\13\47\1\174"
192: + "\2\47\1\0\1\170\1\175\101\0\1\176\41\0\1\177"
193: + "\36\0\2\43\2\0\12\43\1\70\3\43\1\0\5\43"
194: + "\1\0\14\43\1\200\1\43\4\0\2\47\2\0\12\47"
195: + "\1\0\3\47\1\70\5\47\1\0\14\47\1\201\1\47"
196: + "\1\0\1\175\52\0\1\176\1\202\71\0\1\203\35\0"
197: + "\2\43\2\0\12\43\1\70\3\43\1\0\5\43\1\0"
198: + "\3\43\1\204\12\43\4\0\2\47\2\0\12\47\1\0"
199: + "\3\47\1\70\5\47\1\0\3\47\1\205\12\47\1\0"
200: + "\1\202\65\0\1\206\42\0\2\43\2\0\12\43\1\70"
201: + "\1\207\2\43\1\0\5\43\1\0\16\43\4\0\2\47"
202: + "\2\0\12\47\1\0\1\210\2\47\1\70\5\47\1\0"
203: + "\16\47\1\0\1\206\1\211\54\0\2\43\2\0\12\43"
204: + "\1\212\3\43\1\0\5\43\1\0\16\43\4\0\2\47"
205: + "\2\0\12\47\1\0\3\47\1\212\5\47\1\0\16\47"
206: + "\1\0\1\211\51\0";
207:
208: /**
209: * The transition table of the DFA
210: */
211: final private static int yytrans[] = yy_unpack();
212:
213: /* error codes */
214: final private static int YY_UNKNOWN_ERROR = 0;
215: final private static int YY_ILLEGAL_STATE = 1;
216: final private static int YY_NO_MATCH = 2;
217: final private static int YY_PUSHBACK_2BIG = 3;
218: final private static int YY_SKIP_2BIG = 4;
219:
220: /* error messages for the codes above */
221: final private static String YY_ERROR_MSG[] = {
222: "Unkown internal scanner error",
223: "Internal error: unknown state",
224: "Error: could not match input",
225: "Error: pushback value was too large",
226: "Error: skip value was too large" };
227:
228: /**
229: * YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
230: */
231: private final static byte YY_ATTRIBUTE[] = { 0, 0, 0, 0, 0, 0, 0,
232: 0, 9, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
233: 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
234: 0, 0, 0, 0, 0, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
235: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 2, 0,
236: 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 5, 0, 0, 0, 0, 9,
237: 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
238: 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 9 };
239:
240: /** the input device */
241: private java.io.Reader yy_reader;
242:
243: /** the current state of the DFA */
244: private int yy_state;
245:
246: /** the current lexical state */
247: private int yy_lexical_state = YYINITIAL;
248:
249: /** this buffer contains the current text to be matched and is
250: the source of the yytext() string */
251: private char yy_buffer[] = new char[YY_BUFFERSIZE];
252:
253: /** a pointer to the internal buffer, used to restore it when yyreset() changes
254: the buffer to an externally created one. */
255: private char yy_saved_buffer[] = null;
256:
257: /** the textposition at the last accepting state */
258: private int yy_markedPos;
259:
260: /** the textposition at the last state to be included in yytext */
261: private int yy_pushbackPos;
262:
263: /** the current text position in the buffer */
264: private int yy_currentPos;
265:
266: /** startRead marks the beginning of the yytext() string in the buffer */
267: private int yy_startRead;
268:
269: /** endRead marks the last character in the buffer, that has been read
270: from input */
271: private int yy_endRead;
272:
273: /** number of newlines encountered up to the start of the matched text */
274: private int yyline;
275:
276: /** the number of characters up to the start of the matched text */
277: private int yychar;
278:
279: /**
280: * the number of characters from the last newline up to the start of the
281: * matched text
282: */
283: private int yycolumn;
284:
285: /**
286: * yy_atBOL == true <=> the scanner is currently at the beginning of a line
287: */
288: private boolean yy_atBOL = true;
289:
290: /** yy_atEOF == true <=> the scanner is at the EOF */
291: private boolean yy_atEOF;
292:
293: /* user code: */
294: static public final int SUCCESS = 1;
295: static public final int NO_DECLARATION = YYEOF;
296:
297: private String xmlVersion = null;
298: private String xmlEncoding = null;
299: private boolean xmlStandalone = false;
300: private boolean xmlStandaloneDeclared = false;
301:
302: public XMLDeclParser(char[] buf, int off, int len)
303: throws IOException {
304: yyreset(buf, off, len);
305: }
306:
307: public XMLDeclParser() {
308: }
309:
310: public void reset(char[] buf, int off, int len) throws IOException {
311: xmlVersion = xmlEncoding = null;
312: xmlStandaloneDeclared = xmlStandalone = false;
313: yyreset(buf, off, len);
314: }
315:
316: public String getXMLVersion() {
317: return xmlVersion;
318: }
319:
320: public String getXMLEncoding() {
321: return xmlEncoding;
322: }
323:
324: public boolean isXMLStandaloneDeclared() {
325: return xmlStandaloneDeclared;
326: }
327:
328: public boolean isXMLStandalone() {
329: return xmlStandalone;
330: }
331:
332: public int getCharsRead() {
333: return yychar + yylength();
334: }
335:
336: /**
337: * Creates a new scanner
338: * There is also a java.io.InputStream version of this constructor.
339: *
340: * @param in the java.io.Reader to read input from.
341: */
342: XMLDeclParser(java.io.Reader in) {
343: this .yy_reader = in;
344: }
345:
346: /**
347: * Creates a new scanner.
348: * There is also java.io.Reader version of this constructor.
349: *
350: * @param in the java.io.Inputstream to read input from.
351: */
352: XMLDeclParser(java.io.InputStream in) {
353: this (new java.io.InputStreamReader(in));
354: }
355:
356: /**
357: * Unpacks the split, compressed DFA transition table.
358: *
359: * @return the unpacked transition table
360: */
361: private static int[] yy_unpack() {
362: int[] trans = new int[5203];
363: int offset = 0;
364: offset = yy_unpack(yy_packed0, offset, trans);
365: return trans;
366: }
367:
368: /**
369: * Unpacks the compressed DFA transition table.
370: *
371: * @param packed the packed transition table
372: * @return the index of the last entry
373: */
374: private static int yy_unpack(String packed, int offset, int[] trans) {
375: int i = 0; /* index in packed string */
376: int j = offset; /* index in unpacked array */
377: int l = packed.length();
378: while (i < l) {
379: int count = packed.charAt(i++);
380: int value = packed.charAt(i++);
381: value--;
382: do
383: trans[j++] = value;
384: while (--count > 0);
385: }
386: return j;
387: }
388:
389: /**
390: * Unpacks the compressed character translation table.
391: *
392: * @param packed the packed character translation table
393: * @return the unpacked character translation table
394: */
395: private static char[] yy_unpack_cmap(String packed) {
396: char[] map = new char[0x10000];
397: int i = 0; /* index in packed string */
398: int j = 0; /* index in unpacked array */
399: while (i < 144) {
400: int count = packed.charAt(i++);
401: char value = packed.charAt(i++);
402: do
403: map[j++] = value;
404: while (--count > 0);
405: }
406: return map;
407: }
408:
409: /**
410: * Refills the input buffer.
411: *
412: * @return <code>false</code>, iff there was new input.
413: *
414: * @exception IOException if any I/O-Error occurs
415: */
416: private boolean yy_refill() throws java.io.IOException {
417:
418: /* first: make room (if you can) */
419: if (yy_startRead > 0) {
420: System.arraycopy(yy_buffer, yy_startRead, yy_buffer, 0,
421: yy_endRead - yy_startRead);
422:
423: /* translate stored positions */
424: yy_endRead -= yy_startRead;
425: yy_currentPos -= yy_startRead;
426: yy_markedPos -= yy_startRead;
427: yy_pushbackPos -= yy_startRead;
428: yy_startRead = 0;
429: }
430:
431: /* is the buffer big enough? */
432: if (yy_markedPos >= yy_buffer.length
433: || yy_currentPos >= yy_buffer.length) {
434: /* if not: blow it up */
435: char newBuffer[] = new char[yy_buffer.length * 2];
436: System.arraycopy(yy_buffer, 0, newBuffer, 0,
437: yy_buffer.length);
438: yy_buffer = newBuffer;
439: }
440:
441: /* finally: fill the buffer with new input */
442: int numRead = yy_reader.read(yy_buffer, yy_endRead,
443: yy_buffer.length - yy_endRead);
444:
445: if (numRead < 0) {
446: return true;
447: } else {
448: yy_endRead += numRead;
449: return false;
450: }
451: }
452:
453: /**
454: * Closes the input stream.
455: */
456: final public void yyclose() throws java.io.IOException {
457: yy_atEOF = true; /* indicate end of file */
458: yy_endRead = yy_startRead; /* invalidate buffer */
459:
460: if (yy_reader != null)
461: yy_reader.close();
462: }
463:
464: /**
465: * Closes the current stream, and resets the
466: * scanner to read from a new input stream.
467: *
468: * All internal variables are reset, the old input stream
469: * <b>cannot</b> be reused (internal buffer is discarded and lost).
470: * Lexical state is set to <tt>YY_INITIAL</tt>.
471: *
472: * @param reader the new input stream
473: *
474: * @see #yypushStream(java.io.Reader)
475: * @see #yypopStream()
476: */
477: final public void yyreset(java.io.Reader reader)
478: throws java.io.IOException {
479: yyclose();
480:
481: if (yy_saved_buffer != null) {
482: yy_buffer = yy_saved_buffer;
483: yy_saved_buffer = null;
484: }
485:
486: yy_reader = reader;
487: yy_atBOL = true;
488: yy_atEOF = false;
489: yy_endRead = yy_startRead = 0;
490: yy_currentPos = yy_markedPos = yy_pushbackPos = 0;
491:
492: yyline = yychar = yycolumn = 0;
493: yy_state = yy_lexical_state = YYINITIAL;
494: yy_sawCR = false;
495: yyline_next = yycolumn_next = 0;
496: }
497:
498: final public void yyreset(char[] buffer, int off, int len)
499: throws java.io.IOException {
500: yyclose();
501: if (yy_saved_buffer == null)
502: yy_saved_buffer = yy_buffer;
503: yy_buffer = buffer;
504: yy_reader = null;
505: yy_atBOL = true;
506: yy_atEOF = true;
507: yy_currentPos = yy_markedPos = yy_pushbackPos = yy_startRead = off;
508:
509: yy_endRead = off + len;
510: yyline = yychar = yycolumn = 0;
511: yy_state = yy_lexical_state = YYINITIAL;
512: yy_sawCR = false;
513: yyline_next = yycolumn_next = 0;
514:
515: yy_endRead_l = yy_endRead;
516: yy_buffer_l = yy_buffer;
517: }
518:
519: /**
520: * Returns the current lexical state.
521: */
522: final public int yystate() {
523: return yy_lexical_state;
524: }
525:
526: /**
527: * Enters a new lexical state
528: *
529: * @param newState the new lexical state
530: */
531: final public void yybegin(int newState) {
532: yy_lexical_state = newState;
533: }
534:
535: /**
536: * Returns the text matched by the current regular expression.
537: */
538: final public String yytext() {
539: return new String(yy_buffer, yy_startRead, yy_markedPos
540: - yy_startRead);
541: }
542:
543: /**
544: * Returns the text matched by the current regular expression.
545: *
546: * @param start starting offset from the beginning of the current expression.
547: * @param length number of characters to include in the string.
548: */
549: final public String yytext(int offset, int length) {
550: return new String(yy_buffer, yy_startRead + offset, length);
551: }
552:
553: /**
554: * Accept the current action as completed and update line, column and
555: * character counters accordingly. Used in conjunction with
556: * yynextChar().
557: *
558: * @see #yynextChar()
559: */
560: final public void yynextAction() {
561: yyline = yyline_next;
562: yycolumn = yycolumn_next;
563: // Uncomment for %char directive: yychar += (yy_markedPos - yy_startRead);
564: yy_currentPos = yy_startRead = yy_markedPos;
565: }
566:
567: /**
568: * Extends the matched text by one character and returns it.
569: *
570: * @returns the next character, or YYEOF
571: */
572: final public int yynextChar() throws IOException {
573: int yy_input;
574: if (yy_markedPos < yy_endRead)
575: yy_input = yy_buffer[yy_markedPos++];
576: else if (yy_atEOF) {
577: return YYEOF;
578: } else {
579: boolean eof = yy_refill();
580: yy_buffer_l = yy_buffer;
581: yy_endRead_l = yy_endRead;
582: if (eof)
583: return YYEOF;
584: else
585: yy_input = yy_buffer[yy_markedPos++];
586: }
587:
588: yy_doCount(yy_input);
589: return yy_input;
590: }
591:
592: /**
593: * Extends the matched text by one character and returns it.
594: * Similar to yynextChar(), but the caller guarantees [by using
595: * yybufferLeft()] that there is at least one more character in the
596: * buffer.
597: *
598: *
599: * @returns the next character, or YYEOF
600: */
601: final public int yynextBufferChar() throws IOException {
602: int yy_input = yy_buffer[yy_markedPos++];
603: yy_doCount(yy_input);
604: return yy_input;
605: }
606:
607: final private int yy_doCount(int yy_input) {
608: switch (yy_input) {
609:
610: case '\r':
611: yyline_next++;
612: yycolumn_next = 0;
613: yy_sawCR = true;
614: break;
615:
616: case '\n':
617: if (yy_sawCR)
618: yy_sawCR = false;
619: else {
620: yyline_next++;
621: yycolumn_next = 0;
622: }
623: break;
624:
625: default:
626: yy_sawCR = false;
627: yycolumn_next++;
628: break;
629: }
630: return yy_input;
631: }
632:
633: /**
634: * Returns the character at position <tt>pos</tt> from the
635: * matched text.
636: *
637: * It is equivalent to yytext().charAt(pos), but faster
638: *
639: * @param pos the position of the character to fetch.
640: * A value from 0 to yylength()-1.
641: *
642: * @return the character at position pos
643: */
644: final public char yycharat(int pos) {
645: return yy_buffer[yy_startRead + pos];
646: }
647:
648: /**
649: * Returns the number of characters remaining in the buffer,
650: * not including the matched text, before more
651: * characters must be read from the input Reader.
652: *
653: */
654: final public int yybufferLeft() {
655: return yy_endRead - yy_markedPos;
656: }
657:
658: /**
659: * Skips past the specified number of characters.
660: * These characters will be included in line, column, and character
661: * counting, but they will not be used for matching.
662: *
663: * @param n the number of characters to skip
664: */
665: final public void yyskip(int n) {
666: yy_markedPos += n;
667: yy_markedPos_l = yy_markedPos;
668: if (yy_markedPos > yy_endRead)
669: yy_ScanError(YY_SKIP_2BIG);
670: }
671:
672: /**
673: * Returns the length of the matched text region.
674: */
675: final public int yylength() {
676: return yy_markedPos - yy_startRead;
677: }
678:
679: /**
680: * Reports an error that occured while scanning.
681: *
682: * In a wellformed scanner (no or only correct usage of
683: * yypushback(int) and a match-all fallback rule) this method
684: * will only be called with things that "Can't Possibly Happen".
685: * If this method is called, something is seriously wrong
686: * (e.g. a JFlex bug producing a faulty scanner etc.).
687: *
688: * Usual syntax/scanner level error handling should be done
689: * in error fallback rules.
690: *
691: * @param errorCode the code of the errormessage to display
692: */
693: private void yy_ScanError(int errorCode) {
694: String message;
695: try {
696: message = YY_ERROR_MSG[errorCode];
697: } catch (ArrayIndexOutOfBoundsException e) {
698: message = YY_ERROR_MSG[YY_UNKNOWN_ERROR];
699: }
700:
701: throw new Error(message);
702: }
703:
704: /**
705: * Pushes the specified amount of characters back into the input stream.
706: *
707: * They will be read again by then next call of the scanning method
708: *
709: * @param number the number of characters to be read again.
710: * This number must not be greater than yylength()!
711: */
712: private void yypushback(int number) {
713: if (number > yylength())
714: yy_ScanError(YY_PUSHBACK_2BIG);
715:
716: yy_markedPos -= number;
717:
718: // Recount the lines and columns
719: yyline_next = yyline;
720: yycolumn_next = yycolumn;
721: yy_sawCR = yy_prev_sawCR;
722: for (int pos = yy_startRead; pos < yy_markedPos; pos++)
723: yy_doCount(yy_buffer[pos]);
724: }
725:
726: // Yuval moved cached fields to class level so yypushStream() can set them.
727: private int yy_currentPos_l;
728: private int yy_startRead_l;
729: private int yy_markedPos_l;
730: private int yy_endRead_l;
731: private char[] yy_buffer_l;
732: private char[] yycmap_l;
733:
734: // Line and column counting variables.
735: private boolean yy_sawCR = false; // Was the last character a CR?
736: private boolean yy_prev_sawCR = false; // value of yy_sawCR before this action was parsed
737: private int yyline_next = 0; // What yyline should be after matched text
738: private int yycolumn_next = 0; // What yycolumn should be after matched text
739:
740: /**
741: * Resumes scanning until the next regular expression is matched,
742: * the end of input is encountered or an I/O-Error occurs.
743: *
744: * @return the next token
745: * @exception IOException if any I/O-Error occurs
746: */
747:
748: public int parse() throws java.io.IOException, FileFormatException {
749: int yy_input;
750: int yy_action;
751:
752: // Set cached fields:
753: yy_endRead_l = yy_endRead;
754: yy_buffer_l = yy_buffer;
755: yycmap_l = yycmap;
756:
757: int[] yytrans_l = yytrans;
758: int[] yy_rowMap_l = yy_rowMap;
759: byte[] yy_attr_l = YY_ATTRIBUTE;
760: int yy_pushbackPos_l = yy_pushbackPos = -1;
761: boolean yy_was_pushback;
762: int yyline_next_l, yycolumn_next_l;
763:
764: while (true) {
765: yy_markedPos_l = yy_markedPos;
766:
767: yychar += yy_markedPos_l - yy_startRead;
768:
769: // Add the lines and columns found in the last matching text
770: // yyline = yyline_next_l = yyline_next;
771: // yycolumn = yycolumn_next_l = yycolumn_next;
772: // yy_prev_sawCR = yy_sawCR;
773:
774: yy_action = -1;
775:
776: yy_startRead_l = yy_currentPos_l = yy_currentPos = yy_startRead = yy_markedPos_l;
777:
778: yy_state = yy_lexical_state;
779:
780: yy_was_pushback = false;
781:
782: yy_forAction: {
783: while (true) {
784:
785: if (yy_currentPos_l < yy_endRead_l)
786: yy_input = yy_buffer_l[yy_currentPos_l++];
787: else if (yy_atEOF) {
788: yy_input = YYEOF;
789: break yy_forAction;
790: } else {
791: // store back cached positions
792: yy_currentPos = yy_currentPos_l;
793: yy_markedPos = yy_markedPos_l;
794: yy_pushbackPos = yy_pushbackPos_l;
795: boolean eof = yy_refill();
796: // get translated positions and possibly new buffer
797: yy_currentPos_l = yy_currentPos;
798: yy_markedPos_l = yy_markedPos;
799: yy_buffer_l = yy_buffer;
800: yy_endRead_l = yy_endRead;
801: yy_pushbackPos_l = yy_pushbackPos;
802: if (eof) {
803: yy_input = YYEOF;
804: break yy_forAction;
805: } else {
806: yy_input = yy_buffer_l[yy_currentPos_l++];
807: }
808: }
809: /*
810: switch (yy_input) {
811: case '\r':
812: yyline_next_l++;
813: yycolumn_next_l = 0;
814: yy_sawCR = true;
815: break;
816: case '\n':
817: if (yy_sawCR)
818: yy_sawCR = false;
819: else {
820: yyline_next_l++;
821: yycolumn_next_l = 0;
822: }
823: break;
824:
825: default:
826: yy_sawCR = false;
827: yycolumn_next_l++;
828: break;
829: }
830: */
831: int yy_next = yytrans_l[yy_rowMap_l[yy_state]
832: + yycmap_l[yy_input]];
833: if (yy_next == -1)
834: break yy_forAction;
835: yy_state = yy_next;
836:
837: int yy_attributes = yy_attr_l[yy_state];
838: if ((yy_attributes & 2) == 2)
839: yy_pushbackPos_l = yy_currentPos_l;
840:
841: if ((yy_attributes & 1) == 1) {
842: yy_was_pushback = (yy_attributes & 4) == 4;
843: yy_action = yy_state;
844: yy_markedPos_l = yy_currentPos_l;
845: // yyline_next = yyline_next_l;
846: // yycolumn_next = yycolumn_next_l;
847:
848: if ((yy_attributes & 8) == 8)
849: break yy_forAction;
850: }
851:
852: }
853: }
854:
855: // store back cached position
856: yy_markedPos = yy_markedPos_l;
857:
858: if (yy_was_pushback)
859: yy_markedPos = yy_pushbackPos_l;
860:
861: switch (yy_action) {
862:
863: case 115: {
864: xmlEncoding = "UTF-16";
865: yybegin(GOT_ENCODING);
866: }
867: case 139:
868: break;
869: case 106: {
870: xmlEncoding = "UTF-8";
871: yybegin(GOT_ENCODING);
872: }
873: case 140:
874: break;
875: case 89: {
876: xmlVersion = "1.0";
877: yybegin(GOT_VERSION);
878: }
879: case 141:
880: break;
881: case 101: {
882: yybegin(XML_DECL);
883: }
884: case 142:
885: break;
886: case 10:
887: case 11:
888: case 12:
889: case 13:
890: case 14:
891: case 15:
892: case 16:
893: case 17:
894: case 18:
895: case 19:
896: case 20:
897: case 21: {
898: throw new FileFormatException(
899: "XML Declaration not well-formed", -1, -1);
900: }
901: case 143:
902: break;
903: case 82: {
904: xmlStandalone = false;
905: yybegin(GOT_STANDALONE);
906: }
907: case 144:
908: break;
909: case 100: {
910: xmlStandalone = true;
911: yybegin(GOT_STANDALONE);
912: }
913: case 145:
914: break;
915: case 28: {
916: return SUCCESS; // success
917: }
918: case 146:
919: break;
920: case 8:
921: case 9: {
922: return NO_DECLARATION;
923: }
924: case 147:
925: break;
926: case 124: {
927: yybegin(VERSION);
928: }
929: case 148:
930: break;
931: case 52: {
932: xmlVersion = yytext(1, yylength() - 2);
933: yybegin(GOT_VERSION);
934: }
935: case 149:
936: break;
937: case 55: {
938: xmlEncoding = yytext(1, yylength() - 2);
939: yybegin(GOT_ENCODING);
940: }
941: case 150:
942: break;
943: case 129: {
944: yybegin(ENCODING);
945: }
946: case 151:
947: break;
948: case 137: {
949: xmlEncoding = "ISO-8859-1";
950: yybegin(GOT_ENCODING);
951: }
952: case 152:
953: break;
954: case 136: {
955: xmlStandaloneDeclared = true;
956: yybegin(STANDALONE);
957: }
958: case 153:
959: break;
960: case 116: {
961: xmlEncoding = "US-ASCII";
962: yybegin(GOT_ENCODING);
963: }
964: case 154:
965: break;
966: default:
967: if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
968: yy_atEOF = true;
969: return YYEOF;
970: } else {
971: yy_ScanError(YY_NO_MATCH);
972: }
973: }
974: }
975: }
976:
977: }
|