Fix new grammar files to have correct starting symbol at the top.

This commit is contained in:
Georg Brandl 2014-01-12 20:29:37 +01:00
parent 42a8138c30
commit 4650f5a1b5
2 changed files with 8 additions and 3 deletions

View File

@ -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)* [','] )

View File

@ -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