Blame tests/cxx_yywrap.ll

Packit f00812
/*
Packit f00812
 * This file is part of flex.
Packit f00812
 * 
Packit f00812
 * Redistribution and use in source and binary forms, with or without
Packit f00812
 * modification, are permitted provided that the following conditions
Packit f00812
 * are met:
Packit f00812
 * 
Packit f00812
 * 1. Redistributions of source code must retain the above copyright
Packit f00812
 *    notice, this list of conditions and the following disclaimer.
Packit f00812
 * 2. Redistributions in binary form must reproduce the above copyright
Packit f00812
 *    notice, this list of conditions and the following disclaimer in the
Packit f00812
 *    documentation and/or other materials provided with the distribution.
Packit f00812
 * 
Packit f00812
 * Neither the name of the University nor the names of its contributors
Packit f00812
 * may be used to endorse or promote products derived from this software
Packit f00812
 * without specific prior written permission.
Packit f00812
 * 
Packit f00812
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
Packit f00812
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
Packit f00812
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
Packit f00812
 * PURPOSE.
Packit f00812
 */
Packit f00812
Packit f00812
%{
Packit f00812
Packit f00812
#include "config.h"
Packit f00812
#include <fstream>
Packit f00812
Packit f00812
%}
Packit f00812
Packit f00812
%option 8bit prefix="test"
Packit f00812
%option nounput nomain
Packit f00812
%option warn c++
Packit f00812
Packit f00812
Packit f00812
%%
Packit f00812
Packit f00812
.              { }
Packit f00812
Packit f00812
%%
Packit f00812
Packit f00812
#define MAX_FILES 10
Packit f00812
Packit f00812
char *files[MAX_FILES] = { 0 };
Packit f00812
int filecounter = 0;
Packit f00812
Packit f00812
int testFlexLexer::yywrap()
Packit f00812
{
Packit f00812
    if (filecounter-- > 0) {
Packit f00812
        std::cout << "NOW WRAPPING TO READ " << files[filecounter] << std::endl;
Packit f00812
        std::ifstream *ifs = new std::ifstream(files[filecounter]);
Packit f00812
        switch_streams(ifs);
Packit f00812
        return 0;
Packit f00812
    }
Packit f00812
    return 1;
Packit f00812
}
Packit f00812
Packit f00812
int
Packit f00812
main (int argc, char *argv[])
Packit f00812
{
Packit f00812
    for (int i = 1; i < argc && i <= MAX_FILES; i++) {
Packit f00812
        files[i-1] = argv[i];
Packit f00812
	filecounter++;
Packit f00812
    }
Packit f00812
    testFlexLexer* f = new testFlexLexer;
Packit f00812
    f->yywrap();
Packit f00812
    f->yylex();
Packit f00812
    std::cout << "TEST RETURNING OK." << std::endl;
Packit f00812
    return 0;
Packit f00812
}