\documentclass[10pt]{article}
\usepackage{amsmath}


\begin{document}
\section{Inroduction}
 [ ... ]
\section{Objects types for Extension of Parser}

 We describe objects which we want to put in an extended version of Benchmark file format in the following table. The first column lists the nonterminal symbol. The second column lists grammar rules where several alternative choices are listed below each other. The third column gives a description of the object.

\begin{tabular}{|c|c|c|}  \hline Type & syntax & description  \\ \hline
\hline\hline
Circle\_2 & Circle\_2 (Point\_2,Rational) & Squered radius can be rational\\
\hline
CircularPoint\_2 &  CircularPoint\_2(Point\_2)     &\\
              &  CircularPoint\_2(AlgebraicReal,&\\
	      &  AlgebraicReal) 	     &\\
\hline
 CircularArc\_2  &  CircularArc\_2(Circle\_2) &  Constructs an arc from a full circle. \\
		 &CircularArc\_2(Circle\_2,	  &Circular\_arc\_2(Circle\_2 c,\\
		 &CircularPoint\_2,		  &CircularPoint p1,  \\
		 &CircularPoint\_2)		  &CircularPoint p2);Constructthe\\
		 &				  &linesegment supported by c, thatis \\
		 &				  &oriented counterclockwise, whose \\
		 &				  &source is p1 and whose target is p2.\\
		 &				  &Precondition: p1 and p2 lie on c.\\
	         &CircularArc\_2(Point\_2,      &Circular\_arc\_2(begin, end, bulge).\\
		 &Point\_2,			  &\\
		 &Rational) 			  &\\
\hline
 LineArc\_2  & LineArc\_2(LineSegment)        &\\
	       &  LineArc\_2(CircularPoint,	  &\\
	       &  CircularPoint)	          &\\
 	       & LineArc\_2(Point\_2, 	  &\\
	       &  Point\_2),          	          &\\

\hline
\end{tabular}

\section{Extention of the Parser}
  In following we describe necessary changes to add our new tokens and rules to the parser. First, we describe new Benchmark Visitor functions. Second, we explain how to make changes in Parser source to make possible parsing our new objects.
\subsection{New Benchmark Visitors functions}

In the following table are listed functions that do not exist in the Benchmark\_visitor class and must be added . The statements in curly braces \{...\} are function calls to the visitor. There are always a pair of functions that enclose the parsing parameters.
\\ 
\begin{tabular}{|c|c|}  \hline Object & grammar rule with visitor function  \\ \hline
\hline\hline 
Circle\_2 &Circle\_2\{begin\_circle\_2();\}\\
          &(Point\_2,Rational)\\
 	  &\{end\_circle\_2();\}\\
\hline
CircularPoint\_2 &CircularPoint\_2\{begin\_CircularPoint\_2();\}\\
		      &(Point\_2)\\
		      &\{end\_circular\_CircularPoint\_2();\}\\
		      &CircularPoint\_2\{begin\_CircularPoint\_2();\}\\
		      &(AlgebraicReal,AlgebraicReal)\\
		      &\{end\_circular\_CircularPoint\_2();\}\\

\hline

 CircularArc\_2    & CircularArc\_2 \{begin\_CircularArc\_2();\}\\
      		   &(Circle\_2)\\
                   &\{end\_CircularArc\_2();\}\\
		   & CircularArc\_2 \{begin\_CircularArc\_2();\}\\
      		   &(Circle\_2,CircularPoint\_2,CircularPoint\_2)\\
                   &\{end\_CircularArc\_2();\}\\
		   & CircularArc\_2\{begin\_CircularArc\_2();\}\\
      		   &(Point\_2,Point\_2,Rational)\\
                   &\{end\_CircularArc\_2();\}\\

\hline

LineArc\_2  &LineArc\_2\{begin\_LineArc\_2();\}\\
            &(LineSegment)\\
            &\{end\_LineArc\_2();\}\\\
	    &LineArc\_2\{begin\_LineArc\_2();\}\\
            &(CircularPoint\_2,CircularPoint\_2)\\
            &\{end\_LineArc\_2();\}\\
	    &LineArc\_2\{begin\_LineArc\_2();\}\\
            &(Point\_2,Point\_2)\\
            &\{end\_LineArc\_2();\}\\
 \hline
\end{tabular}

\subsection{Extending of Parser by new types}
Here we describe how to add new tokens and rules to the parser.
\subsubsection{Extend the Scanner in benchmark\_lexer.l}
First thing that is needed to extend parser is to put new tokens in section with Token in coments. It is looks  like this:

\begin{verbatim}
 /* Tokens    */
 /* --------- */
"FileFormat"                    { return FileFormat;}
"BenchmarkName"                 { return BenchmarkName; }
.......
\end{verbatim}

In the end of this section add these lines:

\begin{verbatim}
"CircularArc_2"              { return CircularArc_2;} 
"LineArc_2"                    { return LineArc_2;} 
"CircularPoint_2"          {return CircularPoint_2;} 
\end{verbatim}

The left string is representation in file format, the right word is its indentifier in the program code.
\subsubsection{Extended the Parser in benchmark\_parser.y}
 In a section with words Structure tokens in coments, which looks like this:

\begin{verbatim}
/* Structure tokens */
/* ---------------- */
%token FileFormat
%token BenchmarkName
%token Classification
....
\end{verbatim}
 add anywhere new lines with new tokens:
\begin{verbatim}
%token CircularArc_2
%token LineArc_2
%token CircularPoint_2

\end{verbatim}

Now go to Grammar section and add new rules. In the and of stmt block add new lines with rules:

\begin{verbatim}
  | CircularPoint_2                 {visitor->begin_CircularPoint_2();}
             '(' circular_arc_point ')'
                                        {visitor->end_CircularPoint_2();}
  | LineArc_2                          {visitor->begin_LineArc_2();}
              '(' line_arc_2 ')'
                                        {visitor->end_LineArc_2();}
  | CircularArc_2                      {visitor->begin_CircularArc_2();} 
               '('circular_arc_2 ')'
                                        { visitor->end_CircularArc_2();}
\end{verbatim}

And after stmt block add new lines with definition for circular\_arc\_point ; line\_arc\_2 ; circular\_arc\_2 :

\begin{verbatim}
circular_arc_point:
error_rules{}
 | point_2
 | AlgebraicReal, AlgebraicReal
;
line_arc_2:
error_rules {}
 | LineSegment
 | point_2 ',' point_2 
 | CircularPoint_2 '(' circular_arc_point ')' 
       ',' CircularPoint_2 '(' circular_arc_point ')'
;
circular_arc_2:
error_rules {}
 | Circle_2 '(' circle ')'
 | Circle_2 '(' circle ')' ',' CircularPoint_2 '(' circular_arc_point ')' 
       ',' CircularPoint_2 '(' circular_arc_point ')'
 | point_2 ',' point_2 ',' rational
;
\end{verbatim}

For add new rule for circle\_2 (Point\_2, Rational) change in stmt block this lines :

\begin{verbatim}
 | Circle_2                      { visitor->begin_circle_2(); } 
        '(' point_2 ',' INTEGER  { visitor->accept_integer( $6); } ')' 
                                 { visitor->end_circle_2(); } 
\end{verbatim}

By this :

\begin{verbatim}
 | Circle_2      		 { visitor->begin_circle_2(); } 
       '(' circle_2 ')'   	 { visitor->end_circle_2(); } 
\end{verbatim}

And add after stmt block this lines:

\begin{verbatim}
circle_2:
error_rules {}
|  point_2 ',' rational  
|  point_2 ',' INTEGER  { visitor->accept_integer($3); } 
\end{verbatim}

\subsection{extend the Visitor in benchmark\_visitor.h}
All what is needed for extending the Visitor is to add new virtual functions. It can be easyly made by addition
 of these lines in end of definition of benchmark\_visitor class :

\begin{verbatim}
    virtual void begin_CircularArc_2(){
        tnh("begin_CircularArc_2");
        }
    virtual void end_CircularArc_2(){
        tnh("end_CircularArc_2");
        }
   virtual void begin_LineArc_2(){
        tnh("begin_LineArc_2");
        }
    virtual void end_LineArc_2(){
        tnh("end_LineArc_2");
        }
   virtual void begin_CircularPoint_2(){
        tnh("begin_CircularPoint_2");
        }
    virtual void end_CircularPoint_2(){
        tnh("end_CircularPoint_2");
        }
\end{verbatim}

Congratulation! Now you have extended vertion of Parser of Benchmark File format. 
\end{document}