Mercurial > cpython-lru_cache-weakref
annotate Parser/parser.h @ 87690:66c1c9f32567 default tip
Add use_weakref option to functools.lru_cache
The use_weakref option makes lru_cache create weak references to the function
arguments when creating the cache key, which prevents them from staying in the
memory forever even after all other references to them are gone.
This is a proof of concept for http://bugs.python.org/issue19859
| author | Radomir Dopieralski <devel@sheep.art.pl> |
|---|---|
| date | Tue, 03 Dec 2013 16:02:48 +0100 |
| parents | ca5f2f960617 |
| children |
| rev | line source |
|---|---|
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1 #ifndef Py_PARSER_H |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
2 #define Py_PARSER_H |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
3 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
4 extern "C" { |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
5 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
6 |
| 145 | 7 |
| 6 | 8 /* Parser interface */ |
| 9 | |
|
45443
ca5f2f960617
Issue 1881. Increased the stack limit from 500 to 1500. Also added
Facundo Batista <facundobatista@gmail.com>
parents:
36786
diff
changeset
|
10 #define MAXSTACK 1500 |
| 6 | 11 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
12 typedef struct { |
| 6 | 13 int s_state; /* State in current DFA */ |
| 14 dfa *s_dfa; /* Current DFA */ | |
| 86 | 15 struct _node *s_parent; /* Where to add next node */ |
| 6 | 16 } stackentry; |
| 17 | |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
18 typedef struct { |
| 6 | 19 stackentry *s_top; /* Top entry */ |
| 20 stackentry s_base[MAXSTACK];/* Array of stack entries */ | |
| 21 /* NB The stack grows down */ | |
| 22 } stack; | |
| 23 | |
| 24 typedef struct { | |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
25 stack p_stack; /* Stack of parser states */ |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
26 grammar *p_grammar; /* Grammar to use */ |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
27 node *p_tree; /* Top of parse tree */ |
|
36726
bbf16fd024df
from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents:
22468
diff
changeset
|
28 #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD |
|
bbf16fd024df
from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents:
22468
diff
changeset
|
29 unsigned long p_flags; /* see co_flags in Include/code.h */ |
|
22468
eebae4f60d05
Disable the parser hacks that enabled the "yield" keyword using a future
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
18609
diff
changeset
|
30 #endif |
| 6 | 31 } parser_state; |
| 32 | |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
33 parser_state *PyParser_New(grammar *g, int start); |
|
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
34 void PyParser_Delete(parser_state *ps); |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36726
diff
changeset
|
35 int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, int col_offset, |
|
13539
feab677269e0
Create two new exceptions: IndentationError and TabError. These are
Fred Drake <fdrake@acm.org>
parents:
13447
diff
changeset
|
36 int *expected_ret); |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
37 void PyGrammar_AddAccelerators(grammar *g); |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
38 |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
39 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
40 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
41 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
42 #endif /* !Py_PARSER_H */ |
