1*357f1050SThomas Veerman /* 2*357f1050SThomas Veerman * This file is part of flex. 3*357f1050SThomas Veerman * 4*357f1050SThomas Veerman * Redistribution and use in source and binary forms, with or without 5*357f1050SThomas Veerman * modification, are permitted provided that the following conditions 6*357f1050SThomas Veerman * are met: 7*357f1050SThomas Veerman * 8*357f1050SThomas Veerman * 1. Redistributions of source code must retain the above copyright 9*357f1050SThomas Veerman * notice, this list of conditions and the following disclaimer. 10*357f1050SThomas Veerman * 2. Redistributions in binary form must reproduce the above copyright 11*357f1050SThomas Veerman * notice, this list of conditions and the following disclaimer in the 12*357f1050SThomas Veerman * documentation and/or other materials provided with the distribution. 13*357f1050SThomas Veerman * 14*357f1050SThomas Veerman * Neither the name of the University nor the names of its contributors 15*357f1050SThomas Veerman * may be used to endorse or promote products derived from this software 16*357f1050SThomas Veerman * without specific prior written permission. 17*357f1050SThomas Veerman * 18*357f1050SThomas Veerman * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 19*357f1050SThomas Veerman * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 20*357f1050SThomas Veerman * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21*357f1050SThomas Veerman * PURPOSE. 22*357f1050SThomas Veerman */ 23*357f1050SThomas Veerman 24*357f1050SThomas Veerman %{ 25*357f1050SThomas Veerman 26*357f1050SThomas Veerman #include "config.h" 27*357f1050SThomas Veerman #include <fstream> 28*357f1050SThomas Veerman 29*357f1050SThomas Veerman %} 30*357f1050SThomas Veerman 31*357f1050SThomas Veerman %option 8bit outfile="scanner.cpp" prefix="test" 32*357f1050SThomas Veerman %option nounput nomain 33*357f1050SThomas Veerman %option warn c++ 34*357f1050SThomas Veerman 35*357f1050SThomas Veerman 36*357f1050SThomas Veerman %% 37*357f1050SThomas Veerman 38*357f1050SThomas Veerman . { } 39*357f1050SThomas Veerman 40*357f1050SThomas Veerman %% 41*357f1050SThomas Veerman 42*357f1050SThomas Veerman #define MAX_FILES 10 43*357f1050SThomas Veerman 44*357f1050SThomas Veerman char *files[MAX_FILES] = { 0 }; 45*357f1050SThomas Veerman int filecounter = 0; 46*357f1050SThomas Veerman yywrap()47*357f1050SThomas Veermanint testFlexLexer::yywrap() 48*357f1050SThomas Veerman { 49*357f1050SThomas Veerman if (filecounter-- > 0) { 50*357f1050SThomas Veerman std::cout << "NOW WRAPPING TO READ " << files[filecounter] << std::endl; 51*357f1050SThomas Veerman std::ifstream *ifs = new std::ifstream(files[filecounter]); 52*357f1050SThomas Veerman switch_streams(ifs); 53*357f1050SThomas Veerman return 0; 54*357f1050SThomas Veerman } 55*357f1050SThomas Veerman return 1; 56*357f1050SThomas Veerman } 57*357f1050SThomas Veerman 58*357f1050SThomas Veerman int main(int argc,char * argv[])59*357f1050SThomas Veermanmain (int argc, char *argv[]) 60*357f1050SThomas Veerman { 61*357f1050SThomas Veerman for (int i = 1; i < argc && i <= MAX_FILES; i++) { 62*357f1050SThomas Veerman files[i-1] = argv[i]; 63*357f1050SThomas Veerman filecounter++; 64*357f1050SThomas Veerman } 65*357f1050SThomas Veerman testFlexLexer* f = new testFlexLexer; 66*357f1050SThomas Veerman f->yywrap(); 67*357f1050SThomas Veerman f->yylex(); 68*357f1050SThomas Veerman std::cout << "TEST RETURNING OK." << std::endl; 69*357f1050SThomas Veerman return 0; 70*357f1050SThomas Veerman } 71