Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/xpressive/doc/preface.qbk @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

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