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

Last change on this file since 6170 was 6170, checked in by cameron, 13 months ago

RE Transformation names and printing

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