Introduction to grammars --
A fragment defining the X-Axis of a data graph

 

Below we briefly discuss a fragment of the full x,y graph grammar dealing with the X-Axis structure highlighted in the previous example. The fragment consists of three productions. The full grammar is also available for browsing. After looking over this fragment, you can proceed to the discussion of how the grammar rules drive the parsing process.

The overall structure of this grammar fragment is:

The grammar fragment:


;;; ****************** < Image > ******************

   ( Image -> Set ( Diagram ) );


;;; ****************** < Diagram > ******************

   ( Diagram -> Axis  X-Axis  Y-Axis  Data
      (Axis)
      (X-Axis   ($ :axis Axis))
      (Y-Axis   ($ :axis Axis))
      (Data     
       ($ (difference*  (contain Axis '?) 
                        (union* X-Axis Y-Axis))
          :x-ln (ln (X-Line Axis))
          :y-ln (ln (Y-Line Axis))
          :axis Axis)) );

      
;;; ******************  < X-AXIS >  ******************

    ( X-Axis -> X-Axis-Line   X-Ticks   X-Labels  X-Annotation   X-Text
       (:optional X-Annotation X-Text)
       (X-Axis-Line  (X-Line (get-val axis)))
       (X-Ticks      ($ :x-line X-Axis-Line)  :constraints (>= (size X-Ticks) 3))
       (X-Labels     (below '? X-Axis-Line :strip t))
       (X-Annotation (difference* (near X-Axis-Line 700) (union* X-Ticks X-Labels))) ; label-size
       (X-Text       (near&below '? X-Labels (* 2 (height X-Labels)))
                                  ) )

 

Next: How the Grammar Rules Drive the Parsing Process

Back to Index page