Main Page | Directories | File List

mootNgramsCompiler.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*- */
00002 
00003 /*
00004    libmoot : moocow's part-of-speech tagging library
00005    Copyright (C) 2003-2005 by Bryan Jurish <moocow@ling.uni-potsdam.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011    
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016    
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with this library; if not, write to the Free Software
00019    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00020 */
00021 
00022 /*============================================================================
00023  * File: mootNgramsCompiler.h
00024  * Author:  Bryan Jurish <moocow@ling.uni-potsdam.de>
00025  * Description:
00026  *    Compiler for TnT parameter files for moot PoS tagger
00027  *============================================================================*/
00028 
00029 #ifndef _moot_NGRAMS_COMPILER_H
00030 #define _moot_NGRAMS_COMPILER_H
00031 
00032 #include <stdio.h>
00033 #include <string.h>
00034 
00035 #include "mootNgramsLexer.h"
00036 #include "mootNgramsParser.h"
00037 
00038 moot_BEGIN_NAMESPACE
00039 
00047 class mootNgramsCompiler : public mootNgramsParser {
00048  public:
00049   // -- public data
00051   mootNgramsLexer theLexer;
00052 
00057   char *objname;
00058 
00063   char *srcname;
00064 
00065  public:
00066   // -- public methods: CONSTRUCTORS / DESTRUCTORS
00068   mootNgramsCompiler() : objname(NULL), srcname(NULL) {};
00070   virtual ~mootNgramsCompiler() {};
00071 
00072   // -- high-level parsing methods
00073 
00075   inline mootNgrams *parse_from_file(FILE *file, const char *filename=NULL) {
00076       select_streams(file,stdout);
00077       return parse_ngrams();
00078   };
00079 
00081   inline mootNgrams *parse_from_string(const char *string, const char *srcname=NULL) {
00082     select_string(string,srcname);
00083     return parse_ngrams();
00084   };
00085 
00086   // -- low-level public methods: INPUT SELECTION
00088   void select_streams(FILE *in, FILE *out, const char *my_srcname=NULL) {
00089     theLexer.select_streams(in,out);
00090     srcname = (char *)my_srcname;
00091   };
00092 
00097   void select_string(const char *in, const char *my_srcname=NULL) {
00098     theLexer.select_string(in);
00099     srcname = (char *)my_srcname;
00100   };
00101 
00102   // -- low-level public methods: PARSING
00103   virtual int yylex();
00104 
00109   mootNgrams *parse_ngrams();
00110 
00111   // -- low-level public methods: ERRORS & WARNINGS
00113   virtual void yyerror(const char *msg);
00114 
00116   virtual void yywarn(const char *msg);
00117 };
00118 
00119 
00120 moot_END_NAMESPACE
00121 
00122 #endif /* _moot_NGRAMS_COMPILER_H */

Generated on Sat Sep 17 01:20:33 2005 for libmoot by  doxygen 1.4.4