]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/xpressive/doc/preface.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / xpressive / doc / preface.qbk
CommitLineData
7c673cae
FG
1[/
2 / Copyright (c) 2008 Eric Niebler
3 /
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 /]
7
8[section Preface]
9
10[:['Wife:] New Shimmer is a floor wax!\n
11 ['Husband:] No, new Shimmer is a dessert topping!\n
12 ['Wife:] It's a floor wax!\n
13 ['Husband:] It's a dessert topping!\n
14 ['Wife:] It's a floor wax, I'm telling you!\n
15 ['Husband:] It's a dessert topping, you cow!\n
16 ['Announcer:] Hey, hey, hey, calm down, you two. New Shimmer is both a floor wax ['and] a dessert topping!]
17[:[*['-- Saturday Night Live]]]
18
19[h2 Description]
20
21xpressive is an advanced, object-oriented regular expression template library for C++.
22Regular expressions can be written as strings that are parsed at run-time, or as expression
23templates that are parsed at compile-time. Regular expressions can refer to each other and
24to themselves recursively, allowing you to build arbitrarily complicated grammars out of
25them.
26
27[h2 Motivation]
28
29If you need to manipulate text in C++, you have typically had two disjoint options: a regular
30expression engine or a parser generator. Regular expression engines (like _regexpp_) are powerful
31and flexible; patterns are represented as strings which can be specified at runtime. However,
32that means that syntax errors are likewise not detected until runtime. Also, regular expressions
33are ill-suited to advanced text processing tasks such as matching balanced, nested tags. Those
34tasks have traditionally been handled by parser generators (like the _spirit_fx_). These
35beasts are more powerful but less flexible. They generally don't allow you to arbitrarily modify
36your grammar rules on the fly. In addition, they don't have the exhaustive backtracking semantics
37of regular expressions, which can make it more challenging to author some types of patterns.
38
39xpressive brings these two approaches seamlessly together and occupies a unique niche in the
40world of C++ text processing. With xpressive, you can choose to use it much as you would use
41_regexpp_, representing regular expressions as strings. Or you can use it as you would use _spirit_,
42writing your regexes as C++ expressions, enjoying all the benefits of an embedded language
43dedicated to text manipulation. What's more, you can mix the two to get the benefits of
44both, writing regular expression ['grammars] in which some of the regular expressions are
45statically bound -- hard-coded and syntax\-checked by the compiler \-- and others are dynamically
46bound and specified at runtime. These regular expressions can refer to each other recursively,
47matching patterns in strings that ordinary regular expressions cannot.
48
49[h2 Influences and Related Work]
50
51The design of xpressive's interface has been strongly influenced by John Maddock's
52_regexpp_ library and his _proposal_
53to add regular expressions to the Standard Library. I also drew a great deal of
54inspiration from Joel de Guzman's _spirit_fx_, which served as the model
55for static xpressive. Other sources of inspiration are the _perl6_ redesign and _greta_.
56(You can read a summary of the changes Perl 6 will bring to regex culture
57[@http://dev.perl.org/perl6/doc/design/syn/S05.html here].)
58
59[endsect]