The SmPL Grammar (version 1.0.4 )

# The SmPL Grammar (version 1.0.4 ) ### Research group on Coccinelle ### March 31, 2018

This document presents the grammar of the SmPL language used by the 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 arguments. The grammar also uses some unspecified nonterminals, such as id, const, etc. These refer to the sets suggested by the name, i.e., id refers to the set of possible C-language identifiers, while const refers to the set of possible C-language constants.

A square bracket that is surrounded by spaces in the description of a term should appear explicitly in the term, as in an array reference. On the other hand, square brackets that surround some other term indicat that the presence of that term is optional.

A PDF version of this documentation is available at http://coccinelle.lip6.fr/docs/main_grammar.pdf.

- Program
- Metavariables for transformations
- Metavariables for scripts
- Transformation
- Types
- Function declarations
- Declarations
- Statements
- Expressions
- Constants, Identifiers and Types for Transformations
- Comments and preprocessor directives
- Command-line semantic match
- Iteration
- Examples
  - Function renaming
  - Removing a function argument
  - Introduction of a macro
  - Look for NULL dereference
  - Reference counter: the of_xxx API
  - Filtering identifiers, declarers or iterators with regular expressions
- Tips and Tricks
  - How to remove useless parentheses?

> This document was translated from LATEX by HEVEA.