Skip to content

Commit fda3202

Browse files
committed
linking all the compiler stuff together. quite a lot of shotgun surgery
1 parent 92afde2 commit fda3202

File tree

17 files changed

+703
-293
lines changed

17 files changed

+703
-293
lines changed

Grammar/python.gram

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ atom[expr_ty]:
696696
| NUMBER
697697
| &'(' (tuple | group | genexp)
698698
| &'[' (list | listcomp)
699-
| &'{' (dict | set | dictcomp | setcomp)
699+
| &'{' (dict | set | dictcomp | setcomp | record)
700700
| '...' { _PyAST_Constant(Py_Ellipsis, NULL, EXTRA) }
701701

702702
strings[expr_ty] (memo): a=STRING+ { _PyPegen_concatenate_strings(p, a) }
@@ -725,6 +725,13 @@ dict[expr_ty]:
725725
CHECK(asdl_expr_seq*, _PyPegen_get_values(p, a)),
726726
EXTRA) }
727727
| '{' invalid_double_starred_kvpairs '}'
728+
record[expr_ty]:
729+
| '{' '|' a=[kwargs] '|' '}' {
730+
_PyAST_Record(
731+
CHECK(asdl_expr_seq*, _PyPegen_get_record_keys(p, a)),
732+
CHECK(asdl_expr_seq*, _PyPegen_get_record_values(p, a)),
733+
EXTRA) }
734+
| '{' '|' invalid_kwarg '|' '}'
728735

729736
dictcomp[expr_ty]:
730737
| '{' a=kvpair b=for_if_clauses '}' { _PyAST_DictComp(a->key, a->value, b, EXTRA) }

Include/internal/pycore_ast.h

Lines changed: 16 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_ast_state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ struct ast_state {
122122
PyObject *RShift_singleton;
123123
PyObject *RShift_type;
124124
PyObject *Raise_type;
125+
PyObject *Record_type;
125126
PyObject *Return_type;
126127
PyObject *SetComp_type;
127128
PyObject *Set_type;

Include/opcode.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/opcode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def jabs_op(name, op):
147147
def_op('BUILD_LIST', 103) # Number of list items
148148
def_op('BUILD_SET', 104) # Number of set items
149149
def_op('BUILD_MAP', 105) # Number of dict entries
150+
def_op('BUILD_RECORD', 166) # Number of record fields
150151
name_op('LOAD_ATTR', 106) # Index in name list
151152
def_op('COMPARE_OP', 107) # Comparison operator
152153
hascompare.append(107)

Parser/Python.asdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module Python
6161
| Lambda(arguments args, expr body)
6262
| IfExp(expr test, expr body, expr orelse)
6363
| Dict(expr* keys, expr* values)
64+
| Record(expr* keys, expr* values)
6465
| Set(expr* elts)
6566
| ListComp(expr elt, comprehension* generators)
6667
| SetComp(expr elt, comprehension* generators)

0 commit comments

Comments
 (0)