options { LOOKAHEAD=1; JAVA_UNICODE_ESCAPE = true; STATIC = false; // USER_CHAR_STREAM = true; } PARSER_BEGIN(PAParser) package com.lowagie.text.pdf.codec.postscript; import java.lang.*; import java.lang.reflect.*; import java.util.*; import java.awt.*; import java.awt.geom.*; import java.awt.color.*; import java.awt.font.*; import java.io.*; import java.net.URL; public class PAParser extends Object { } PARSER_END(PAParser) /* WHITE SPACE ,WITHINSTRING */ SKIP : { < WHITESPACE: " " | "\t" | "\n" | "\r" | "\f" |"\u0004" > | < "%" ( ~["\n"] )* "\n" > | < "%" ( ~["\r"] )* "\r" > | < "%" ( ~["\r"] )* "\r\n" > } /* LITERALS */ TOKEN : { < INTEGER_LITERAL: ("-")? ( (["l","L"])? | (["l","L"])? ) > | < #DECIMAL_LITERAL: ["0"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < FLOATING_POINT_LITERAL: ((["0"-"9"])+ "." (["0"-"9"])* ()? (["f","F","d","D"])?) | ("." (["0"-"9"])+ ()? (["f","F","d","D"])?) | ((["0"-"9"])+ (["f","F","d","D"])?) | ((["0"-"9"])+ ()? ["f","F","d","D"]) | ("-" (["0"-"9"])+ "." (["0"-"9"])* ()? (["f","F","d","D"])?) | ("-" "." (["0"-"9"])+ ()? (["f","F","d","D"])?) | ("-" (["0"-"9"])+ (["f","F","d","D"])?) | ("-" (["0"-"9"])+ ()? ["f","F","d","D"]) > | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | < STRING_LITERAL: "(" ( (~[")","\\"]) | ("\\" ( ["n","t","b","r","f","\\","'",")", "(","\n"] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) )* ")" > } /* IDENTIFIERS */ TOKEN : { < IDENTIFIER: (||"-"|".")* > | < KEY_IDENTIFIER: "/" ((".")|("#"))? > | < IMMEDIATE_IDENTIFIER: "//" > | < #LETTER: [ "+", "-", "?", "\u0024", "\u0041"-"\u005a", "\u005f", "\u0061"-"\u007a", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u00ff", "\u0100"-"\u1fff", "\u3040"-"\u318f", "\u3300"-"\u337f", "\u3400"-"\u3d2d", "\u4e00"-"\u9fff", "\uf900"-"\ufaff" ] > | < #DIGIT: [ "\u0030"-"\u0039", "\u0660"-"\u0669", "\u06f0"-"\u06f9", "\u0966"-"\u096f", "\u09e6"-"\u09ef", "\u0a66"-"\u0a6f", "\u0ae6"-"\u0aef", "\u0b66"-"\u0b6f", "\u0be7"-"\u0bef", "\u0c66"-"\u0c6f", "\u0ce6"-"\u0cef", "\u0d66"-"\u0d6f", "\u0e50"-"\u0e59", "\u0ed0"-"\u0ed9", "\u1040"-"\u1049" ] > } /* SEPARATORS */ TOKEN : { < LBRACE: "{" > | < RBRACE: "}" > | < LBRACKET: "[" > | < RBRACKET: "]" > | < LDICT: "<<" > | < RDICT: ">>" > } MORE: { "] > } TOKEN: { " > {matchedToken.image=image.toString().substring(0,image.toString().length()-1); } :DEFAULT } TOKEN : { < Instring: "<" > :WITHINSTRING } JAVACODE void error_skipto(int kind){ 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+"<"); } JAVACODE String ExceptionString(String hint,JavaCharStream jj_input_stream,PAContext context,Token t,Exception e ){ return "\nparser "+hint+" ["+jj_input_stream.bufpos+"]"+context.engine.litMode()+":\""+t.image+"\" in line "+t.beginLine+" column "+t.beginColumn+"\n"+e.toString(); } void parse(PAContext context) : { Token x = null; } { try{ ( ( ( ( x = { 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) { throw new ParseException(ExceptionString("int_literal",jj_input_stream,context,token,e)); } catch(PainterException e) { throw new ParseException(ExceptionString("int_literal",jj_input_stream,context,token,e)); } } ) | ( x = { 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) { throw new ParseException(ExceptionString("float_literal",jj_input_stream,context,token,e)); } catch(PainterException e) { throw new ParseException(ExceptionString("float_literal",jj_input_stream,context,token,e)); } } ) | ( x = { 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) { throw new ParseException(ExceptionString("hex_string_literal",jj_input_stream,context,token,e)); } } ) | ( x = { 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) { throw new ParseException(ExceptionString("string_literal",jj_input_stream,context,token,e)); } } ) | ( x = { 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) { throw new ParseException(ExceptionString("identifier",jj_input_stream,context,token,e)); } } ) | ( x = { 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) { throw new ParseException(ExceptionString("key_identifier",jj_input_stream,context,token,e)); } } ) | ( x = { 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) { throw new ParseException(ExceptionString("immediate_identifier",jj_input_stream,context,token,e)); } } ) ) | ( { 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) { throw new ParseException(ExceptionString("lbrace",jj_input_stream,context,token,e)); } } ) | ( { 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) { throw new ParseException(ExceptionString("rbrace",jj_input_stream,context,token,e)); } } ) | ( { 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) { throw new ParseException(ExceptionString("lbracket",jj_input_stream,context,token,e)); } } ) | ( { 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) { throw new ParseException(ExceptionString("rbracket",jj_input_stream,context,token,e)); } } ) | ( { 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) { throw new ParseException(ExceptionString("ldict",jj_input_stream,context,token,e)); } } ) | ( { 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) { throw new ParseException(ExceptionString("rdict",jj_input_stream,context,token,e)); } } ) ) )* }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); } }