/**
* @file Scanner.h
*
* @author <a href="mailto:mellmann@informatik.hu-berlin.de">Heinrich Mellmann</a>
* Declaration of class Scanner
*/
#ifndef __Scanner_h_
#define __Scanner_h_
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <cctype>
// defines the maximal length of a token
#define MAX_TOKEN_LENGTH 1024
class Scanner
{
public:
Scanner(std::istream& inputStream)<--- Class 'Scanner' has a constructor with 1 argument that is not explicit. [+]Class 'Scanner' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.
: inputStream(inputStream),
nextChar(' '),
bufferLength(0),
lineNumber(1)
{
buffer[0] = '\0';
}
virtual ~Scanner(){}
bool eof();
bool isToken(std::string token);
void getNextToken();
bool endOfFile();
char buffer[MAX_TOKEN_LENGTH];
int getLineNumber();
private:
std::istream& inputStream;
char nextChar;
int bufferLength;
virtual bool isTokenChar(char c);
int lineNumber;
void getNextChar();
void skipLine();
void skipSpace();
};
#endif //__Scanner_h_