Source Code Cross Referenced for HtmlLexer.java in  » HTML-Parser » HotSAX » HotSAX » html » sax » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » HTML Parser » HotSAX » HotSAX.html.sax 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* The following code was generated by JFlex 1.3.2 on 6/16/01 4:43 AM */
002:
003:        package hotsax.html.sax;
004:
005:        import java.io.*;
006:
007:        /**
008:         * This class is a scanner generated by 
009:         * <a href="http://www.jflex.de/">JFlex</a> 1.3.2
010:         * on 6/16/01 4:43 AM from the specification file
011:         * <tt>file:/home/edh/sourceforge/HotSAX/hotsax/xml/sax/HtmlLexer.flex</tt>
012:         */
013:        class HtmlLexer {
014:
015:            /** This character denotes the end of file */
016:            final public static int YYEOF = -1;
017:
018:            /** initial size of the lookahead buffer */
019:            final private static int YY_BUFFERSIZE = 16384;
020:
021:            /** lexical states */
022:            final public static int ATTRIBUTE = 2;
023:            final public static int STRING = 4;
024:            final public static int CDATA = 9;
025:            final public static int APOSSTRING = 3;
026:            final public static int YYINITIAL = 0;
027:            final public static int PROCESSINGINSTRUCTION = 7;
028:            final public static int ELEMENT = 1;
029:            final public static int END = 5;
030:            final public static int COMMENT = 6;
031:            final public static int DOCTYPE = 8;
032:
033:            /** 
034:             * Translates characters to character classes
035:             */
036:            final private static char[] yycmap = { 0, 0, 0, 0, 0, 0, 0, 0, 5,
037:                    25, 4, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
038:                    0, 0, 0, 0, 5, 10, 23, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 11,
039:                    0, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 8, 6, 22, 21, 0,
040:                    20, 1, 14, 12, 18, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13, 17, 1, 1,
041:                    1, 15, 1, 1, 1, 1, 16, 1, 19, 0, 26, 0, 7, 0, 1, 1, 1, 1,
042:                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
043:                    1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
044:                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
045:                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
046:                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
047:                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
048:                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
049:                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
050:
051:            /** 
052:             * Translates a state to a row index in the transition table
053:             */
054:            final private static int yy_rowMap[] = { 0, 27, 54, 81, 108, 135,
055:                    162, 189, 216, 243, 270, 297, 270, 324, 351, 378, 270, 270,
056:                    405, 432, 459, 270, 270, 270, 270, 270, 486, 270, 270, 297,
057:                    513, 270, 297, 540, 270, 297, 270, 270, 297, 567, 270, 594,
058:                    270, 621, 270, 648, 675, 702, 729, 270, 270, 270, 756, 783,
059:                    810, 837, 864, 891, 918, 945, 972, 999, 270, 270 };
060:
061:            /** 
062:             * The packed transition table of the DFA (part 0)
063:             */
064:            final private static String yy_packed0 = "\3\13\1\14\1\15\3\13\1\16\22\13\1\15\1\17"
065:                    + "\1\15\3\20\6\15\7\17\1\15\1\17\1\15\1\21"
066:                    + "\2\15\1\20\1\15\1\22\1\23\1\24\3\25\1\15"
067:                    + "\5\22\7\23\1\22\1\23\1\22\1\26\1\27\1\30"
068:                    + "\1\25\1\22\3\31\1\14\1\15\23\31\1\32\1\15"
069:                    + "\4\31\1\14\1\15\22\31\1\32\1\31\1\15\1\31"
070:                    + "\1\15\1\33\1\15\1\14\10\15\7\33\1\15\1\33"
071:                    + "\1\15\1\34\4\15\3\35\1\36\7\35\1\37\17\35"
072:                    + "\3\40\1\41\21\40\1\42\5\40\3\43\1\44\1\15"
073:                    + "\21\43\1\45\4\43\3\46\1\47\1\15\25\46\1\50"
074:                    + "\37\0\1\15\37\0\1\51\1\52\12\0\1\53\6\0"
075:                    + "\2\17\4\0\1\17\4\0\7\17\1\0\1\17\11\0"
076:                    + "\3\20\23\0\1\20\2\0\2\23\4\0\1\23\4\0"
077:                    + "\7\23\1\0\1\23\10\0\1\24\33\0\3\25\23\0"
078:                    + "\1\25\2\0\2\33\4\0\1\33\4\0\7\33\1\0"
079:                    + "\1\33\21\0\1\54\45\0\1\55\36\0\1\56\13\0"
080:                    + "\1\57\1\60\6\0\1\61\35\0\1\62\32\0\1\63"
081:                    + "\17\0\1\64\34\0\1\65\33\0\1\66\32\0\1\67"
082:                    + "\30\0\1\70\35\0\1\71\37\0\1\72\26\0\1\73"
083:                    + "\31\0\1\74\34\0\1\75\35\0\1\76\30\0\1\77"
084:                    + "\33\0\1\100\7\0";
085:
086:            /** 
087:             * The transition table of the DFA
088:             */
089:            final private static int yytrans[] = yy_unpack();
090:
091:            /* error codes */
092:            final private static int YY_UNKNOWN_ERROR = 0;
093:            final private static int YY_ILLEGAL_STATE = 1;
094:            final private static int YY_NO_MATCH = 2;
095:            final private static int YY_PUSHBACK_2BIG = 3;
096:
097:            /* error messages for the codes above */
098:            final private static String YY_ERROR_MSG[] = {
099:                    "Unkown internal scanner error",
100:                    "Internal error: unknown state",
101:                    "Error: could not match input",
102:                    "Error: pushback value was too large" };
103:
104:            /**
105:             * YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
106:             */
107:            private final static byte YY_ATTRIBUTE[] = { 0, 1, 1, 0, 0, 0, 0,
108:                    0, 0, 0, 9, 1, 9, 1, 1, 1, 9, 9, 1, 1, 1, 9, 9, 9, 9, 9, 1,
109:                    9, 9, 1, 1, 9, 1, 1, 9, 1, 9, 9, 1, 1, 9, 0, 9, 0, 9, 0, 0,
110:                    0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9 };
111:
112:            /** the input device */
113:            private java.io.Reader yy_reader;
114:
115:            /** the current state of the DFA */
116:            private int yy_state;
117:
118:            /** the current lexical state */
119:            private int yy_lexical_state = YYINITIAL;
120:
121:            /** this buffer contains the current text to be matched and is
122:                the source of the yytext() string */
123:            private char yy_buffer[] = new char[YY_BUFFERSIZE];
124:
125:            /** the textposition at the last accepting state */
126:            private int yy_markedPos;
127:
128:            /** the textposition at the last state to be included in yytext */
129:            private int yy_pushbackPos;
130:
131:            /** the current text position in the buffer */
132:            private int yy_currentPos;
133:
134:            /** startRead marks the beginning of the yytext() string in the buffer */
135:            private int yy_startRead;
136:
137:            /** endRead marks the last character in the buffer, that has been read
138:                from input */
139:            private int yy_endRead;
140:
141:            /** number of newlines encountered up to the start of the matched text */
142:            private int yyline;
143:
144:            /** the number of characters up to the start of the matched text */
145:            private int yychar;
146:
147:            /**
148:             * the number of characters from the last newline up to the start of the 
149:             * matched text
150:             */
151:            private int yycolumn;
152:
153:            /** 
154:             * yy_atBOL == true <=> the scanner is currently at the beginning of a line
155:             */
156:            private boolean yy_atBOL = true;
157:
158:            /** yy_atEOF == true <=> the scanner is at the EOF */
159:            private boolean yy_atEOF;
160:
161:            /** denotes if the user-EOF-code has already been executed */
162:            private boolean yy_eof_done;
163:
164:            /* user code: */
165:            private HtmlParser yyparser;
166:            private StringBuffer string = new StringBuffer();
167:            private StringBuffer text = new StringBuffer();
168:            private StringBuffer attr = new StringBuffer();
169:            private StringBuffer comment = new StringBuffer();
170:            private StringBuffer pi = new StringBuffer();
171:            private StringBuffer cdata = new StringBuffer();
172:            private StringBuffer doctype = new StringBuffer();
173:
174:            public void p(String s) {
175:                System.out.println(s);
176:            }
177:
178:            public boolean getEOF() {
179:                return yy_atEOF;
180:            }
181:
182:            public HtmlLexer(Reader r, HtmlParser p) {
183:                this (r);
184:                yyparser = p;
185:            }
186:
187:            private boolean first = false;
188:            private boolean last = false;
189:
190:            /** 
191:             *   mask the actual implementation of yylex to return the first SOF
192:             *   and the final EOF. Markign the startDocument, EndDocuemnt events
193:             */
194:            public int _yylex() throws IOException {
195:                int token;
196:                if (!first) {
197:                    first = true;
198:
199:                    return HtmlParser.SOF; // should fire the startDocument event 
200:                } else {
201:                    if (last)
202:                        return 0; // signal end of input
203:                    else {
204:                        token = yylex();
205:
206:                        if (token == 0) {
207:                            last = true;
208:                            return HtmlParser.EOF; // should fire the endDocument event
209:                        } else
210:                            return token;
211:                    }
212:                }
213:            }
214:
215:            // set the LH side of the parser
216:            void setLval(String text) {
217:                yyparser.yylval = new Lval(text);
218:            }
219:
220:            void setLval(Attribute a) {
221:                yyparser.yylval = a;
222:            }
223:
224:            /**
225:             * Creates a new scanner
226:             * There is also a java.io.InputStream version of this constructor.
227:             *
228:             * @param   in  the java.io.Reader to read input from.
229:             */
230:            HtmlLexer(java.io.Reader in) {
231:                this .yy_reader = in;
232:            }
233:
234:            /**
235:             * Creates a new scanner.
236:             * There is also java.io.Reader version of this constructor.
237:             *
238:             * @param   in  the java.io.Inputstream to read input from.
239:             */
240:            HtmlLexer(java.io.InputStream in) {
241:                this (new java.io.InputStreamReader(in));
242:            }
243:
244:            /** 
245:             * Unpacks the split, compressed DFA transition table.
246:             *
247:             * @return the unpacked transition table
248:             */
249:            private static int[] yy_unpack() {
250:                int[] trans = new int[1026];
251:                int offset = 0;
252:                offset = yy_unpack(yy_packed0, offset, trans);
253:                return trans;
254:            }
255:
256:            /** 
257:             * Unpacks the compressed DFA transition table.
258:             *
259:             * @param packed   the packed transition table
260:             * @return         the index of the last entry
261:             */
262:            private static int yy_unpack(String packed, int offset, int[] trans) {
263:                int i = 0; /* index in packed string  */
264:                int j = offset; /* index in unpacked array */
265:                int l = packed.length();
266:                while (i < l) {
267:                    int count = packed.charAt(i++);
268:                    int value = packed.charAt(i++);
269:                    value--;
270:                    do
271:                        trans[j++] = value;
272:                    while (--count > 0);
273:                }
274:                return j;
275:            }
276:
277:            /**
278:             * Gets the next input character.
279:             *
280:             * @return      the next character of the input stream, EOF if the
281:             *              end of the stream is reached.
282:             * @exception   IOException  if any I/O-Error occurs
283:             */
284:            private int yy_advance() throws java.io.IOException {
285:
286:                /* standard case */
287:                if (yy_currentPos < yy_endRead)
288:                    return yy_buffer[yy_currentPos++];
289:
290:                /* if the eof is reached, we don't need to work hard */
291:                if (yy_atEOF)
292:                    return YYEOF;
293:
294:                /* otherwise: need to refill the buffer */
295:
296:                /* first: make room (if you can) */
297:                if (yy_startRead > 0) {
298:                    System.arraycopy(yy_buffer, yy_startRead, yy_buffer, 0,
299:                            yy_endRead - yy_startRead);
300:
301:                    /* translate stored positions */
302:                    yy_endRead -= yy_startRead;
303:                    yy_currentPos -= yy_startRead;
304:                    yy_markedPos -= yy_startRead;
305:                    yy_pushbackPos -= yy_startRead;
306:                    yy_startRead = 0;
307:                }
308:
309:                /* is the buffer big enough? */
310:                if (yy_currentPos >= yy_buffer.length) {
311:                    /* if not: blow it up */
312:                    char newBuffer[] = new char[yy_currentPos * 2];
313:                    System.arraycopy(yy_buffer, 0, newBuffer, 0,
314:                            yy_buffer.length);
315:                    yy_buffer = newBuffer;
316:                }
317:
318:                /* finally: fill the buffer with new input */
319:                int numRead = yy_reader.read(yy_buffer, yy_endRead,
320:                        yy_buffer.length - yy_endRead);
321:
322:                if (numRead == -1)
323:                    return YYEOF;
324:
325:                yy_endRead += numRead;
326:
327:                return yy_buffer[yy_currentPos++];
328:            }
329:
330:            /**
331:             * Closes the input stream.
332:             */
333:            final public void yyclose() throws java.io.IOException {
334:                yy_atEOF = true; /* indicate end of file */
335:                yy_endRead = yy_startRead; /* invalidate buffer    */
336:
337:                if (yy_reader != null)
338:                    yy_reader.close();
339:            }
340:
341:            /**
342:             * Closes the current stream, and resets the
343:             * scanner to read from a new input stream.
344:             *
345:             * All internal variables are reset, the old input stream 
346:             * <b>cannot</b> be reused (internal buffer is discarded and lost).
347:             * Lexical state is set to <tt>YY_INITIAL</tt>.
348:             *
349:             * @param reader   the new input stream 
350:             */
351:            final public void yyreset(java.io.Reader reader)
352:                    throws java.io.IOException {
353:                yyclose();
354:                yy_reader = reader;
355:                yy_atBOL = true;
356:                yy_atEOF = false;
357:                yy_endRead = yy_startRead = 0;
358:                yy_currentPos = yy_markedPos = yy_pushbackPos = 0;
359:                yyline = yychar = yycolumn = 0;
360:                yy_lexical_state = YYINITIAL;
361:            }
362:
363:            /**
364:             * Returns the current lexical state.
365:             */
366:            final public int yystate() {
367:                return yy_lexical_state;
368:            }
369:
370:            /**
371:             * Enters a new lexical state
372:             *
373:             * @param newState the new lexical state
374:             */
375:            final public void yybegin(int newState) {
376:                yy_lexical_state = newState;
377:            }
378:
379:            /**
380:             * Returns the text matched by the current regular expression.
381:             */
382:            final public String yytext() {
383:                return new String(yy_buffer, yy_startRead, yy_markedPos
384:                        - yy_startRead);
385:            }
386:
387:            /**
388:             * Returns the character at position <tt>pos</tt> from the 
389:             * matched text. 
390:             * 
391:             * It is equivalent to yytext().charAt(pos), but faster
392:             *
393:             * @param pos the position of the character to fetch. 
394:             *            A value from 0 to yylength()-1.
395:             *
396:             * @return the character at position pos
397:             */
398:            final public char yycharat(int pos) {
399:                return yy_buffer[yy_startRead + pos];
400:            }
401:
402:            /**
403:             * Returns the length of the matched text region.
404:             */
405:            final public int yylength() {
406:                return yy_markedPos - yy_startRead;
407:            }
408:
409:            /**
410:             * Reports an error that occured while scanning.
411:             *
412:             * In a wellformed scanner (no or only correct usage of 
413:             * yypushback(int) and a match-all fallback rule) this method 
414:             * will only be called with things that "Can't Possibly Happen".
415:             * If this method is called, something is seriously wrong
416:             * (e.g. a JFlex bug producing a faulty scanner etc.).
417:             *
418:             * Usual syntax/scanner level error handling should be done
419:             * in error fallback rules.
420:             *
421:             * @param   errorCode  the code of the errormessage to display
422:             */
423:            private void yy_ScanError(int errorCode) {
424:                String message;
425:                try {
426:                    message = YY_ERROR_MSG[errorCode];
427:                } catch (ArrayIndexOutOfBoundsException e) {
428:                    message = YY_ERROR_MSG[YY_UNKNOWN_ERROR];
429:                }
430:
431:                throw new Error(message);
432:            }
433:
434:            /**
435:             * Pushes the specified amount of characters back into the input stream.
436:             *
437:             * They will be read again by then next call of the scanning method
438:             *
439:             * @param number  the number of characters to be read again.
440:             *                This number must not be greater than yylength()!
441:             */
442:            private void yypushback(int number) {
443:                if (number > yylength())
444:                    yy_ScanError(YY_PUSHBACK_2BIG);
445:
446:                yy_markedPos -= number;
447:            }
448:
449:            /**
450:             * Contains user EOF-code, which will be executed exactly once,
451:             * when the end of file is reached
452:             */
453:            private void yy_do_eof() throws java.io.IOException {
454:                if (!yy_eof_done) {
455:                    yy_eof_done = true;
456:                    yyclose();
457:                }
458:            }
459:
460:            /**
461:             * Resumes scanning until the next regular expression is matched,
462:             * the end of input is encountered or an I/O-Error occurs.
463:             *
464:             * @return      the next token
465:             * @exception   IOException  if any I/O-Error occurs
466:             */
467:            public int yylex() throws java.io.IOException {
468:                int yy_input;
469:                int yy_action;
470:
471:                while (true) {
472:
473:                    yychar += yylength();
474:
475:                    boolean yy_r = false;
476:                    for (yy_currentPos = yy_startRead; yy_currentPos < yy_markedPos; yy_currentPos++) {
477:                        switch (yy_buffer[yy_currentPos]) {
478:                        case '\u000B':
479:                        case '\u000C':
480:                        case '\u0085':
481:                        case '\u2028':
482:                        case '\u2029':
483:                            yyline++;
484:                            yy_r = false;
485:                            break;
486:                        case '\r':
487:                            yyline++;
488:                            yy_r = true;
489:                            break;
490:                        case '\n':
491:                            if (yy_r)
492:                                yy_r = false;
493:                            else {
494:                                yyline++;
495:                            }
496:                            break;
497:                        default:
498:                            yy_r = false;
499:                        }
500:                    }
501:
502:                    if (yy_r) {
503:                        if (yy_advance() == '\n')
504:                            yyline--;
505:                        if (!yy_atEOF)
506:                            yy_currentPos--;
507:                    }
508:
509:                    yy_action = -1;
510:
511:                    yy_currentPos = yy_startRead = yy_markedPos;
512:
513:                    yy_state = yy_lexical_state;
514:
515:                    yy_forAction: {
516:                        while (true) {
517:
518:                            yy_input = yy_advance();
519:
520:                            if (yy_input == YYEOF)
521:                                break yy_forAction;
522:
523:                            int yy_next = yytrans[yy_rowMap[yy_state]
524:                                    + yycmap[yy_input]];
525:                            if (yy_next == -1)
526:                                break yy_forAction;
527:                            yy_state = yy_next;
528:
529:                            int yy_attributes = YY_ATTRIBUTE[yy_state];
530:                            if ((yy_attributes & 1) > 0) {
531:                                yy_action = yy_state;
532:                                yy_markedPos = yy_currentPos;
533:                                if ((yy_attributes & 8) > 0)
534:                                    break yy_forAction;
535:                            }
536:
537:                        }
538:                    }
539:
540:                    switch (yy_action) {
541:
542:                    case 16: {
543:                        yybegin(YYINITIAL);
544:                        text.setLength(0);
545:                        return HtmlParser.TAG_START_COMPLETE; // signal end for attribute stop collection
546:                    }
547:                    case 65:
548:                        break;
549:                    case 20: { /*setLval(new Attribute(attr.toString(), string.toString()));
550:                    					  return HtmlParser.ATTR; */
551:                    }
552:                    case 66:
553:                        break;
554:                    case 21: {
555:                        yybegin(YYINITIAL);
556:                        text.setLength(0);
557:                        setLval("");
558:                        return HtmlParser.TAG_START_COMPLETE;
559:                    }
560:                    case 67:
561:                        break;
562:                    case 26: {
563:                        setLval(yytext());
564:                        return HtmlParser.TAG_END;
565:                    }
566:                    case 68:
567:                        break;
568:                    case 17: { /* yybegin(ELEMENT);  setLval(new Attribute(attr.toString(), string.toString()));
569:                    					  return HtmlParser.ATTR; */
570:                    }
571:                    case 69:
572:                        break;
573:                    case 63: {
574:                        yybegin(CDATA);
575:                        cdata.setLength(0);
576:                        if (text.length() > 0) {
577:                            setLval(text.toString());
578:                            return HtmlParser.TEXT;
579:                        }
580:                    }
581:                    case 70:
582:                        break;
583:                    case 62: {
584:                        yybegin(DOCTYPE);
585:                        doctype.setLength(0);
586:                    }
587:                    case 71:
588:                        break;
589:                    case 51: {
590:                        yybegin(COMMENT);
591:                        comment.setLength(0);
592:                        if (text.length() > 0) {
593:                            setLval(text.toString());
594:                            return HtmlParser.TEXT;
595:                        }
596:                    }
597:                    case 72:
598:                        break;
599:                    case 50: {
600:                        yybegin(YYINITIAL);
601:                        setLval(cdata.toString());
602:                        return HtmlParser.CDATA;
603:                    }
604:                    case 73:
605:                        break;
606:                    case 49: {
607:                        yybegin(YYINITIAL);
608:                        setLval(comment.toString());
609:                        return HtmlParser.COMMENT;
610:                    }
611:                    case 74:
612:                        break;
613:                    case 44: {
614:                        yybegin(YYINITIAL);
615:                        setLval(pi.toString());
616:                        return HtmlParser.PI;
617:                    }
618:                    case 75:
619:                        break;
620:                    case 42: {
621:                        yybegin(PROCESSINGINSTRUCTION);
622:                        pi.setLength(0);
623:                    }
624:                    case 76:
625:                        break;
626:                    case 40: {
627:                        yybegin(END);
628:                        if (text.length() > 0) {
629:                            setLval(text.toString());
630:                            return HtmlParser.TEXT;
631:                        }
632:                    }
633:                    case 77:
634:                        break;
635:                    case 37:
636:                    case 38:
637:                    case 39: {
638:                        cdata.append(yytext());
639:                    }
640:                    case 78:
641:                        break;
642:                    case 36: {
643:                        yybegin(YYINITIAL);
644:                        setLval(doctype.toString());
645:                        return HtmlParser.DOCTYPE;
646:                    }
647:                    case 79:
648:                        break;
649:                    case 34:
650:                    case 35: {
651:                        doctype.append(yytext());
652:                    }
653:                    case 80:
654:                        break;
655:                    case 31:
656:                    case 32: {
657:                        pi.append(yytext());
658:                    }
659:                    case 81:
660:                        break;
661:                    case 28:
662:                    case 29: {
663:                        comment.append(yytext());
664:                    }
665:                    case 82:
666:                        break;
667:                    case 14: {
668:                        setLval(yytext());
669:                        return HtmlParser.TAG_START;
670:                    }
671:                    case 83:
672:                        break;
673:                    case 13: {
674:                        yybegin(ELEMENT);
675:                        if (text.length() > 0) {
676:                            setLval(text.toString());
677:                            return HtmlParser.TEXT; // return leading text before this element
678:                        }
679:                    }
680:                    case 84:
681:                        break;
682:                    case 11:
683:                    case 12:
684:                    case 30:
685:                    case 33: {
686:                    }
687:                    case 85:
688:                        break;
689:                    case 10: {
690:                        text.append(yytext());
691:                    }
692:                    case 86:
693:                        break;
694:                    case 2:
695:                    case 19: {
696:                        setLval(new Attribute(attr.toString(), yytext()));
697:                        return HtmlParser.ATTR;
698:                    }
699:                    case 87:
700:                        break;
701:                    case 1:
702:                    case 15: {
703:                        yybegin(ATTRIBUTE);
704:                    }
705:                    case 88:
706:                        break;
707:                    case 18: {
708:                        attr.setLength(0);
709:                        attr.append(yytext());
710:                    }
711:                    case 89:
712:                        break;
713:                    case 22: {
714:                        string.setLength(0);
715:                        yybegin(STRING);
716:                    }
717:                    case 90:
718:                        break;
719:                    case 23: {
720:                        string.setLength(0);
721:                        yybegin(APOSSTRING);
722:                    }
723:                    case 91:
724:                        break;
725:                    case 24: {
726:                        string.append(yytext());
727:                    }
728:                    case 92:
729:                        break;
730:                    case 25: {
731:                        yybegin(ATTRIBUTE);
732:                        setLval(new Attribute(attr.toString(), string
733:                                .toString()));
734:                        return HtmlParser.ATTR;
735:                    }
736:                    case 93:
737:                        break;
738:                    case 27: {
739:                        yybegin(YYINITIAL);
740:                        text.setLength(0);
741:                    }
742:                    case 94:
743:                        break;
744:                    default:
745:                        if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
746:                            yy_atEOF = true;
747:                            yy_do_eof();
748:                            {
749:                                return 0;
750:                            }
751:                        } else {
752:                            yy_ScanError(YY_NO_MATCH);
753:                        }
754:                    }
755:                }
756:            }
757:
758:            /**
759:             * Runs the scanner on input files.
760:             *
761:             * This main method is the debugging routine for the scanner.
762:             * It prints each returned token to System.out until the end of
763:             * file is reached, or an error occured.
764:             *
765:             * @param argv   the command line, contains the filenames to run
766:             *               the scanner on.
767:             */
768:            public static void main(String argv[]) {
769:                for (int i = 0; i < argv.length; i++) {
770:                    HtmlLexer scanner = null;
771:                    try {
772:                        scanner = new HtmlLexer(new java.io.FileReader(argv[i]));
773:                    } catch (java.io.FileNotFoundException e) {
774:                        System.out.println("File not found : \"" + argv[i]
775:                                + "\"");
776:                        System.exit(1);
777:                    } catch (java.io.IOException e) {
778:                        System.out.println("Error opening file \"" + argv[i]
779:                                + "\"");
780:                        System.exit(1);
781:                    } catch (ArrayIndexOutOfBoundsException e) {
782:                        System.out
783:                                .println("Usage : java HtmlLexer <inputfile>");
784:                        System.exit(1);
785:                    }
786:
787:                    try {
788:                        do {
789:                            System.out.println(scanner.yylex());
790:                        } while (!scanner.yy_atEOF);
791:
792:                    } catch (java.io.IOException e) {
793:                        System.out
794:                                .println("An I/O error occured while scanning :");
795:                        System.out.println(e);
796:                        System.exit(1);
797:                    } catch (Exception e) {
798:                        e.printStackTrace();
799:                        System.exit(1);
800:                    }
801:                }
802:            }
803:
804:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.