KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > pdf > codec > postscript > PAParser


1 /* Generated By:JavaCC: Do not edit this line. PAParser.java */
2 package com.lowagie.text.pdf.codec.postscript;
3
4 import java.lang.*;
5 import java.lang.reflect.*;
6 import java.util.*;
7 import java.awt.*;
8 import java.awt.geom.*;
9 import java.awt.color.*;
10 import java.awt.font.*;
11
12 import java.io.*;
13 import java.net.URL;
14
15 public class PAParser extends Object implements PAParserConstants {
16
17   void error_skipto(int kind) throws ParseException {
18 ParseException e=generateParseException();
19 Token t;
20 String dump="";
21 do{
22 if(getToken(1).kind==kind)break;
23 t=getNextToken();
24 dump+=t.image;
25 }while(t.kind!=kind);
26 System.out.println("Ignoriere >"+dump+"<");
27   }
28
29   final public void parse(PAContext context) throws ParseException {
30         Token x = null;
31     try {
32       label_1:
33       while (true) {
34         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
35         case INTEGER_LITERAL:
36         case FLOATING_POINT_LITERAL:
37         case STRING_LITERAL:
38         case IDENTIFIER:
39         case KEY_IDENTIFIER:
40         case IMMEDIATE_IDENTIFIER:
41         case LBRACE:
42         case RBRACE:
43         case LBRACKET:
44         case RBRACKET:
45           ;
46           break;
47         default:
48           jj_la1[0] = jj_gen;
49           break label_1;
50         }
51         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
52         case INTEGER_LITERAL:
53         case FLOATING_POINT_LITERAL:
54         case STRING_LITERAL:
55         case IDENTIFIER:
56         case KEY_IDENTIFIER:
57         case IMMEDIATE_IDENTIFIER:
58           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
59           case INTEGER_LITERAL:
60             x = jj_consume_token(INTEGER_LITERAL);
61                                 try {
62                                         context.engine.process(new Integer(x.image));
63                                 } catch(NumberFormatException e) {
64                                         {if (true) throw new ParseException(e.toString());}
65                                 } catch(PainterException e) {
66                                         {if (true) throw new ParseException(e.toString());}
67                                 }
68             break;
69           case FLOATING_POINT_LITERAL:
70             x = jj_consume_token(FLOATING_POINT_LITERAL);
71                                 try {
72                                         context.engine.process(new Double(x.image));
73                                 } catch(NumberFormatException e) {
74                                         {if (true) throw new ParseException(e.toString());}
75                                 } catch(PainterException e) {
76                                         {if (true) throw new ParseException(e.toString());}
77                                 }
78             break;
79           case STRING_LITERAL:
80             x = jj_consume_token(STRING_LITERAL);
81                                 try {
82                                         context.engine.process(x.image.substring(1, x.image.length() -1));
83                                 } catch(PainterException e) {
84                                         {if (true) throw new ParseException(e.toString());}
85                                 }
86             break;
87           case IDENTIFIER:
88             x = jj_consume_token(IDENTIFIER);
89                                 try {
90                                         context.engine.process(new PAToken(x.image, PAToken.IDENTIFIER));
91                                 } catch(PainterException e) {
92                                         {if (true) throw new ParseException(e.toString());}
93                                 }
94             break;
95           case KEY_IDENTIFIER:
96             x = jj_consume_token(KEY_IDENTIFIER);
97                                 try {
98                                         context.engine.process(new PAToken(x.image.substring(1, x.image.length()), PAToken.KEY));
99                                 } catch(PainterException e) {
100                                         {if (true) throw new ParseException(e.toString());}
101                                 }
102             break;
103           case IMMEDIATE_IDENTIFIER:
104             x = jj_consume_token(IMMEDIATE_IDENTIFIER);
105                                 try {
106                                         context.engine.process(new PAToken(x.image.substring(2, x.image.length()), PAToken.IMMEDIATE));
107                                 } catch(PainterException e) {
108                                         {if (true) throw new ParseException(e.toString());}
109                                 }
110             break;
111           default:
112             jj_la1[1] = jj_gen;
113             jj_consume_token(-1);
114             throw new ParseException();
115           }
116           break;
117         case LBRACE:
118           jj_consume_token(LBRACE);
119                                 try {
120                                         context.engine.process(new PAToken(null, PAToken.START_PROCEDURE));
121                                 } catch(PainterException e) {
122                                         {if (true) throw new ParseException(e.toString());}
123                                 }
124           break;
125         case RBRACE:
126           jj_consume_token(RBRACE);
127                                 try {
128                                         context.engine.process(new PAToken(null, PAToken.END_PROCEDURE));
129                                 } catch(PainterException e) {
130                                         {if (true) throw new ParseException(e.toString());}
131                                 }
132           break;
133         case LBRACKET:
134           jj_consume_token(LBRACKET);
135                                 try {
136                                         context.engine.process(new PAToken(null, PAToken.START_ARRAY));
137                                 } catch(PainterException e) {
138                                         {if (true) throw new ParseException(e.toString());}
139                                 }
140           break;
141         case RBRACKET:
142           jj_consume_token(RBRACKET);
143                                 try {
144                                         context.engine.process(new PAToken(null, PAToken.END_ARRAY));
145                                 } catch(PainterException e) {
146                                         {if (true) throw new ParseException(e.toString());}
147                                 }
148           break;
149         default:
150           jj_la1[2] = jj_gen;
151           jj_consume_token(-1);
152           throw new ParseException();
153         }
154       }
155     } catch (ParseException e) {
156                   //System.out.println("Fehlerhaftes Element in Spalte "+e.currentToken.beginColumn+" in Eingabedatei in Zeile="+e.currentToken.next.beginLine+" in Zeichen Nr. "+e.currentToken.next.beginColumn+". >"+e.currentToken.next.image+"< wurde hier nicht erwartet.");
157
//System.err.println("Fehler:"+e);
158
e.printStackTrace();
159                   error_skipto(WHITESPACE);
160     }
161   }
162
163   public PAParserTokenManager token_source;
164   JavaCharStream jj_input_stream;
165   public Token token, jj_nt;
166   private int jj_ntk;
167   private int jj_gen;
168   final private int[] jj_la1 = new int[3];
169   final private int[] jj_la1_0 = {0x79e90,0x1e90,0x79e90,};
170
171   public PAParser(java.io.InputStream stream) {
172     jj_input_stream = new JavaCharStream(stream, 1, 1);
173     token_source = new PAParserTokenManager(jj_input_stream);
174     token = new Token();
175     jj_ntk = -1;
176     jj_gen = 0;
177     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
178   }
179
180   public void ReInit(java.io.InputStream stream) {
181     jj_input_stream.ReInit(stream, 1, 1);
182     token_source.ReInit(jj_input_stream);
183     token = new Token();
184     jj_ntk = -1;
185     jj_gen = 0;
186     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
187   }
188
189   public PAParser(java.io.Reader stream) {
190     jj_input_stream = new JavaCharStream(stream, 1, 1);
191     token_source = new PAParserTokenManager(jj_input_stream);
192     token = new Token();
193     jj_ntk = -1;
194     jj_gen = 0;
195     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
196   }
197
198   public void ReInit(java.io.Reader stream) {
199     jj_input_stream.ReInit(stream, 1, 1);
200     token_source.ReInit(jj_input_stream);
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   public PAParser(PAParserTokenManager tm) {
208     token_source = tm;
209     token = new Token();
210     jj_ntk = -1;
211     jj_gen = 0;
212     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
213   }
214
215   public void ReInit(PAParserTokenManager tm) {
216     token_source = tm;
217     token = new Token();
218     jj_ntk = -1;
219     jj_gen = 0;
220     for (int i = 0; i < 3; i++) jj_la1[i] = -1;
221   }
222
223   final private Token jj_consume_token(int kind) throws ParseException {
224     Token oldToken;
225     if ((oldToken = token).next != null) token = token.next;
226     else token = token.next = token_source.getNextToken();
227     jj_ntk = -1;
228     if (token.kind == kind) {
229       jj_gen++;
230       return token;
231     }
232     token = oldToken;
233     jj_kind = kind;
234     throw generateParseException();
235   }
236
237   final public Token getNextToken() {
238     if (token.next != null) token = token.next;
239     else token = token.next = token_source.getNextToken();
240     jj_ntk = -1;
241     jj_gen++;
242     return token;
243   }
244
245   final public Token getToken(int index) {
246     Token t = token;
247     for (int i = 0; i < index; i++) {
248       if (t.next != null) t = t.next;
249       else t = t.next = token_source.getNextToken();
250     }
251     return t;
252   }
253
254   final private int jj_ntk() {
255     if ((jj_nt=token.next) == null)
256       return (jj_ntk = (token.next=token_source.getNextToken()).kind);
257     else
258       return (jj_ntk = jj_nt.kind);
259   }
260
261   private java.util.Vector jj_expentries = new java.util.Vector();
262   private int[] jj_expentry;
263   private int jj_kind = -1;
264
265   final public ParseException generateParseException() {
266     jj_expentries.removeAllElements();
267     boolean[] la1tokens = new boolean[19];
268     for (int i = 0; i < 19; i++) {
269       la1tokens[i] = false;
270     }
271     if (jj_kind >= 0) {
272       la1tokens[jj_kind] = true;
273       jj_kind = -1;
274     }
275     for (int i = 0; i < 3; i++) {
276       if (jj_la1[i] == jj_gen) {
277         for (int j = 0; j < 32; j++) {
278           if ((jj_la1_0[i] & (1<<j)) != 0) {
279             la1tokens[j] = true;
280           }
281         }
282       }
283     }
284     for (int i = 0; i < 19; i++) {
285       if (la1tokens[i]) {
286         jj_expentry = new int[1];
287         jj_expentry[0] = i;
288         jj_expentries.addElement(jj_expentry);
289       }
290     }
291     int[][] exptokseq = new int[jj_expentries.size()][];
292     for (int i = 0; i < jj_expentries.size(); i++) {
293       exptokseq[i] = (int[])jj_expentries.elementAt(i);
294     }
295     return new ParseException(token, exptokseq, tokenImage);
296   }
297
298   final public void enable_tracing() {
299   }
300
301   final public void disable_tracing() {
302   }
303
304 }
305
Popular Tags