[2] | 1 | //----------------------------------------------------------- |
---|
| 2 | // Copyright Christian Arnault LAL-Orsay CNRS |
---|
| 3 | // arnault@lal.in2p3.fr |
---|
[272] | 4 | // Modified by garonne@lal.in2p3.fr |
---|
[2] | 5 | // See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
| 6 | //----------------------------------------------------------- |
---|
| 7 | |
---|
| 8 | #ifndef __cmt_syntax_h__ |
---|
| 9 | #define __cmt_syntax_h__ |
---|
| 10 | |
---|
| 11 | #include "cmt_map.h" |
---|
| 12 | #include "cmt_string.h" |
---|
| 13 | #include "cmt_system.h" |
---|
| 14 | #include "cmt_use.h" |
---|
| 15 | #include "cmt_project.h" |
---|
| 16 | |
---|
| 17 | class Kwd |
---|
| 18 | { |
---|
| 19 | public: |
---|
| 20 | virtual void action (const CmtSystem::cmt_string_vector& words, |
---|
| 21 | Use* use, |
---|
| 22 | const cmt_string& file_name, |
---|
| 23 | int line_number) = 0; |
---|
| 24 | |
---|
| 25 | virtual void action (const CmtSystem::cmt_string_vector& words, |
---|
| 26 | Project* project, |
---|
| 27 | const cmt_string& file_name, |
---|
[272] | 28 | int line_number) = 0; |
---|
[2] | 29 | }; |
---|
| 30 | |
---|
| 31 | class SyntaxParser |
---|
| 32 | { |
---|
| 33 | public: |
---|
| 34 | static SyntaxParser& instance (); |
---|
| 35 | |
---|
| 36 | static void parse_requirements (const cmt_string& file_name, Use* use); |
---|
| 37 | |
---|
| 38 | static void parse_project_file_text (const cmt_string& text, |
---|
| 39 | const cmt_string& file_name, |
---|
| 40 | Project* project); |
---|
| 41 | |
---|
| 42 | static void parse_requirements_text (const cmt_string& text, |
---|
| 43 | const cmt_string& file_name, |
---|
| 44 | Use* use); |
---|
| 45 | |
---|
| 46 | static void parse_requirements_line (const cmt_string& line, |
---|
| 47 | Use* use, |
---|
| 48 | const cmt_string& file_name = "", |
---|
| 49 | int line_number = 0); |
---|
| 50 | |
---|
| 51 | private: |
---|
| 52 | |
---|
| 53 | typedef enum |
---|
| 54 | { |
---|
| 55 | project_context, |
---|
| 56 | package_context |
---|
| 57 | } ContextType; |
---|
| 58 | |
---|
| 59 | void do_parse_requirements (const cmt_string& file_name, Use* use); |
---|
| 60 | |
---|
| 61 | void do_parse_text (const cmt_string& text, |
---|
| 62 | const cmt_string& file_name, |
---|
| 63 | ContextType context, |
---|
| 64 | Use* use, |
---|
| 65 | Project* project); |
---|
| 66 | |
---|
| 67 | void do_parse_line (const cmt_string& line, |
---|
| 68 | const cmt_string& file_name, |
---|
| 69 | int line_number, |
---|
| 70 | ContextType context, |
---|
| 71 | Use* use, |
---|
| 72 | Project* project); |
---|
| 73 | |
---|
| 74 | void do_parse_words (const CmtSystem::cmt_string_vector& words, |
---|
| 75 | const cmt_string& file_name, |
---|
| 76 | int line_number, |
---|
| 77 | Use* use); |
---|
| 78 | |
---|
| 79 | void do_parse_words (const CmtSystem::cmt_string_vector& words, |
---|
| 80 | const cmt_string& file_name, |
---|
| 81 | int line_number, |
---|
| 82 | Project* project); |
---|
| 83 | |
---|
| 84 | SyntaxParser (); |
---|
| 85 | cmt_map <cmt_string, Kwd> m_keywords; |
---|
| 86 | cmt_map <cmt_string, Kwd> m_project_keywords; |
---|
| 87 | cmt_string m_filtered_text; |
---|
| 88 | }; |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | #endif |
---|