additional fixes to checkstate
[deliverable/titan.core.git] / compiler2 / Identifier.hh
CommitLineData
d44e3c4f 1/******************************************************************************
2 * Copyright (c) 2000-2016 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 * Contributors:
9 * Balasko, Jeno
10 * Forstner, Matyas
11 * Raduly, Csaba
12 * Szabo, Janos Zoltan – initial implementation
13 *
14 ******************************************************************************/
970ed795
EL
15#ifndef _Common_Identifier_HH
16#define _Common_Identifier_HH
17
18#include "string.hh"
19#include "map.hh"
20
21namespace Common {
22
23 /**
24 * \addtogroup AST
25 *
26 * @{
27 */
28
29 /**
30 * This is a universal identifier class which can handle all
31 * reserved keywords. It contains also the name mappings. It is
32 * effective because of using reference counter.
33 */
34 class Identifier {
35 public:
36 enum id_t {
37 ID_NAME, /**< internal name == C++ (generated) name */
38 ID_ASN, /**< ASN.1 display name */
39 ID_TTCN /**< TTCN-3 display name */
40 };
41 struct id_data_t;
42 /** Returns whether \a p_name is a reserved word in the language
43 * identified by \a p_id_t */
44 static bool is_reserved_word(const string& p_name, id_t p_id_t);
45 /** Converts ASN.1 name \a p_name to internal (C++) name */
46 static string asn_2_name(const string& p_name);
47 /** Converts internal (C++) name \a p_name to ASN.1 name */
48 static string name_2_asn(const string& p_name);
49 /** Converts TTCN-3 name \a p_from to internal (C++) name */
50 static string ttcn_2_name(const string& p_name);
51 /** Converts internal (C++) name \a p_from to TTCN-3 name */
52 static string name_2_ttcn(const string& p_name);
53 private:
54 id_data_t *id_data;
55 id_t origin;
56 public:
57 /** Creates a new identifier with origin \a p_id_t and name \a
58 * p_name. If \a dontreg is true, then this new identifier will
59 * not be registered in the mapping tables. */
60 Identifier(id_t p_id_t, const string& p_name, bool dontreg=false);
61 Identifier(const Identifier& p);
62 ~Identifier();
63
64 Identifier *clone() const { return new Identifier(*this); }
65 Identifier& operator=(const Identifier& p);
66 bool operator==(const Identifier& p) const;
67 inline bool operator!=(const Identifier& p) const
68 { return !(*this == p); }
69 bool operator<(const Identifier& p) const;
70
71 /** Gets the origin. */
72 id_t get_origin() const { return origin; }
73 /** Gets the internal (and C++) name. */
74 const string& get_name() const;
75 /** Gets the display name according to its origin. */
76 const string& get_dispname() const;
77 /** Gets the ASN display name. */
78 const string& get_asnname() const;
79 /** Gets the TTCN display name. */
80 const string& get_ttcnname() const;
81 /** Returns false if this identifier does not have a valid name
82 * for the requested purpose. */
83 bool get_has_valid(id_t p_id_t) const;
84 /** Gets each valid/set name. */
85 string get_names() const;
86
87 /** True if it is a valid ASN modulereference. */
88 bool isvalid_asn_modref() const;
89 /** True if it is a valid ASN typereference. */
90 bool isvalid_asn_typeref() const;
91 /** True if it is a valid ASN valuereference. */
92 bool isvalid_asn_valref() const;
93 /** True if it is a valid ASN valuesetreference. */
94 bool isvalid_asn_valsetref() const;
95 /** True if it is a valid ASN objectclassreference. */
96 bool isvalid_asn_objclassref() const;
97 /** True if it is a valid ASN objectreference. */
98 bool isvalid_asn_objref() const;
99 /** True if it is a valid ASN objectsetreference. */
100 bool isvalid_asn_objsetref() const;
101 /** True if it is a valid ASN typefieldreference. */
102 bool isvalid_asn_typefieldref() const;
103 /** True if it is a valid ASN valuefieldreference. */
104 bool isvalid_asn_valfieldref() const;
105 /** True if it is a valid ASN valuesetfieldreference. */
106 bool isvalid_asn_valsetfieldref() const;
107 /** True if it is a valid ASN objectfieldreference. */
108 bool isvalid_asn_objfieldref() const;
109 /** True if it is a valid ASN objectsetfieldreference. */
110 bool isvalid_asn_objsetfieldref() const;
111 /** True if it is a valid ASN "word". */
112 bool isvalid_asn_word() const;
113
114 void dump(unsigned level) const;
115 };
116
117 /// Identifier to represent the contained type of a record-of
118 /// as a pseudo-component when checking attribute qualifiers.
119 extern const Identifier underscore_zero;
120
121 /** @} end of AST group */
122
123} // namespace Common
124
125#endif // _Common_Identifier_HH
This page took 0.028786 seconds and 5 git commands to generate.