Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright (c) 2000-2014 Ericsson Telecom AB | |
3 | // All rights reserved. This program and the accompanying materials | |
4 | // are made available under the terms of the Eclipse Public License v1.0 | |
5 | // which accompanies this distribution, and is available at | |
6 | // http://www.eclipse.org/legal/epl-v10.html | |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #ifndef _Ttcn_PatternString_HH | |
9 | #define _Ttcn_PatternString_HH | |
10 | ||
11 | #include "../vector.hh" | |
12 | #include "../Setting.hh" | |
13 | #include "AST_ttcn3.hh" | |
14 | ||
15 | #include "../Value.hh" | |
16 | ||
17 | namespace Ttcn { | |
18 | ||
19 | class Module; | |
20 | using namespace Common; | |
21 | ||
22 | /** | |
23 | * The instances of this class can represent a TTCN pattern | |
24 | * string. It can built up from different kinds of elements: | |
25 | * "regular" RE-elements and "reference" elements ({reference} and | |
26 | * \\N{reference}). | |
27 | */ | |
28 | class PatternString : public Node { | |
29 | public: | |
30 | enum pstr_type_t { | |
31 | CSTR_PATTERN, | |
32 | USTR_PATTERN | |
33 | }; | |
34 | private: | |
35 | Scope *my_scope; | |
36 | struct ps_elem_t; | |
37 | vector<ps_elem_t> elems; | |
38 | PatternString(const PatternString& p); | |
39 | /** returns the last element if it contains a regular string or NULL | |
40 | * otherwise */ | |
41 | ps_elem_t *get_last_elem() const; | |
42 | ||
43 | Value* cstr_value; | |
44 | ||
45 | pstr_type_t pattern_type; | |
46 | ||
47 | public: | |
48 | PatternString(): Node(), my_scope(0), cstr_value(0), | |
49 | pattern_type(CSTR_PATTERN) { } | |
50 | virtual ~PatternString(); | |
51 | virtual PatternString* clone() const; | |
52 | virtual void set_fullname(const string& p_fullname); | |
53 | virtual void set_my_scope(Scope *p_scope); | |
54 | void set_code_section(GovernedSimple::code_section_t p_code_section); | |
55 | void addChar(char c); | |
56 | void addString(const char *p_str); | |
57 | void addString(const string& p_str); | |
58 | void addRef(Ttcn::Reference *p_ref); | |
59 | void addRefdCharSet(Ttcn::Reference *p_ref); | |
60 | string get_full_str() const; | |
61 | ||
62 | void set_pattern_type(pstr_type_t p_type); | |
63 | pstr_type_t get_pattern_type() const; | |
64 | ||
65 | /** Returns whether the pattern contains embedded references */ | |
66 | bool has_refs() const; | |
67 | /** Checks the embedded referenced values */ | |
68 | void chk_refs(Type::expected_value_t expected_value=Type::EXPECTED_DYNAMIC_VALUE); | |
69 | void chk_recursions(ReferenceChain& refch); | |
70 | /** Checks the pattern by translating it to POSIX regexp */ | |
71 | void chk_pattern(); | |
72 | bool chk_self_ref(Common::Assignment *lhs); | |
73 | /** Joins adjacent string components into one for more efficient code | |
74 | * generation. */ | |
75 | void join_strings(); | |
76 | /** Temporary hack... */ | |
77 | string create_charstring_literals(Common::Module *p_mod); | |
78 | virtual void dump(unsigned level) const; | |
79 | ||
80 | /** Called by Value::get_value_refd_last() */ | |
81 | Value* get_value(); | |
82 | }; | |
83 | ||
84 | } // namespace Ttcn | |
85 | ||
86 | #endif // _Ttcn_PatternString_HH |