// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
#include <config.h>
#include <sstream>
+#include <cstring>
#include <stdexcept>
#include <iostream>
c = 0;
bufend = 0;
nextChar();
- } catch(EOFException& e) {
+ } catch(EOFException& ) {
}
}
throw EOFException();
stream.read(buffer, BUFFER_SIZE);
size_t bytes_read = stream.gcount();
-
+
c = buffer;
bufend = buffer + bytes_read;
++linenumber;
nextChar();
};
-
+
token_length = 0;
-
+
switch(*c) {
case ';': // comment
while(true) {
nextChar();
if(*c == '"')
break;
+ else if (*c == '\r') // XXX this breaks with pure \r EOL
+ continue;
else if(*c == '\n')
linenumber++;
else if(*c == '\\') {
} catch(EOFException& ) {
std::stringstream msg;
msg << "Parse error in line " << startline << ": "
- << "EOF while parsing string.";
+ << "EOF while parsing string.";
throw std::runtime_error(msg.str());
}
nextChar();
case '#': // constant
try {
nextChar();
-
+
while(isalnum(*c) || *c == '_') {
if(token_length < MAX_TOKEN_LENGTH)
token_string[token_length++] = *c;
bool have_nondigits = false;
bool have_digits = false;
int have_floating_point = 0;
-
+
do {
if(isdigit(*c))
have_digits = true;
else if(*c == '.')
++have_floating_point;
else if(isalnum(*c) || *c == '_')
- have_nondigits = true;
-
+ have_nondigits = true;
+
if(token_length < MAX_TOKEN_LENGTH)
token_string[token_length++] = *c;
} while(!isspace(*c) && !strchr(delims, *c));
token_string[token_length] = 0;
-
+
// no nextChar
if(have_nondigits || !have_digits || have_floating_point > 1)
nextChar();
} while(!isspace(*c) && !strchr(delims, *c));
token_string[token_length] = 0;
-
+
// no nextChar
return TOKEN_SYMBOL;
- }
+ }
}
} catch(EOFException& ) {
return TOKEN_EOF;
}
} // end of namespace lisp
-