This is first part of campaign to remove 'stream_lc.h'.
{
}
-Scanner::Scanner(std::istream& i, OutputFile & o)
- : ScannerState(), in(i), out(o)
-{
-}
+Scanner::Scanner (FILE * i, OutputFile & o)
+ : ScannerState ()
+ , in (i)
+ , out (o)
+{}
char *Scanner::fill(char *cursor, uint need)
{
bot = buf;
}
/* Append to buffer. */
- in.read(lim, need);
- if ((cnt = in.gcount()) != need)
+ cnt = fread (lim, 1, need, in);
+ if (cnt != need)
{
eof = &lim[cnt];
*eof++ = '\0';
}
// set up the source stream
- re2c::ifstream_lc source;
-
+ FILE * source = NULL;
if (sourceFileName[0] == '-' && sourceFileName[1] == '\0')
{
if (fFlag)
return 1;
}
sourceFileName = "<stdin>";
- source.open(stdin);
+ source = stdin;
+ }
+ else
+ {
+ source = fopen (sourceFileName, "rb");
}
- else if (!source.open(sourceFileName).is_open())
+ if (source == NULL)
{
cerr << "re2c: error: cannot open " << sourceFileName << "\n";
return 1;
// output generated code
output.emit ();
+ fclose (source);
return 0;
}
#ifndef _scanner_h
#define _scanner_h
-#include <iosfwd>
#include <string>
#include "globals.h"
public line_number, private ScannerState
{
private:
- std::istream& in;
+ FILE * in;
OutputFile & out;
private:
void set_sourceline(char *& cursor);
public:
- Scanner(std::istream&, OutputFile &);
+ Scanner(FILE *, OutputFile &);
~Scanner();
enum ParseMode {