![]() |
Home | Libraries | People | FAQ | More |
Copyright c 2008 Eric Niebler
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Table of Contents 目錄
「There are more things in heaven and earth, Horatio, than are dreamt of in your philosophy.」
-- William Shakespeare
Proto is a framework for building Domain Specific Embedded Languages in C++.
It provides tools for constructing, type-checking, transforming and executing
expression templates
[2]
. More specifically, Proto provides:
Proto 是一個在C++中構建專用領域嵌入式語言的框架。它提供了構造、類型檢查、轉化和執行 表達式模板[2]
的工具。具體地說,Proto 提供了:
Expression Templates are an advanced technique that C++ library developers
use to define embedded mini-languages that target specific problem domains.
The technique has been used to create efficient and easy-to-use libraries for
linear algebra as well as to define C++ parser generators with a readable syntax.
But developing such a library involves writing an inordinate amount of unreadable
and unmaintainable template mumbo-jumbo. Boost.Proto eases the development
of domain-specific embedded
languages (DSELs). Use Proto to define the primitives of your mini-language
and let Proto handle the operator overloading and the construction of the expression
parse tree. Immediately evaluate the expression tree by passing it a function
object. Or transform the expression tree by defining the grammar of your mini-language,
decorated with an assortment of tree transforms provided by Proto or defined
by you. Then use the grammar to give your users short and readable syntax errors
for invalid expressions! No more mumbo-jumbo -- an expression template library
developed with Proto is declarative and readable.
表
達式模板是一種高級技術,C++庫開發者所使用它來定義以某個特定問題域為目標的嵌入式小型語言。該技術已被用於創建高效且易用的線性代數庫,還被用於以
可讀的語法來定義 C++ 分析器的生成器。但是,開發這樣一個庫需要編寫大量難以閱讀且難以維護的模板。Boost.Proto 使得 專用領域嵌入式語言(DSELs)
的開發變得容易。使用 Proto 來定義你的小型語言的基本組件,並讓 Proto
處理操作符的重載和表達式分析樹的構造。通過將表達式樹傳遞給一個函數對象,可以立即對它進行求值。或者通過定義定義你的小型語言的語法,再以由
Proto
所提供的或由你定義的各種各樣的樹變換操作來對表達式樹進行變換。然後,使用該語法給你的用戶帶來對無效表達式的簡短易讀的語法錯誤提示!沒有更多的繁文
縟節了 -- 用 Proto 開發出來的表達式模板庫是具有宣示性和可讀性的。
In short, Proto is a DSEL for defining DSELs.
簡而言之,Proto 是一個用於定義 DSELs 的 DSEL。
This documentation makes use of the following naming and formatting conventions.
本文檔使用了以下命名約定和格式約定。
fixed width
font and is syntax-highlighted.fixed width
font 並具有語法高亮。
italics
.
italics 。
free_function();
that is, it is in code font and its name is followed by ()
to indicate that it is a free function.free_function(); 即採用代碼的字體並在名字後跟 ()
以表示它是一個普通函數。
class_template<>;
that is, it is in code font and its name is followed by <>
to indicate that it is a class template.class_template<>;
即採用代碼的字體並在名字後跟 <> 以表示它是一個類模板。
MACRO();
that is, it is uppercase in code font and its name is followed by () to indicate that it is a function-like
macro. Object-like macros appear without the trailing ().MACRO();
即採用代碼字體的大寫並在名字後跟 () 以表示它是一個類似於函數的宏。類似於對象的宏則沒有後面的 ()。
![]() |
Note 備註 |
|---|---|
In addition, notes such as this one specify non-essential information that provides additional background or rationale. 此外,像這樣的備註則用於指定非必要的信息,以提供額外的背景或原理的說明。 |
Finally, you can mentally add the following to any code fragments in this document:
最後,在本文檔中的所有代碼片斷中,你都可以認為已經增加了以下代碼:
// Include all of Proto
#include <boost/proto/proto.hpp> // Create some namespace aliases
namespace mpl = boost::mpl; namespace fusion = boost::fusion; namespace proto = boost::proto; // Allow unqualified use of Proto's wildcard pattern
using proto::_;
Last revised: November 02, 2008 at 13:06:54 GMT |