% our implementation using the Menhir parser generator \cite{menhir}.
This document presents the grammar of the SmPL language used by the
-\href{http://www.emn.fr/x-info/coccinelle}{Coccinelle tool}. For the most
+\href{http://coccinelle.lip6.fr/}{Coccinelle tool}. For the most
part, the grammar is written using standard notation. In some rules,
however, the left-hand side is in all uppercase letters. These are
macros, which take one or more grammar rule right-hand-sides as
as \T{id}, \T{const}, etc. These refer to the sets suggested by
the name, {\em i.e.}, \T{id} refers to the set of possible
C-language identifiers, while \T{const} refers to the set of
-possible C-language constants.
+possible C-language constants.
%
-\ifhevea
+\ifhevea
A PDF version of this documentation is available at
-\url{http://www.emn.fr/x-info/coccinelle/docs/cocci_syntax.pdf}.
+\url{http://coccinelle.lip6.fr/docs/main_grammar.pdf}.
\else
A HTML version of this documentation is available online at
-\url{http://www.emn.fr/x-info/coccinelle/docs/cocci_syntax.html}.
+\url{http://coccinelle.lip6.fr/docs/main_grammar.html}.
\fi
-%% \ifhevea A PDF
-%% version of this documentation is available at
-%% \url{http://localhost:8080/coccinelle/cocci_syntax.pdf}.\else A HTML
-%% version of this documentation is available online at
-%% \url{http://localhost:8080/coccinelle/cocci_syntax.html}. \fi
-
\section{Program}
\begin{grammar}
\noindent
\T{script\_code} is any code in the chosen scripting language. Parsing of
the semantic patch does not check the validity of this code; any errors are
-first detected when the code is executed.
+first detected when the code is executed. Furthermore, \texttt{@} should
+not be use in this code. Spatch scans the script code for the next
+\texttt{@} and considers that to be the beginning of the next rule, even if
+\texttt{@} occurs within e.g., a string or a comment.
% Between the metavariables and the transformation rule, there can be a
% specification of constraints on the names of the old and new files,
\begin{grammar}
\RULE{\rt{metadecl}}
\CASE{fresh identifier \NT{ids} ;}
+ \CASE{identifier \NT{COMMA\_LIST}\mth{(}\NT{pmid\_with\_regexp}\mth{)} ;}
\CASE{identifier \NT{COMMA\_LIST}\mth{(}\NT{pmid\_with\_not\_eq}\mth{)} ;}
\CASE{parameter \opt{list} \NT{ids} ;}
\CASE{parameter list [ \NT{id} ] \NT{ids} ;}
\CASE{typedef \NT{ids} ;}
\CASE{declarer name \NT{ids} ;}
% \CASE{\opt{local} function \NT{pmid\_with\_not\_eq\_list} ;}
+ \CASE{declarer \NT{COMMA\_LIST}\mth{(}\NT{pmid\_with\_regexp}\mth{)} ;}
\CASE{declarer \NT{COMMA\_LIST}\mth{(}\NT{pmid\_with\_not\_eq}\mth{)} ;}
\CASE{iterator name \NT{ids} ;}
+ \CASE{iterator \NT{COMMA\_LIST}\mth{(}\NT{pmid\_with\_regexp}\mth{)} ;}
\CASE{iterator \NT{COMMA\_LIST}\mth{(}\NT{pmid\_with\_not\_eq}\mth{)} ;}
% \CASE{error \NT{pmid\_with\_not\_eq\_list} ; }
\CASE{\opt{local} idexpression \opt{\NT{ctype}} \NT{COMMA\_LIST}\mth{(}\NT{pmid\_with\_not\_eq}\mth{)} ;}
\RULE{\rt{mid}} \CASE{\T{rulename\_id}.\T{id}}
+ \RULE{\rt{pmid\_with\_regexp}}
+ \CASE{\NT{pmid} \~{}= \NT{regexp}}
+
\RULE{\rt{pmid\_with\_not\_eq}}
\CASE{\NT{pmid} \OPT{!= \T{id}}}
\CASE{\NT{pmid} \OPT{!= \ttlb~\NT{COMMA\_LIST}\mth{(}\T{id}\mth{)} \ttrb}}
\RULE{\rt{pathToIsoFile}}
\CASE{<.*>}
+
+ \RULE{\rt{regexp}}
+ \CASE{"\any{[\^{}"]}"}
\end{grammar}