Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11321)

Delta Between Two Patch Sets: Grammar/Grammar

Issue 11682: PEP 380 reference implementation for 3.3
Left Patch Set: Created 7 years, 6 months ago
Right Patch Set: Created 7 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 # Grammar for Python 1 # Grammar for Python
2 2
3 # Note: Changing the grammar specified in this file will most likely 3 # Note: Changing the grammar specified in this file will most likely
4 # require corresponding changes in the parser module 4 # require corresponding changes in the parser module
5 # (../Modules/parsermodule.c). If you can't make the changes to 5 # (../Modules/parsermodule.c). If you can't make the changes to
6 # that module yourself, please co-ordinate the required changes 6 # that module yourself, please co-ordinate the required changes
7 # with someone who can; ask around on python-dev for help. Fred 7 # with someone who can; ask around on python-dev for help. Fred
8 # Drake <fdrake@acm.org> will probably be listening there. 8 # Drake <fdrake@acm.org> will probably be listening there.
9 9
10 # NOTE WELL: You should also follow all the steps listed in PEP 306, 10 # NOTE WELL: You should also follow all the steps listed in PEP 306,
11 # "How to Change Python's Grammar" 11 # "How to Change Python's Grammar"
12 12
13 # Start symbols for the grammar: 13 # Start symbols for the grammar:
14 # single_input is a single interactive statement; 14 # single_input is a single interactive statement;
15 # file_input is a module or sequence of commands read from an input file; 15 # file_input is a module or sequence of commands read from an input file;
16 # eval_input is the input for the eval() and input() functions. 16 # eval_input is the input for the eval() functions.
17 # NB: compound_stmt in single_input is followed by extra NEWLINE! 17 # NB: compound_stmt in single_input is followed by extra NEWLINE!
18 single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE 18 single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
19 file_input: (NEWLINE | stmt)* ENDMARKER 19 file_input: (NEWLINE | stmt)* ENDMARKER
20 eval_input: testlist NEWLINE* ENDMARKER 20 eval_input: testlist NEWLINE* ENDMARKER
21 21
22 decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE 22 decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
23 decorators: decorator+ 23 decorators: decorator+
24 decorated: decorators (classdef | funcdef) 24 decorated: decorators (classdef | funcdef)
25 funcdef: 'def' NAME parameters ['->' test] ':' suite 25 funcdef: 'def' NAME parameters ['->' test] ':' suite
26 parameters: '(' [typedargslist] ')' 26 parameters: '(' [typedargslist] ')'
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT 81 suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
82 82
83 test: or_test ['if' or_test 'else' test] | lambdef 83 test: or_test ['if' or_test 'else' test] | lambdef
84 test_nocond: or_test | lambdef_nocond 84 test_nocond: or_test | lambdef_nocond
85 lambdef: 'lambda' [varargslist] ':' test 85 lambdef: 'lambda' [varargslist] ':' test
86 lambdef_nocond: 'lambda' [varargslist] ':' test_nocond 86 lambdef_nocond: 'lambda' [varargslist] ':' test_nocond
87 or_test: and_test ('or' and_test)* 87 or_test: and_test ('or' and_test)*
88 and_test: not_test ('and' not_test)* 88 and_test: not_test ('and' not_test)*
89 not_test: 'not' not_test | comparison 89 not_test: 'not' not_test | comparison
90 comparison: expr (comp_op expr)* 90 comparison: expr (comp_op expr)*
91 # <> isn't actually a valid comparison operator in Python. It's here for the
92 # sake of a __future__ import described in PEP 401
91 comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' 93 comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
92 star_expr: '*' expr 94 star_expr: '*' expr
93 expr: xor_expr ('|' xor_expr)* 95 expr: xor_expr ('|' xor_expr)*
94 xor_expr: and_expr ('^' and_expr)* 96 xor_expr: and_expr ('^' and_expr)*
95 and_expr: shift_expr ('&' shift_expr)* 97 and_expr: shift_expr ('&' shift_expr)*
96 shift_expr: arith_expr (('<<'|'>>') arith_expr)* 98 shift_expr: arith_expr (('<<'|'>>') arith_expr)*
97 arith_expr: term (('+'|'-') term)* 99 arith_expr: term (('+'|'-') term)*
98 term: factor (('*'|'/'|'%'|'//') factor)* 100 term: factor (('*'|'/'|'%'|'//') factor)*
99 factor: ('+'|'-'|'~') factor | power 101 factor: ('+'|'-'|'~') factor | power
100 power: atom trailer* ['**' factor] 102 power: atom trailer* ['**' factor]
(...skipping 21 matching lines...) Expand all
122 argument: (test) [comp_for] | test '=' test # Really [keyword '='] test 124 argument: (test) [comp_for] | test '=' test # Really [keyword '='] test
123 comp_iter: comp_for | comp_if 125 comp_iter: comp_for | comp_if
124 comp_for: 'for' exprlist 'in' or_test [comp_iter] 126 comp_for: 'for' exprlist 'in' or_test [comp_iter]
125 comp_if: 'if' test_nocond [comp_iter] 127 comp_if: 'if' test_nocond [comp_iter]
126 128
127 # not used in grammar, but may appear in "node" passed from Parser to Compiler 129 # not used in grammar, but may appear in "node" passed from Parser to Compiler
128 encoding_decl: NAME 130 encoding_decl: NAME
129 131
130 yield_expr: 'yield' [yield_arg] 132 yield_expr: 'yield' [yield_arg]
131 yield_arg: 'from' test | testlist 133 yield_arg: 'from' test | testlist
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+