[1] | 1 | #ifndef __cmt_symbol_h__ |
---|
| 2 | #define __cmt_symbol_h__ |
---|
| 3 | |
---|
| 4 | #include "cmt_tag.h" |
---|
| 5 | #include "cmt_use.h" |
---|
| 6 | |
---|
| 7 | class SymbolValue |
---|
| 8 | { |
---|
| 9 | public: |
---|
| 10 | typedef cmt_vector<SymbolValue> SymbolValueVector; |
---|
| 11 | |
---|
| 12 | SymbolValue (); |
---|
| 13 | ~SymbolValue (); |
---|
| 14 | |
---|
| 15 | Tag* tag; |
---|
| 16 | cmt_string text; /* A symbol value is created only if */ |
---|
| 17 | /* its text is non empty */ |
---|
| 18 | int selected; |
---|
| 19 | }; |
---|
| 20 | |
---|
| 21 | class SymbolValueList |
---|
| 22 | { |
---|
| 23 | public: |
---|
| 24 | typedef cmt_vector<SymbolValueList> SymbolValueListVector; |
---|
| 25 | |
---|
| 26 | int select_first (const cmt_string& tag_name = "") const; |
---|
| 27 | int select_last () const; |
---|
| 28 | |
---|
| 29 | CommandType command_type; |
---|
| 30 | Use* use; |
---|
| 31 | SymbolValue::SymbolValueVector values; |
---|
| 32 | bool is_reflexive; |
---|
| 33 | bool discarded; |
---|
| 34 | }; |
---|
| 35 | |
---|
| 36 | class Symbol; |
---|
| 37 | |
---|
| 38 | class ValueBuilder |
---|
| 39 | { |
---|
| 40 | public: |
---|
| 41 | virtual const cmt_string& build (const Symbol& symbol, |
---|
| 42 | const cmt_string& tag_name = "") = 0; |
---|
| 43 | virtual const cmt_string& clean (const Symbol& symbol, |
---|
| 44 | const cmt_string& tag_name = "") = 0; |
---|
| 45 | }; |
---|
| 46 | |
---|
| 47 | class Symbol |
---|
| 48 | { |
---|
| 49 | public: |
---|
| 50 | typedef cmt_vector<Symbol> SymbolVector; |
---|
| 51 | |
---|
| 52 | static Symbol* create (const cmt_string& name, |
---|
| 53 | CommandType command, |
---|
| 54 | ScopeType scope); |
---|
| 55 | static Symbol* find (const cmt_string& name); |
---|
| 56 | static void action (const CmtSystem::cmt_string_vector& words, |
---|
| 57 | CommandType command_type, |
---|
| 58 | Use* use); |
---|
| 59 | static int is_selected (const cmt_string& name); |
---|
| 60 | static void all_print (PrintMode mode); |
---|
| 61 | static void all_print_clean (PrintMode mode); |
---|
| 62 | static int symbol_number (); |
---|
| 63 | static SymbolVector& symbols (); |
---|
| 64 | static Symbol& symbol (int index); |
---|
| 65 | static void clear_all (); |
---|
| 66 | static void expand (cmt_string& text); |
---|
| 67 | |
---|
| 68 | public: |
---|
| 69 | Symbol (); |
---|
| 70 | ~Symbol (); |
---|
| 71 | bool value_is_reflexive (const cmt_string& text) const; |
---|
| 72 | void add_value_to_list (CommandType command_type, |
---|
| 73 | Use* use, |
---|
| 74 | Tag* tag, |
---|
| 75 | const cmt_string& text); |
---|
| 76 | |
---|
| 77 | int valid (PrintMode mode); |
---|
| 78 | int print_clean (int tabs, PrintMode mode); |
---|
| 79 | int print (int tabs, PrintMode mode); |
---|
| 80 | cmt_string build_macro_value () const; |
---|
| 81 | cmt_string clean_macro_value () const; |
---|
| 82 | cmt_string resolve_macro_value (const cmt_string& tag_name = ""); |
---|
| 83 | void show_macro (PrintMode mode); |
---|
| 84 | |
---|
| 85 | ValueBuilder* builder; |
---|
| 86 | |
---|
| 87 | cmt_string name; /* The original symbol's name */ |
---|
| 88 | ScopeType scope; /* copy of the current scope */ |
---|
| 89 | CommandType command; /* symbol's type */ |
---|
| 90 | |
---|
| 91 | SymbolValueList::SymbolValueListVector value_lists; |
---|
| 92 | |
---|
| 93 | int selected_value; /* according to the last selected tag */ |
---|
| 94 | }; |
---|
| 95 | |
---|
| 96 | #endif |
---|