001    /* Generated By:JavaCC: Do not edit this line. ConfParser.java */
002    package org.dllearner.parser;
003    
004    import java.util.HashMap;
005    import java.util.List;
006    import java.util.LinkedList;
007    import java.util.Map;
008    import java.util.Set;
009    import java.util.HashSet;
010    import java.util.SortedSet;
011    import java.util.TreeSet;
012    
013    import java.io.File;
014    import java.io.FileInputStream;
015    import java.io.FileNotFoundException;
016    import java.io.IOException;
017    
018    import org.dllearner.Info;
019    
020    import org.dllearner.cli.*;
021    import org.dllearner.utilities.datastructures.*;
022    
023    @SuppressWarnings("all")
024    public class ConfParser implements ConfParserConstants {
025    
026            // examples
027            private SortedSet<String> positiveExamples = new TreeSet<String>();
028            private SortedSet<String> negativeExamples = new TreeSet<String>();
029    
030            // conf file options
031            private List<ConfFileOption> confOptions = new LinkedList<ConfFileOption>();
032            private Map<String,ConfFileOption> confOptionsByName = new HashMap<String,ConfFileOption>();
033            private Map<String,List<ConfFileOption>> confOptionsByPrefix = new HashMap<String,List<ConfFileOption>>();
034    
035            // Funktionsaufrufe (die gleiche Funktion darf mehrmals mit unterschiedlichen
036            // Argumenten aufgerufen werden)
037            // private static Map<String,Set<String>> functionCallsAlt = new TreeMap<String,Set<String>>();
038            // jeder Funktionsaufruf hat eine Liste von n Argumenten; alle Funktionsaufrufe
039            // werden in einer Liste gespeichert
040            // private List<List<String>> functionCalls = new LinkedList<List<String>>();
041            // => irgendwie Funktionsname + Argumente speichern
042            // => d.h. man bräuchte für jede Funktion so eine Liste oder das erste Element
043            // der Liste ist der Funktionsname <= ist noch die praktikabelste Variante
044    
045            private Map<String,List<List<String>>> functionCalls = new HashMap<String,List<List<String>>>();
046    
047            private void addFunctionCall(String name, List<String> arguments) {
048                    if(functionCalls.containsKey(name))
049                            functionCalls.get(name).add(arguments);
050                    else {
051                            List<List<String>> calls = new LinkedList<List<String>>();
052                            calls.add(arguments);
053                            functionCalls.put(name,calls);
054                    }
055            }
056    
057            private void addConfOption(ConfFileOption confOption) {
058                    confOptions.add(confOption);
059                    confOptionsByName.put(confOption.getFullName(), confOption);
060                    String prefix = confOption.getOption();
061                    if(confOptionsByPrefix.containsKey(prefix))
062                            confOptionsByPrefix.get(prefix).add(confOption);
063                    else {
064                            LinkedList<ConfFileOption> optionList = new LinkedList<ConfFileOption>();
065                            optionList.add(confOption);
066                            confOptionsByPrefix.put(prefix,optionList);
067                    }
068            }
069    
070            public SortedSet<String> getPositiveExamples() {
071                    return positiveExamples;
072            }
073    
074            public SortedSet<String> getNegativeExamples() {
075                    return negativeExamples;
076            }
077    
078            public List<ConfFileOption> getConfOptions() {
079                    return confOptions;
080            }
081    
082            public Map<String,ConfFileOption> getConfOptionsByName() {
083                    return confOptionsByName;
084            }
085    
086            public ConfFileOption getConfOptionsByName(String name) {
087                    return confOptionsByName.get(name);
088            }
089    
090            public Map<String,List<ConfFileOption>> getConfOptionsByPrefix() {
091                    return confOptionsByPrefix;
092            }
093    
094            public List<ConfFileOption> getConfOptionsByPrefix(String prefix) {
095                    return confOptionsByPrefix.get(prefix);
096            }
097    
098            public Map<String,List<List<String>>> getFunctionCalls() {
099                    return functionCalls;
100            }
101    
102            /*
103            private static void addFunctionCall(String functionName, String argument) {
104                    if(functionCalls.containsKey(functionName)) {
105                            functionCalls.get(functionName).add(argument);
106                    } else {
107                            Set<String> newFunction = new TreeSet<String>();
108                            newFunction.add(argument);
109                            functionCalls.put(functionName,newFunction);
110                    }               
111            }
112            */
113    
114    
115            /*
116            public static SimpleNode parseString(String str) throws ParseException {
117                    StringReader sr = new StringReader(str);
118                    DLLearner learner = new DLLearner(sr);
119                    SimpleNode n = learner.Start();
120                    return n;
121            }
122            */
123    
124            public static ConfParser parseFile(File filename) throws FileNotFoundException, ParseException {
125                    ConfParser learner = null;
126    //              try {
127                            learner = new ConfParser(new FileInputStream(filename));
128                            learner.Start();
129    //              } catch(FileNotFoundException e) {
130    //                      e.printStackTrace();
131    //              } catch(ParseException e) {
132    //                      e.printStackTrace();
133    //              }
134                    return learner;
135            }
136    
137      public static void main(String args[]) {
138    
139        if(args.length==0) {
140            System.out.println("Please specify an input file.");
141            System.exit(0);
142        }
143    
144        System.out.println("Starting DL-Learner (Build " + Info.build + ")");
145            // System.out.println(args);
146    
147            // System.out.println(args[0]);
148            // System.out.println(args[1]);
149            // System.out.println(args.length);
150    
151        File f = new File(args[args.length-1]);
152    //    String baseDir = "";
153    
154            System.out.print("Parsing " + f.getName() + " ... ");
155        long parseStartTime = System.currentTimeMillis();
156    
157        // SimpleNode n = null;
158        ConfParser learner = null;
159        try {
160            learner = new ConfParser(new FileInputStream(args[args.length-1]));
161    //        baseDir = f.getParentFile().getPath();        
162        } catch(IOException e) {
163            System.err.println(e);
164            System.exit(0);
165        }
166        try {
167          learner.Start();
168          // n.dump("");
169          // System.out.println("Thank you.");
170        } catch (Exception e) {
171          System.out.println("\nParse exception occurred. Please follow the advise given below.");
172          System.out.println(e.getMessage());
173          e.printStackTrace();
174          System.exit(0);
175        }
176    
177        long parseDuration = System.currentTimeMillis() - parseStartTime;
178        System.out.println("OK (" + parseDuration + " ms)");
179    
180    //    boolean queryMode = false;
181        // solution test mode wird nicht unbedingt gebraucht, da man die covers
182        // gleich standardmäßig beim query mit anzeigen kann
183        // boolean solutionTestMode = false;
184    
185    //    if(args.length>1 && args[0].equals("-q"))
186    //      queryMode = true;
187    
188        //if(args.length>1 && args[0].equals("-qt")) {
189        //  queryMode = true;
190        //  solutionTestMode = true;
191        //}
192    
193        // new Main(n, baseDir, queryMode);
194        // Parser erstmal Standalone testen
195        // n.dump("");
196    
197        // neuer Aufruf des Hauptprogramms
198        // TODO: remove (in the future, the parser will be called from whatever method
199        // needs it, instead of starting the learning process itself)
200        // new Main(kb,positiveExamples,negativeExamples,confOptions,functionCalls,baseDir,queryMode);
201      }
202    
203      final public void Start() throws ParseException {
204            ConfFileOption confOption;
205        label_1:
206        while (true) {
207          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
208          case POS_EX:
209          case NEG_EX:
210          case ID:
211            ;
212            break;
213          default:
214            jj_la1[0] = jj_gen;
215            break label_1;
216          }
217          if (jj_2_1(2147483647)) {
218            confOption = ConfOption();
219                        addConfOption(confOption);
220          } else if (jj_2_2(2147483647)) {
221            FunctionCall();
222          } else if (jj_2_3(2147483647)) {
223            PosExample();
224          } else if (jj_2_4(2147483647)) {
225            NegExample();
226          } else {
227            jj_consume_token(-1);
228            throw new ParseException();
229          }
230        }
231        jj_consume_token(0);
232      }
233    
234      final public ConfFileOption ConfOption() throws ParseException {
235            boolean containsSubOption=false, isNumeric=false, isDouble=false, isSet=false, isList=false;
236            String option="", subOption="", value="", tmp="", tmp2="";
237            int number = 0;
238            double numberDouble = 0;
239            ConfFileOption confOption;
240            Set<String> values = new HashSet<String>();
241            List<StringTuple> tuples = new LinkedList<StringTuple>();
242        option = Id();
243        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
244        case COMMAND_END:
245          jj_consume_token(COMMAND_END);
246          subOption = Id();
247                                        containsSubOption=true;
248          break;
249        default:
250          jj_la1[1] = jj_gen;
251          ;
252        }
253        jj_consume_token(25);
254        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
255        case ID:
256          value = Id();
257          break;
258        case STRING:
259          value = String();
260          break;
261        case NUMBER:
262          number = Integer();
263                                 isNumeric=true;
264          break;
265        case DOUBLE:
266          numberDouble = Double();
267                                      isNumeric=true; isDouble=true;
268          break;
269        default:
270          jj_la1[8] = jj_gen;
271          if (jj_2_7(2147483647)) {
272            jj_consume_token(26);
273            jj_consume_token(31);
274                                           isSet=true;
275          } else {
276            switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
277            case 26:
278              jj_consume_token(26);
279              label_2:
280              while (true) {
281                if (jj_2_5(2)) {
282                  ;
283                } else {
284                  break label_2;
285                }
286                switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
287                case STRING:
288                  tmp = String();
289                  break;
290                case ID:
291                  tmp = Id();
292                  break;
293                default:
294                  jj_la1[2] = jj_gen;
295                  jj_consume_token(-1);
296                  throw new ParseException();
297                }
298                                                               values.add(tmp);
299                jj_consume_token(29);
300              }
301              switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
302              case STRING:
303                tmp = String();
304                break;
305              case ID:
306                tmp = Id();
307                break;
308              default:
309                jj_la1[3] = jj_gen;
310                jj_consume_token(-1);
311                throw new ParseException();
312              }
313                                          values.add(tmp);
314              jj_consume_token(31);
315                                                                 isSet=true;
316              break;
317            default:
318              jj_la1[9] = jj_gen;
319              if (jj_2_8(2147483647)) {
320                jj_consume_token(27);
321                jj_consume_token(32);
322                                           isList=true;
323              } else {
324                switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
325                case 27:
326                  jj_consume_token(27);
327                  label_3:
328                  while (true) {
329                    if (jj_2_6(6)) {
330                      ;
331                    } else {
332                      break label_3;
333                    }
334                    jj_consume_token(28);
335                    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
336                    case STRING:
337                      tmp = String();
338                      break;
339                    case ID:
340                      tmp = Id();
341                      break;
342                    default:
343                      jj_la1[4] = jj_gen;
344                      jj_consume_token(-1);
345                      throw new ParseException();
346                    }
347                    jj_consume_token(29);
348                    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
349                    case STRING:
350                      tmp2 = String();
351                      break;
352                    case ID:
353                      tmp2 = Id();
354                      break;
355                    default:
356                      jj_la1[5] = jj_gen;
357                      jj_consume_token(-1);
358                      throw new ParseException();
359                    }
360                    jj_consume_token(30);
361                tuples.add(new StringTuple(tmp,tmp2));
362                    jj_consume_token(29);
363                  }
364                  jj_consume_token(28);
365                  switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
366                  case STRING:
367                    tmp = String();
368                    break;
369                  case ID:
370                    tmp = Id();
371                    break;
372                  default:
373                    jj_la1[6] = jj_gen;
374                    jj_consume_token(-1);
375                    throw new ParseException();
376                  }
377                  jj_consume_token(29);
378                  switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
379                  case STRING:
380                    tmp2 = String();
381                    break;
382                  case ID:
383                    tmp2 = Id();
384                    break;
385                  default:
386                    jj_la1[7] = jj_gen;
387                    jj_consume_token(-1);
388                    throw new ParseException();
389                  }
390                  jj_consume_token(30);
391                tuples.add(new StringTuple(tmp,tmp2));
392                  jj_consume_token(32);
393                    isList=true;
394                  break;
395                default:
396                  jj_la1[10] = jj_gen;
397                  jj_consume_token(-1);
398                  throw new ParseException();
399                }
400              }
401            }
402          }
403        }
404        jj_consume_token(CONF_END);
405            if(containsSubOption) {
406                    if(isNumeric)
407                            if(isDouble)
408                                    confOption = new ConfFileOption(option,subOption,numberDouble);
409                            else
410                                    confOption = new ConfFileOption(option,subOption,number);
411                    else
412                            if(isSet)
413                                    confOption = new ConfFileOption(option,subOption,values);
414                            else if(isList)
415                                    confOption = new ConfFileOption(option,subOption,tuples);
416                            else
417                                    confOption = new ConfFileOption(option,subOption,value);
418            } else {
419                    if(isNumeric)
420                            if(isDouble)
421                                    confOption = new ConfFileOption(option,numberDouble);
422                            else
423                                    confOption = new ConfFileOption(option,number);
424                    else
425                            if(isSet)
426                                    confOption = new ConfFileOption(option,values);
427                            else if(isList)
428                                    confOption = new ConfFileOption(option,tuples);
429                            else
430                                    confOption = new ConfFileOption(option,value);
431            }
432            {if (true) return confOption;}
433            // confOptions.add(confOption);
434    
435        throw new Error("Missing return statement in function");
436      }
437    
438      final public void FunctionCall() throws ParseException {
439            String s, s1, s2;
440            List<String> list = new LinkedList<String>();
441        s1 = Id();
442        jj_consume_token(28);
443        s2 = String();
444                                      list.add(s2);
445        label_4:
446        while (true) {
447          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
448          case 29:
449            ;
450            break;
451          default:
452            jj_la1[11] = jj_gen;
453            break label_4;
454          }
455          jj_consume_token(29);
456          s = String();
457                              list.add(s);
458        }
459        jj_consume_token(30);
460        jj_consume_token(CONF_END);
461              addFunctionCall(s1,list);
462      }
463    
464      final public void PosExample() throws ParseException {
465                          String i;
466        jj_consume_token(POS_EX);
467        i = Individual();
468              positiveExamples.add(i);
469      }
470    
471      final public void NegExample() throws ParseException {
472                          String i;
473        jj_consume_token(NEG_EX);
474        i = Individual();
475              negativeExamples.add(i);
476      }
477    
478      final public String Individual() throws ParseException {
479            String name;
480        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
481        case ID:
482          name = Id();
483          break;
484        case STRING:
485          name = String();
486          break;
487        default:
488          jj_la1[12] = jj_gen;
489          jj_consume_token(-1);
490          throw new ParseException();
491        }
492                    {if (true) return KBParser.getInternalURI(name);}
493        throw new Error("Missing return statement in function");
494      }
495    
496      final public String Id() throws ParseException {
497      Token t;
498        t = jj_consume_token(ID);
499        {if (true) return t.image;}
500        throw new Error("Missing return statement in function");
501      }
502    
503      final public double Double() throws ParseException {
504      Token t;
505        t = jj_consume_token(DOUBLE);
506        {if (true) return new Double(t.image);}
507        throw new Error("Missing return statement in function");
508      }
509    
510      final public int Integer() throws ParseException {
511      Token t;
512        t = jj_consume_token(NUMBER);
513        {if (true) return new Integer(t.image);}
514        throw new Error("Missing return statement in function");
515      }
516    
517      final public String String() throws ParseException {
518      Token t;
519      String s;
520        t = jj_consume_token(STRING);
521        // enclosing "" are removed
522        s = t.image;
523        s = s.substring(1, s.length() - 1);
524        {if (true) return s;}
525        throw new Error("Missing return statement in function");
526      }
527    
528      private boolean jj_2_1(int xla) {
529        jj_la = xla; jj_lastpos = jj_scanpos = token;
530        try { return !jj_3_1(); }
531        catch(LookaheadSuccess ls) { return true; }
532        finally { jj_save(0, xla); }
533      }
534    
535      private boolean jj_2_2(int xla) {
536        jj_la = xla; jj_lastpos = jj_scanpos = token;
537        try { return !jj_3_2(); }
538        catch(LookaheadSuccess ls) { return true; }
539        finally { jj_save(1, xla); }
540      }
541    
542      private boolean jj_2_3(int xla) {
543        jj_la = xla; jj_lastpos = jj_scanpos = token;
544        try { return !jj_3_3(); }
545        catch(LookaheadSuccess ls) { return true; }
546        finally { jj_save(2, xla); }
547      }
548    
549      private boolean jj_2_4(int xla) {
550        jj_la = xla; jj_lastpos = jj_scanpos = token;
551        try { return !jj_3_4(); }
552        catch(LookaheadSuccess ls) { return true; }
553        finally { jj_save(3, xla); }
554      }
555    
556      private boolean jj_2_5(int xla) {
557        jj_la = xla; jj_lastpos = jj_scanpos = token;
558        try { return !jj_3_5(); }
559        catch(LookaheadSuccess ls) { return true; }
560        finally { jj_save(4, xla); }
561      }
562    
563      private boolean jj_2_6(int xla) {
564        jj_la = xla; jj_lastpos = jj_scanpos = token;
565        try { return !jj_3_6(); }
566        catch(LookaheadSuccess ls) { return true; }
567        finally { jj_save(5, xla); }
568      }
569    
570      private boolean jj_2_7(int xla) {
571        jj_la = xla; jj_lastpos = jj_scanpos = token;
572        try { return !jj_3_7(); }
573        catch(LookaheadSuccess ls) { return true; }
574        finally { jj_save(6, xla); }
575      }
576    
577      private boolean jj_2_8(int xla) {
578        jj_la = xla; jj_lastpos = jj_scanpos = token;
579        try { return !jj_3_8(); }
580        catch(LookaheadSuccess ls) { return true; }
581        finally { jj_save(7, xla); }
582      }
583    
584      private boolean jj_3R_11() {
585        if (jj_scan_token(STRING)) return true;
586        return false;
587      }
588    
589      private boolean jj_3_8() {
590        if (jj_scan_token(27)) return true;
591        if (jj_scan_token(32)) return true;
592        return false;
593      }
594    
595      private boolean jj_3R_7() {
596        if (jj_3R_5()) return true;
597        return false;
598      }
599    
600      private boolean jj_3_7() {
601        if (jj_scan_token(26)) return true;
602        if (jj_scan_token(31)) return true;
603        return false;
604      }
605    
606      private boolean jj_3R_12() {
607        if (jj_scan_token(29)) return true;
608        if (jj_3R_11()) return true;
609        return false;
610      }
611    
612      private boolean jj_3R_17() {
613        if (jj_3R_11()) return true;
614        return false;
615      }
616    
617      private boolean jj_3_6() {
618        if (jj_scan_token(28)) return true;
619        Token xsp;
620        xsp = jj_scanpos;
621        if (jj_3R_15()) {
622        jj_scanpos = xsp;
623        if (jj_3R_16()) return true;
624        }
625        if (jj_scan_token(29)) return true;
626        xsp = jj_scanpos;
627        if (jj_3R_17()) {
628        jj_scanpos = xsp;
629        if (jj_3R_18()) return true;
630        }
631        if (jj_scan_token(30)) return true;
632        if (jj_scan_token(29)) return true;
633        return false;
634      }
635    
636      private boolean jj_3_5() {
637        Token xsp;
638        xsp = jj_scanpos;
639        if (jj_3R_13()) {
640        jj_scanpos = xsp;
641        if (jj_3R_14()) return true;
642        }
643        if (jj_scan_token(29)) return true;
644        return false;
645      }
646    
647      private boolean jj_3R_19() {
648        if (jj_scan_token(NUMBER)) return true;
649        return false;
650      }
651    
652      private boolean jj_3R_10() {
653        if (jj_3R_11()) return true;
654        return false;
655      }
656    
657      private boolean jj_3R_6() {
658        if (jj_scan_token(COMMAND_END)) return true;
659        if (jj_3R_5()) return true;
660        return false;
661      }
662    
663      private boolean jj_3R_16() {
664        if (jj_3R_5()) return true;
665        return false;
666      }
667    
668      private boolean jj_3_4() {
669        if (jj_scan_token(NEG_EX)) return true;
670        return false;
671      }
672    
673      private boolean jj_3_3() {
674        if (jj_scan_token(POS_EX)) return true;
675        return false;
676      }
677    
678      private boolean jj_3R_20() {
679        if (jj_scan_token(DOUBLE)) return true;
680        return false;
681      }
682    
683      private boolean jj_3_2() {
684        if (jj_3R_5()) return true;
685        if (jj_scan_token(28)) return true;
686        if (jj_3R_11()) return true;
687        Token xsp;
688        while (true) {
689          xsp = jj_scanpos;
690          if (jj_3R_12()) { jj_scanpos = xsp; break; }
691        }
692        if (jj_scan_token(30)) return true;
693        if (jj_scan_token(CONF_END)) return true;
694        return false;
695      }
696    
697      private boolean jj_3R_14() {
698        if (jj_3R_5()) return true;
699        return false;
700      }
701    
702      private boolean jj_3_1() {
703        if (jj_3R_5()) return true;
704        Token xsp;
705        xsp = jj_scanpos;
706        if (jj_3R_6()) jj_scanpos = xsp;
707        if (jj_scan_token(25)) return true;
708        xsp = jj_scanpos;
709        if (jj_3R_7()) {
710        jj_scanpos = xsp;
711        if (jj_3R_8()) {
712        jj_scanpos = xsp;
713        if (jj_3R_9()) {
714        jj_scanpos = xsp;
715        if (jj_3R_10()) {
716        jj_scanpos = xsp;
717        if (jj_scan_token(26)) {
718        jj_scanpos = xsp;
719        if (jj_scan_token(27)) return true;
720        }
721        }
722        }
723        }
724        }
725        return false;
726      }
727    
728      private boolean jj_3R_9() {
729        if (jj_3R_20()) return true;
730        return false;
731      }
732    
733      private boolean jj_3R_5() {
734        if (jj_scan_token(ID)) return true;
735        return false;
736      }
737    
738      private boolean jj_3R_15() {
739        if (jj_3R_11()) return true;
740        return false;
741      }
742    
743      private boolean jj_3R_18() {
744        if (jj_3R_5()) return true;
745        return false;
746      }
747    
748      private boolean jj_3R_13() {
749        if (jj_3R_11()) return true;
750        return false;
751      }
752    
753      private boolean jj_3R_8() {
754        if (jj_3R_19()) return true;
755        return false;
756      }
757    
758      /** Generated Token Manager. */
759      public ConfParserTokenManager token_source;
760      SimpleCharStream jj_input_stream;
761      /** Current token. */
762      public Token token;
763      /** Next token. */
764      public Token jj_nt;
765      private int jj_ntk;
766      private Token jj_scanpos, jj_lastpos;
767      private int jj_la;
768      private int jj_gen;
769      final private int[] jj_la1 = new int[13];
770      static private int[] jj_la1_0;
771      static private int[] jj_la1_1;
772      static {
773          jj_la1_init_0();
774          jj_la1_init_1();
775       }
776       private static void jj_la1_init_0() {
777          jj_la1_0 = new int[] {0x1c00,0x100,0x1001000,0x1001000,0x1001000,0x1001000,0x1001000,0x1001000,0x1007000,0x4000000,0x8000000,0x20000000,0x1001000,};
778       }
779       private static void jj_la1_init_1() {
780          jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
781       }
782      final private JJCalls[] jj_2_rtns = new JJCalls[8];
783      private boolean jj_rescan = false;
784      private int jj_gc = 0;
785    
786      /** Constructor with InputStream. */
787      public ConfParser(java.io.InputStream stream) {
788         this(stream, null);
789      }
790      /** Constructor with InputStream and supplied encoding */
791      public ConfParser(java.io.InputStream stream, String encoding) {
792        try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
793        token_source = new ConfParserTokenManager(jj_input_stream);
794        token = new Token();
795        jj_ntk = -1;
796        jj_gen = 0;
797        for (int i = 0; i < 13; i++) jj_la1[i] = -1;
798        for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
799      }
800    
801      /** Reinitialise. */
802      public void ReInit(java.io.InputStream stream) {
803         ReInit(stream, null);
804      }
805      /** Reinitialise. */
806      public void ReInit(java.io.InputStream stream, String encoding) {
807        try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
808        token_source.ReInit(jj_input_stream);
809        token = new Token();
810        jj_ntk = -1;
811        jj_gen = 0;
812        for (int i = 0; i < 13; i++) jj_la1[i] = -1;
813        for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
814      }
815    
816      /** Constructor. */
817      public ConfParser(java.io.Reader stream) {
818        jj_input_stream = new SimpleCharStream(stream, 1, 1);
819        token_source = new ConfParserTokenManager(jj_input_stream);
820        token = new Token();
821        jj_ntk = -1;
822        jj_gen = 0;
823        for (int i = 0; i < 13; i++) jj_la1[i] = -1;
824        for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
825      }
826    
827      /** Reinitialise. */
828      public void ReInit(java.io.Reader stream) {
829        jj_input_stream.ReInit(stream, 1, 1);
830        token_source.ReInit(jj_input_stream);
831        token = new Token();
832        jj_ntk = -1;
833        jj_gen = 0;
834        for (int i = 0; i < 13; i++) jj_la1[i] = -1;
835        for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
836      }
837    
838      /** Constructor with generated Token Manager. */
839      public ConfParser(ConfParserTokenManager tm) {
840        token_source = tm;
841        token = new Token();
842        jj_ntk = -1;
843        jj_gen = 0;
844        for (int i = 0; i < 13; i++) jj_la1[i] = -1;
845        for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
846      }
847    
848      /** Reinitialise. */
849      public void ReInit(ConfParserTokenManager tm) {
850        token_source = tm;
851        token = new Token();
852        jj_ntk = -1;
853        jj_gen = 0;
854        for (int i = 0; i < 13; i++) jj_la1[i] = -1;
855        for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
856      }
857    
858      private Token jj_consume_token(int kind) throws ParseException {
859        Token oldToken;
860        if ((oldToken = token).next != null) token = token.next;
861        else token = token.next = token_source.getNextToken();
862        jj_ntk = -1;
863        if (token.kind == kind) {
864          jj_gen++;
865          if (++jj_gc > 100) {
866            jj_gc = 0;
867            for (int i = 0; i < jj_2_rtns.length; i++) {
868              JJCalls c = jj_2_rtns[i];
869              while (c != null) {
870                if (c.gen < jj_gen) c.first = null;
871                c = c.next;
872              }
873            }
874          }
875          return token;
876        }
877        token = oldToken;
878        jj_kind = kind;
879        throw generateParseException();
880      }
881    
882      static private final class LookaheadSuccess extends java.lang.Error { }
883      final private LookaheadSuccess jj_ls = new LookaheadSuccess();
884      private boolean jj_scan_token(int kind) {
885        if (jj_scanpos == jj_lastpos) {
886          jj_la--;
887          if (jj_scanpos.next == null) {
888            jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
889          } else {
890            jj_lastpos = jj_scanpos = jj_scanpos.next;
891          }
892        } else {
893          jj_scanpos = jj_scanpos.next;
894        }
895        if (jj_rescan) {
896          int i = 0; Token tok = token;
897          while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
898          if (tok != null) jj_add_error_token(kind, i);
899        }
900        if (jj_scanpos.kind != kind) return true;
901        if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
902        return false;
903      }
904    
905    
906    /** Get the next Token. */
907      final public Token getNextToken() {
908        if (token.next != null) token = token.next;
909        else token = token.next = token_source.getNextToken();
910        jj_ntk = -1;
911        jj_gen++;
912        return token;
913      }
914    
915    /** Get the specific Token. */
916      final public Token getToken(int index) {
917        Token t = token;
918        for (int i = 0; i < index; i++) {
919          if (t.next != null) t = t.next;
920          else t = t.next = token_source.getNextToken();
921        }
922        return t;
923      }
924    
925      private int jj_ntk() {
926        if ((jj_nt=token.next) == null)
927          return (jj_ntk = (token.next=token_source.getNextToken()).kind);
928        else
929          return (jj_ntk = jj_nt.kind);
930      }
931    
932      private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
933      private int[] jj_expentry;
934      private int jj_kind = -1;
935      private int[] jj_lasttokens = new int[100];
936      private int jj_endpos;
937    
938      private void jj_add_error_token(int kind, int pos) {
939        if (pos >= 100) return;
940        if (pos == jj_endpos + 1) {
941          jj_lasttokens[jj_endpos++] = kind;
942        } else if (jj_endpos != 0) {
943          jj_expentry = new int[jj_endpos];
944          for (int i = 0; i < jj_endpos; i++) {
945            jj_expentry[i] = jj_lasttokens[i];
946          }
947          jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
948            int[] oldentry = (int[])(it.next());
949            if (oldentry.length == jj_expentry.length) {
950              for (int i = 0; i < jj_expentry.length; i++) {
951                if (oldentry[i] != jj_expentry[i]) {
952                  continue jj_entries_loop;
953                }
954              }
955              jj_expentries.add(jj_expentry);
956              break jj_entries_loop;
957            }
958          }
959          if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
960        }
961      }
962    
963      /** Generate ParseException. */
964      public ParseException generateParseException() {
965        jj_expentries.clear();
966        boolean[] la1tokens = new boolean[33];
967        if (jj_kind >= 0) {
968          la1tokens[jj_kind] = true;
969          jj_kind = -1;
970        }
971        for (int i = 0; i < 13; i++) {
972          if (jj_la1[i] == jj_gen) {
973            for (int j = 0; j < 32; j++) {
974              if ((jj_la1_0[i] & (1<<j)) != 0) {
975                la1tokens[j] = true;
976              }
977              if ((jj_la1_1[i] & (1<<j)) != 0) {
978                la1tokens[32+j] = true;
979              }
980            }
981          }
982        }
983        for (int i = 0; i < 33; i++) {
984          if (la1tokens[i]) {
985            jj_expentry = new int[1];
986            jj_expentry[0] = i;
987            jj_expentries.add(jj_expentry);
988          }
989        }
990        jj_endpos = 0;
991        jj_rescan_token();
992        jj_add_error_token(0, 0);
993        int[][] exptokseq = new int[jj_expentries.size()][];
994        for (int i = 0; i < jj_expentries.size(); i++) {
995          exptokseq[i] = jj_expentries.get(i);
996        }
997        return new ParseException(token, exptokseq, tokenImage);
998      }
999    
1000      /** Enable tracing. */
1001      final public void enable_tracing() {
1002      }
1003    
1004      /** Disable tracing. */
1005      final public void disable_tracing() {
1006      }
1007    
1008      private void jj_rescan_token() {
1009        jj_rescan = true;
1010        for (int i = 0; i < 8; i++) {
1011        try {
1012          JJCalls p = jj_2_rtns[i];
1013          do {
1014            if (p.gen > jj_gen) {
1015              jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
1016              switch (i) {
1017                case 0: jj_3_1(); break;
1018                case 1: jj_3_2(); break;
1019                case 2: jj_3_3(); break;
1020                case 3: jj_3_4(); break;
1021                case 4: jj_3_5(); break;
1022                case 5: jj_3_6(); break;
1023                case 6: jj_3_7(); break;
1024                case 7: jj_3_8(); break;
1025              }
1026            }
1027            p = p.next;
1028          } while (p != null);
1029          } catch(LookaheadSuccess ls) { }
1030        }
1031        jj_rescan = false;
1032      }
1033    
1034      private void jj_save(int index, int xla) {
1035        JJCalls p = jj_2_rtns[index];
1036        while (p.gen > jj_gen) {
1037          if (p.next == null) { p = p.next = new JJCalls(); break; }
1038          p = p.next;
1039        }
1040        p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
1041      }
1042    
1043      static final class JJCalls {
1044        int gen;
1045        Token first;
1046        int arg;
1047        JJCalls next;
1048      }
1049    
1050    }