00001 #ifndef __cmt_pattern_h__
00002 #define __cmt_pattern_h__
00003
00004 #include "cmt_parser.h"
00005 #include "cmt_system.h"
00006
00007 class Use;
00008
00009 class Template
00010 {
00011 public:
00012 typedef cmt_vector<Template> TemplateVector;
00013 cmt_string name;
00014 cmt_string value;
00015 };
00016
00017 class Pattern
00018 {
00019 public:
00020 typedef cmt_vector<Pattern> PatternVector;
00021
00022 static void action (const CmtSystem::cmt_string_vector& words, Use* use);
00023
00024 static Pattern* find (const cmt_string& name);
00025 static Pattern* find (const cmt_string& name, Use* use);
00026 static void add (const cmt_string& name,
00027 const CmtSystem::cmt_string_vector& words,
00028 int start_index,
00029 bool global,
00030 Use* use);
00031
00032 static int pattern_number ();
00033 static Pattern& pattern (int index);
00034 static void clear_all ();
00035 static PatternVector& patterns ();
00036
00037 static void apply_all_globals ();
00038 static void apply_all_globals (Use* use);
00039 static void show_all_names ();
00040 static void show_all ();
00041 static void show_all_applied_patterns ();
00042 static void show (const cmt_string& name);
00043
00044 public:
00045 Pattern ();
00046 ~Pattern ();
00047
00048 void clear ();
00049 void apply () const;
00050 void apply (Use* constext_use) const;
00051 void apply (Use* constext_use,
00052 const Template::TemplateVector& templates) const;
00053 void expand (Use* constext_use,
00054 const Template::TemplateVector& templates,
00055 cmt_string& line) const;
00056
00057 cmt_string name;
00058 CmtSystem::cmt_string_vector words;
00059 bool global;
00060 Use* use;
00061 };
00062
00063 class ApplyPattern
00064 {
00065 public:
00066 typedef cmt_vector<ApplyPattern> ApplyPatternVector;
00067
00068 static void action (const CmtSystem::cmt_string_vector& words,
00069 Use* use);
00070
00071 static ApplyPattern* add (const cmt_string& name, Use* use);
00072
00073 public:
00074 ApplyPattern ();
00075 ~ApplyPattern ();
00076
00077 void show () const;
00078 void apply_globals () const;
00079 void apply () const;
00080
00081 cmt_string name;
00082 Use* use;
00083 cmt_vector<Template> replacements;
00084 };
00085
00086 class IgnorePattern
00087 {
00088 public:
00089 typedef cmt_vector<IgnorePattern> IgnorePatternVector;
00090
00091 static void action (const CmtSystem::cmt_string_vector& words, Use* use);
00092
00093 static IgnorePattern* find (const cmt_string& name, Use* use);
00094 static void add (const cmt_string& name, Use* use);
00095
00096 public:
00097 IgnorePattern ();
00098 ~IgnorePattern ();
00099
00100 void show () const;
00101
00102 cmt_string name;
00103 Use* use;
00104 };
00105
00106 #endif