1 /*  _______________________________________________________________________
2 
3     Surfpack: A Software Library of Multidimensional Surface Fitting Methods
4     Copyright (c) 2006, Sandia National Laboratories.
5     This software is distributed under the GNU Lesser General Public License.
6     For more information, see the README file in the top Surfpack directory.
7     _______________________________________________________________________ */
8 
9 #include "FlexWrapper.h"
10 
11 // Symbols and functions that will be implemented through flex
12 
13 /// The Current token
14 extern "C" char* yytext;
15 
16 /// The input stream for the lexer
17 extern "C" FILE* yyin;
18 
19 /// The output stream for the lexer
20 extern "C" FILE* yyout;
21 
22 /// The "next token" method-- gets called by bison-generated code
23 extern "C" int yylex();
24 
FlexWrapper()25 FlexWrapper::FlexWrapper()
26   : infile(0), outfile(0)
27 {
28 }
29 
~FlexWrapper()30 FlexWrapper::~FlexWrapper()
31 {
32   if (infile) fclose(infile);
33   if (outfile) fclose(outfile);
34 }
35 
setParseStreams(const std::string * input_string,const std::string * output_string)36 void FlexWrapper::setParseStreams(const std::string* input_string,
37   const std::string* output_string)
38 {
39   if (input_string) {
40     infile = fopen(input_string->c_str(),"r");
41   }
42   if (output_string) {
43     outfile = fopen(output_string->c_str(),"w");
44   }
45   yyin = infile;
46   yyout = outfile;
47 }
48 
nextToken()49 int FlexWrapper::nextToken()
50 {
51   return yylex();
52 }
53 
currentToken()54 const char* FlexWrapper::currentToken()
55 {
56   return yytext;
57 }
58