001 /* Generated By:JJTree&JavaCC: Do not edit this line. JSSPParser.java */
002 package org.descripter.js.ss.parse;
003 
004 public class JSSPParser/*@bgen(jjtree)*/implements JSSPParserTreeConstants, JSSPParserConstants {/*@bgen(jjtree)*/
005   protected JJTJSSPParserState jjtree = new JJTJSSPParserState();void jjtreeOpenNodeScope(Node n) {
006                 ((AbstractNode)n).firstToken = getToken(1);
007         }
008 
009         void jjtreeCloseNodeScope(Node n) {
010                 ((AbstractNode)n).lastToken = getToken(0);
011         }
012 
013   final public JSSPPage Page() throws ParseException {
014  /*@bgen(jjtree) Page */
015   JSSPPage jjtn000 = new JSSPPage(this, JJTPAGE);
016   boolean jjtc000 = true;
017   jjtree.openNodeScope(jjtn000);
018   jjtreeOpenNodeScope(jjtn000);
019     try {
020       label_1:
021       while (true) {
022         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
023         case SCRIPT:
024         case DOUBLE_STRING:
025         case SINGLE_STRING:
026         case HTML:
027           ;
028           break;
029         default:
030           jj_la1[0] = jj_gen;
031           break label_1;
032         }
033         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
034         case SCRIPT:
035           Script();
036           break;
037         case DOUBLE_STRING:
038         case SINGLE_STRING:
039         case HTML:
040           Html();
041           break;
042         default:
043           jj_la1[1] = jj_gen;
044           jj_consume_token(-1);
045           throw new ParseException();
046         }
047       }
048       jj_consume_token(0);
049     jjtree.closeNodeScope(jjtn000, true);
050     jjtc000 = false;
051     jjtreeCloseNodeScope(jjtn000);
052     {if (true) return jjtn000;}
053     } catch (Throwable jjte000) {
054     if (jjtc000) {
055       jjtree.clearNodeScope(jjtn000);
056       jjtc000 = false;
057     } else {
058       jjtree.popNode();
059     }
060     if (jjte000 instanceof RuntimeException) {
061       {if (true) throw (RuntimeException)jjte000;}
062     }
063     if (jjte000 instanceof ParseException) {
064       {if (true) throw (ParseException)jjte000;}
065     }
066     {if (true) throw (Error)jjte000;}
067     } finally {
068     if (jjtc000) {
069       jjtree.closeNodeScope(jjtn000, true);
070       jjtreeCloseNodeScope(jjtn000);
071     }
072     }
073     throw new Error("Missing return statement in function");
074   }
075 
076   final public void Script() throws ParseException {
077  /*@bgen(jjtree) Script */
078         JSSPScript jjtn000 = new JSSPScript(this, JJTSCRIPT);
079         boolean jjtc000 = true;
080         jjtree.openNodeScope(jjtn000);
081         jjtreeOpenNodeScope(jjtn000);Token t;
082     try {
083       t = jj_consume_token(SCRIPT);
084           jjtree.closeNodeScope(jjtn000, true);
085           jjtc000 = false;
086           jjtreeCloseNodeScope(jjtn000);
087                 jjtn000.jjtSetValue(t.image.substring(2, t.image.length() - 2));
088     } finally {
089   if (jjtc000) {
090     jjtree.closeNodeScope(jjtn000, true);
091     jjtreeCloseNodeScope(jjtn000);
092   }
093     }
094   }
095 
096   final public void Html() throws ParseException {
097  /*@bgen(jjtree) Html */
098         JSSPHtml jjtn000 = new JSSPHtml(this, JJTHTML);
099         boolean jjtc000 = true;
100         jjtree.openNodeScope(jjtn000);
101         jjtreeOpenNodeScope(jjtn000);Token t;
102     try {
103       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
104       case DOUBLE_STRING:
105         t = jj_consume_token(DOUBLE_STRING);
106         break;
107       case SINGLE_STRING:
108         t = jj_consume_token(SINGLE_STRING);
109         break;
110       case HTML:
111         t = jj_consume_token(HTML);
112         break;
113       default:
114         jj_la1[2] = jj_gen;
115         jj_consume_token(-1);
116         throw new ParseException();
117       }
118           jjtree.closeNodeScope(jjtn000, true);
119           jjtc000 = false;
120           jjtreeCloseNodeScope(jjtn000);
121                 jjtn000.jjtSetValue(t.image);
122     } finally {
123   if (jjtc000) {
124     jjtree.closeNodeScope(jjtn000, true);
125     jjtreeCloseNodeScope(jjtn000);
126   }
127     }
128   }
129 
130   /** Generated Token Manager. */
131   public JSSPParserTokenManager token_source;
132   JavaCharStream jj_input_stream;
133   /** Current token. */
134   public Token token;
135   /** Next token. */
136   public Token jj_nt;
137   private int jj_ntk;
138   private int jj_gen;
139   final private int[] jj_la1 = new int[3];
140   static private int[] jj_la1_0;
141   static {
142       jj_la1_init_0();
143    }
144    private static void jj_la1_init_0() {
145       jj_la1_0 = new int[] {0xf00,0xf00,0xe00,};
146    }
147 
148   /** Constructor with InputStream. */
149   public JSSPParser(java.io.InputStream stream) {
150      this(stream, null);
151   }
152   /** Constructor with InputStream and supplied encoding */
153   public JSSPParser(java.io.InputStream stream, String encoding) {
154     try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
155     token_source = new JSSPParserTokenManager(jj_input_stream);
156     token = new Token();
157     jj_ntk = -1;
158     jj_gen = 0;
159     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
160   }
161 
162   /** Reinitialise. */
163   public void ReInit(java.io.InputStream stream) {
164      ReInit(stream, null);
165   }
166   /** Reinitialise. */
167   public void ReInit(java.io.InputStream stream, String encoding) {
168     try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
169     token_source.ReInit(jj_input_stream);
170     token = new Token();
171     jj_ntk = -1;
172     jjtree.reset();
173     jj_gen = 0;
174     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
175   }
176 
177   /** Constructor. */
178   public JSSPParser(java.io.Reader stream) {
179     jj_input_stream = new JavaCharStream(stream, 1, 1);
180     token_source = new JSSPParserTokenManager(jj_input_stream);
181     token = new Token();
182     jj_ntk = -1;
183     jj_gen = 0;
184     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
185   }
186 
187   /** Reinitialise. */
188   public void ReInit(java.io.Reader stream) {
189     jj_input_stream.ReInit(stream, 1, 1);
190     token_source.ReInit(jj_input_stream);
191     token = new Token();
192     jj_ntk = -1;
193     jjtree.reset();
194     jj_gen = 0;
195     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
196   }
197 
198   /** Constructor with generated Token Manager. */
199   public JSSPParser(JSSPParserTokenManager tm) {
200     token_source = tm;
201     token = new Token();
202     jj_ntk = -1;
203     jj_gen = 0;
204     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
205   }
206 
207   /** Reinitialise. */
208   public void ReInit(JSSPParserTokenManager tm) {
209     token_source = tm;
210     token = new Token();
211     jj_ntk = -1;
212     jjtree.reset();
213     jj_gen = 0;
214     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
215   }
216 
217   private Token jj_consume_token(int kind) throws ParseException {
218     Token oldToken;
219     if ((oldToken = token).next != null) token = token.next;
220     else token = token.next = token_source.getNextToken();
221     jj_ntk = -1;
222     if (token.kind == kind) {
223       jj_gen++;
224       return token;
225     }
226     token = oldToken;
227     jj_kind = kind;
228     throw generateParseException();
229   }
230 
231 
232 /** Get the next Token. */
233   final public Token getNextToken() {
234     if (token.next != null) token = token.next;
235     else token = token.next = token_source.getNextToken();
236     jj_ntk = -1;
237     jj_gen++;
238     return token;
239   }
240 
241 /** Get the specific Token. */
242   final public Token getToken(int index) {
243     Token t = token;
244     for (int i = 0; i < index; i++) {
245       if (t.next != null) t = t.next;
246       else t = t.next = token_source.getNextToken();
247     }
248     return t;
249   }
250 
251   private int jj_ntk() {
252     if ((jj_nt=token.next) == null)
253       return (jj_ntk = (token.next=token_source.getNextToken()).kind);
254     else
255       return (jj_ntk = jj_nt.kind);
256   }
257 
258   private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
259   private int[] jj_expentry;
260   private int jj_kind = -1;
261 
262   /** Generate ParseException. */
263   public ParseException generateParseException() {
264     jj_expentries.clear();
265     boolean[] la1tokens = new boolean[13];
266     if (jj_kind >= 0) {
267       la1tokens[jj_kind] = true;
268       jj_kind = -1;
269     }
270     for (int i = 0; i < 3; i++) {
271       if (jj_la1[i] == jj_gen) {
272         for (int j = 0; j < 32; j++) {
273           if ((jj_la1_0[i] & (1<<j)) != 0) {
274             la1tokens[j] = true;
275           }
276         }
277       }
278     }
279     for (int i = 0; i < 13; i++) {
280       if (la1tokens[i]) {
281         jj_expentry = new int[1];
282         jj_expentry[0] = i;
283         jj_expentries.add(jj_expentry);
284       }
285     }
286     int[][] exptokseq = new int[jj_expentries.size()][];
287     for (int i = 0; i < jj_expentries.size(); i++) {
288       exptokseq[i] = jj_expentries.get(i);
289     }
290     return new ParseException(token, exptokseq, tokenImage);
291   }
292 
293   /** Enable tracing. */
294   final public void enable_tracing() {
295   }
296 
297   /** Disable tracing. */
298   final public void disable_tracing() {
299   }
300 
301 }