summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-08-30 20:51:59 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-08-30 20:51:59 (GMT)
commitd507dab91f9790a24bd53d41d7fcf52fe89a6eff (patch)
treebfd040b35180f81cb9b0376df6070d91a08e7c57 /Parser
parent21922aa9393996b1ea3f324759e158ec623acb43 (diff)
downloadcpython-d507dab91f9790a24bd53d41d7fcf52fe89a6eff.zip
cpython-d507dab91f9790a24bd53d41d7fcf52fe89a6eff.tar.gz
cpython-d507dab91f9790a24bd53d41d7fcf52fe89a6eff.tar.bz2
SF patch #455966: Allow leading 0 in float/imag literals.
Consequences for Jython still unknown (but raised on Jython-Dev).
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 7270629..324d9b6 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -722,7 +722,7 @@ PyTokenizer_Get(register struct tok_state *tok, char **p_start,
/* Number */
if (isdigit(c)) {
if (c == '0') {
- /* Hex or octal */
+ /* Hex or octal -- maybe. */
c = tok_nextc(tok);
if (c == '.')
goto fraction;
@@ -737,13 +737,31 @@ PyTokenizer_Get(register struct tok_state *tok, char **p_start,
} while (isxdigit(c));
}
else {
- /* XXX This is broken! E.g.,
- 09.9 should be accepted as float! */
+ int found_decimal = 0;
/* Octal; c is first char of it */
/* There's no 'isoctdigit' macro, sigh */
while ('0' <= c && c < '8') {
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')
c = tok_nextc(tok);
@@ -765,6 +783,7 @@ PyTokenizer_Get(register struct tok_state *tok, char **p_start,
} while (isdigit(c));
}
if (c == 'e' || c == 'E') {
+ exponent:
/* Exponent part */
c = tok_nextc(tok);
if (c == '+' || c == '-')