Mercurial > cpython-lru_cache-weakref
annotate Parser/tokenizer.h @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | 6f6f965c5e2d |
| children | 06f1e2fd05bc |
| rev | line source |
|---|---|
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
1 #ifndef Py_TOKENIZER_H |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
2 #define Py_TOKENIZER_H |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
3 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
4 extern "C" { |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
5 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
6 |
| 145 | 7 |
| 6 | 8 /* Tokenizer interface */ |
| 9 | |
| 10 #include "token.h" /* For token types */ | |
| 11 | |
| 12 #define MAXINDENT 100 /* Max indentation level */ | |
| 13 | |
| 14 /* Tokenizer state */ | |
| 15 struct tok_state { | |
| 16 /* Input state; buf <= cur <= inp <= end */ | |
|
1282
e0464e7115ca
* pythonrun.c: Print exception type+arg *after* stack trace instead of
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
17 /* NB an entire line is held in the buffer */ |
|
e0464e7115ca
* pythonrun.c: Print exception type+arg *after* stack trace instead of
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
18 char *buf; /* Input buffer, or NULL; malloc'ed if fp != NULL */ |
| 6 | 19 char *cur; /* Next character in buffer */ |
| 20 char *inp; /* End of data in buffer */ | |
|
1282
e0464e7115ca
* pythonrun.c: Print exception type+arg *after* stack trace instead of
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
21 char *end; /* End of input buffer if buf != NULL */ |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1441
diff
changeset
|
22 char *start; /* Start of current token if not NULL */ |
|
1282
e0464e7115ca
* pythonrun.c: Print exception type+arg *after* stack trace instead of
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
23 int done; /* E_OK normally, E_EOF at EOF, otherwise error code */ |
|
e0464e7115ca
* pythonrun.c: Print exception type+arg *after* stack trace instead of
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
24 /* NB If done != E_OK, cur must be == inp!!! */ |
| 6 | 25 FILE *fp; /* Rest of input; NULL if tokenizing a string */ |
| 26 int tabsize; /* Tab spacing */ | |
| 27 int indent; /* Current indentation index */ | |
| 28 int indstack[MAXINDENT]; /* Stack of indents */ | |
| 29 int atbol; /* Nonzero if at begin of new line */ | |
| 30 int pendin; /* Pending indents (if > 0) or dedents (if < 0) */ | |
| 31 char *prompt, *nextprompt; /* For interactive prompting */ | |
| 32 int lineno; /* Current line number */ | |
|
1284
dbce72afe261
* selectmodule.c: fix (another!) two memory leaks -- this time in list2set
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
33 int level; /* () [] {} Parentheses nesting level */ |
|
dbce72afe261
* selectmodule.c: fix (another!) two memory leaks -- this time in list2set
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
34 /* Used to allow free continuations inside them */ |
|
7945
dc132cc39573
Add checking for inconsistent tab usage
Guido van Rossum <guido@python.org>
parents:
5379
diff
changeset
|
35 /* Stuff for checking on different tab sizes */ |
|
dc132cc39573
Add checking for inconsistent tab usage
Guido van Rossum <guido@python.org>
parents:
5379
diff
changeset
|
36 char *filename; /* For error messages */ |
|
dc132cc39573
Add checking for inconsistent tab usage
Guido van Rossum <guido@python.org>
parents:
5379
diff
changeset
|
37 int altwarning; /* Issue warning if alternate tabs don't match */ |
|
dc132cc39573
Add checking for inconsistent tab usage
Guido van Rossum <guido@python.org>
parents:
5379
diff
changeset
|
38 int alterror; /* Issue error if alternate tabs don't match */ |
|
dc132cc39573
Add checking for inconsistent tab usage
Guido van Rossum <guido@python.org>
parents:
5379
diff
changeset
|
39 int alttabsize; /* Alternate tab spacing */ |
|
dc132cc39573
Add checking for inconsistent tab usage
Guido van Rossum <guido@python.org>
parents:
5379
diff
changeset
|
40 int altindstack[MAXINDENT]; /* Stack of alternate indents */ |
| 6 | 41 }; |
| 42 | |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
43 extern struct tok_state *PyTokenizer_FromString(char *); |
|
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
44 extern struct tok_state *PyTokenizer_FromFile(FILE *, char *, char *); |
|
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
45 extern void PyTokenizer_Free(struct tok_state *); |
|
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
46 extern int PyTokenizer_Get(struct tok_state *, char **, char **); |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
47 |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
48 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
49 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
50 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1284
diff
changeset
|
51 #endif /* !Py_TOKENIZER_H */ |
