1 | //----------------------------------------------------------- |
---|
2 | // Copyright Christian Arnault LAL-Orsay CNRS |
---|
3 | // arnault@lal.in2p3.fr |
---|
4 | // See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
5 | //----------------------------------------------------------- |
---|
6 | |
---|
7 | #ifndef __cmt_symbol_h__ |
---|
8 | #define __cmt_symbol_h__ |
---|
9 | |
---|
10 | #include "cmt_tag.h" |
---|
11 | #include "cmt_use.h" |
---|
12 | #include "cmt_map.h" |
---|
13 | |
---|
14 | class SymbolValue |
---|
15 | { |
---|
16 | public: |
---|
17 | typedef cmt_vector<SymbolValue> SymbolValueVector; |
---|
18 | |
---|
19 | SymbolValue (); |
---|
20 | ~SymbolValue (); |
---|
21 | |
---|
22 | Tag* tag; |
---|
23 | cmt_string text; /* A symbol value is created only if */ |
---|
24 | /* its text is non empty */ |
---|
25 | int selected; |
---|
26 | }; |
---|
27 | |
---|
28 | class SymbolValueList |
---|
29 | { |
---|
30 | public: |
---|
31 | typedef cmt_vector<SymbolValueList> SymbolValueListVector; |
---|
32 | |
---|
33 | int select_first (const cmt_string& tag_name = "") const; |
---|
34 | int select_last () const; |
---|
35 | void show (const Symbol& symbol, const SymbolValue& value, bool& first_definition) const; |
---|
36 | |
---|
37 | CommandType command_type; |
---|
38 | Use* use; |
---|
39 | SymbolValue::SymbolValueVector values; |
---|
40 | bool is_reflexive; |
---|
41 | bool discarded; |
---|
42 | }; |
---|
43 | |
---|
44 | class Symbol; |
---|
45 | |
---|
46 | class ValueBuilder |
---|
47 | { |
---|
48 | public: |
---|
49 | ValueBuilder (); |
---|
50 | const cmt_string build_and_display (const Symbol& symbol); |
---|
51 | |
---|
52 | virtual const cmt_string build (const Symbol& symbol, |
---|
53 | const cmt_string& tag_name = "") = 0; |
---|
54 | virtual const cmt_string clean (const Symbol& symbol, |
---|
55 | const cmt_string& tag_name = "") = 0; |
---|
56 | protected: |
---|
57 | bool m_display_it; |
---|
58 | }; |
---|
59 | |
---|
60 | class Symbol |
---|
61 | { |
---|
62 | public: |
---|
63 | typedef cmt_vector<Symbol> SymbolVector; |
---|
64 | typedef cmt_map<cmt_string, Symbol> SymbolMap; |
---|
65 | |
---|
66 | typedef enum |
---|
67 | { |
---|
68 | SymbolUndefined, |
---|
69 | SymbolAction, |
---|
70 | SymbolAlias, |
---|
71 | SymbolMacro, |
---|
72 | SymbolSetupScript, |
---|
73 | SymbolCleanupScript, |
---|
74 | SymbolSet, |
---|
75 | SymbolPath |
---|
76 | } SymbolType; |
---|
77 | |
---|
78 | static Symbol* create (const cmt_string& name, |
---|
79 | CommandType command, |
---|
80 | Use* use = 0); |
---|
81 | |
---|
82 | static Symbol* find (const cmt_string& name); |
---|
83 | static void action (const CmtSystem::cmt_string_vector& words, |
---|
84 | CommandType command_type, |
---|
85 | Use* use); |
---|
86 | static int is_selected (const cmt_string& name); |
---|
87 | |
---|
88 | static void all_set (); |
---|
89 | static void all_print (PrintMode mode); |
---|
90 | static void all_print_clean (PrintMode mode); |
---|
91 | |
---|
92 | static int symbol_number (); |
---|
93 | static SymbolVector& symbols (); |
---|
94 | static SymbolMap& symbol_map (); |
---|
95 | static Symbol& symbol (int index); |
---|
96 | static void clear_all (); |
---|
97 | static void expand (cmt_string& text); |
---|
98 | |
---|
99 | static bool check_tag_used (Tag* tag); |
---|
100 | |
---|
101 | public: |
---|
102 | Symbol (); |
---|
103 | ~Symbol (); |
---|
104 | bool value_is_reflexive (const cmt_string& text) const; |
---|
105 | void add_value_to_list (CommandType command_type, |
---|
106 | Use* use, |
---|
107 | Tag* tag, |
---|
108 | const cmt_string& text); |
---|
109 | |
---|
110 | int print_clean (PrintMode mode); |
---|
111 | int print (PrintMode mode); |
---|
112 | cmt_string build_macro_value (bool display_it = false) const; |
---|
113 | cmt_string clean_macro_value () const; |
---|
114 | cmt_string resolve_macro_value (const cmt_string& tag_name = ""); |
---|
115 | void show_macro (PrintMode mode); |
---|
116 | |
---|
117 | ValueBuilder* builder; |
---|
118 | |
---|
119 | cmt_string name; |
---|
120 | ScopeType scope; |
---|
121 | SymbolType type; |
---|
122 | |
---|
123 | SymbolValueList::SymbolValueListVector value_lists; |
---|
124 | |
---|
125 | int selected_value; /* according to the last selected tag */ |
---|
126 | }; |
---|
127 | |
---|
128 | #endif |
---|