Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / docs / manual / cocci_syntax.tex
index ca65f89..82311bc 100644 (file)
@@ -217,6 +217,17 @@ considered C identifiers when encountered in the body of the rule.
 Identifiers in the body of the rule that are not declared explicitly are
 by default considered symbols, thus symbol declarations are optional.
 
+A position metavariable is used by attaching it using \texttt{@} to any
+token, including another metavariable.  Its value is the position (file,
+line number, etc.) of the code matched by the token.  It is also possible
+to attach expression, declaration, type, initialiser, and statement
+metavariables in this manner.  In that case, the metavariable is bound to
+the closest enclosing expression, declaration, etc.  If such a metavariable
+is itself followed by a position metavariable, the position metavariable
+applies to the metavariable that it follows, and not to the attached token.
+This makes it possible to get eg the starting and ending position of {\tt
+  f(...)}, by writing {\tt f(...)@E@p}, for expression metavariable {\tt E}
+and position metavariable {\tt p}.
 
 \begin{grammar}
   \RULE{\rt{ids}}