Few more things
[apertium.git] / lttoolbox / lttoolbox / EntryToken.H
blob837a2828d1c89f1af77a31614c52884bee143ae1
1 /*
2  * Copyright (C) 2005 Universitat d'Alacant / Universidad de Alicante
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  */
19 #ifndef _ENTRYTOKEN_
20 #define _ENTRYTOKEN_
22 #include <string>
23 #include <list>
25 using namespace std;
27 /**
28  * This is a "Compiler" helper class, to store the parts of each entry
29  * before combining it to build the transducer being "compiled".
30  */
31 class EntryToken
33   /**
34    * Type of tokens, inner enum.
35    */
36   enum Type {paradigm, single_transduction, regexp};
37 private:
38   /**
39    * Type of this token
40    */
41   Type type;
42   
43   /**
44    * Name of the paradigm (if it is of 'paradigm' 'type')
45    */
46   string parName;
47   
48   /**
49    * Left side of transduction (if 'single_transduction')
50    */
51   list<string> leftSide;
52   
53   /**
54    * Right side of transduction (if 'single_transduction')
55    */
56   list<string> rightSide;
57   
58   /**
59    * Regular expression (if 'regexp')
60    */
61   string myregexp;
63   /**
64    * copy method
65    */
66   void copy(EntryToken const &e);
67   
68   /**
69    * destroy method
70    */
71   void destroy();
72 public:
74   /**
75    * Non-parametric constructor
76    */
77   EntryToken();
78   
79   /**
80    * Destructor
81    */
82   ~EntryToken();
83   
84   /**
85    * Copy constructor
86    */
87   EntryToken(EntryToken const &e);
88   
89   /**
90    * Operator assignment
91    */
92   EntryToken & operator = (EntryToken const &e);
93   
94   /**
95    * Sets the name of the paradigm.
96    * @param np the paradigm name
97    */
98   void setParadigm(string const &np);
99   
100   /**
101    * Set both parts of a single transduction.
102    * @param pi left part
103    * @param pd right part
104    */
105   void setSingleTransduction(list<string> const &pi, list<string> const &pd);
106   
107   /**
108    * Set regular expression.
109    * @param r the regular expression specification.
110    */
111   void setRegExp(string const &r);
112   
113   /**
114    * eTest EntryToken to detect if is a paradigm.
115    * @return true if it is a paradigm.
116    */
117   bool isParadigm() const;
118   
119   /**
120    * Test EntryToken to check if it is a single transduction.
121    * @return true if it is a single transduction.
122    */
123   bool isSingleTransduction() const;
125   /**
126    * Test EntryToken to check if it is a single regular expression.
127    * @return true if it is a regular expression.
128    */
129   bool isRegExp() const;
131   /**
132    * Retrieve the name of the paradigm.
133    * @return the name of the paradigm.
134    */
135   string const & paradigmName() const;
136   
137   /**
138    * Retrieve the left part of the paradigm.
139    * @return the left part of the paradigm.
140    */
141   list<string> const & left() const;
142   
143   /**
144    * Retrieve the right part of the paradigm.
145    * @return the right part of the paradigm.
146    */
147   list<string> const & right() const;
148   
149   /**
150    * Retrieve the regular expression specification.
151    * @return the regular expression specification.
152    */
153   string const & regExp() const;
156 #endif