From 4c42a82ebc44a35880cbd922eaca177e3b769b78 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 24 Mar 2020 22:35:21 +0100 Subject: [PATCH] Allow multiple newlines in a suite, this makes the diff parser easier --- parso/python/grammar27.txt | 4 ++-- parso/python/grammar33.txt | 4 ++-- parso/python/grammar34.txt | 4 ++-- parso/python/grammar35.txt | 4 ++-- parso/python/grammar36.txt | 4 ++-- parso/python/grammar37.txt | 4 ++-- parso/python/grammar38.txt | 4 ++-- parso/python/grammar39.txt | 4 ++-- test/test_diff_parser.py | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/parso/python/grammar27.txt b/parso/python/grammar27.txt index ddb6847..29f1b82 100644 --- a/parso/python/grammar27.txt +++ b/parso/python/grammar27.txt @@ -16,7 +16,7 @@ # eval_input is the input for the eval() and input() functions. # NB: compound_stmt in single_input is followed by extra NEWLINE! single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER +file_input: stmt* ENDMARKER eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE @@ -30,7 +30,7 @@ varargslist: ((fpdef ['=' test] ',')* fpdef: NAME | '(' fplist ')' fplist: fpdef (',' fpdef)* [','] -stmt: simple_stmt | compound_stmt +stmt: simple_stmt | compound_stmt | NEWLINE simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt) diff --git a/parso/python/grammar33.txt b/parso/python/grammar33.txt index 787a166..dd93d8b 100644 --- a/parso/python/grammar33.txt +++ b/parso/python/grammar33.txt @@ -16,7 +16,7 @@ # eval_input is the input for the eval() functions. # NB: compound_stmt in single_input is followed by extra NEWLINE! single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER +file_input: stmt* ENDMARKER eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE @@ -33,7 +33,7 @@ varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef) vfpdef: NAME -stmt: simple_stmt | compound_stmt +stmt: simple_stmt | compound_stmt | NEWLINE simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt) diff --git a/parso/python/grammar34.txt b/parso/python/grammar34.txt index 2b497d5..999f4cd 100644 --- a/parso/python/grammar34.txt +++ b/parso/python/grammar34.txt @@ -16,7 +16,7 @@ # eval_input is the input for the eval() functions. # NB: compound_stmt in single_input is followed by extra NEWLINE! single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER +file_input: stmt* ENDMARKER eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE @@ -33,7 +33,7 @@ varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef) vfpdef: NAME -stmt: simple_stmt | compound_stmt +stmt: simple_stmt | compound_stmt | NEWLINE simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt) diff --git a/parso/python/grammar35.txt b/parso/python/grammar35.txt index e2ee9c7..29f49e4 100644 --- a/parso/python/grammar35.txt +++ b/parso/python/grammar35.txt @@ -16,7 +16,7 @@ # eval_input is the input for the eval() functions. # NB: compound_stmt in single_input is followed by extra NEWLINE! single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER +file_input: stmt* ENDMARKER eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE @@ -38,7 +38,7 @@ varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef) vfpdef: NAME -stmt: simple_stmt | compound_stmt +stmt: simple_stmt | compound_stmt | NEWLINE simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt) diff --git a/parso/python/grammar36.txt b/parso/python/grammar36.txt index 3e1e3e2..2fec1f9 100644 --- a/parso/python/grammar36.txt +++ b/parso/python/grammar36.txt @@ -9,7 +9,7 @@ # eval_input is the input for the eval() functions. # NB: compound_stmt in single_input is followed by extra NEWLINE! single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER +file_input: stmt* ENDMARKER eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE decorators: decorator+ @@ -35,7 +35,7 @@ varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' [ ) vfpdef: NAME -stmt: simple_stmt | compound_stmt +stmt: simple_stmt | compound_stmt | NEWLINE simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt) diff --git a/parso/python/grammar37.txt b/parso/python/grammar37.txt index 3090b93..8799b84 100644 --- a/parso/python/grammar37.txt +++ b/parso/python/grammar37.txt @@ -9,7 +9,7 @@ # eval_input is the input for the eval() functions. # NB: compound_stmt in single_input is followed by extra NEWLINE! single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER +file_input: stmt* ENDMARKER eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE decorators: decorator+ @@ -33,7 +33,7 @@ varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' [ ) vfpdef: NAME -stmt: simple_stmt | compound_stmt +stmt: simple_stmt | compound_stmt | NEWLINE simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt) diff --git a/parso/python/grammar38.txt b/parso/python/grammar38.txt index 1cea0fa..40908ed 100644 --- a/parso/python/grammar38.txt +++ b/parso/python/grammar38.txt @@ -9,7 +9,7 @@ # eval_input is the input for the eval() functions. # NB: compound_stmt in single_input is followed by extra NEWLINE! single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER +file_input: stmt* ENDMARKER eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE @@ -46,7 +46,7 @@ varargslist: vfpdef ['=' test ](',' vfpdef ['=' test])* ',' '/' [',' [ (vfpdef [ ) vfpdef: NAME -stmt: simple_stmt | compound_stmt +stmt: simple_stmt | compound_stmt | NEWLINE simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt) diff --git a/parso/python/grammar39.txt b/parso/python/grammar39.txt index 1cea0fa..40908ed 100644 --- a/parso/python/grammar39.txt +++ b/parso/python/grammar39.txt @@ -9,7 +9,7 @@ # eval_input is the input for the eval() functions. # NB: compound_stmt in single_input is followed by extra NEWLINE! single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER +file_input: stmt* ENDMARKER eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE @@ -46,7 +46,7 @@ varargslist: vfpdef ['=' test ](',' vfpdef ['=' test])* ',' '/' [',' [ (vfpdef [ ) vfpdef: NAME -stmt: simple_stmt | compound_stmt +stmt: simple_stmt | compound_stmt | NEWLINE simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt) diff --git a/test/test_diff_parser.py b/test/test_diff_parser.py index fbc545e..b7f03b2 100644 --- a/test/test_diff_parser.py +++ b/test/test_diff_parser.py @@ -45,7 +45,7 @@ def _assert_nodes_are_equal(node1, node2): except AttributeError: assert not hasattr(node2, 'children'), (node1, node2) assert node1.value == node2.value - #assert node1.type == node2.type + assert node1.type == node2.type assert node1.prefix == node2.prefix assert node1.start_pos == node2.start_pos return