source: icGREP/icgrep-devel/icgrep/re/re_utility.h @ 6160

Last change on this file since 6160 was 6160, checked in by cameron, 9 months ago

Generic RE_Transformer

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#ifndef RE_UTILITY_H
8#define RE_UTILITY_H
9
10namespace re { class RE; }
11namespace re { class Name; class Start; class End; class CC; class Seq; class Alt;
12               class Rep; class Intersect; class Diff; class Range; class Group;
13               class Assertion;
14}
15
16namespace re {
17
18RE * makeComplement(RE * s);
19RE * makeWordBoundary();
20RE * makeWordNonBoundary();
21RE * makeWordBegin();
22RE * makeWordEnd();
23Name * makeDigitSet();
24Name * makeAlphaNumeric();
25Name * makeWhitespaceSet();
26Name * makeWordSet();
27RE * makeUnicodeBreak();
28
29void UndefinedNameError (const Name * n);
30
31enum class NameTransformationMode {None, TransformDefinition};
32
33class RE_Transformer {
34public:
35    RE_Transformer(NameTransformationMode m = NameTransformationMode::None) : mNameTransform(m) {}
36    RE * transform(RE * r);
37    virtual RE * transformName(Name * n);
38    virtual RE * transformStart(Start * s);
39    virtual RE * transformEnd(End * e);
40    virtual RE * transformCC(CC * cc);
41    virtual RE * transformSeq(Seq * s);
42    virtual RE * transformAlt(Alt * a);
43    virtual RE * transformRep(Rep * rep);
44    virtual RE * transformIntersect(Intersect * e);
45    virtual RE * transformDiff(Diff * d);
46    virtual RE * transformRange(Range * rg);
47    virtual RE * transformGroup(Group * g);
48    virtual RE * transformAssertion(Assertion * a);
49protected:
50    NameTransformationMode mNameTransform;
51};
52
53}
54#endif // RE_UTILITY_H
Note: See TracBrowser for help on using the repository browser.