[1] | 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 | virtual const cmt_string build (const Symbol& symbol, |
---|
| 50 | const cmt_string& tag_name = "") = 0; |
---|
| 51 | virtual const cmt_string clean (const Symbol& symbol, |
---|
| 52 | const cmt_string& tag_name = "") = 0; |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | class Symbol |
---|
| 56 | { |
---|
| 57 | public: |
---|
| 58 | typedef cmt_vector<Symbol> SymbolVector; |
---|
| 59 | typedef cmt_map<cmt_string, Symbol> SymbolMap; |
---|
| 60 | |
---|
| 61 | typedef enum |
---|
| 62 | { |
---|
| 63 | SymbolUndefined, |
---|
| 64 | SymbolAction, |
---|
| 65 | SymbolAlias, |
---|
| 66 | SymbolMacro, |
---|
| 67 | SymbolSetupScript, |
---|
| 68 | SymbolCleanupScript, |
---|
| 69 | SymbolSet, |
---|
| 70 | SymbolPath |
---|
| 71 | } SymbolType; |
---|
| 72 | |
---|
| 73 | static Symbol* create (const cmt_string& name, |
---|
| 74 | CommandType command, |
---|
| 75 | Use* use = 0); |
---|
| 76 | |
---|
| 77 | static Symbol* find (const cmt_string& name); |
---|
| 78 | static void action (const CmtSystem::cmt_string_vector& words, |
---|
| 79 | CommandType command_type, |
---|
| 80 | Use* use); |
---|
| 81 | static int is_selected (const cmt_string& name); |
---|
| 82 | |
---|
| 83 | static void all_set (); |
---|
| 84 | static void all_print (PrintMode mode); |
---|
| 85 | static void all_print_clean (PrintMode mode); |
---|
| 86 | |
---|
| 87 | static int symbol_number (); |
---|
| 88 | static SymbolVector& symbols (); |
---|
| 89 | static SymbolMap& symbol_map (); |
---|
| 90 | static Symbol& symbol (int index); |
---|
| 91 | static void clear_all (); |
---|
| 92 | static void expand (cmt_string& text); |
---|
| 93 | |
---|
| 94 | public: |
---|
| 95 | Symbol (); |
---|
| 96 | ~Symbol (); |
---|
| 97 | bool value_is_reflexive (const cmt_string& text) const; |
---|
| 98 | void add_value_to_list (CommandType command_type, |
---|
| 99 | Use* use, |
---|
| 100 | Tag* tag, |
---|
| 101 | const cmt_string& text); |
---|
| 102 | |
---|
| 103 | int print_clean (PrintMode mode); |
---|
| 104 | int print (PrintMode mode); |
---|
| 105 | cmt_string build_macro_value () const; |
---|
| 106 | cmt_string clean_macro_value () const; |
---|
| 107 | cmt_string resolve_macro_value (const cmt_string& tag_name = ""); |
---|
| 108 | void show_macro (PrintMode mode); |
---|
| 109 | |
---|
| 110 | ValueBuilder* builder; |
---|
| 111 | |
---|
| 112 | cmt_string name; |
---|
| 113 | ScopeType scope; |
---|
| 114 | SymbolType type; |
---|
| 115 | |
---|
| 116 | SymbolValueList::SymbolValueListVector value_lists; |
---|
| 117 | |
---|
| 118 | int selected_value; /* according to the last selected tag */ |
---|
| 119 | }; |
---|
| 120 | |
---|
| 121 | #endif |
---|