mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #1102: Support multi-context "with" statements in autodoc by updating
pycode grammar from lib2to3.
This commit is contained in:
parent
34c8a68e74
commit
2e8b8ba7e3
1
CHANGES
1
CHANGES
@ -170,6 +170,7 @@ Bugs fixed
|
|||||||
:confval:`html_search_language` is 'ja'. Thanks to Tomo Saito.
|
:confval:`html_search_language` is 'ja'. Thanks to Tomo Saito.
|
||||||
* #1108: The text writer now correctly numbers enumerated lists with
|
* #1108: The text writer now correctly numbers enumerated lists with
|
||||||
non-default start values (based on patch by Ewan Edwards).
|
non-default start values (based on patch by Ewan Edwards).
|
||||||
|
* #1102: Support multi-context "with" statements in autodoc.
|
||||||
* #1090: Fix gettext not extracting glossary terms.
|
* #1090: Fix gettext not extracting glossary terms.
|
||||||
* #1074: Add environment version info to the generated search index to avoid
|
* #1074: Add environment version info to the generated search index to avoid
|
||||||
compatibility issues with old builds.
|
compatibility issues with old builds.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Grammar for Python
|
# Grammar for Python. This grammar supports Python 2.x and 3.x.
|
||||||
|
|
||||||
# Note: Changing the grammar specified in this file will most likely
|
# Note: Changing the grammar specified in this file will most likely
|
||||||
# require corresponding changes in the parser module
|
# require corresponding changes in the parser module
|
||||||
@ -10,22 +10,10 @@
|
|||||||
# NOTE WELL: You should also follow all the steps listed in PEP 306,
|
# NOTE WELL: You should also follow all the steps listed in PEP 306,
|
||||||
# "How to Change Python's Grammar"
|
# "How to Change Python's Grammar"
|
||||||
|
|
||||||
# Commands for Kees Blom's railroad program
|
|
||||||
#diagram:token NAME
|
|
||||||
#diagram:token NUMBER
|
|
||||||
#diagram:token STRING
|
|
||||||
#diagram:token NEWLINE
|
|
||||||
#diagram:token ENDMARKER
|
|
||||||
#diagram:token INDENT
|
|
||||||
#diagram:output\input python.bla
|
|
||||||
#diagram:token DEDENT
|
|
||||||
#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm
|
|
||||||
#diagram:rules
|
|
||||||
|
|
||||||
# Start symbols for the grammar:
|
# Start symbols for the grammar:
|
||||||
# file_input is a module or sequence of commands read from an input file;
|
# file_input is a module or sequence of commands read from an input file;
|
||||||
# single_input is a single interactive statement;
|
# single_input is a single interactive statement;
|
||||||
# eval_input is the input for the eval() and input() functions.
|
# eval_input is the input for the eval() and input() functions.
|
||||||
# NB: compound_stmt in single_input is followed by extra NEWLINE!
|
# NB: compound_stmt in single_input is followed by extra NEWLINE!
|
||||||
file_input: (NEWLINE | stmt)* ENDMARKER
|
file_input: (NEWLINE | stmt)* ENDMARKER
|
||||||
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
|
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
|
||||||
@ -53,8 +41,9 @@ stmt: simple_stmt | compound_stmt
|
|||||||
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
|
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
|
||||||
small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
|
small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
|
||||||
import_stmt | global_stmt | exec_stmt | assert_stmt)
|
import_stmt | global_stmt | exec_stmt | assert_stmt)
|
||||||
expr_stmt: testlist (augassign (yield_expr|testlist) |
|
expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) |
|
||||||
('=' (yield_expr|testlist))*)
|
('=' (yield_expr|testlist_star_expr))*)
|
||||||
|
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
|
||||||
augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |
|
augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |
|
||||||
'<<=' | '>>=' | '**=' | '//=')
|
'<<=' | '>>=' | '**=' | '//=')
|
||||||
# For normal assignments, additional restrictions enforced by the interpreter
|
# For normal assignments, additional restrictions enforced by the interpreter
|
||||||
@ -87,11 +76,11 @@ while_stmt: 'while' test ':' suite ['else' ':' suite]
|
|||||||
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
|
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
|
||||||
try_stmt: ('try' ':' suite
|
try_stmt: ('try' ':' suite
|
||||||
((except_clause ':' suite)+
|
((except_clause ':' suite)+
|
||||||
['else' ':' suite]
|
['else' ':' suite]
|
||||||
['finally' ':' suite] |
|
['finally' ':' suite] |
|
||||||
'finally' ':' suite))
|
'finally' ':' suite))
|
||||||
with_stmt: 'with' test [ with_var ] ':' suite
|
with_stmt: 'with' with_item (',' with_item)* ':' suite
|
||||||
with_var: 'as' expr
|
with_item: test ['as' expr]
|
||||||
# NB compile.c makes sure that the default except clause is last
|
# NB compile.c makes sure that the default except clause is last
|
||||||
except_clause: 'except' [test [(',' | 'as') test]]
|
except_clause: 'except' [test [(',' | 'as') test]]
|
||||||
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
|
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
|
||||||
@ -111,6 +100,7 @@ and_test: not_test ('and' not_test)*
|
|||||||
not_test: 'not' not_test | comparison
|
not_test: 'not' not_test | comparison
|
||||||
comparison: expr (comp_op expr)*
|
comparison: expr (comp_op expr)*
|
||||||
comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
|
comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
|
||||||
|
star_expr: '*' expr
|
||||||
expr: xor_expr ('|' xor_expr)*
|
expr: xor_expr ('|' xor_expr)*
|
||||||
xor_expr: and_expr ('^' and_expr)*
|
xor_expr: and_expr ('^' and_expr)*
|
||||||
and_expr: shift_expr ('&' shift_expr)*
|
and_expr: shift_expr ('&' shift_expr)*
|
||||||
@ -124,14 +114,14 @@ atom: ('(' [yield_expr|testlist_gexp] ')' |
|
|||||||
'{' [dictsetmaker] '}' |
|
'{' [dictsetmaker] '}' |
|
||||||
'`' testlist1 '`' |
|
'`' testlist1 '`' |
|
||||||
NAME | NUMBER | STRING+ | '.' '.' '.')
|
NAME | NUMBER | STRING+ | '.' '.' '.')
|
||||||
listmaker: test ( comp_for | (',' test)* [','] )
|
listmaker: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
|
||||||
testlist_gexp: test ( comp_for | (',' test)* [','] )
|
testlist_gexp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
|
||||||
lambdef: 'lambda' [varargslist] ':' test
|
lambdef: 'lambda' [varargslist] ':' test
|
||||||
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
|
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
|
||||||
subscriptlist: subscript (',' subscript)* [',']
|
subscriptlist: subscript (',' subscript)* [',']
|
||||||
subscript: test | [test] ':' [test] [sliceop]
|
subscript: test | [test] ':' [test] [sliceop]
|
||||||
sliceop: ':' [test]
|
sliceop: ':' [test]
|
||||||
exprlist: expr (',' expr)* [',']
|
exprlist: (expr|star_expr) (',' (expr|star_expr))* [',']
|
||||||
testlist: test (',' test)* [',']
|
testlist: test (',' test)* [',']
|
||||||
dictsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) |
|
dictsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) |
|
||||||
(test (comp_for | (',' test)* [','])) )
|
(test (comp_for | (',' test)* [','])) )
|
||||||
|
Loading…
Reference in New Issue
Block a user