# HG changeset patch # User Mario de Sousa # Date 1314291348 -3600 # Node ID 1aeb29ee93818d781e413108280cf561555c2e41 # Parent 84ad67170c113f5db77c7a3dccca404cfaab7d96 Ignore underscores when extracting value of integer. diff -r 84ad67170c11 -r 1aeb29ee9381 absyntax_utils/absyntax_utils.cc --- 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 #include #include +#include /* required for strlen() */ #include /* 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(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(sym)) != NULL) + return - extract_integer((integer_c *)neg_integer->exp); + + if ((integer = dynamic_cast(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()); } + /***********************************************************************/ /***********************************************************************/ /***********************************************************************/