1 /**
2  *  Yudit Unicode Editor Source File
3  *
4  *  GNU Copyright (C) 1997-2006  Gaspar Sinai <gaspar@yudit.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License, version 2,
8  *  dated June 1991. See file COPYYING for details.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef SPattern_h
21 #define SPattern_h
22 
23 #include "stoolkit/STypes.h"
24 #include "stoolkit/SString.h"
25 #include "stoolkit/syntax/SMatcherIterator.h"
26 
27 /**
28  * A regular expression pattern.
29  * @author Gaspar Sinai
30  * @version 2007-11-27
31  */
32 class SPattern
33 {
34 public:
35   SPattern (void);
36   virtual ~SPattern ();
isValid()37   bool isValid () const { return valid; }
38 
39   // This method updates matchBegin and matchEnd (exclusive)
40   // variables in case of a match, in case of no match, this
41   // will not be touched. Action will contain that action string.
42   virtual bool   checkMatch ();
43   unsigned int   matchBegin;
44   unsigned int   matchEnd;
45   SString        action;
46 
47   // Actions
48   SString        ACT_NONE;
49   SString        ACT_ERROR;
50   SString        ACT_NUMBER;
51   SString        ACT_KEYWORD;
52   SString        ACT_VARIABLE;
53   SString        ACT_DEFINE;
54   SString        ACT_CONTROL;
55   SString        ACT_OTHER;
56 
57   // Append a character and update the next to show how
58   // many characters we received so far.
59   void           append (SS_UCS4 in);
60   unsigned int   next;
61 
62   void           clear ();
63 
64 protected:
65   SV_UCS4        current;
66   bool           checkMatchTest ();
67   bool           singleMatchTest (unsigned int leaveSize);
68   bool           valid;
69 };
70 
71 #endif /* SPattern_h */
72