[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_syntax_h__ |
---|
| 8 | #define __cmt_syntax_h__ |
---|
| 9 | |
---|
| 10 | #include "cmt_map.h" |
---|
| 11 | #include "cmt_string.h" |
---|
| 12 | #include "cmt_system.h" |
---|
| 13 | #include "cmt_use.h" |
---|
| 14 | #include "cmt_project.h" |
---|
| 15 | |
---|
| 16 | class Kwd |
---|
| 17 | { |
---|
| 18 | public: |
---|
| 19 | virtual void action (const CmtSystem::cmt_string_vector& words, |
---|
| 20 | Use* use, |
---|
| 21 | const cmt_string& file_name, |
---|
| 22 | int line_number) = 0; |
---|
| 23 | |
---|
| 24 | virtual void action (const CmtSystem::cmt_string_vector& words, |
---|
| 25 | Project* project, |
---|
| 26 | const cmt_string& file_name, |
---|
| 27 | int line_number); |
---|
| 28 | }; |
---|
| 29 | |
---|
| 30 | class SyntaxParser |
---|
| 31 | { |
---|
| 32 | public: |
---|
| 33 | static SyntaxParser& instance (); |
---|
| 34 | |
---|
| 35 | static void parse_requirements (const cmt_string& file_name, Use* use); |
---|
| 36 | |
---|
| 37 | static void parse_project_file_text (const cmt_string& text, |
---|
| 38 | const cmt_string& file_name, |
---|
| 39 | Project* project); |
---|
| 40 | |
---|
| 41 | static void parse_requirements_text (const cmt_string& text, |
---|
| 42 | const cmt_string& file_name, |
---|
| 43 | Use* use); |
---|
| 44 | |
---|
| 45 | static void parse_requirements_line (const cmt_string& line, |
---|
| 46 | Use* use, |
---|
| 47 | const cmt_string& file_name = "", |
---|
| 48 | int line_number = 0); |
---|
| 49 | |
---|
| 50 | private: |
---|
| 51 | |
---|
| 52 | typedef enum |
---|
| 53 | { |
---|
| 54 | project_context, |
---|
| 55 | package_context |
---|
| 56 | } ContextType; |
---|
| 57 | |
---|
| 58 | void do_parse_requirements (const cmt_string& file_name, Use* use); |
---|
| 59 | |
---|
| 60 | void do_parse_text (const cmt_string& text, |
---|
| 61 | const cmt_string& file_name, |
---|
| 62 | ContextType context, |
---|
| 63 | Use* use, |
---|
| 64 | Project* project); |
---|
| 65 | |
---|
| 66 | void do_parse_line (const cmt_string& line, |
---|
| 67 | const cmt_string& file_name, |
---|
| 68 | int line_number, |
---|
| 69 | ContextType context, |
---|
| 70 | Use* use, |
---|
| 71 | Project* project); |
---|
| 72 | |
---|
| 73 | void do_parse_words (const CmtSystem::cmt_string_vector& words, |
---|
| 74 | const cmt_string& file_name, |
---|
| 75 | int line_number, |
---|
| 76 | Use* use); |
---|
| 77 | |
---|
| 78 | void do_parse_words (const CmtSystem::cmt_string_vector& words, |
---|
| 79 | const cmt_string& file_name, |
---|
| 80 | int line_number, |
---|
| 81 | Project* project); |
---|
| 82 | |
---|
| 83 | SyntaxParser (); |
---|
| 84 | cmt_map <cmt_string, Kwd> m_keywords; |
---|
| 85 | cmt_map <cmt_string, Kwd> m_project_keywords; |
---|
| 86 | cmt_string m_filtered_text; |
---|
| 87 | }; |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | class CommandParser |
---|
| 91 | { |
---|
| 92 | public: |
---|
| 93 | typedef cmt_map <ActionType, cmt_string> HelpMap; |
---|
| 94 | typedef cmt_vector<cmt_string> HelpTexts; |
---|
| 95 | |
---|
| 96 | static HelpMap& get_help (); |
---|
| 97 | static HelpTexts& get_help_texts (); |
---|
| 98 | static const cmt_string& get_help_text (ActionType key); |
---|
| 99 | static void show_all (); |
---|
| 100 | static void show (ActionType action); |
---|
| 101 | |
---|
| 102 | private: |
---|
| 103 | static CommandParser& instance (); |
---|
| 104 | |
---|
| 105 | CommandParser (); |
---|
| 106 | |
---|
| 107 | HelpMap m_help; |
---|
| 108 | HelpTexts m_help_texts; |
---|
| 109 | }; |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | #endif |
---|