[Python-checkins] CVS: python/dist/src/Parser tokenizer.c,2.52,2.53

Tim Peters tim_one@users.sourceforge.net
Thu, 30 Aug 2001 13:52:01 -0700


Update of /cvsroot/python/python/dist/src/Parser
In directory usw-pr-cvs1:/tmp/cvs-serv10452/python/Parser

Modified Files:
	tokenizer.c 
Log Message:
SF patch #455966:  Allow leading 0 in float/imag literals.
Consequences for Jython still unknown (but raised on Jython-Dev).


Index: tokenizer.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/tokenizer.c,v
retrieving revision 2.52
retrieving revision 2.53
diff -C2 -d -r2.52 -r2.53
*** tokenizer.c	2001/08/27 19:19:28	2.52
--- tokenizer.c	2001/08/30 20:51:59	2.53
***************
*** 723,727 ****
  	if (isdigit(c)) {
  		if (c == '0') {
! 			/* Hex or octal */
  			c = tok_nextc(tok);
  			if (c == '.')
--- 723,727 ----
  	if (isdigit(c)) {
  		if (c == '0') {
! 			/* Hex or octal -- maybe. */
  			c = tok_nextc(tok);
  			if (c == '.')
***************
*** 738,743 ****
  			}
  			else {
! 				/* XXX This is broken!  E.g.,
! 				   09.9 should be accepted as float! */
  				/* Octal; c is first char of it */
  				/* There's no 'isoctdigit' macro, sigh */
--- 738,742 ----
  			}
  			else {
! 				int found_decimal = 0;
  				/* Octal; c is first char of it */
  				/* There's no 'isoctdigit' macro, sigh */
***************
*** 745,748 ****
--- 744,766 ----
  					c = tok_nextc(tok);
  				}
+ 				if (isdigit(c)) {
+ 					found_decimal = 1;
+ 					do {
+ 						c = tok_nextc(tok);
+ 					} while (isdigit(c));
+ 				}
+ 				if (c == '.')
+ 					goto fraction;
+ 				else if (c == 'e' || c == 'E')
+ 					goto exponent;
+ #ifndef WITHOUT_COMPLEX
+ 				else if (c == 'j' || c == 'J')
+ 					goto imaginary;
+ #endif
+ 				else if (found_decimal) {
+ 					tok->done = E_TOKEN;
+ 					tok_backup(tok, c);
+ 					return ERRORTOKEN;
+ 				}
  			}
  			if (c == 'l' || c == 'L')
***************
*** 766,769 ****
--- 784,788 ----
  				}
  				if (c == 'e' || c == 'E') {
+ 		exponent:
  					/* Exponent part */
  					c = tok_nextc(tok);