source: icGREP/icgrep-devel/icgrep/cc_compiler.h @ 4197

Last change on this file since 4197 was 4197, checked in by nmedfort, 5 years ago

More refactoring of the RE system; moved the original re/RE_Compiler to compiler.cpp and the PBIX_Compiler to the re/RE_Compiler.

File size: 1.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#ifndef CC_COMPILER_H
8#define CC_COMPILER_H
9
10#include <string>
11#include <list>
12#include <map>
13#include "utf_encoding.h"
14#include "ps_pablos.h"
15#include "pe_pabloe.h"
16#include "re/re_cc.h"
17
18struct Expression{
19    std::string expr_string;
20    PabloE* pablo_expr;
21};
22
23class CC_Compiler{
24    typedef std::map<std::string, re::RE*>      REMap;
25    typedef std::map<std::string, Expression*>  ExpressionMap;
26    typedef ExpressionMap::iterator             MapIterator;
27
28public:
29    CC_Compiler(const UTF_Encoding encoding, const std::string basis_pattern, const std::string gensym_pattern);
30    std::string compile1(re::CC* cc);
31    void compile_from_map(const REMap & re_map);
32    std::list<PabloS*> get_compiled();
33private:
34    void process_re_map(const REMap &re_map);
35    void process_re(const re::RE *re);
36    std::string bit_var(int n);
37    PabloE* make_bitv(int n);
38    PabloE* bit_pattern_expr(int pattern, int selected_bits);
39    PabloE* char_test_expr(const re::CodePointType ch);
40    PabloE* make_range(const re::CodePointType n1, const re::CodePointType n2);
41    PabloE* GE_Range(int N, int n);
42    PabloE* LE_Range(int N, int n);
43    PabloE* char_or_range_expr(const re::CodePointType lo, const re::CodePointType hi);
44    PabloE* charset_expr(const re::CC *cc);
45    Expression* expr2pabloe(PabloE* expr);
46    void cc2pablos(const re::CC *cc);
47
48    UTF_Encoding mEncoding;
49
50    void add_predefined(std::string key_value, Expression *mapped_value);
51    Expression* add_assignment(std::string value, Expression* expr);
52    Expression* expr_to_variable(Expression* cgo);
53
54    std::string mGenSym_Template;
55    int mGenSymCounter;
56    std::list<PabloS*> mStmtsl;
57    ExpressionMap mCommon_Expression_Map;
58};
59
60#endif // CC_COMPILER_H
61
62
Note: See TracBrowser for help on using the repository browser.