>From b5eaf8174267ac466ad3d8be63bae4448f476d16 Mon Sep 17 00:00:00 2001 From: Kapuze Martin Date: Wed, 18 Nov 2020 17:54:22 +0100 Subject: [PATCH 1/3] add python grammar for type hints in variable definitions --- admin/grammars/python.wy | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/admin/grammars/python.wy b/admin/grammars/python.wy index aaa25ced20..b7254e2533 100644 --- a/admin/grammars/python.wy +++ b/admin/grammars/python.wy @@ -1140,7 +1140,7 @@ fpdef_opt_test ;; fpdef: NAME | '(' fplist ')' fpdef - : NAME + : NAME type_hint (VARIABLE-TAG $1 nil nil) ;; Below breaks the parser. Don't know why, but my guess is that ;; LPAREN/RPAREN clashes with the ones in function_parameters. @@ -1160,6 +1160,15 @@ fpdef ;; | fpdef_list COMMA fpdef ;; ; +type_hint + : ;;EMPTY + | COLON type + ; + +type + : dotted_name + ; + ;; ['=' test] eq_test_opt : ;;EMPTY -- 2.25.1