[2] | 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; |
---|
[549] | 36 | int print (const Symbol& symbol, const SymbolValue& value, bool& first_definition) const; |
---|
[2] | 37 | |
---|
| 38 | CommandType command_type; |
---|
| 39 | Use* use; |
---|
| 40 | SymbolValue::SymbolValueVector values; |
---|
| 41 | bool is_reflexive; |
---|
| 42 | bool discarded; |
---|
| 43 | }; |
---|
| 44 | |
---|
| 45 | class Symbol; |
---|
| 46 | |
---|
| 47 | class ValueBuilder |
---|
| 48 | { |
---|
| 49 | public: |
---|
[3] | 50 | ValueBuilder (); |
---|
| 51 | const cmt_string build_and_display (const Symbol& symbol); |
---|
[549] | 52 | int print (const Symbol& symbol, ostream& out = cout); |
---|
[3] | 53 | |
---|
[2] | 54 | virtual const cmt_string build (const Symbol& symbol, |
---|
| 55 | const cmt_string& tag_name = "") = 0; |
---|
| 56 | virtual const cmt_string clean (const Symbol& symbol, |
---|
| 57 | const cmt_string& tag_name = "") = 0; |
---|
[3] | 58 | protected: |
---|
| 59 | bool m_display_it; |
---|
[2] | 60 | }; |
---|
| 61 | |
---|
| 62 | class Symbol |
---|
| 63 | { |
---|
| 64 | public: |
---|
| 65 | typedef cmt_vector<Symbol> SymbolVector; |
---|
| 66 | typedef cmt_map<cmt_string, Symbol> SymbolMap; |
---|
| 67 | |
---|
| 68 | typedef enum |
---|
| 69 | { |
---|
| 70 | SymbolUndefined, |
---|
| 71 | SymbolAction, |
---|
| 72 | SymbolAlias, |
---|
| 73 | SymbolMacro, |
---|
| 74 | SymbolSetupScript, |
---|
| 75 | SymbolCleanupScript, |
---|
| 76 | SymbolSet, |
---|
| 77 | SymbolPath |
---|
| 78 | } SymbolType; |
---|
| 79 | |
---|
| 80 | static Symbol* create (const cmt_string& name, |
---|
| 81 | CommandType command, |
---|
| 82 | Use* use = 0); |
---|
| 83 | |
---|
| 84 | static Symbol* find (const cmt_string& name); |
---|
| 85 | static void action (const CmtSystem::cmt_string_vector& words, |
---|
| 86 | CommandType command_type, |
---|
| 87 | Use* use); |
---|
| 88 | static int is_selected (const cmt_string& name); |
---|
| 89 | |
---|
| 90 | static void all_set (); |
---|
| 91 | static void all_print (PrintMode mode); |
---|
| 92 | static void all_print_clean (PrintMode mode); |
---|
[144] | 93 | static void check_all_paths (); |
---|
[2] | 94 | |
---|
| 95 | static int symbol_number (); |
---|
| 96 | static SymbolVector& symbols (); |
---|
| 97 | static SymbolMap& symbol_map (); |
---|
| 98 | static Symbol& symbol (int index); |
---|
| 99 | static void clear_all (); |
---|
| 100 | static void expand (cmt_string& text); |
---|
| 101 | |
---|
[102] | 102 | static void filter_path_value (const cmt_string& name, cmt_string& text); |
---|
| 103 | |
---|
[588] | 104 | static bool check_tag_used (const Tag* tag); |
---|
[3] | 105 | |
---|
[136] | 106 | static cmt_string get_env_value (const cmt_string& name); |
---|
| 107 | |
---|
| 108 | static bool get_inhibit_display (); |
---|
| 109 | |
---|
[2] | 110 | public: |
---|
| 111 | Symbol (); |
---|
| 112 | ~Symbol (); |
---|
| 113 | bool value_is_reflexive (const cmt_string& text) const; |
---|
| 114 | void add_value_to_list (CommandType command_type, |
---|
| 115 | Use* use, |
---|
| 116 | Tag* tag, |
---|
| 117 | const cmt_string& text); |
---|
| 118 | |
---|
| 119 | int print_clean (PrintMode mode); |
---|
| 120 | int print (PrintMode mode); |
---|
[3] | 121 | cmt_string build_macro_value (bool display_it = false) const; |
---|
[549] | 122 | int print_macro (PrintMode mode, ostream& out = cout) const; |
---|
[2] | 123 | cmt_string clean_macro_value () const; |
---|
[588] | 124 | cmt_string resolve_macro_value (const cmt_string& tag_name = "") const; |
---|
[547] | 125 | void show_macro (PrintMode mode, ostream& out = cout); |
---|
| 126 | // void show_macro (PrintMode mode); |
---|
[2] | 127 | |
---|
| 128 | ValueBuilder* builder; |
---|
| 129 | |
---|
| 130 | cmt_string name; |
---|
| 131 | ScopeType scope; |
---|
| 132 | SymbolType type; |
---|
| 133 | |
---|
| 134 | SymbolValueList::SymbolValueListVector value_lists; |
---|
| 135 | |
---|
| 136 | int selected_value; /* according to the last selected tag */ |
---|
[549] | 137 | bool printed; |
---|
[136] | 138 | |
---|
| 139 | private: |
---|
| 140 | |
---|
| 141 | static bool m_inhibit_display; // Global inhibitor of any display |
---|
| 142 | |
---|
[2] | 143 | }; |
---|
| 144 | |
---|
| 145 | #endif |
---|