diff --git a/sphinx/pycode/Grammar-py2.txt b/sphinx/pycode/Grammar-py2.txt index 54d6fa970..98bd1f22b 100644 --- a/sphinx/pycode/Grammar-py2.txt +++ b/sphinx/pycode/Grammar-py2.txt @@ -1,12 +1,15 @@ # Grammar for Python 2.x +# IMPORTANT: when copying over a new Grammar file, make sure file_input +# is the first nonterminal in the file! + # Start symbols for the grammar: # single_input is a single interactive statement; # file_input is a module or sequence of commands read from an input file; # 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 +single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE @@ -94,7 +97,6 @@ atom: ('(' [yield_expr|testlist_comp] ')' | '[' [listmaker] ']' | '{' [dictorsetmaker] '}' | '`' testlist1 '`' | -# '>>' test | NAME | NUMBER | STRING+) listmaker: test ( list_for | (',' test)* [','] ) testlist_comp: test ( comp_for | (',' test)* [','] ) diff --git a/sphinx/pycode/Grammar-py3.txt b/sphinx/pycode/Grammar-py3.txt index 92922accf..083b5f91e 100644 --- a/sphinx/pycode/Grammar-py3.txt +++ b/sphinx/pycode/Grammar-py3.txt @@ -1,12 +1,15 @@ # Grammar for Python 3.x (with at least x <= 4) +# IMPORTANT: when copying over a new Grammar file, make sure file_input +# is the first nonterminal in the file! + # Start symbols for the grammar: # single_input is a single interactive statement; # file_input is a module or sequence of commands read from an input file; # 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 +single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE