|
From: Jose M. <ho...@us...> - 2005-06-25 23:49:59
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7283/src Modified Files: parser_stuff.c Log Message: - Fixed bug with variables ending in 'e' followed by '+' or '-' leche=2 leche+3 -> error tried to use the exponential notation (like 1e4) - Fixed bug with variables and specifying basis: a= 2 a_16 -> error, it understood 'a' as a variable Index: parser_stuff.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/parser_stuff.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** parser_stuff.c 24 Jun 2005 22:02:12 -0000 1.21 --- parser_stuff.c 25 Jun 2005 23:49:50 -0000 1.22 *************** *** 186,190 **** int yylex (void) { ! int epos, return_value, id; int handled=0; char *copy_text, aux; --- 186,190 ---- int yylex (void) { ! int epos, return_value, id, numdigits, i; int handled=0; char *copy_text, aux; *************** *** 201,211 **** epos= pos; while (isdigit ((int) input[epos]) || isalpha ((int) input[epos]) ! || input[epos]==decimal_char) ++epos; // we've got an 'entry', lets check it if (epos>pos) { // check if we have an exponent coming up (only for base 10) ! if ((input[epos - 1]=='e' || input[epos - 1]=='E') && GetSystemVariable (SYSTEMVAR_IBASE)==10 && (input[epos]=='+' || input[epos]=='-')) { --- 201,216 ---- epos= pos; + numdigits= 0; while (isdigit ((int) input[epos]) || isalpha ((int) input[epos]) ! || input[epos]==decimal_char) { ! if (isdigit ((int) input[epos])) ++numdigits; ! ++epos; ! } // we've got an 'entry', lets check it if (epos>pos) { // check if we have an exponent coming up (only for base 10) ! if (numdigits==epos - pos - 1 && ! (input[epos - 1]=='e' || input[epos - 1]=='E') && GetSystemVariable (SYSTEMVAR_IBASE)==10 && (input[epos]=='+' || input[epos]=='-')) { *************** *** 220,244 **** handled= 1; } else { // not syntactically open ! aux= input[epos]; ! input[epos]= '\0'; ! if ((id= CheckCommand (input + pos))!=-1) { // command ! yylval.id= id; ! return_value= COMMAND; ! } else if ((id= CheckFunction (input + pos))!=-1) { // it's a function ! yylval.id= id; ! return_value= FUNCTION; ! } else if (CheckVariable (input + pos)) { // it's a known variable ! copy_text= NewNameListEntry (input + pos); ! yylval.name= copy_text; ! return_value= VARIABLE; ! previous_token_closing_new= 1; ! } else { // it's an 'entry' (either new variable or number) copy_text= NewNameListEntry (input + pos); yylval.name= copy_text; return_value= ENTRY; previous_token_closing_new= 1; } - input[epos]= aux; - handled= 1; } } else { // no entry, just an operator (single character) --- 225,263 ---- handled= 1; } else { // not syntactically open ! // before trying to guess anything check we're not indicating a "based" number ! // if we don't do this we have problem with this: a=2 ; a_16 (it understands 'a' as a variable) ! for (i=epos; input[i]==' '; ++i); ! if (input[i]=='_') { // we are defining a based number, stop guessing ! aux= input[epos]; ! input[epos]= '\0'; copy_text= NewNameListEntry (input + pos); yylval.name= copy_text; return_value= ENTRY; previous_token_closing_new= 1; + input[epos]= aux; + handled= 1; + } else { // don't know yet, keep guessing + aux= input[epos]; + input[epos]= '\0'; + if ((id= CheckCommand (input + pos))!=-1) { // command + yylval.id= id; + return_value= COMMAND; + } else if ((id= CheckFunction (input + pos))!=-1) { // it's a function + yylval.id= id; + return_value= FUNCTION; + } else if (CheckVariable (input + pos)) { // it's a known variable + copy_text= NewNameListEntry (input + pos); + yylval.name= copy_text; + return_value= VARIABLE; + previous_token_closing_new= 1; + } else { // it's an 'entry' (either new variable or number) + copy_text= NewNameListEntry (input + pos); + yylval.name= copy_text; + return_value= ENTRY; + previous_token_closing_new= 1; + } + input[epos]= aux; + handled= 1; } } } else { // no entry, just an operator (single character) |