Section Header
  
  
    + name    := AI_PARSER;
  
  
    - comment     :="Startup system : First object.";
  
  
    - version := 1;  
  
Section Inherit  
  
  
    - parent_object:OBJECT := 
  
Section Public
  
  
    - msg_err:STRING;
  
    - trace:BOOLEAN;
  
  
    + position:INTEGER;
  
  
    + source:FAST_ARRAY[CHARACTER];
  
  
    - string_tmp:STRING;
  
  
    - last_character:CHARACTER <-
    
  
    - end_source:BOOLEAN <-
    
  
    - last_integer:INTEGER;
  
  
    - last_string:STRING_CONSTANT;
  
  
    - last_real_16_16:REAL_16_16;
  
  
    - last_flag:BOOLEAN;
  
  
    - is_new_line:BOOLEAN;
  
  
    - is_space:BOOLEAN <-
    
  
    - read_space:BOOLEAN <-
      
  
    - read_keyword s:STRING_CONSTANT :BOOLEAN <- 
    
  
    - read_identifier:BOOLEAN <-
    
  
    - read_string:BOOLEAN <-
    
  
    - read_flag:BOOLEAN <-
    
  
    - read_integer:BOOLEAN <-
    
  
    - read_real_16_16:BOOLEAN <-
    
  
    - read_comment:BOOLEAN <-
  
  
    - read_character c:CHARACTER :BOOLEAN <- 
  
  
  
 Error Management
  
 
  
  
    - syntax_error txt:ABSTRACT_STRING <-
    
  
    - missing_keyword txt:ABSTRACT_STRING <-
    
  
    - print_line <-
    
  
    - get_line:INTEGER <-
    
  
 Last read coordinates
  
    - last_x:REAL_16_16;  
  
    - last_y:REAL_16_16;
    
  
 Current Point
  
    - x_cur:REAL_16_16;
  
    - y_cur:REAL_16_16;
  
Section Public
  
  
    + llx:REAL_16_16; 
         lower horizontal bound
  
    + urx:REAL_16_16; 
         upper horizontal bound
  
    + lly:REAL_16_16; 
         lower vertical bound
  
    + ury:REAL_16_16; 
         upper vertical bound
  
  
    + width :INTEGER;  
  
    + height:INTEGER;
    
  
  
 Results
  
  
  
    + list_layer:LINKED_LIST[AI_LAYER];
  
  
    + current_list:LINKED_LIST[AI_OPERATION];
  
  
    + current_color:AI_COLOR;
  
  
  
 Grammar Rules
  
  
  
++ DOCUMENT          -> PROLOGUE
  
++                      SCRIPT  
  
    - read_document <-
      
  
++ PROLOGUE          -> '%!PS-Adobe-2.0 EPSF-1.2'
  
++                      [ comment ]
  
++                      '%%BoundingBox:'real real real real
  
++                      [ comment ]
  
++                      '%%EndProlog'  
  
    - read_prologue:BOOLEAN <-
    
  
++ SCRIPT            -> SETUP
  
++                      SCRIPT_BODY
  
++                      TRAILER  
  
    - read_script:BOOLEAN <-
    
  
++ SETUP             -> '%%BeginSetup'
  
++                      ['Adobe_illustrator_' real 'begin']
  
++                      [PROC_SETS_INIT]
  
++                      FONT_ENCODING
  
++                      [PATTERN_DEFS]
  
++                      '%%EndSetup'  
  
    - read_setup:BOOLEAN <-
    
  
++ PROC_SETS_INIT    -> { INITIALIZE }
  
    - read_proc_sets_init:BOOLEAN <-
    
  
++ INITIALIZE        -> identifier '/initialize get exec'
  
    - read_initialize:BOOLEAN <-
    
  
++ FONT_ENCODING     -> { RE_ENCODING }
  
    - read_font_encoding:BOOLEAN <-
    
  
++ RE_ENCODING       -> '%%BeginEncoding:' newfontname oldfontname
  
++                      Z
  
++                      '%%EndEncoding'
  
    - read_re_encoding:BOOLEAN <-
    
  
++ Z                 -> '['[NEW_ENCODING]']' '/' identifier '/' identifier integer 'Z'
  
    - read_upper_z:BOOLEAN <-
    
  
++ NEW_ENCODING      -> { integer '/' identifier { '/' identifier}}
  
    - read_new_encoding:BOOLEAN <-
    
  
++ PATTERN_DEFS      -> { PATTERN }
  
    - read_pattern_defs:BOOLEAN <-
    
  
++ PATTERN           -> '%%BeginPattern:' '('patternname')'
  
++                      E
  
++                      '%%EndPattern'
  
    - read_pattern:BOOLEAN <-
    
  
++ E                 -> '(' patternname ')' real real real real real [LAYER_LIST] 'E'
  
    - read_upper_e:BOOLEAN <-
    
  
++ LAYER_LIST        -> { LAYER_COLOR LAYER_TILE }
  
    - read_layer_list:BOOLEAN <-
    
  
++ LAYER_COLOR       -> '(' COLOR ')' '@'
  
    - read_layer_color:BOOLEAN <-
    
  
++ LAYER_TILE        -> '(' TILE_DEFINITION ')' '&' 
  
++                    | '_' '&'  
  
    - read_layer_tile:BOOLEAN <-
    
  
++ COLOR             -> COLOR_COMPOSITE { COLOR_COMPOSITE }
  
    - read_color:BOOLEAN <-
    
  
++ COLOR_COMPOSITE   -> flag 'O'
  
++                    | flag 'R'
  
++                    | real 'g' 
  
++                    | real 'G' 
  
++                    | real real real real 'k' 
  
++                    | real real real real 'K'  
  
++                    | real real real real '(' string ')' real 'x' 
  
++                    | real real real real '(' string ')' real 'X'   
  
    - read_color_composite:BOOLEAN <-
    
  
++ TILE_DEFINITION   -> OBJ_WITHOUT_COL
  
    - read_tile_definition:BOOLEAN <-
    
  
++ OBJECT            -> COLOR { OBJ_WITHOUT_COL }
  
    - read_object:BOOLEAN <-
    
  
++ OBJ_WITHOUT_COL   -> [ GRAPHICS_STATE ] { '%%Note:' comment } ( GRAPHIC | TEXT )   
  
    - read_obj_without_col:BOOLEAN <-
    
  
++ GRAPHICS_STATE    -> GRAPH_COMPOSITE { GRAPH_COMPOSITE } 
  
    - read_graphics_state:BOOLEAN <-
    
  
++ GRAPH_COMPOSITE   -> '[' { real } ']' integer 'd'
  
++                    | integer  ( 'j' | 'J' | 'M' ) 
  
++                    | real ( 'i' | 'w' )
  
    - read_graph_composite:BOOLEAN <-
    
  
++ GRAPHIC           -> PATH PAINT_OPERATOR
  
    - read_graphic:BOOLEAN <-
    
  
++ PATH              -> COORD 'm' {PATH_COMPOSITE}
  
    - read_path:BOOLEAN <-
    
  
++ PATH_COMPOSITE    -> COORD ( 'l' | 'L' )
  
++                    | COORD COORD ( 'v' | 'V' | 'y' | 'Y' )
  
++                    | COORD COORD COORD ( 'c' | 'C' )
  
    - read_path_composite:BOOLEAN <-
    
  
++ PAINT_OPERATOR    -> 'N' | 'n' | 'F' | 'f' | 'S' | 's' | 'B' | 'b' | 'H' | 'h' | 'W'
  
    - read_paint_operator:BOOLEAN <-
    
  
++ TEXT              -> '/' identifier real real real integer 'z' TEXT_COMPOSITE { TEXT_CONTENT } 'T'
  
    - read_text:BOOLEAN <-
    
  
++ TEXT_CONTENT      -> [ integer ] '(' string ')' 't' 
  
    - read_text_content:BOOLEAN <-
    
  
++ TEXT_COMPOSITE    -> '[' real real real real real real ']' ( 'a' | 'e' | 'I' | 'o' | 'r' )
  
    - read_text_composite:BOOLEAN <-
    
  
++ COORD             -> real real 
  
    - read_coord:BOOLEAN <-
    
  
++ SCRIPT_BODY       -> { ELEMENT | IMPORT_DOC }
  
    - read_script_body:BOOLEAN <-
    
  
++ ELEMENT           -> { A }
  
++                      GROUP | OBJECT
  
    - read_element:BOOLEAN <-
    
  
++ A                 -> flag 'A'
  
    - read_upper_a:BOOLEAN <-
    
  
++ GROUP             -> ['*'] 'u'
  
++                      OBJECT_SEQ
  
++                      ['*'] 'U'
  
++                    | 'q'
  
++                      OBJECT_SEQ
  
++                      'Q'
  
    - read_group:BOOLEAN <-
    
  
++ OBJECT_SEQ        -> { ELEMENT }
  
    - read_object_seq:BOOLEAN <-
    
  
++ IMPORT_DOC        -> '''
  
++                      '%%IncludeFile:' filename
  
++                      '~'
  
    - read_import_doc:BOOLEAN <-
    
  
++ TRAILER           -> '%%Trailer'
  
++                      { TERMINATE }
  
    - read_trailer:BOOLEAN <-
    
  
++ TERMINATE         -> (identifier '/terminate get exec' | '_E end')
  
    - read_terminate:BOOLEAN <-
    
  
  
 Parser
  
  
  
    - create s:FAST_ARRAY[CHARACTER] :SELF <-
    
  
    - make s:FAST_ARRAY[CHARACTER] <-
    
  
    - draw b:BITMAP scale coef:REAL_16_16 <-