]>
Commit | Line | Data |
---|---|---|
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 | ||
21 | xpressive is an advanced, object-oriented regular expression template library for C++. | |
22 | Regular expressions can be written as strings that are parsed at run-time, or as expression | |
23 | templates that are parsed at compile-time. Regular expressions can refer to each other and | |
24 | to themselves recursively, allowing you to build arbitrarily complicated grammars out of | |
25 | them. | |
26 | ||
27 | [h2 Motivation] | |
28 | ||
29 | If you need to manipulate text in C++, you have typically had two disjoint options: a regular | |
30 | expression engine or a parser generator. Regular expression engines (like _regexpp_) are powerful | |
31 | and flexible; patterns are represented as strings which can be specified at runtime. However, | |
32 | that means that syntax errors are likewise not detected until runtime. Also, regular expressions | |
33 | are ill-suited to advanced text processing tasks such as matching balanced, nested tags. Those | |
34 | tasks have traditionally been handled by parser generators (like the _spirit_fx_). These | |
35 | beasts are more powerful but less flexible. They generally don't allow you to arbitrarily modify | |
36 | your grammar rules on the fly. In addition, they don't have the exhaustive backtracking semantics | |
37 | of regular expressions, which can make it more challenging to author some types of patterns. | |
38 | ||
39 | xpressive brings these two approaches seamlessly together and occupies a unique niche in the | |
40 | world 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_, | |
42 | writing your regexes as C++ expressions, enjoying all the benefits of an embedded language | |
43 | dedicated to text manipulation. What's more, you can mix the two to get the benefits of | |
44 | both, writing regular expression ['grammars] in which some of the regular expressions are | |
45 | statically bound -- hard-coded and syntax\-checked by the compiler \-- and others are dynamically | |
46 | bound and specified at runtime. These regular expressions can refer to each other recursively, | |
47 | matching patterns in strings that ordinary regular expressions cannot. | |
48 | ||
49 | [h2 Influences and Related Work] | |
50 | ||
51 | The design of xpressive's interface has been strongly influenced by John Maddock's | |
52 | _regexpp_ library and his _proposal_ | |
53 | to add regular expressions to the Standard Library. I also drew a great deal of | |
54 | inspiration from Joel de Guzman's _spirit_fx_, which served as the model | |
55 | for 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] |