Ignore underscores when extracting value of integer.
--- a/absyntax_utils/absyntax_utils.cc Tue Aug 23 17:18:37 2011 +0100
+++ b/absyntax_utils/absyntax_utils.cc Thu Aug 25 17:55:48 2011 +0100
@@ -50,6 +50,7 @@
#include <typeinfo>
#include <list>
#include <strings.h>
+#include <string.h> /* required for strlen() */
#include <stdlib.h> /* required for atoi() */
#include "../util/symtable.hh"
@@ -98,13 +99,23 @@
/* extract the value of an integer from an integer_c object !! */
/* NOTE: it must ignore underscores! */
int extract_integer(symbol_c *sym) {
- integer_c *integer = dynamic_cast<integer_c *>(sym);
- if (integer == NULL) ERROR;
-
- return atoi(integer->value);
+ std::string str = "";
+ integer_c *integer;
+ neg_integer_c * neg_integer;
+
+ if ((neg_integer = dynamic_cast<neg_integer_c *>(sym)) != NULL)
+ return - extract_integer((integer_c *)neg_integer->exp);
+
+ if ((integer = dynamic_cast<integer_c *>(sym)) == NULL) ERROR;
+
+ for(unsigned int i = 0; i < strlen(integer->value); i++)
+ if (integer->value[i] != '_') str += integer->value[i];
+
+ return atoi(str.c_str());
}
+
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/