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

Last change on this file since 6104 was 5998, checked in by nmedfort, 16 months ago

Added temporary buffer functionality to the pipeline for single stream source buffers. Fixed memory leak from UCD::UnicodeBreakRE()

File size: 1.7 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_utility.h"
8#include <re/re_any.h>
9#include <re/re_name.h>
10#include <re/re_alt.h>
11#include <re/re_seq.h>
12#include <re/re_diff.h>
13#include <re/re_assertion.h>
14
15namespace re {
16   
17RE * makeComplement(RE * s) {
18  return makeDiff(makeAny(), s);
19}
20
21                           
22Name * makeDigitSet() {
23    return makeName("nd", Name::Type::UnicodeProperty);
24}
25
26Name * makeAlphaNumeric() {
27    return makeName("alnum", Name::Type::UnicodeProperty);
28}
29
30Name * makeWhitespaceSet() {
31    return makeName("whitespace", Name::Type::UnicodeProperty);
32}
33
34Name * makeWordSet() {
35    return makeName("word", Name::Type::UnicodeProperty);
36}
37
38RE * makeWordBoundary() {
39    Name * wordC = makeWordSet();
40    return makeAlt({makeSeq({makeNegativeLookBehindAssertion(wordC), makeLookAheadAssertion(wordC)}),
41        makeSeq({makeLookBehindAssertion(wordC), makeNegativeLookAheadAssertion(wordC)})});
42}
43
44RE * makeWordNonBoundary() {
45    Name * wordC = makeWordSet();
46    return makeAlt({makeSeq({makeNegativeLookBehindAssertion(wordC), makeNegativeLookAheadAssertion(wordC)}),
47        makeSeq({makeLookBehindAssertion(wordC), makeLookAheadAssertion(wordC)})});
48}
49
50RE * makeWordBegin() {
51    Name * wordC = makeWordSet();
52    return makeNegativeLookBehindAssertion(wordC);
53}
54
55RE * makeWordEnd() {
56    Name * wordC = makeWordSet();
57    return makeNegativeLookAheadAssertion(wordC);
58}
59
60RE * makeUnicodeBreak() {
61    return makeAlt({makeCC(0x0A, 0x0C), makeCC(0x85), makeCC(0x2028,0x2029), makeSeq({makeCC(0x0D), makeNegativeLookAheadAssertion(makeCC(0x0A))})});
62}
63   
64}
Note: See TracBrowser for help on using the repository browser.