Kaydet (Commit) cf588f64 authored tarafından Brett Cannon's avatar Brett Cannon

Remove support for backticks from the grammar and compiler.

Still need to remove traces of the UNARY_CONVERT opcode.
üst 8b6de130
......@@ -268,49 +268,6 @@ stored for a given key value prevails.
\indexii{immutable}{object}
\subsection{String conversions\label{string-conversions}}
\indexii{string}{conversion}
\indexii{reverse}{quotes}
\indexii{backward}{quotes}
\index{back-quotes}
A string conversion is an expression list enclosed in reverse (a.k.a.
backward) quotes:
\begin{productionlist}
\production{string_conversion}
{"`" \token{expression_list} "`"}
\end{productionlist}
A string conversion evaluates the contained expression list and
converts the resulting object into a string according to rules
specific to its type.
If the object is a string, a number, \code{None}, or a tuple, list or
dictionary containing only objects whose type is one of these, the
resulting string is a valid Python expression which can be passed to
the built-in function \function{eval()} to yield an expression with the
same value (or an approximation, if floating point numbers are
involved).
(In particular, converting a string adds quotes around it and converts
``funny'' characters to escape sequences that are safe to print.)
Recursive objects (for example, lists or dictionaries that contain a
reference to themselves, directly or indirectly) use \samp{...} to
indicate a recursive reference, and the result cannot be passed to
\function{eval()} to get an equal value (\exception{SyntaxError} will
be raised instead).
\obindex{recursive}
The built-in function \function{repr()} performs exactly the same
conversion in its argument as enclosing it in parentheses and reverse
quotes does. The built-in function \function{str()} performs a
similar but more user-friendly conversion.
\bifuncindex{repr}
\bifuncindex{str}
\section{Primaries\label{primaries}}
\index{primary}
......
......@@ -102,7 +102,6 @@ power: atom trailer* ['**' factor]
atom: ('(' [yield_expr|testlist_gexp] ')' |
'[' [listmaker] ']' |
'{' [dictmaker] '}' |
'`' testlist1 '`' |
NAME | NUMBER | STRING+)
listmaker: test ( list_for | (',' test)* [','] )
testlist_gexp: test ( gen_for | (',' test)* [','] )
......
......@@ -83,7 +83,7 @@ Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"!=",
r"~")
Bracket = '[][(){}]'
Special = group(r'\r?\n', r'[:;.,`@]')
Special = group(r'\r?\n', r'[:;.,@]')
Funny = group(Operator, Bracket, Special)
PlainToken = group(Number, Funny, String, Name)
......
......@@ -67,7 +67,6 @@ char *_PyParser_TokenNames[] = {
"EQUAL",
"DOT",
"PERCENT",
"BACKQUOTE",
"LBRACE",
"RBRACE",
"EQEQUAL",
......@@ -955,7 +954,6 @@ PyToken_OneChar(int c)
case '=': return EQUAL;
case '.': return DOT;
case '%': return PERCENT;
case '`': return BACKQUOTE;
case '{': return LBRACE;
case '}': return RBRACE;
case '^': return CIRCUMFLEX;
......
......@@ -1190,7 +1190,7 @@ static expr_ty
ast_for_atom(struct compiling *c, const node *n)
{
/* atom: '(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']'
| '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+
| '{' [dictmaker] '}' | NAME | NUMBER | STRING+
*/
node *ch = CHILD(n, 0);
......@@ -1276,13 +1276,6 @@ ast_for_atom(struct compiling *c, const node *n)
}
return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);
}
case BACKQUOTE: { /* repr */
expr_ty expression = ast_for_testlist(c, CHILD(n, 1));
if (!expression)
return NULL;
return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena);
}
default:
PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch));
return NULL;
......
......@@ -721,7 +721,6 @@ opcode_stack_effect(int opcode, int oparg)
case UNARY_POSITIVE:
case UNARY_NEGATIVE:
case UNARY_NOT:
case UNARY_CONVERT:
case UNARY_INVERT:
return 0;
......@@ -2983,10 +2982,6 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
return compiler_compare(c, e);
case Call_kind:
return compiler_call(c, e);
case Repr_kind:
VISIT(c, expr, e->v.Repr.value);
ADDOP(c, UNARY_CONVERT);
break;
case Num_kind:
ADDOP_O(c, LOAD_CONST, e->v.Num.n, consts);
break;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment