61 if(ch ==
'"' || ch ==
'\'') {
64 }
else if(isalpha(ch)) {
67 }
else if(isdigit(ch) ||
118 value = 10.0 * value + double(
line_m[currentChar_m] -
'0');
123 if(digit &&
line_m[currentChar_m] !=
'.' && toupper(
line_m[currentChar_m]) !=
'E') {
125 std::string lexeme(
line_m.data() + lex_pos, currentChar_m - lex_pos);
126 return Token(
"string", 1, lexeme,
int(value + 0.5));
130 if(
line_m[currentChar_m] ==
'.') {
134 while(isdigit(
line_m[currentChar_m])) {
135 value = 10.0 * value + double(
line_m[currentChar_m++] -
'0');
141 if(! digit) eflag =
true;
144 if(toupper(
line_m[currentChar_m]) ==
'E') {
148 if(
line_m[currentChar_m] ==
'+') {
150 }
else if(
line_m[currentChar_m] ==
'-') {
155 while(isdigit(
line_m[currentChar_m])) {
156 expval = 10 * expval + (
line_m[currentChar_m++] -
'0');
160 if(! digit) eflag =
true;
165 while(! isspace(ch) && ! ispunct(ch)) {
173 std::string lexeme(
line_m.data() + lex_pos, currentChar_m - lex_pos);
177 "Invalid numeric token \"" + lexeme +
"\".");
179 int power = expsig * expval - places;
182 for(places = power; places > 0; places--)
185 for(places = - power; places > 0; places--)
189 return Token(
"string", 1, lexeme, value);
204 "String not terminated.");
227 lexeme += toupper(ch);
230 while(isalnum(ch) || ch ==
'_' || ch ==
'.' || ch ==
'\'') {
231 lexeme += toupper(ch);
virtual Token readToken()
Read single token from file.
Abstract interface for a stream of input tokens.
Representation of a single input token.
std::string::size_type currentChar_m