/usr/include/lttoolbox-3.3/lttoolbox/compiler.h is in lttoolbox-dev 3.3.3~r68466-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | /*
* Copyright (C) 2005 Universitat d'Alacant / Universidad de Alicante
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MYCOMPILER_
#define _MYCOMPILER_
#include <lttoolbox/alphabet.h>
#include <lttoolbox/regexp_compiler.h>
#include <lttoolbox/entry_token.h>
#include <lttoolbox/ltstr.h>
#include <lttoolbox/transducer.h>
#include <map>
#include <string>
#include <set>
#include <libxml/xmlreader.h>
using namespace std;
/**
* A compiler of dictionaries to letter transducers
*/
class Compiler
{
private:
/**
* The libxml2's XML reader
*/
xmlTextReaderPtr reader;
/**
* The alt value
*/
wstring alt;
/**
* The variant value (monodix)
*/
wstring variant;
/**
* The variant value (left side of bidix)
*/
wstring variant_left;
/**
* The variant value (right side of bidix)
*/
wstring variant_right;
/**
* The paradigm being compiled
*/
wstring current_paradigm;
/**
* The dictionary section being compiled
*/
wstring current_section;
/**
* The direction of the compilation, 'lr' (left-to-right) or 'rl'
* (right-to-left)
*/
wstring direction;
/**
* List of characters to be considered alphabetic
*/
wstring letters;
/**
* Set verbose mode: warnings which may or may not be correct
*/
bool verbose;
/**
* First element (of an entry)
*/
bool first_element;
/**
* Identifier of all the symbols during the compilation
*/
Alphabet alphabet;
/**
* List of named transducers-paradigms
*/
map<wstring, Transducer, Ltstr> paradigms;
/**
* List of named dictionary sections
*/
map<wstring, Transducer, Ltstr> sections;
/**
* List of named prefix copy of a paradigm
*/
map<wstring, map<wstring, int, Ltstr>, Ltstr> prefix_paradigms;
/**
* List of named suffix copy of a paradigm
*/
map<wstring, map<wstring, int, Ltstr>, Ltstr> suffix_paradigms;
/**
* List of named endings of a suffix copy of a paradgim
*/
map<wstring, map<wstring, int, Ltstr>, Ltstr> postsuffix_paradigms;
/**
* Mapping of aliases of characters specified in ACX files
*/
map<int, set<int> > acx_map;
/**
* Original char being mapped
*/
int acx_current_char;
/*
static string range(char const a, char const b);
string readAlphabet();
*/
/**
* Method to parse an XML Node
*/
void procNode();
/**
* Method to parse an XML Node in ACX files
*/
void procNodeACX();
/**
* Parse the <alphabet> element
*/
void procAlphabet();
/**
* Parse the <sdef< element
*/
void procSDef();
/**
* Parse the <pardef> element
*/
void procParDef();
/**
* Parse the <e> element
*/
void procEntry();
/**
* Parse the <re> element
* @return a list of tokens from the dictionary's entry
*/
EntryToken procRegexp();
/**
* Parse the <section> element
*/
void procSection();
/**
* Gets an attribute value with their name and the current context
* @param name the name of the attribute
* @return the value of the attribute
*/
wstring attrib(wstring const &name);
/**
* Construct symbol pairs by align left side of both parts and insert
* them into a transducer
* @param lp left part of the transduction
* @param rp right part of the transduction
* @param state the state from wich insert the new transduction
* @param t the transducer
* @return the last state of the inserted transduction
*/
int matchTransduction(list<int> const &lp, list<int> const &rp,
int state, Transducer &t);
/**
* Parse the <p< element
* @return a list of tokens from the dictionary's entry
*/
EntryToken procTransduction();
/**
* Parse the <i< element
* @return a list of tokens from the dictionary's entry
*/
EntryToken procIdentity();
/**
* Parse the <par> element
* @return a list of tokens from the dictionary's entry
*/
EntryToken procPar();
/**
* Insert a list of tokens into the paradigm / section being processed
* @param elements the list
*/
void insertEntryTokens(vector<EntryToken> const &elements);
/**
* Skip all document #text nodes before "elem"
* @param name the name of the node
* @param elem the name of the expected node
*/
void skip(wstring &name, wstring const &elem);
/**
* Skip all document #text nodes before "elem"
* @param name the name of the node
* @param elem the name of the expected node
* @param open true for open element, false for closed
*/
void skip(wstring &name, wstring const &elem, bool open);
/**
* Skip all blank #text nodes before "name"
* @param name the name of the node
*/
void skipBlanks(wstring &name);
void readString(list<int> &result, wstring const &name);
/**
* Force an element to be empty, and check for it
* @param name the element
*/
void requireEmptyError(wstring const &name);
/**
* Force an attribute to be specified, amd check for it
* @param value the value of the attribute
* @param attrname the name of the attribute
* @param elemname the parent of the attribute
*/
void requireAttribute(wstring const &value, wstring const &attrname,
wstring const &elemname);
/**
* True if all the elements in the current node are blanks
* @return true if all are blanks
*/
bool allBlanks();
public:
/*
* Constants to represent the element and the attributes of
* dictionaries
*/
static wstring const COMPILER_DICTIONARY_ELEM;
static wstring const COMPILER_ALPHABET_ELEM;
static wstring const COMPILER_SDEFS_ELEM;
static wstring const COMPILER_SDEF_ELEM;
static wstring const COMPILER_N_ATTR;
static wstring const COMPILER_PARDEFS_ELEM;
static wstring const COMPILER_PARDEF_ELEM;
static wstring const COMPILER_PAR_ELEM;
static wstring const COMPILER_ENTRY_ELEM;
static wstring const COMPILER_RESTRICTION_ATTR;
static wstring const COMPILER_RESTRICTION_LR_VAL;
static wstring const COMPILER_RESTRICTION_RL_VAL;
static wstring const COMPILER_PAIR_ELEM;
static wstring const COMPILER_LEFT_ELEM;
static wstring const COMPILER_RIGHT_ELEM;
static wstring const COMPILER_S_ELEM;
static wstring const COMPILER_REGEXP_ELEM;
static wstring const COMPILER_SECTION_ELEM;
static wstring const COMPILER_ID_ATTR;
static wstring const COMPILER_TYPE_ATTR;
static wstring const COMPILER_IDENTITY_ELEM;
static wstring const COMPILER_JOIN_ELEM;
static wstring const COMPILER_BLANK_ELEM;
static wstring const COMPILER_POSTGENERATOR_ELEM;
static wstring const COMPILER_GROUP_ELEM;
static wstring const COMPILER_LEMMA_ATTR;
static wstring const COMPILER_IGNORE_ATTR;
static wstring const COMPILER_IGNORE_YES_VAL;
static wstring const COMPILER_ALT_ATTR;
static wstring const COMPILER_V_ATTR;
static wstring const COMPILER_VL_ATTR;
static wstring const COMPILER_VR_ATTR;
/**
* Constructor
*/
Compiler();
/**
* Destructor
*/
~Compiler();
/**
* Compile dictionary to letter transducers
*/
void parse(string const &fichero, wstring const &dir);
/**
* Read ACX file
*/
void parseACX(string const &fichero, wstring const &dir);
/**
* Write the result of compilation
* @param fd the stream where write the result
*/
void write(FILE *fd);
/**
* Set verbose output
*/
void setVerbose(bool verbosity = false);
/**
* Set the alt value to use in compilation
* @param a the value
*/
void setAltValue(string const &a);
/**
* Set the variant value to use in compilation
* @param v the value
*/
void setVariantValue(string const &v);
/**
* Set the variant_left value to use in compilation
* @param v the value
*/
void setVariantLeftValue(string const &v);
/**
* Set the variant_right value to use in compilation
* @param v the value
*/
void setVariantRightValue(string const &v);
};
#endif
|