source: icGREP/icgrep-devel/icgrep/re/re_utility.cpp @ 5217

Last change on this file since 5217 was 5197, checked in by cameron, 3 years ago

Support for -x, -w, -l, -L flags (in progress)

File size: 1.6 KB
Line 
1/*
2 *  Copyright (c) 2016 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include <re/re_any.h>
8#include <re/re_name.h>
9#include <re/re_alt.h>
10#include <re/re_seq.h>
11#include <re/re_start.h>
12#include <re/re_end.h>
13#include <re/re_diff.h>
14#include <re/re_assertion.h>
15
16namespace re {
17   
18RE * makeComplement(RE * s) {
19  return makeDiff(makeAny(), s);
20}
21
22                           
23Name * makeDigitSet() {
24    return makeName("nd", Name::Type::UnicodeProperty);
25}
26
27Name * makeAlphaNumeric() {
28    return makeName("alnum", Name::Type::UnicodeProperty);
29}
30
31Name * makeWhitespaceSet() {
32    return makeName("whitespace", Name::Type::UnicodeProperty);
33}
34
35Name * makeWordSet() {
36    return makeName("word", Name::Type::UnicodeProperty);
37}
38
39RE * makeWordBoundary() {
40    Name * wordC = makeWordSet();
41    return makeAlt({makeSeq({makeNegativeLookBehindAssertion(wordC), makeLookAheadAssertion(wordC)}),
42        makeSeq({makeLookBehindAssertion(wordC), makeNegativeLookAheadAssertion(wordC)})});
43}
44
45RE * makeWordNonBoundary() {
46    Name * wordC = makeWordSet();
47    return makeAlt({makeSeq({makeNegativeLookBehindAssertion(wordC), makeNegativeLookAheadAssertion(wordC)}),
48        makeSeq({makeLookBehindAssertion(wordC), makeLookAheadAssertion(wordC)})});
49}
50
51RE * makeWordBegin() {
52    Name * wordC = makeWordSet();
53    return makeNegativeLookBehindAssertion(wordC);
54}
55
56RE * makeWordEnd() {
57    Name * wordC = makeWordSet();
58    return makeNegativeLookAheadAssertion(wordC);
59}
60
61   
62}
Note: See TracBrowser for help on using the repository browser.