Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Expression Transformation: Semantic Actions

Activating Your Grammars
Handling Alternation and Recursion
Callable Transforms
Object Transforms
Example: Calculator Arity
Transforms With State Accumulation
Passing Auxiliary Data to Transforms
Implicit Parameters to Primitive Transforms
Unpacking Expressions
Separating Grammars And Transforms
Proto's Built-In Transforms
Building Custom Primitive Transforms
Making Your Transform Callable

If you have ever built a parser with the help of a tool like Antlr, yacc or Boost.Spirit, you might be familiar with semantic actions. In addition to allowing you to define the grammar of the language recognized by the parser, these tools let you embed code within your grammar that executes when parts of the grammar participate in a parse. Proto has the equivalent of semantic actions. They are called transforms. This section describes how to embed transforms within your Proto grammars, turning your grammars into function objects that can manipulate or evaluate expressions in powerful ways.

Proto transforms are an advanced topic. We'll take it slow, using examples to illustrate the key concepts, starting simple.


PrevUpHomeNext