Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Users' Guide

Getting Started
Installing Proto
Naming Conventions
Hello World
Hello Calculator
Fronts Ends: Defining Terminals and Non-Terminals of Your EDSL
Making Terminals
Proto's Operator Overloads
Making Lazy Functions
Customizing Expressions in Your Domain
Domains
The extends<> Expression Wrapper
Expression Generators
Controlling Operator Overloads
Controlling How Child Expressions Are Captured
EDSL Interoperatability: Sub-Domains
Adapting Existing Types to Proto
Generating Repetitive Code with the Preprocessor
Intermediate Form: Understanding and Introspecting Expressions
Accessing Parts of an Expression
Deep-copying Expressions
Debugging Expressions
Operator Tags and Metafunctions
Expressions as Fusion Sequences
Expression Introspection: Defining a Grammar
Finding Patterns in Expressions
Fuzzy and Exact Matches of Terminals
if_<>, and_<>, and not_<>
Improving Compile Times With switch_<>
Matching Vararg Expressions
Defining EDSL Grammars
Back Ends: Making Expression Templates Do Useful Work
Expression Evaluation: Imparting Behaviors with a Context
Evaluating an Expression with proto::eval()
Defining an Evaluation Context
Proto's Built-In Contexts
default_context
null_context
callable_context<>
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
Examples
Hello World: Building an Expression Template and Evaluating It
Calc1: Defining an Evaluation Context
Calc2: Adding Members Using proto::extends<>
Calc3: Defining a Simple Transform
Lazy Vector: Controlling Operator Overloads
RGB: Type Manipulations with Proto Transforms
TArray: A Simple Linear Algebra Library
Vec3: Computing With Transforms and Contexts
Vector: Adapting a Non-Proto Terminal Type
Mixed: Adapting Several Non-Proto Terminal Types
Map Assign: An Intermediate Transform
Future Group: A More Advanced Transform
Lambda: A Simple Lambda Library with Proto
Checked Calculator: A Simple Example of External Transforms
Background and Resources
Glossary

Compilers, Compiler Construction Toolkits, and Proto

Most compilers have front ends and back ends. The front end parses the text of an input program into some intermediate form like an abstract syntax tree, and the back end takes the intermediate form and generates an executable from it.

A library built with Proto is essentially a compiler for an embedded domain-specific language (EDSL). It also has a front end, an intermediate form, and a back end. The front end is comprised of the symbols (a.k.a., terminals), members, operators and functions that make up the user-visible aspects of the EDSL. The back end is made of evaluation contexts and transforms that give meaning and behavior to the expression templates generated by the front end. In between is the intermediate form: the expression template itself, which is an abstract syntax tree in a very real sense.

To build a library with Proto, you will first decide what your interface will be; that is, you'll design a programming language for your domain and build the front end with tools provided by Proto. Then you'll design the back end by writing evaluation contexts and/or transforms that accept expression templates and do interesting things with them.

This users' guide is organized as follows. After a Getting Started guide, we'll cover the tools Proto provides for defining and manipulating the three major parts of a compiler:

Front Ends

How to define the aspects of your EDSL with which your users will interact directly.

Intermediate Form

What Proto expression templates look like, how to discover their structure and access their constituents.

Back Ends

How to define evaluation contexts and transforms that make expression templates do interesting things.

After that, you may be interested in seeing some Examples to get a better idea of how the pieces all fit together.


PrevUpHomeNext