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

Last change on this file since 4133 was 4132, checked in by cameron, 5 years ago

Restructure - collapse cc_codegenobject into cc_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 "pe_sel.h"
17#include "pe_advance.h"
18#include "pe_all.h"
19#include "pe_and.h"
20#include "pe_charclass.h"
21#include "pe_matchstar.h"
22#include "pe_not.h"
23#include "pe_or.h"
24#include "pe_var.h"
25#include "pe_xor.h"
26#include "re_cc.h"
27
28struct Expression{
29    std::string expr_string;
30    PabloE* pablo_expr;
31};
32
33
34class CC_Compiler
35{
36public:
37    CC_Compiler(const UTF_Encoding encoding, const std::string basis_pattern, const std::string gensym_pattern);
38    std::string compile1(CC* cc);   
39    void compile_from_map(const std::map<std::string, RE*>& re_map);   
40    std::list<PabloS*> get_compiled();
41private:
42    void process_re_map(const std::map<std::string, RE*>& re_map);
43    void process_re(RE* re);
44    std::string bit_var(int n);
45    PabloE* make_bitv(int n);
46    PabloE* bit_pattern_expr(int pattern, int selected_bits);
47    PabloE* char_test_expr(int ch);
48    PabloE* make_range(int n1, int n2);
49    PabloE* GE_Range(int N, int n);
50    PabloE* LE_Range(int N, int n);
51    PabloE* char_or_range_expr(CharSetItem charset_item);
52    PabloE* charset_expr(CC* cc);
53    Expression* expr2pabloe(PabloE* expr);
54    void cc2pablos(CC* cc);
55
56    UTF_Encoding mEncoding;
57
58
59    void add_predefined(std::string key_value, Expression *mapped_value);
60    Expression* add_assignment(std::string value, Expression* expr);
61    Expression* expr_to_variable(Expression* cgo);
62
63    std::string mGenSym_Template;
64    int mGenSymCounter;
65    std::list<PabloS*> mStmtsl;
66    std::map<std::string, Expression*> mCommon_Expression_Map;
67};
68
69#endif // CC_COMPILER_H
70
71
Note: See TracBrowser for help on using the repository browser.