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