62 if(ch ==
'"' || ch ==
'\'') {
65 }
else if(isalpha(ch)) {
68 }
else if(isdigit(ch) ||
119 value = 10.0 * value + double(
line[curr_char] -
'0');
124 if(digit &&
line[curr_char] !=
'.' && toupper(
line[curr_char]) !=
'E') {
126 std::string lexeme(
line.data() + lex_pos, curr_char - lex_pos);
127 return Token(
"string", 1, lexeme,
int(value + 0.5));
131 if(
line[curr_char] ==
'.') {
135 while(isdigit(
line[curr_char])) {
136 value = 10.0 * value + double(
line[curr_char++] -
'0');
142 if(! digit) eflag =
true;
145 if(toupper(
line[curr_char]) ==
'E') {
149 if(
line[curr_char] ==
'+') {
151 }
else if(
line[curr_char] ==
'-') {
156 while(isdigit(
line[curr_char])) {
157 expval = 10 * expval + (
line[curr_char++] -
'0');
161 if(! digit) eflag =
true;
166 while(! isspace(ch) && ! ispunct(ch)) {
174 std::string lexeme(
line.data() + lex_pos, curr_char - lex_pos);
178 "Invalid numeric token \"" + lexeme +
"\".");
180 int power = expsig * expval - places;
183 for(places = power; places > 0; places--)
186 for(places = - power; places > 0; places--)
190 return Token(
"string", 1, lexeme, value);
205 "String not terminated.");
228 lexeme += toupper(ch);
231 while(isalnum(ch) || ch ==
'_' || ch ==
'.' || ch ==
'\'') {
232 lexeme += toupper(ch);
std::string::size_type curr_char
Abstract interface for a stream of input tokens.
virtual Token readToken()
Read single token from file.
Representation of a single input token.