1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
|
/* Generated By:JavaCC: Do not edit this line. PAParser.java */
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the License.
*
* The Original Code is 'iText, a free JAVA-PDF library'.
*
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
* the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
* All Rights Reserved.
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
* are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
*
* Contributor(s): all the names of the contributors are added in the source code
* where applicable.
*
* Alternatively, the contents of this file may be used under the terms of the
* LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
* provisions of LGPL are applicable instead of those above. If you wish to
* allow use of your version of this file only under the terms of the LGPL
* License and not to allow others to use your version of this file under
* the MPL, indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by the LGPL.
* If you do not delete the provisions above, a recipient may use your version
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MPL as stated above or under the terms of the GNU
* Library General Public License as published by the Free Software Foundation;
* either version 2 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
* details.
*
* If you didn't download this code from the following link, you should check if
* you aren't using an obsolete version:
* http://www.lowagie.com/iText/
*
* This class is generated based on a grammar file privided by SUN, and updated
* by Carsten Hammer. SUN's license agreement can be found at this URL:
* http://java.sun.com/products/java-media/2D/samples/samples-license.html
* See also the file sun.txt in directory com.lowagie.text.pdf
*/
package com.lowagie.text.pdf.codec.postscript;
public class PAParser extends Object implements PAParserConstants {
void error_skipto(int kind) throws ParseException {
ParseException e=generateParseException();
Token t;
String dump="";
do{
if(getToken(1).kind==kind)break;
t=getNextToken();
dump+=t.image;
}while(t.kind!=kind);
System.out.println("Ignoriere >"+dump+"<");
}
String ExceptionString(String hint,JavaCharStream jj_input_stream,PAContext context,Token t,Exception e) throws ParseException {
return "\nparser "+hint+" ["+jj_input_stream.bufpos+"]"+context.engine.litMode()+":\""+t.image+"\" in line "+t.beginLine+" column "+t.beginColumn+"\n"+e.toString();
}
final public void parse(PAContext context) throws ParseException {
Token x = null;
try {
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case INTEGER_LITERAL:
case FLOATING_POINT_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case KEY_IDENTIFIER:
case IMMEDIATE_IDENTIFIER:
case LBRACE:
case RBRACE:
case LBRACKET:
case RBRACKET:
case LDICT:
case RDICT:
case Instring:
;
break;
default:
jj_la1[0] = jj_gen;
break label_1;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case INTEGER_LITERAL:
case FLOATING_POINT_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case KEY_IDENTIFIER:
case IMMEDIATE_IDENTIFIER:
case Instring:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case INTEGER_LITERAL:
x = jj_consume_token(INTEGER_LITERAL);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+x.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new Integer(x.image));
} catch(NumberFormatException e) {
{if (true) throw new ParseException(ExceptionString("int_literal",jj_input_stream,context,token,e));}
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("int_literal",jj_input_stream,context,token,e));}
}
break;
case FLOATING_POINT_LITERAL:
x = jj_consume_token(FLOATING_POINT_LITERAL);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+x.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new Double(x.image));
} catch(NumberFormatException e) {
{if (true) throw new ParseException(ExceptionString("float_literal",jj_input_stream,context,token,e));}
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("float_literal",jj_input_stream,context,token,e));}
}
break;
case Instring:
jj_consume_token(Instring);
x = jj_consume_token(HEX_STRING_LITERAL);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+x.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process((x.image.substring(1, x.image.length() -1)));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("hex_string_literal",jj_input_stream,context,token,e));}
}
break;
case STRING_LITERAL:
x = jj_consume_token(STRING_LITERAL);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+x.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(x.image.substring(1, x.image.length() -1));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("string_literal",jj_input_stream,context,token,e));}
}
break;
case IDENTIFIER:
x = jj_consume_token(IDENTIFIER);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+x.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new PAToken(x.image, PAToken.IDENTIFIER));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("identifier",jj_input_stream,context,token,e));}
}
break;
case KEY_IDENTIFIER:
x = jj_consume_token(KEY_IDENTIFIER);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+x.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new PAToken(x.image.substring(1, x.image.length()), PAToken.KEY));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("key_identifier",jj_input_stream,context,token,e));}
}
break;
case IMMEDIATE_IDENTIFIER:
x = jj_consume_token(IMMEDIATE_IDENTIFIER);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+x.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new PAToken(x.image.substring(2, x.image.length()), PAToken.IMMEDIATE));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("immediate_identifier",jj_input_stream,context,token,e));}
}
break;
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
case LBRACE:
jj_consume_token(LBRACE);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+token.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new PAToken(null, PAToken.START_PROCEDURE));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("lbrace",jj_input_stream,context,token,e));}
}
break;
case RBRACE:
jj_consume_token(RBRACE);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+token.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new PAToken(null, PAToken.END_PROCEDURE));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("rbrace",jj_input_stream,context,token,e));}
}
break;
case LBRACKET:
jj_consume_token(LBRACKET);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+token.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new PAToken(null, PAToken.START_ARRAY));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("lbracket",jj_input_stream,context,token,e));}
}
break;
case RBRACKET:
jj_consume_token(RBRACKET);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+token.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new PAToken(null, PAToken.END_ARRAY));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("rbracket",jj_input_stream,context,token,e));}
}
break;
case LDICT:
jj_consume_token(LDICT);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+token.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new PAToken(null, PAToken.START_DICT));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("ldict",jj_input_stream,context,token,e));}
}
break;
case RDICT:
jj_consume_token(RDICT);
try {
{if(PAContext.DebugExecution){System.out.print("\nparser ["+jj_input_stream.getBeginLine()+","+jj_input_stream.getBeginColumn()+"]"+context.engine.litMode()+":\""+token.image+"\"");System.out.flush();System.err.flush();}}
context.engine.process(new PAToken(null, PAToken.END_DICT));
} catch(PainterException e) {
{if (true) throw new ParseException(ExceptionString("rdict",jj_input_stream,context,token,e));}
}
break;
default:
jj_la1[2] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
} catch (ParseException e) {
System.out.flush();System.err.flush();
//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.");
//System.err.println("Fehler:"+e);
e.printStackTrace();
error_skipto(WHITESPACE);
System.exit(0);
}
}
public PAParserTokenManager token_source;
JavaCharStream jj_input_stream;
public Token token, jj_nt;
private int jj_ntk;
private int jj_gen;
final private int[] jj_la1 = new int[3];
final private int[] jj_la1_0 = {0x13f3d20,0x1003d20,0x13f3d20,};
public PAParser(java.io.InputStream stream) {
jj_input_stream = new JavaCharStream(stream, 1, 1);
token_source = new PAParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 3; i++) jj_la1[i] = -1;
}
public void ReInit(java.io.InputStream stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 3; i++) jj_la1[i] = -1;
}
public PAParser(java.io.Reader stream) {
jj_input_stream = new JavaCharStream(stream, 1, 1);
token_source = new PAParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 3; i++) jj_la1[i] = -1;
}
public void ReInit(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 3; i++) jj_la1[i] = -1;
}
public PAParser(PAParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 3; i++) jj_la1[i] = -1;
}
public void ReInit(PAParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 3; i++) jj_la1[i] = -1;
}
final private Token jj_consume_token(int kind) throws ParseException {
Token oldToken;
if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
if (token.kind == kind) {
jj_gen++;
return token;
}
token = oldToken;
jj_kind = kind;
throw generateParseException();
}
final public Token getNextToken() {
if (token.next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
jj_gen++;
return token;
}
final public Token getToken(int index) {
Token t = token;
for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken();
}
return t;
}
final private int jj_ntk() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
return (jj_ntk = jj_nt.kind);
}
private java.util.Vector jj_expentries = new java.util.Vector();
private int[] jj_expentry;
private int jj_kind = -1;
final public ParseException generateParseException() {
jj_expentries.removeAllElements();
boolean[] la1tokens = new boolean[25];
for (int i = 0; i < 25; i++) {
la1tokens[i] = false;
}
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 3; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
la1tokens[j] = true;
}
}
}
}
for (int i = 0; i < 25; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.addElement(jj_expentry);
}
}
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.elementAt(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
final public void enable_tracing() {
}
final public void disable_tracing() {
}
}
|