#include "abstract.h"
#endif /* PGEN */
+/* Alternate tab spacing */
+#define ALTTABSIZE 1
+
#define is_potential_identifier_start(c) (\
(c >= 'a' && c <= 'z')\
|| (c >= 'A' && c <= 'Z')\
tok->prompt = tok->nextprompt = NULL;
tok->lineno = 0;
tok->level = 0;
- tok->altwarning = 1;
- tok->alterror = 1;
- tok->alttabsize = 1;
tok->altindstack[0] = 0;
tok->decoding_state = STATE_INIT;
tok->decoding_erred = 0;
static int
indenterror(struct tok_state *tok)
{
- if (tok->alterror) {
- tok->done = E_TABSPACE;
- tok->cur = tok->inp;
- return 1;
- }
- if (tok->altwarning) {
-#ifdef PGEN
- PySys_WriteStderr("inconsistent use of tabs and spaces "
- "in indentation\n");
-#else
- PySys_FormatStderr("%U: inconsistent use of tabs and spaces "
- "in indentation\n", tok->filename);
-#endif
- tok->altwarning = 0;
- }
- return 0;
+ tok->done = E_TABSPACE;
+ tok->cur = tok->inp;
+ return ERRORTOKEN;
}
#ifdef PGEN
col++, altcol++;
}
else if (c == '\t') {
- col = (col/tok->tabsize + 1) * tok->tabsize;
- altcol = (altcol/tok->alttabsize + 1)
- * tok->alttabsize;
+ col = (col / tok->tabsize + 1) * tok->tabsize;
+ altcol = (altcol / ALTTABSIZE + 1) * ALTTABSIZE;
}
else if (c == '\014') {/* Control-L (formfeed) */
col = altcol = 0; /* For Emacs users */
if (col == tok->indstack[tok->indent]) {
/* No change */
if (altcol != tok->altindstack[tok->indent]) {
- if (indenterror(tok)) {
- return ERRORTOKEN;
- }
+ return indenterror(tok);
}
}
else if (col > tok->indstack[tok->indent]) {
return ERRORTOKEN;
}
if (altcol <= tok->altindstack[tok->indent]) {
- if (indenterror(tok)) {
- return ERRORTOKEN;
- }
+ return indenterror(tok);
}
tok->pendin++;
tok->indstack[++tok->indent] = col;
return ERRORTOKEN;
}
if (altcol != tok->altindstack[tok->indent]) {
- if (indenterror(tok)) {
- return ERRORTOKEN;
- }
+ return indenterror(tok);
}
}
}
(Grammar/Grammar). */
PyObject *filename;
#endif
- int altwarning; /* Issue warning if alternate tabs don't match */
- int alterror; /* Issue error if alternate tabs don't match */
- int alttabsize; /* Alternate tab spacing */
int altindstack[MAXINDENT]; /* Stack of alternate indents */
/* Stuff for PEP 0263 */
enum decoding_state decoding_state;