source: icGREP/icgrep-devel/icgrep/re_parser.h @ 4132

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

Restructure - collapse cc_codegenobject into cc_compiler

File size: 2.6 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 RE_PARSER_H
8#define RE_PARSER_H
9
10#include "re_re.h"
11#include "re_alt.h"
12#include "re_cc.h"
13#include "re_name.h"
14#include "re_end.h"
15#include "re_rep.h"
16#include "re_seq.h"
17#include "re_start.h"
18#include "parseresult.h"
19#include "parsesuccess.h"
20#include "parsefailure.h"
21
22#include <fstream>
23#include <iostream>
24#include <string>
25#include <sstream>
26#include <vector>
27#include <ctype.h>
28
29
30struct parse_int_retVal{
31    int i;
32    std::string remaining;
33};
34
35struct parse_result_retVal{
36    ParseResult* result;
37    std::string remaining;
38};
39
40struct parse_re_list_retVal{
41    std::list<RE*> re_list;
42    std::string remaining;
43};
44
45struct parse_re_vector_retVal{
46    std::vector<RE*> re_vector;
47    std::string remaining;
48};
49
50class RE_Parser
51{
52public:
53    //RE_Parser();
54    //The module exports the parse result.
55    static ParseResult* parse_re(std::string intput_string);
56private:
57    static parse_result_retVal parse_re_helper(std::string s);
58    static parse_re_list_retVal parse_re_alt_form_list(std::string s);
59    static parse_result_retVal parse_re_form(std::string s);
60    static parse_re_list_retVal parse_re_item_list(std::string s);
61    static parse_result_retVal parse_re_item(std::string s);
62    static parse_result_retVal parse_re_unit(std::string s);
63    static parse_result_retVal extend_item(RE* re, std::string s);
64    static parse_result_retVal parse_cc(std::string s);
65    static parse_result_retVal parse_cc_body(std::string s);
66    static parse_result_retVal parse_cc_body0(std::string s, CC* cc_sofar);
67    static parse_result_retVal parse_cc_body1(int chr, std::string s, CC* cc_sofar);
68    static parse_result_retVal parse_utf8_bytes(int suffix_count, std::string s);
69    static parse_result_retVal parse_utf8_suffix_byte(int suffix_byte_num, std::string s, Seq* seq_sofar);
70
71    static parse_result_retVal parse_unicode_category(std::string s, bool negated);
72    static parse_result_retVal parse_unicode_category1(std::string character, std::string s, Name* name_sofar);
73    static bool isValidUnicodeCategoryName(Name* name);
74
75    static parse_int_retVal parse_hex(std::string s);
76    static parse_int_retVal parse_hex_body(int i, std::string s);
77    static int parse_hex_body1(int i, std::string hex_str);
78
79    static parse_int_retVal parse_int(std::string s);
80    static parse_int_retVal parse_int1(int i, std::string s);
81    static parse_result_retVal negate_cc_result(parse_result_retVal cc_result);
82};
83
84#endif // RE_PARSER_H
Note: See TracBrowser for help on using the repository browser.