next up previous contents
Next: SUMMARY Up: AVAILABLE TECHNOLOGIES Previous: High level vs Low   Contents

Spirit

The description of spirit from it's home page (http://spirit.sourceforge.net) is ``Spirit is an object oriented recursive descent parser generator framework implemented using template meta-programming techniques''.

It allows EBNF grammars to be defined using only C++.

Figure 2.13: Example EBNF grammar
\begin{figure}{\centering\( \begin{array}{l}
\begin{array}{ccccc}
group & ::= & ...
...\vert & ('-' & expr2))^{\star }
\end{array}\end{array} \)\par }
\par\end{figure}

Aside from a changes to the representation to allow for the syntax of C++, the two grammars in figures 2.13 and 2.14 are identical. Since it is not possible to separate variables using only whitespace, the symbol \( \gg \) is introduced, and the normal kleene star representation cannot be allowed so the \( ^{\star } \) is moved to the start of the expression it denotes rather than at the end.

Figure 2.14: Example EBNF grammar using spirit's facilities
\begin{figure}\begin{displaymath}
\begin{array}{l}
\begin{array}{ccccccc}
group ...
... & ('-' & \gg & expr2));
\end{array}\end{array}\end{displaymath}\par\end{figure}

Spirit does not allow parsing techniques other than top-down, recursive descent to be developed in C++, as the amount of recursion and tail-recursion that occurs with other parsing algorithms is far from easy to implement with an imperative language, especially with the complexities backtracking adds.


next up previous contents
Next: SUMMARY Up: AVAILABLE TECHNOLOGIES Previous: High level vs Low   Contents
Andrew P Coates (UG) 2002-07-17