// It does not pull in all the rational number code.
// General includes.
-#include "cl_sysdep.h"
+#include "base/cl_sysdep.h"
// Specification.
#include "cln/integer_io.h"
#include "cln/input.h"
#include "cln/io.h"
-#include "cl_spushstring.h"
+#include "base/string/cl_spushstring.h"
namespace cln {
char* end_pointer (void) { return buffer+index; }
};
-static cl_boolean number_char_p (char c)
+static bool number_char_p (char c)
{
if ((c >= '0') && (c <= '9'))
- return cl_true;
+ return true;
if (((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')))
- return cl_true;
+ return true;
switch (c) {
case '+': case '-': case '.': case '_': case '/':
- return cl_true;
+ return true;
default:
- return cl_false;
+ return false;
}
}
var int c;
// Skip whitespace at the beginning.
loop {
- c = freadchar(stream);
- if (c == cl_EOF) goto eof;
+ c = stream.get();
+ if (stream.eof() || stream.fail()) goto eof;
if ((c == ' ') || (c == '\t') || (c == '\n'))
continue;
else
buffer.push(c);
// Read some digits, then a letter, then a token.
loop {
- c = freadchar(stream);
- if (c == cl_EOF) goto eof;
+ c = stream.get();
+ if (stream.eof() || stream.fail()) goto eof;
buffer.push(c);
if ((c >= '0') && (c <= '9'))
continue;
}
if (!(((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))))
goto syntax1;
- c = freadchar(stream);
- if (c == cl_EOF) goto eof;
+ c = stream.get();
+ if (stream.eof() || stream.fail()) goto eof;
}
// Read a number token.
if (!number_char_p(c))
goto syntax1;
loop {
buffer.push(c);
- c = freadchar(stream);
- if (c == cl_EOF)
+ c = stream.get();
+ if (stream.eof() || stream.fail())
break;
if (!number_char_p(c)) {
- funreadchar(stream,c);
+ stream.putback(c);
break;
}
}
// Handle syntax error.
syntax1: buffer.push(c);
- read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+ throw read_number_bad_syntax_exception(buffer.start_pointer(),buffer.end_pointer());
// Handle premature EOF.
-eof: read_number_eof();
+eof: throw read_number_eof_exception();
}
} // namespace cln