From 0eae829b117a5786b2e6532fe5c540f5026f10cd Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 30 May 2013 19:49:22 -0500 Subject: [PATCH] factor out isNumber() in dsnlexer.cpp, add support for numbers with exponents, leave commented out for further testing --- common/dsnlexer.cpp | 108 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 15 deletions(-) diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp index e70f5e1fa8..ed2aac67ef 100644 --- a/common/dsnlexer.cpp +++ b/common/dsnlexer.cpp @@ -394,6 +394,93 @@ static bool isSpace( int cc ) } +/** + * Function isNumber + * return true if the next sequence of s-expression text is a number: + * either an integer, fixed point, or float with exponent. + * + * @param cp is the start of the current token. + * @param limit is the end of the current line of text. + * @param next is where to put a pointer to the start of the token after this one, but is only + * updated if the return value is true. + * @return bool - true if this is a number, else false. + */ +static bool isNumber( const char* cp, const char* limit, const char** next ) +{ +#if 1 // no exponents supported + + if( strchr( "+-.0123456789", *cp ) ) + { + ++cp; + while( cp