source: java/FramclipsePlugin/src/main/java/com/framsticks/framclipse/internal/parser/FramclipseNonScriptParser.java @ 193

Last change on this file since 193 was 193, checked in by Maciej Komosinski, 10 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain
File size: 20.1 KB
Line 
1/* Generated By:JJTree&JavaCC: Do not edit this line. FramclipseNonScriptParser.java */
2package com.framsticks.framclipse.internal.parser;
3
4import java.io.StringReader;
5
6public class FramclipseNonScriptParser/*@bgen(jjtree)*/implements FramclipseNonScriptParserTreeConstants, FramclipseNonScriptParserConstants {/*@bgen(jjtree)*/
7  protected JJTFramclipseNonScriptParserState jjtree = new JJTFramclipseNonScriptParserState();
8  private CharStreamWithOffset charStream = null;
9
10  public java.util.Collection<Exception> exceptions = new java.util.ArrayList<Exception>();
11
12  public FramclipseNonScriptParser(String input)
13  {
14        this(new CharStreamWithOffset(new StringReader(input)));
15  }
16
17  private FramclipseNonScriptParser(CharStreamWithOffset charStream)
18  {
19        this((CharStream)charStream);
20        this.charStream = charStream;
21  }
22
23  public static void main(String args[]) {
24    String s = "expdef: \u005cn name: urnohorl \u005cn id: horla \u005cn code:~ function kupa(a,b) { yeah \u005cn } \u005cn~\u005cn\u005cn\u005cn";
25
26    FramclipseNonScriptParser t = new FramclipseNonScriptParser(s);
27    try {
28      SimpleNode n = t.FramclipseFile();
29      n.dump("");
30      System.out.println("Thank you.");
31    } catch (Exception e) {
32      System.out.println("Oops.");
33      System.out.println(e.getMessage());
34      //e.printStackTrace();
35    }
36  }
37
38  final public ASTFramclipseFile FramclipseFile() throws ParseException {
39                                      /*@bgen(jjtree) FramclipseFile */
40  ASTFramclipseFile jjtn000 = new ASTFramclipseFile(JJTFRAMCLIPSEFILE);
41  boolean jjtc000 = true;
42  jjtree.openNodeScope(jjtn000);
43    try {
44      label_1:
45      while (true) {
46        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
47        case IDENTIFIER:
48        case EOL:
49        case GLOBAL_INCLUDE_KWD:
50          ;
51          break;
52        default:
53          jj_la1[0] = jj_gen;
54          break label_1;
55        }
56        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
57        case IDENTIFIER:
58        case GLOBAL_INCLUDE_KWD:
59          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
60          case IDENTIFIER:
61            FObject();
62            break;
63          case GLOBAL_INCLUDE_KWD:
64            GlobalInclude();
65            break;
66          default:
67            jj_la1[1] = jj_gen;
68            jj_consume_token(-1);
69            throw new ParseException();
70          }
71          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
72          case EOL:
73            jj_consume_token(EOL);
74            break;
75          case 0:
76            jj_consume_token(0);
77            break;
78          default:
79            jj_la1[2] = jj_gen;
80            jj_consume_token(-1);
81            throw new ParseException();
82          }
83          break;
84        case EOL:
85          jj_consume_token(EOL);
86          break;
87        default:
88          jj_la1[3] = jj_gen;
89          jj_consume_token(-1);
90          throw new ParseException();
91        }
92      }
93    jjtree.closeNodeScope(jjtn000, true);
94    jjtc000 = false;
95    {if (true) return jjtn000;}
96    } catch (Throwable jjte000) {
97    if (jjtc000) {
98      jjtree.clearNodeScope(jjtn000);
99      jjtc000 = false;
100    } else {
101      jjtree.popNode();
102    }
103    if (jjte000 instanceof RuntimeException) {
104      {if (true) throw (RuntimeException)jjte000;}
105    }
106    if (jjte000 instanceof ParseException) {
107      {if (true) throw (ParseException)jjte000;}
108    }
109    {if (true) throw (Error)jjte000;}
110    } finally {
111    if (jjtc000) {
112      jjtree.closeNodeScope(jjtn000, true);
113    }
114    }
115    throw new Error("Missing return statement in function");
116  }
117
118  final public void FObject() throws ParseException {
119                  /*@bgen(jjtree) FObject */
120  ASTFObject jjtn000 = new ASTFObject(JJTFOBJECT);
121  boolean jjtc000 = true;
122  jjtree.openNodeScope(jjtn000);
123    try {
124    jjtn000.setBeginOffset(charStream.getBeginOffset());
125      jj_consume_token(IDENTIFIER);
126    jjtn000.setClassName(token.image);
127      jj_consume_token(SINGLE_SECT_START);
128      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
129      case SINGLE_SECT_END:
130        jj_consume_token(SINGLE_SECT_END);
131        break;
132      case 0:
133        jj_consume_token(0);
134        break;
135      default:
136        jj_la1[4] = jj_gen;
137        jj_consume_token(-1);
138        throw new ParseException();
139      }
140      label_2:
141      while (true) {
142        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
143        case IDENTIFIER:
144        case CODE_SECTION_START:
145          ;
146          break;
147        default:
148          jj_la1[5] = jj_gen;
149          break label_2;
150        }
151        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
152        case IDENTIFIER:
153          Property();
154          break;
155        case CODE_SECTION_START:
156          CodeSection();
157          break;
158        default:
159          jj_la1[6] = jj_gen;
160          jj_consume_token(-1);
161          throw new ParseException();
162        }
163      }
164     jjtree.closeNodeScope(jjtn000, true);
165     jjtc000 = false;
166     jjtn000.setEndOffset(charStream.getBeginOffset() - 1);
167    } catch (Throwable jjte000) {
168     if (jjtc000) {
169       jjtree.clearNodeScope(jjtn000);
170       jjtc000 = false;
171     } else {
172       jjtree.popNode();
173     }
174     if (jjte000 instanceof RuntimeException) {
175       {if (true) throw (RuntimeException)jjte000;}
176     }
177     if (jjte000 instanceof ParseException) {
178       {if (true) throw (ParseException)jjte000;}
179     }
180     {if (true) throw (Error)jjte000;}
181    } finally {
182     if (jjtc000) {
183       jjtree.closeNodeScope(jjtn000, true);
184     }
185    }
186  }
187
188  final public void CodeSection() throws ParseException {
189                      /*@bgen(jjtree) CodeSection */
190  ASTCodeSection jjtn000 = new ASTCodeSection(JJTCODESECTION);
191  boolean jjtc000 = true;
192  jjtree.openNodeScope(jjtn000);
193    try {
194          jjtn000.setBeginOffset(charStream.getBeginOffset());
195      jj_consume_token(CODE_SECTION_START);
196      label_3:
197      while (true) {
198        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
199        case GLOBAL_KWD:
200        case FUNCTION_KWD:
201        case INCLUDE_KWD:
202          ;
203          break;
204        default:
205          jj_la1[7] = jj_gen;
206          break label_3;
207        }
208        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
209        case GLOBAL_KWD:
210          GlobalDecl();
211          break;
212        case FUNCTION_KWD:
213          Function();
214          break;
215        case INCLUDE_KWD:
216          IncludeStmt();
217          break;
218        default:
219          jj_la1[8] = jj_gen;
220          jj_consume_token(-1);
221          throw new ParseException();
222        }
223      }
224      jj_consume_token(CODE_SECTION_END);
225          jjtree.closeNodeScope(jjtn000, true);
226          jjtc000 = false;
227          jjtn000.setEndOffset(charStream.getBeginOffset());
228    } catch (Throwable jjte000) {
229          if (jjtc000) {
230            jjtree.clearNodeScope(jjtn000);
231            jjtc000 = false;
232          } else {
233            jjtree.popNode();
234          }
235          if (jjte000 instanceof RuntimeException) {
236            {if (true) throw (RuntimeException)jjte000;}
237          }
238          if (jjte000 instanceof ParseException) {
239            {if (true) throw (ParseException)jjte000;}
240          }
241          {if (true) throw (Error)jjte000;}
242    } finally {
243          if (jjtc000) {
244            jjtree.closeNodeScope(jjtn000, true);
245          }
246    }
247  }
248
249  final public void Function() throws ParseException {
250                   /*@bgen(jjtree) Function */
251  ASTFunction jjtn000 = new ASTFunction(JJTFUNCTION);
252  boolean jjtc000 = true;
253  jjtree.openNodeScope(jjtn000);
254    try {
255      try {
256        jj_consume_token(FUNCTION_KWD);
257                         jjtn000.setBeginOffset(charStream.getBeginOffset());
258        IdentList();
259        jj_consume_token(LPAREN);
260        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
261        case IDENT:
262          IdentList();
263          break;
264        default:
265          jj_la1[9] = jj_gen;
266          ;
267        }
268        jj_consume_token(RPAREN);
269        jj_consume_token(LBRACE);
270        label_4:
271        while (true) {
272          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
273          case NESTED_LBRACE:
274            ;
275            break;
276          default:
277            jj_la1[10] = jj_gen;
278            break label_4;
279          }
280          CodeBlock();
281        }
282        jj_consume_token(RBRACE);
283      } catch (ParseException e) {
284                token_source.SwitchTo(DEFAULT);
285                //error_skipto(new int[] { EOF });
286
287      }
288          jjtree.closeNodeScope(jjtn000, true);
289          jjtc000 = false;
290          jjtn000.setEndOffset(charStream.getBeginOffset());
291    } catch (Throwable jjte000) {
292          if (jjtc000) {
293            jjtree.clearNodeScope(jjtn000);
294            jjtc000 = false;
295          } else {
296            jjtree.popNode();
297          }
298          if (jjte000 instanceof RuntimeException) {
299            {if (true) throw (RuntimeException)jjte000;}
300          }
301          if (jjte000 instanceof ParseException) {
302            {if (true) throw (ParseException)jjte000;}
303          }
304          {if (true) throw (Error)jjte000;}
305    } finally {
306          if (jjtc000) {
307            jjtree.closeNodeScope(jjtn000, true);
308          }
309    }
310  }
311
312  final public void GlobalDecl() throws ParseException {
313                     /*@bgen(jjtree) GlobalDecl */
314  ASTGlobalDecl jjtn000 = new ASTGlobalDecl(JJTGLOBALDECL);
315  boolean jjtc000 = true;
316  jjtree.openNodeScope(jjtn000);
317    try {
318          jjtn000.setBeginOffset(charStream.getBeginOffset());
319      jj_consume_token(GLOBAL_KWD);
320      IdentList();
321      jj_consume_token(SEMICOLON);
322          jjtree.closeNodeScope(jjtn000, true);
323          jjtc000 = false;
324          jjtn000.setEndOffset(charStream.getBeginOffset());
325    } catch (Throwable jjte000) {
326          if (jjtc000) {
327            jjtree.clearNodeScope(jjtn000);
328            jjtc000 = false;
329          } else {
330            jjtree.popNode();
331          }
332          if (jjte000 instanceof RuntimeException) {
333            {if (true) throw (RuntimeException)jjte000;}
334          }
335          if (jjte000 instanceof ParseException) {
336            {if (true) throw (ParseException)jjte000;}
337          }
338          {if (true) throw (Error)jjte000;}
339    } finally {
340          if (jjtc000) {
341            jjtree.closeNodeScope(jjtn000, true);
342          }
343    }
344  }
345
346  final public void IncludeStmt() throws ParseException {
347                      /*@bgen(jjtree) IncludeStmt */
348  ASTIncludeStmt jjtn000 = new ASTIncludeStmt(JJTINCLUDESTMT);
349  boolean jjtc000 = true;
350  jjtree.openNodeScope(jjtn000);
351    try {
352          jjtn000.setBeginOffset(charStream.getBeginOffset());
353      jj_consume_token(INCLUDE_KWD);
354      jj_consume_token(STRING_LITERAL);
355                                          jjtn000.setFileName(token.image);
356          jjtree.closeNodeScope(jjtn000, true);
357          jjtc000 = false;
358          jjtn000.setEndOffset(charStream.getOffset());
359    } finally {
360          if (jjtc000) {
361            jjtree.closeNodeScope(jjtn000, true);
362          }
363    }
364  }
365
366  final public void GlobalInclude() throws ParseException {
367                        /*@bgen(jjtree) GlobalInclude */
368  ASTGlobalInclude jjtn000 = new ASTGlobalInclude(JJTGLOBALINCLUDE);
369  boolean jjtc000 = true;
370  jjtree.openNodeScope(jjtn000);
371    try {
372          jjtn000.setBeginOffset(charStream.getBeginOffset());
373      jj_consume_token(GLOBAL_INCLUDE_KWD);
374      jj_consume_token(INCLUDE_STRING);
375                                                 jjtn000.setFileName(token.image);
376          jjtree.closeNodeScope(jjtn000, true);
377          jjtc000 = false;
378          jjtn000.setEndOffset(charStream.getOffset());
379    } finally {
380          if (jjtc000) {
381            jjtree.closeNodeScope(jjtn000, true);
382          }
383    }
384  }
385
386  final public void IdentList() throws ParseException {
387                    /*@bgen(jjtree) IdentList */
388  ASTIdentList jjtn000 = new ASTIdentList(JJTIDENTLIST);
389  boolean jjtc000 = true;
390  jjtree.openNodeScope(jjtn000);
391    try {
392      jj_consume_token(IDENT);
393                  jjtn000.addIdent(token.image);
394      label_5:
395      while (true) {
396        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
397        case COMMA:
398          ;
399          break;
400        default:
401          jj_la1[11] = jj_gen;
402          break label_5;
403        }
404        jj_consume_token(COMMA);
405        jj_consume_token(IDENT);
406                                                                      jjtn000.addIdent(token.image);
407      }
408    } finally {
409          if (jjtc000) {
410            jjtree.closeNodeScope(jjtn000, true);
411          }
412    }
413  }
414
415  final public void Property() throws ParseException {
416                   /*@bgen(jjtree) Property */
417  ASTProperty jjtn000 = new ASTProperty(JJTPROPERTY);
418  boolean jjtc000 = true;
419  jjtree.openNodeScope(jjtn000);
420    try {
421          jjtn000.setBeginOffset(charStream.getBeginOffset());
422      jj_consume_token(IDENTIFIER);
423                 jjtn000.setName(token.image);
424      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
425      case SINGLE_SECT_START:
426        SingleLinePropertyValue();
427                                jjtree.closeNodeScope(jjtn000, true);
428                                jjtc000 = false;
429                                jjtn000.setEndOffset(charStream.getBeginOffset() - 1);
430        break;
431      case MULTI_SECT_START:
432        MultiLinePropertyValue();
433                                                                                                                      jjtree.closeNodeScope(jjtn000, true);
434                                                                                                                      jjtc000 = false;
435                                                                                                                      jjtn000.setEndOffset(charStream.getBeginOffset());
436        break;
437      default:
438        jj_la1[12] = jj_gen;
439        jj_consume_token(-1);
440        throw new ParseException();
441      }
442    } catch (Throwable jjte000) {
443          if (jjtc000) {
444            jjtree.clearNodeScope(jjtn000);
445            jjtc000 = false;
446          } else {
447            jjtree.popNode();
448          }
449          if (jjte000 instanceof RuntimeException) {
450            {if (true) throw (RuntimeException)jjte000;}
451          }
452          if (jjte000 instanceof ParseException) {
453            {if (true) throw (ParseException)jjte000;}
454          }
455          {if (true) throw (Error)jjte000;}
456    } finally {
457          if (jjtc000) {
458            jjtree.closeNodeScope(jjtn000, true);
459          }
460    }
461  }
462
463  final public void SingleLinePropertyValue() throws ParseException {
464                                    /*@bgen(jjtree) SingleLinePropertyValue */
465  ASTSingleLinePropertyValue jjtn000 = new ASTSingleLinePropertyValue(JJTSINGLELINEPROPERTYVALUE);
466  boolean jjtc000 = true;
467  jjtree.openNodeScope(jjtn000);
468    try {
469      jj_consume_token(SINGLE_SECT_START);
470      jj_consume_token(PROP_VALUE);
471                                          jjtn000.setValue(token.image);
472      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
473      case SINGLE_SECT_END:
474        jj_consume_token(SINGLE_SECT_END);
475        break;
476      case 0:
477        jj_consume_token(0);
478        break;
479      default:
480        jj_la1[13] = jj_gen;
481        jj_consume_token(-1);
482        throw new ParseException();
483      }
484    } finally {
485          if (jjtc000) {
486            jjtree.closeNodeScope(jjtn000, true);
487          }
488    }
489  }
490
491  final public void CodeBlock() throws ParseException {
492    jj_consume_token(NESTED_LBRACE);
493    label_6:
494    while (true) {
495      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
496      case NESTED_LBRACE:
497        ;
498        break;
499      default:
500        jj_la1[14] = jj_gen;
501        break label_6;
502      }
503      CodeBlock();
504    }
505    jj_consume_token(RBRACE);
506  }
507
508  final public void MultiLinePropertyValue() throws ParseException {
509                                  /*@bgen(jjtree) MultiLinePropertyValue */
510  ASTMultiLinePropertyValue jjtn000 = new ASTMultiLinePropertyValue(JJTMULTILINEPROPERTYVALUE);
511  boolean jjtc000 = true;
512  jjtree.openNodeScope(jjtn000);
513    try {
514      jj_consume_token(MULTI_SECT_START);
515      jj_consume_token(MULTILINE_PROP_VALUE);
516      jj_consume_token(MULTI_SECT_END);
517    } finally {
518          if (jjtc000) {
519            jjtree.closeNodeScope(jjtn000, true);
520          }
521    }
522  }
523
524  void error_skipto(int[] kinds) throws ParseException {
525  //ParseException e = generateParseException();  // generate the exception object.
526  //System.out.println(e.toString());  // print the error message
527  Token t;
528  if(kinds.length > 0)
529  {
530    java.util.Arrays.sort(kinds);
531
532        do {
533        t = getNextToken();
534        } while (java.util.Arrays.binarySearch(kinds, t.kind) < 0);
535
536  }
537  }
538
539  /** Generated Token Manager. */
540  public FramclipseNonScriptParserTokenManager token_source;
541  /** Current token. */
542  public Token token;
543  /** Next token. */
544  public Token jj_nt;
545  private int jj_ntk;
546  private int jj_gen;
547  final private int[] jj_la1 = new int[15];
548  static private int[] jj_la1_0;
549  static private int[] jj_la1_1;
550  static {
551      jj_la1_init_0();
552      jj_la1_init_1();
553   }
554   private static void jj_la1_init_0() {
555      jj_la1_0 = new int[] {0x22400,0x20400,0x2001,0x22400,0x1,0x4400,0x4400,0xe000000,0xe000000,0x0,0x0,0x0,0x18000,0x1,0x0,};
556   }
557   private static void jj_la1_init_1() {
558      jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x200,0x0,0x0,0x0,0x0,0x20,0x40,0x8,0x0,0x200,0x40,};
559   }
560
561  /** Constructor with user supplied CharStream. */
562  public FramclipseNonScriptParser(CharStream stream) {
563    token_source = new FramclipseNonScriptParserTokenManager(stream);
564    token = new Token();
565    jj_ntk = -1;
566    jj_gen = 0;
567    for (int i = 0; i < 15; i++) jj_la1[i] = -1;
568  }
569
570  /** Reinitialise. */
571  public void ReInit(CharStream stream) {
572    token_source.ReInit(stream);
573    token = new Token();
574    jj_ntk = -1;
575    jjtree.reset();
576    jj_gen = 0;
577    for (int i = 0; i < 15; i++) jj_la1[i] = -1;
578  }
579
580  /** Constructor with generated Token Manager. */
581  public FramclipseNonScriptParser(FramclipseNonScriptParserTokenManager tm) {
582    token_source = tm;
583    token = new Token();
584    jj_ntk = -1;
585    jj_gen = 0;
586    for (int i = 0; i < 15; i++) jj_la1[i] = -1;
587  }
588
589  /** Reinitialise. */
590  public void ReInit(FramclipseNonScriptParserTokenManager tm) {
591    token_source = tm;
592    token = new Token();
593    jj_ntk = -1;
594    jjtree.reset();
595    jj_gen = 0;
596    for (int i = 0; i < 15; i++) jj_la1[i] = -1;
597  }
598
599  private Token jj_consume_token(int kind) throws ParseException {
600    Token oldToken;
601    if ((oldToken = token).next != null) token = token.next;
602    else token = token.next = token_source.getNextToken();
603    jj_ntk = -1;
604    if (token.kind == kind) {
605      jj_gen++;
606      return token;
607    }
608    token = oldToken;
609    jj_kind = kind;
610    throw generateParseException();
611  }
612
613
614/** Get the next Token. */
615  final public Token getNextToken() {
616    if (token.next != null) token = token.next;
617    else token = token.next = token_source.getNextToken();
618    jj_ntk = -1;
619    jj_gen++;
620    return token;
621  }
622
623/** Get the specific Token. */
624  final public Token getToken(int index) {
625    Token t = token;
626    for (int i = 0; i < index; i++) {
627      if (t.next != null) t = t.next;
628      else t = t.next = token_source.getNextToken();
629    }
630    return t;
631  }
632
633  private int jj_ntk() {
634    if ((jj_nt=token.next) == null)
635      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
636    else
637      return (jj_ntk = jj_nt.kind);
638  }
639
640  private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
641  private int[] jj_expentry;
642  private int jj_kind = -1;
643
644  /** Generate ParseException. */
645  public ParseException generateParseException() {
646    jj_expentries.clear();
647    boolean[] la1tokens = new boolean[43];
648    if (jj_kind >= 0) {
649      la1tokens[jj_kind] = true;
650      jj_kind = -1;
651    }
652    for (int i = 0; i < 15; i++) {
653      if (jj_la1[i] == jj_gen) {
654        for (int j = 0; j < 32; j++) {
655          if ((jj_la1_0[i] & (1<<j)) != 0) {
656            la1tokens[j] = true;
657          }
658          if ((jj_la1_1[i] & (1<<j)) != 0) {
659            la1tokens[32+j] = true;
660          }
661        }
662      }
663    }
664    for (int i = 0; i < 43; i++) {
665      if (la1tokens[i]) {
666        jj_expentry = new int[1];
667        jj_expentry[0] = i;
668        jj_expentries.add(jj_expentry);
669      }
670    }
671    int[][] exptokseq = new int[jj_expentries.size()][];
672    for (int i = 0; i < jj_expentries.size(); i++) {
673      exptokseq[i] = jj_expentries.get(i);
674    }
675    return new ParseException(token, exptokseq, tokenImage);
676  }
677
678  /** Enable tracing. */
679  final public void enable_tracing() {
680  }
681
682  /** Disable tracing. */
683  final public void disable_tracing() {
684  }
685
686}
Note: See TracBrowser for help on using the repository browser.