diff options
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/Python.asdl | 4 | ||||
-rw-r--r-- | Parser/asdl.py | 2 | ||||
-rwxr-xr-x | Parser/asdl_c.py | 12 | ||||
-rw-r--r-- | Parser/grammar1.c | 2 | ||||
-rw-r--r-- | Parser/myreadline.c | 2 | ||||
-rw-r--r-- | Parser/tokenizer.c | 2 |
6 files changed, 18 insertions, 6 deletions
diff --git a/Parser/Python.asdl b/Parser/Python.asdl index c24d8406192..0d373b09d32 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -1,4 +1,4 @@ --- ASDL's five builtin types are identifier, int, string, bytes, object +-- ASDL's six builtin types are identifier, int, string, bytes, object, singleton module Python { @@ -69,8 +69,8 @@ module Python | Num(object n) -- a number as a PyObject. | Str(string s) -- need to specify raw, unicode, etc? | Bytes(bytes s) + | NameConstant(singleton value) | Ellipsis - -- other literals? bools? -- the following expression can appear in assignment context | Attribute(expr value, identifier attr, expr_context ctx) diff --git a/Parser/asdl.py b/Parser/asdl.py index 08aa05b897c..1f98ada992f 100644 --- a/Parser/asdl.py +++ b/Parser/asdl.py @@ -222,7 +222,7 @@ class ASDLParser(spark.GenericParser, object): " field ::= Id ? " return Field(type[0], opt=True) -builtin_types = ("identifier", "string", "bytes", "int", "object") +builtin_types = ("identifier", "string", "bytes", "int", "object", "singleton") # below is a collection of classes to capture the AST of an AST :-) # not sure if any of the methods are useful yet, but I'm adding them diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index a9e6626ab41..9557ba0cf2c 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -820,6 +820,7 @@ static PyObject* ast2obj_object(void *o) Py_INCREF((PyObject*)o); return (PyObject*)o; } +#define ast2obj_singleton ast2obj_object #define ast2obj_identifier ast2obj_object #define ast2obj_string ast2obj_object #define ast2obj_bytes ast2obj_object @@ -831,6 +832,17 @@ static PyObject* ast2obj_int(long b) /* Conversion Python -> AST */ +static int obj2ast_singleton(PyObject *obj, PyObject** out, PyArena* arena) +{ + if (obj != Py_None && obj != Py_True && obj != Py_False) { + PyErr_SetString(PyExc_ValueError, + "AST singleton must be True, False, or None"); + return 1; + } + *out = obj; + return 0; +} + static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) { if (obj == Py_None) diff --git a/Parser/grammar1.c b/Parser/grammar1.c index 1f7d264be92..4b5aa8a49d6 100644 --- a/Parser/grammar1.c +++ b/Parser/grammar1.c @@ -30,7 +30,7 @@ PyGrammar_FindDFA(grammar *g, register int type) #endif } -char * +const char * PyGrammar_LabelRepr(label *lb) { static char buf[100]; diff --git a/Parser/myreadline.c b/Parser/myreadline.c index d864623f1a2..8b27045f1d6 100644 --- a/Parser/myreadline.c +++ b/Parser/myreadline.c @@ -68,7 +68,7 @@ my_fgets(char *buf, int len, FILE *fp) */ if (GetLastError()==ERROR_OPERATION_ABORTED) { hInterruptEvent = _PyOS_SigintEvent(); - switch (WaitForSingleObject(hInterruptEvent, 10)) { + switch (WaitForSingleObjectEx(hInterruptEvent, 10, FALSE)) { case WAIT_OBJECT_0: ResetEvent(hInterruptEvent); return 1; /* Interrupt */ diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 93a4a5ccb47..c2c182ce195 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -47,7 +47,7 @@ static void tok_backup(struct tok_state *tok, int c); /* Token names */ -char *_PyParser_TokenNames[] = { +const char *_PyParser_TokenNames[] = { "ENDMARKER", "NAME", "NUMBER", |