Source Code Cross Referenced for QueryParser.java in  » Net » lucene-connector » org » apache » lucene » queryParser » surround » parser » 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 » Net » lucene connector » org.apache.lucene.queryParser.surround.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Generated By:JavaCC: Do not edit this line. QueryParser.java */
002:        package org.apache.lucene.queryParser.surround.parser;
003:
004:        import java.util.ArrayList;
005:        import java.util.List;
006:        import java.io.StringReader;
007:
008:        import org.apache.lucene.analysis.TokenStream;
009:
010:        import org.apache.lucene.queryParser.surround.query.SrndQuery;
011:        import org.apache.lucene.queryParser.surround.query.FieldsQuery;
012:        import org.apache.lucene.queryParser.surround.query.OrQuery;
013:        import org.apache.lucene.queryParser.surround.query.AndQuery;
014:        import org.apache.lucene.queryParser.surround.query.NotQuery;
015:        import org.apache.lucene.queryParser.surround.query.DistanceQuery;
016:        import org.apache.lucene.queryParser.surround.query.SrndTermQuery;
017:        import org.apache.lucene.queryParser.surround.query.SrndPrefixQuery;
018:        import org.apache.lucene.queryParser.surround.query.SrndTruncQuery;
019:
020:        /**
021:         * This class is generated by JavaCC.  The only method that clients should need
022:         * to call is <a href="#parse">parse()</a>.
023:         */
024:
025:        public class QueryParser implements  QueryParserConstants {
026:            final int minimumPrefixLength = 3;
027:            final int minimumCharsInTrunc = 3;
028:            final String truncationErrorMessage = "Too unrestrictive truncation: ";
029:            final String boostErrorMessage = "Cannot handle boost value: ";
030:
031:            /* CHECKME: These should be the same as for the tokenizer. How? */
032:            final char truncator = '*';
033:            final char anyChar = '?';
034:            final char quote = '\"';
035:            final char fieldOperator = ':';
036:            final char comma = ','; /* prefix list separator */
037:            final char carat = '^'; /* weight oparator */
038:
039:            static public SrndQuery parse(String query) throws ParseException {
040:                QueryParser parser = new QueryParser();
041:                return parser.parse2(query);
042:            }
043:
044:            public QueryParser() {
045:                this (new FastCharStream(new StringReader("")));
046:            }
047:
048:            public SrndQuery parse2(String query) throws ParseException {
049:                ReInit(new FastCharStream(new StringReader(query)));
050:                try {
051:                    return TopSrndQuery();
052:                } catch (TokenMgrError tme) {
053:                    throw new ParseException(tme.getMessage());
054:                }
055:            }
056:
057:            protected SrndQuery getFieldsQuery(SrndQuery q, ArrayList fieldNames) {
058:                /* FIXME: check acceptable subquery: at least one subquery should not be
059:                 * a fields query.
060:                 */
061:                return new FieldsQuery(q, fieldNames, fieldOperator);
062:            }
063:
064:            protected SrndQuery getOrQuery(List queries, boolean infix,
065:                    Token orToken) {
066:                return new OrQuery(queries, infix, orToken.image);
067:            }
068:
069:            protected SrndQuery getAndQuery(List queries, boolean infix,
070:                    Token andToken) {
071:                return new AndQuery(queries, infix, andToken.image);
072:            }
073:
074:            protected SrndQuery getNotQuery(List queries, Token notToken) {
075:                return new NotQuery(queries, notToken.image);
076:            }
077:
078:            protected static int getOpDistance(String distanceOp) {
079:                /* W, 2W, 3W etc -> 1, 2 3, etc. Same for N, 2N ... */
080:                return distanceOp.length() == 1 ? 1 : Integer
081:                        .parseInt(distanceOp.substring(0,
082:                                distanceOp.length() - 1));
083:            }
084:
085:            protected static void checkDistanceSubQueries(DistanceQuery distq,
086:                    String opName) throws ParseException {
087:                String m = distq.distanceSubQueryNotAllowed();
088:                if (m != null) {
089:                    throw new ParseException("Operator " + opName + ": " + m);
090:                }
091:            }
092:
093:            protected SrndQuery getDistanceQuery(List queries, boolean infix,
094:                    Token dToken, boolean ordered) throws ParseException {
095:                DistanceQuery dq = new DistanceQuery(queries, infix,
096:                        getOpDistance(dToken.image), dToken.image, ordered);
097:                checkDistanceSubQueries(dq, dToken.image);
098:                return dq;
099:            }
100:
101:            protected SrndQuery getTermQuery(String term, boolean quoted) {
102:                return new SrndTermQuery(term, quoted);
103:            }
104:
105:            protected boolean allowedSuffix(String suffixed) {
106:                return (suffixed.length() - 1) >= minimumPrefixLength;
107:            }
108:
109:            protected SrndQuery getPrefixQuery(String prefix, boolean quoted) {
110:                return new SrndPrefixQuery(prefix, quoted, truncator);
111:            }
112:
113:            protected boolean allowedTruncation(String truncated) {
114:                /* At least 3 normal characters needed. */
115:                int nrNormalChars = 0;
116:                for (int i = 0; i < truncated.length(); i++) {
117:                    char c = truncated.charAt(i);
118:                    if ((c != truncator) && (c != anyChar)) {
119:                        nrNormalChars++;
120:                    }
121:                }
122:                return nrNormalChars >= minimumCharsInTrunc;
123:            }
124:
125:            protected SrndQuery getTruncQuery(String truncated) {
126:                return new SrndTruncQuery(truncated, truncator, anyChar);
127:            }
128:
129:            final public SrndQuery TopSrndQuery() throws ParseException {
130:                SrndQuery q;
131:                q = FieldsQuery();
132:                jj_consume_token(0);
133:                {
134:                    if (true)
135:                        return q;
136:                }
137:                throw new Error("Missing return statement in function");
138:            }
139:
140:            final public SrndQuery FieldsQuery() throws ParseException {
141:                SrndQuery q;
142:                ArrayList fieldNames;
143:                fieldNames = OptionalFields();
144:                q = OrQuery();
145:                {
146:                    if (true)
147:                        return (fieldNames == null) ? q : getFieldsQuery(q,
148:                                fieldNames);
149:                }
150:                throw new Error("Missing return statement in function");
151:            }
152:
153:            final public ArrayList OptionalFields() throws ParseException {
154:                Token fieldName;
155:                ArrayList fieldNames = null;
156:                label_1: while (true) {
157:                    if (jj_2_1(2)) {
158:                        ;
159:                    } else {
160:                        break label_1;
161:                    }
162:                    // to the colon
163:                    fieldName = jj_consume_token(TERM);
164:                    jj_consume_token(COLON);
165:                    if (fieldNames == null) {
166:                        fieldNames = new ArrayList();
167:                    }
168:                    fieldNames.add(fieldName.image);
169:                }
170:                {
171:                    if (true)
172:                        return fieldNames;
173:                }
174:                throw new Error("Missing return statement in function");
175:            }
176:
177:            final public SrndQuery OrQuery() throws ParseException {
178:                SrndQuery q;
179:                ArrayList queries = null;
180:                Token oprt = null;
181:                q = AndQuery();
182:                label_2: while (true) {
183:                    switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
184:                    case OR:
185:                        ;
186:                        break;
187:                    default:
188:                        jj_la1[0] = jj_gen;
189:                        break label_2;
190:                    }
191:                    oprt = jj_consume_token(OR);
192:                    /* keep only last used operator */
193:                    if (queries == null) {
194:                        queries = new ArrayList();
195:                        queries.add(q);
196:                    }
197:                    q = AndQuery();
198:                    queries.add(q);
199:                }
200:                {
201:                    if (true)
202:                        return (queries == null) ? q : getOrQuery(queries,
203:                                true /* infix */, oprt);
204:                }
205:                throw new Error("Missing return statement in function");
206:            }
207:
208:            final public SrndQuery AndQuery() throws ParseException {
209:                SrndQuery q;
210:                ArrayList queries = null;
211:                Token oprt = null;
212:                q = NotQuery();
213:                label_3: while (true) {
214:                    switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
215:                    case AND:
216:                        ;
217:                        break;
218:                    default:
219:                        jj_la1[1] = jj_gen;
220:                        break label_3;
221:                    }
222:                    oprt = jj_consume_token(AND);
223:                    /* keep only last used operator */
224:                    if (queries == null) {
225:                        queries = new ArrayList();
226:                        queries.add(q);
227:                    }
228:                    q = NotQuery();
229:                    queries.add(q);
230:                }
231:                {
232:                    if (true)
233:                        return (queries == null) ? q : getAndQuery(queries,
234:                                true /* infix */, oprt);
235:                }
236:                throw new Error("Missing return statement in function");
237:            }
238:
239:            final public SrndQuery NotQuery() throws ParseException {
240:                SrndQuery q;
241:                ArrayList queries = null;
242:                Token oprt = null;
243:                q = NQuery();
244:                label_4: while (true) {
245:                    switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
246:                    case NOT:
247:                        ;
248:                        break;
249:                    default:
250:                        jj_la1[2] = jj_gen;
251:                        break label_4;
252:                    }
253:                    oprt = jj_consume_token(NOT);
254:                    /* keep only last used operator */
255:                    if (queries == null) {
256:                        queries = new ArrayList();
257:                        queries.add(q);
258:                    }
259:                    q = NQuery();
260:                    queries.add(q);
261:                }
262:                {
263:                    if (true)
264:                        return (queries == null) ? q : getNotQuery(queries,
265:                                oprt);
266:                }
267:                throw new Error("Missing return statement in function");
268:            }
269:
270:            final public SrndQuery NQuery() throws ParseException {
271:                SrndQuery q;
272:                ArrayList queries;
273:                Token dt;
274:                q = WQuery();
275:                label_5: while (true) {
276:                    switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
277:                    case N:
278:                        ;
279:                        break;
280:                    default:
281:                        jj_la1[3] = jj_gen;
282:                        break label_5;
283:                    }
284:                    dt = jj_consume_token(N);
285:                    queries = new ArrayList();
286:                    queries.add(q); /* left associative */
287:
288:                    q = WQuery();
289:                    queries.add(q);
290:                    q = getDistanceQuery(queries, true /* infix */, dt, false /* not ordered */);
291:                }
292:                {
293:                    if (true)
294:                        return q;
295:                }
296:                throw new Error("Missing return statement in function");
297:            }
298:
299:            final public SrndQuery WQuery() throws ParseException {
300:                SrndQuery q;
301:                ArrayList queries;
302:                Token wt;
303:                q = PrimaryQuery();
304:                label_6: while (true) {
305:                    switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
306:                    case W:
307:                        ;
308:                        break;
309:                    default:
310:                        jj_la1[4] = jj_gen;
311:                        break label_6;
312:                    }
313:                    wt = jj_consume_token(W);
314:                    queries = new ArrayList();
315:                    queries.add(q); /* left associative */
316:
317:                    q = PrimaryQuery();
318:                    queries.add(q);
319:                    q = getDistanceQuery(queries, true /* infix */, wt, true /* ordered */);
320:                }
321:                {
322:                    if (true)
323:                        return q;
324:                }
325:                throw new Error("Missing return statement in function");
326:            }
327:
328:            final public SrndQuery PrimaryQuery() throws ParseException {
329:                /* bracketed weighted query or weighted term */
330:                SrndQuery q;
331:                switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
332:                case LPAREN:
333:                    jj_consume_token(LPAREN);
334:                    q = FieldsQuery();
335:                    jj_consume_token(RPAREN);
336:                    break;
337:                case OR:
338:                case AND:
339:                case W:
340:                case N:
341:                    q = PrefixOperatorQuery();
342:                    break;
343:                case TRUNCQUOTED:
344:                case QUOTED:
345:                case SUFFIXTERM:
346:                case TRUNCTERM:
347:                case TERM:
348:                    q = SimpleTerm();
349:                    break;
350:                default:
351:                    jj_la1[5] = jj_gen;
352:                    jj_consume_token(-1);
353:                    throw new ParseException();
354:                }
355:                OptionalWeights(q);
356:                {
357:                    if (true)
358:                        return q;
359:                }
360:                throw new Error("Missing return statement in function");
361:            }
362:
363:            final public SrndQuery PrefixOperatorQuery() throws ParseException {
364:                Token oprt;
365:                List queries;
366:                switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
367:                case OR:
368:                    oprt = jj_consume_token(OR);
369:                    /* prefix OR */
370:                    queries = FieldsQueryList();
371:                    {
372:                        if (true)
373:                            return getOrQuery(queries, false /* not infix */,
374:                                    oprt);
375:                    }
376:                    break;
377:                case AND:
378:                    oprt = jj_consume_token(AND);
379:                    /* prefix AND */
380:                    queries = FieldsQueryList();
381:                    {
382:                        if (true)
383:                            return getAndQuery(queries, false /* not infix */,
384:                                    oprt);
385:                    }
386:                    break;
387:                case N:
388:                    oprt = jj_consume_token(N);
389:                    /* prefix N */
390:                    queries = FieldsQueryList();
391:                    {
392:                        if (true)
393:                            return getDistanceQuery(queries,
394:                                    false /* not infix */, oprt, false /* not ordered */);
395:                    }
396:                    break;
397:                case W:
398:                    oprt = jj_consume_token(W);
399:                    /* prefix W */
400:                    queries = FieldsQueryList();
401:                    {
402:                        if (true)
403:                            return getDistanceQuery(queries,
404:                                    false /* not infix */, oprt, true /* ordered */);
405:                    }
406:                    break;
407:                default:
408:                    jj_la1[6] = jj_gen;
409:                    jj_consume_token(-1);
410:                    throw new ParseException();
411:                }
412:                throw new Error("Missing return statement in function");
413:            }
414:
415:            final public List FieldsQueryList() throws ParseException {
416:                SrndQuery q;
417:                ArrayList queries = new ArrayList();
418:                jj_consume_token(LPAREN);
419:                q = FieldsQuery();
420:                queries.add(q);
421:                label_7: while (true) {
422:                    jj_consume_token(COMMA);
423:                    q = FieldsQuery();
424:                    queries.add(q);
425:                    switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
426:                    case COMMA:
427:                        ;
428:                        break;
429:                    default:
430:                        jj_la1[7] = jj_gen;
431:                        break label_7;
432:                    }
433:                }
434:                jj_consume_token(RPAREN);
435:                {
436:                    if (true)
437:                        return queries;
438:                }
439:                throw new Error("Missing return statement in function");
440:            }
441:
442:            final public SrndQuery SimpleTerm() throws ParseException {
443:                Token term;
444:                switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
445:                case TERM:
446:                    term = jj_consume_token(TERM);
447:                    {
448:                        if (true)
449:                            return getTermQuery(term.image, false /* not quoted */);
450:                    }
451:                    break;
452:                case QUOTED:
453:                    term = jj_consume_token(QUOTED);
454:                    {
455:                        if (true)
456:                            return getTermQuery(term.image.substring(1,
457:                                    term.image.length() - 1), true /* quoted */);
458:                    }
459:                    break;
460:                case SUFFIXTERM:
461:                    term = jj_consume_token(SUFFIXTERM);
462:                    /* ending in * */
463:                    if (!allowedSuffix(term.image)) {
464:                        {
465:                            if (true)
466:                                throw new ParseException(truncationErrorMessage
467:                                        + term.image);
468:                        }
469:                    }
470:                    {
471:                        if (true)
472:                            return getPrefixQuery(term.image.substring(0,
473:                                    term.image.length() - 1), false /* not quoted */);
474:                    }
475:                    break;
476:                case TRUNCTERM:
477:                    term = jj_consume_token(TRUNCTERM);
478:                    /* with at least one * or ? */
479:                    if (!allowedTruncation(term.image)) {
480:                        {
481:                            if (true)
482:                                throw new ParseException(truncationErrorMessage
483:                                        + term.image);
484:                        }
485:                    }
486:                    {
487:                        if (true)
488:                            return getTruncQuery(term.image);
489:                    }
490:                    break;
491:                case TRUNCQUOTED:
492:                    term = jj_consume_token(TRUNCQUOTED);
493:                    /* eg. "9b-b,m"* */
494:                    if ((term.image.length() - 3) < minimumPrefixLength) {
495:                        {
496:                            if (true)
497:                                throw new ParseException(truncationErrorMessage
498:                                        + term.image);
499:                        }
500:                    }
501:                    {
502:                        if (true)
503:                            return getPrefixQuery(term.image.substring(1,
504:                                    term.image.length() - 2), true /* quoted */);
505:                    }
506:                    break;
507:                default:
508:                    jj_la1[8] = jj_gen;
509:                    jj_consume_token(-1);
510:                    throw new ParseException();
511:                }
512:                throw new Error("Missing return statement in function");
513:            }
514:
515:            final public void OptionalWeights(SrndQuery q)
516:                    throws ParseException {
517:                Token weight = null;
518:                label_8: while (true) {
519:                    switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
520:                    case CARAT:
521:                        ;
522:                        break;
523:                    default:
524:                        jj_la1[9] = jj_gen;
525:                        break label_8;
526:                    }
527:                    jj_consume_token(CARAT);
528:                    weight = jj_consume_token(NUMBER);
529:                    float f;
530:                    try {
531:                        f = Float.valueOf(weight.image).floatValue();
532:                    } catch (Exception floatExc) {
533:                        {
534:                            if (true)
535:                                throw new ParseException(boostErrorMessage
536:                                        + weight.image + " (" + floatExc + ")");
537:                        }
538:                    }
539:                    if (f <= 0.0) {
540:                        {
541:                            if (true)
542:                                throw new ParseException(boostErrorMessage
543:                                        + weight.image);
544:                        }
545:                    }
546:                    q.setWeight(f * q.getWeight()); /* left associative, fwiw */
547:
548:                }
549:            }
550:
551:            final private boolean jj_2_1(int xla) {
552:                jj_la = xla;
553:                jj_lastpos = jj_scanpos = token;
554:                try {
555:                    return !jj_3_1();
556:                } catch (LookaheadSuccess ls) {
557:                    return true;
558:                } finally {
559:                    jj_save(0, xla);
560:                }
561:            }
562:
563:            final private boolean jj_3_1() {
564:                if (jj_scan_token(TERM))
565:                    return true;
566:                if (jj_scan_token(COLON))
567:                    return true;
568:                return false;
569:            }
570:
571:            public QueryParserTokenManager token_source;
572:            public Token token, jj_nt;
573:            private int jj_ntk;
574:            private Token jj_scanpos, jj_lastpos;
575:            private int jj_la;
576:            public boolean lookingAhead = false;
577:            private boolean jj_semLA;
578:            private int jj_gen;
579:            final private int[] jj_la1 = new int[10];
580:            static private int[] jj_la1_0;
581:            static {
582:                jj_la1_0();
583:            }
584:
585:            private static void jj_la1_0() {
586:                jj_la1_0 = new int[] { 0x100, 0x200, 0x400, 0x1000, 0x800,
587:                        0x7c3b00, 0x1b00, 0x8000, 0x7c0000, 0x20000, };
588:            }
589:
590:            final private JJCalls[] jj_2_rtns = new JJCalls[1];
591:            private boolean jj_rescan = false;
592:            private int jj_gc = 0;
593:
594:            public QueryParser(CharStream stream) {
595:                token_source = new QueryParserTokenManager(stream);
596:                token = new Token();
597:                jj_ntk = -1;
598:                jj_gen = 0;
599:                for (int i = 0; i < 10; i++)
600:                    jj_la1[i] = -1;
601:                for (int i = 0; i < jj_2_rtns.length; i++)
602:                    jj_2_rtns[i] = new JJCalls();
603:            }
604:
605:            public void ReInit(CharStream stream) {
606:                token_source.ReInit(stream);
607:                token = new Token();
608:                jj_ntk = -1;
609:                jj_gen = 0;
610:                for (int i = 0; i < 10; i++)
611:                    jj_la1[i] = -1;
612:                for (int i = 0; i < jj_2_rtns.length; i++)
613:                    jj_2_rtns[i] = new JJCalls();
614:            }
615:
616:            public QueryParser(QueryParserTokenManager tm) {
617:                token_source = tm;
618:                token = new Token();
619:                jj_ntk = -1;
620:                jj_gen = 0;
621:                for (int i = 0; i < 10; i++)
622:                    jj_la1[i] = -1;
623:                for (int i = 0; i < jj_2_rtns.length; i++)
624:                    jj_2_rtns[i] = new JJCalls();
625:            }
626:
627:            public void ReInit(QueryParserTokenManager tm) {
628:                token_source = tm;
629:                token = new Token();
630:                jj_ntk = -1;
631:                jj_gen = 0;
632:                for (int i = 0; i < 10; i++)
633:                    jj_la1[i] = -1;
634:                for (int i = 0; i < jj_2_rtns.length; i++)
635:                    jj_2_rtns[i] = new JJCalls();
636:            }
637:
638:            final private Token jj_consume_token(int kind)
639:                    throws ParseException {
640:                Token oldToken;
641:                if ((oldToken = token).next != null)
642:                    token = token.next;
643:                else
644:                    token = token.next = token_source.getNextToken();
645:                jj_ntk = -1;
646:                if (token.kind == kind) {
647:                    jj_gen++;
648:                    if (++jj_gc > 100) {
649:                        jj_gc = 0;
650:                        for (int i = 0; i < jj_2_rtns.length; i++) {
651:                            JJCalls c = jj_2_rtns[i];
652:                            while (c != null) {
653:                                if (c.gen < jj_gen)
654:                                    c.first = null;
655:                                c = c.next;
656:                            }
657:                        }
658:                    }
659:                    return token;
660:                }
661:                token = oldToken;
662:                jj_kind = kind;
663:                throw generateParseException();
664:            }
665:
666:            static private final class LookaheadSuccess extends java.lang.Error {
667:            }
668:
669:            final private LookaheadSuccess jj_ls = new LookaheadSuccess();
670:
671:            final private boolean jj_scan_token(int kind) {
672:                if (jj_scanpos == jj_lastpos) {
673:                    jj_la--;
674:                    if (jj_scanpos.next == null) {
675:                        jj_lastpos = jj_scanpos = jj_scanpos.next = token_source
676:                                .getNextToken();
677:                    } else {
678:                        jj_lastpos = jj_scanpos = jj_scanpos.next;
679:                    }
680:                } else {
681:                    jj_scanpos = jj_scanpos.next;
682:                }
683:                if (jj_rescan) {
684:                    int i = 0;
685:                    Token tok = token;
686:                    while (tok != null && tok != jj_scanpos) {
687:                        i++;
688:                        tok = tok.next;
689:                    }
690:                    if (tok != null)
691:                        jj_add_error_token(kind, i);
692:                }
693:                if (jj_scanpos.kind != kind)
694:                    return true;
695:                if (jj_la == 0 && jj_scanpos == jj_lastpos)
696:                    throw jj_ls;
697:                return false;
698:            }
699:
700:            final public Token getNextToken() {
701:                if (token.next != null)
702:                    token = token.next;
703:                else
704:                    token = token.next = token_source.getNextToken();
705:                jj_ntk = -1;
706:                jj_gen++;
707:                return token;
708:            }
709:
710:            final public Token getToken(int index) {
711:                Token t = lookingAhead ? jj_scanpos : token;
712:                for (int i = 0; i < index; i++) {
713:                    if (t.next != null)
714:                        t = t.next;
715:                    else
716:                        t = t.next = token_source.getNextToken();
717:                }
718:                return t;
719:            }
720:
721:            final private int jj_ntk() {
722:                if ((jj_nt = token.next) == null)
723:                    return (jj_ntk = (token.next = token_source.getNextToken()).kind);
724:                else
725:                    return (jj_ntk = jj_nt.kind);
726:            }
727:
728:            private java.util.Vector jj_expentries = new java.util.Vector();
729:            private int[] jj_expentry;
730:            private int jj_kind = -1;
731:            private int[] jj_lasttokens = new int[100];
732:            private int jj_endpos;
733:
734:            private void jj_add_error_token(int kind, int pos) {
735:                if (pos >= 100)
736:                    return;
737:                if (pos == jj_endpos + 1) {
738:                    jj_lasttokens[jj_endpos++] = kind;
739:                } else if (jj_endpos != 0) {
740:                    jj_expentry = new int[jj_endpos];
741:                    for (int i = 0; i < jj_endpos; i++) {
742:                        jj_expentry[i] = jj_lasttokens[i];
743:                    }
744:                    boolean exists = false;
745:                    for (java.util.Enumeration e = jj_expentries.elements(); e
746:                            .hasMoreElements();) {
747:                        int[] oldentry = (int[]) (e.nextElement());
748:                        if (oldentry.length == jj_expentry.length) {
749:                            exists = true;
750:                            for (int i = 0; i < jj_expentry.length; i++) {
751:                                if (oldentry[i] != jj_expentry[i]) {
752:                                    exists = false;
753:                                    break;
754:                                }
755:                            }
756:                            if (exists)
757:                                break;
758:                        }
759:                    }
760:                    if (!exists)
761:                        jj_expentries.addElement(jj_expentry);
762:                    if (pos != 0)
763:                        jj_lasttokens[(jj_endpos = pos) - 1] = kind;
764:                }
765:            }
766:
767:            public ParseException generateParseException() {
768:                jj_expentries.removeAllElements();
769:                boolean[] la1tokens = new boolean[24];
770:                for (int i = 0; i < 24; i++) {
771:                    la1tokens[i] = false;
772:                }
773:                if (jj_kind >= 0) {
774:                    la1tokens[jj_kind] = true;
775:                    jj_kind = -1;
776:                }
777:                for (int i = 0; i < 10; i++) {
778:                    if (jj_la1[i] == jj_gen) {
779:                        for (int j = 0; j < 32; j++) {
780:                            if ((jj_la1_0[i] & (1 << j)) != 0) {
781:                                la1tokens[j] = true;
782:                            }
783:                        }
784:                    }
785:                }
786:                for (int i = 0; i < 24; i++) {
787:                    if (la1tokens[i]) {
788:                        jj_expentry = new int[1];
789:                        jj_expentry[0] = i;
790:                        jj_expentries.addElement(jj_expentry);
791:                    }
792:                }
793:                jj_endpos = 0;
794:                jj_rescan_token();
795:                jj_add_error_token(0, 0);
796:                int[][] exptokseq = new int[jj_expentries.size()][];
797:                for (int i = 0; i < jj_expentries.size(); i++) {
798:                    exptokseq[i] = (int[]) jj_expentries.elementAt(i);
799:                }
800:                return new ParseException(token, exptokseq, tokenImage);
801:            }
802:
803:            final public void enable_tracing() {
804:            }
805:
806:            final public void disable_tracing() {
807:            }
808:
809:            final private void jj_rescan_token() {
810:                jj_rescan = true;
811:                for (int i = 0; i < 1; i++) {
812:                    JJCalls p = jj_2_rtns[i];
813:                    do {
814:                        if (p.gen > jj_gen) {
815:                            jj_la = p.arg;
816:                            jj_lastpos = jj_scanpos = p.first;
817:                            switch (i) {
818:                            case 0:
819:                                jj_3_1();
820:                                break;
821:                            }
822:                        }
823:                        p = p.next;
824:                    } while (p != null);
825:                }
826:                jj_rescan = false;
827:            }
828:
829:            final private void jj_save(int index, int xla) {
830:                JJCalls p = jj_2_rtns[index];
831:                while (p.gen > jj_gen) {
832:                    if (p.next == null) {
833:                        p = p.next = new JJCalls();
834:                        break;
835:                    }
836:                    p = p.next;
837:                }
838:                p.gen = jj_gen + xla - jj_la;
839:                p.first = token;
840:                p.arg = xla;
841:            }
842:
843:            static final class JJCalls {
844:                int gen;
845:                Token first;
846:                int arg;
847:                JJCalls next;
848:            }
849:
850:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.