58 Scanner(
const string& formatName, FILE* in);
74 void expect(
char expected);
78 void expect(
char a,
char b);
82 void expect(
const char* str);
141 bool peek(
char character);
193 if (!isalpha(
peek()))
197 str +=
static_cast<char>(
getChar());
198 }
while (isalnum(
peek()) ||
peek() ==
'_');
212 return peek() == EOF;
227 if (got != a && got != b)
259 return isalpha(
peek());
264 return peek() == character;
268 while (isspace(
peek()))
An IOHandler implements input and output for some format in such a way that client code does not need...
This class offers an input interface which is more convenient and for some purposes more efficient th...
const string & getFormat() const
auto_ptr< IOHandler > createIOHandler() const
void expect(const string &str)
Require the following characters to be equal to str.
int peek()
Returns the next character or EOF.
size_t readIntegerString()
Returns the size of the string.
void readIntegerNoSign(string &str)
Read an arbitrary-precision integer.
size_t _tmpStringCapacity
void parseInteger(mpz_class &integer, size_t size)
Scanner(const string &formatName, FILE *in)
Construct a Scanner object.
void reportErrorUnexpectedToken(const string &expected, int got)
void eatWhite()
Reads past any whitespace, where whitespace is defined by the standard function isspace().
vector< char >::iterator _bufferPos
void errorReadIdentifier()
void expectEOF()
Require that there is no more input.
bool peekWhite()
Returns true if the next character is whitespace.
void readIntegerAndNegativeAsZero(mpz_class &integer)
Read an integer and set it to zero if it is negative.
void expectIntegerNoSign()
Read an arbitrary-precision integer.
unsigned long _lineNumber
void expect(char expected)
Require the next character to be equal to expected.
const char * readIdentifier()
The returned string is only valid until the next method on this object gets called.
bool peekIdentifier()
Skips whitespace and returns true if the next token is an identifier.
void readIntegerAndNegativeAsZero(std::string &integer)
Read an integer and set it to zero if it is negative.
void errorExpectTwo(char a, char b, int got)
unsigned int getLineNumber() const
Returns the number of newlines seen.
void readSizeT(size_t &size)
Reads a size_t, where the representable range of that type determines when the number is too big.
size_t readVariable(const VarNames &names)
Reads an identifier and returns the index of that identifier as the index of a variable in names.
bool matchEOF()
Return true if no more input.
void readInteger(mpz_class &integer)
Read an arbitrary-precision integer.
void errorExpectOne(char expected, int got)
void setFormat(const string &format)
void errorReadVariable(const char *name)
bool match(char c)
Return true if the next character is c, and in that case skip past it.
size_t readIntegerStringNoSign()
Returns the size of the string.
Defines the variables of a polynomial ring and facilities IO involving them.
static const size_t invalidIndex
Returns a fixed variable offset that is always invalid.
size_t getIndex(const string &name) const
Returns VarNames::invalidIndex() if name is not known.