source: icGREP/icgrep-devel/icgrep/printer_re.cpp @ 3994

Last change on this file since 3994 was 3984, checked in by cameron, 5 years ago

Eliminate INT2STRING in favor of std::to_string

File size: 2.9 KB
Line 
1/*
2 *  Copyright (c) 2014 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 "printer_re.h"
8
9
10std::string Printer_RE::PrintRE(RE* re)
11{
12    std::string retVal = "";
13
14    if (Alt* re_alt = dynamic_cast<Alt*>(re))
15    {
16        retVal += "(Alt[";
17
18        std::list<RE*>::iterator it;
19        for (it = re_alt->GetREList()->begin(); it != re_alt->GetREList()->end(); ++it)
20        {
21            retVal += PrintRE(*it) + ",";
22        }
23        retVal = retVal.substr(0, retVal.size() - 1);
24        retVal += "])";
25    }
26    else if (CC* re_cc = dynamic_cast<CC*>(re))
27    {
28        retVal += "CC \"";
29        retVal += re_cc->getName();
30        retVal += "\" ";
31
32        std::vector<CharSetItem> items = re_cc->getItems();
33        std::vector<CharSetItem>::iterator it;
34        for (it = items.begin(); it != items.end(); ++it)
35        {
36            retVal += "[";
37            retVal += std::to_string(it->lo_codepoint) + ",";
38            retVal += std::to_string(it->hi_codepoint);
39            retVal += "]";
40        }
41
42        //std::string member = (re_cc->is_member(47) ? "True" : "False");
43        //retVal += " is codepoint 47 a member: " + member;
44
45/*
46        retVal += "CC \"";
47        retVal += re_cc->getName();
48        retVal += "\" ";
49
50        retVal += " Removed: 100 ";
51        re_cc->remove1(100);
52        //re_cc->remove_range(40,50);
53
54        std::vector<CharSetItem> r_items = re_cc->getItems();
55        std::vector<CharSetItem>::iterator r_it;
56        for (r_it = r_items.begin(); r_it != r_items.end(); ++r_it)
57        {
58            retVal += "[";
59            retVal += std::to_string(r_it->lo_codepoint) + ",";
60            retVal += std::to_string(r_it->hi_codepoint);
61            retVal += "]";
62        }
63*/
64    }
65    else if (Name* re_name = dynamic_cast<Name*>(re))
66    {
67        retVal += "Name \"";
68        retVal += re_name->getName();
69        retVal += "\" ";
70    }
71    else if (End* re_end = dynamic_cast<End*>(re))
72    {
73        retVal += "End";
74    }
75    else if (Rep* re_rep = dynamic_cast<Rep*>(re))
76    {
77        retVal += "Rep("  + PrintRE(re_rep->getRE()) + "," + std::to_string(re_rep->getLB()) + ",";
78        retVal += (re_rep->getUB() == unboundedRep ? "Unbounded" : "UpperBound(" + std::to_string(re_rep->getUB()) + ")");
79    }
80    else if (Seq* re_seq = dynamic_cast<Seq*>(re))
81    {
82        retVal += "(Seq[";
83        std::list<RE*>::iterator it;
84        for (it = re_seq->GetREList()->begin(); it != re_seq->GetREList()->end(); ++it)
85        {
86            retVal += PrintRE(*it) + ",";
87        }
88        retVal = retVal.substr(0, retVal.size() - 1);
89        retVal += "])";
90    }
91    else if (Start* re_start = dynamic_cast<Start*>(re))
92    {
93        retVal += "Start";
94    }
95    else
96    {
97        retVal += "--> RE Unknown <--";
98    }
99
100    return retVal;
101}
Note: See TracBrowser for help on using the repository browser.