Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/python2..../lib2to3
File: Grammar.txt
# Grammar for 2to3. This grammar supports Python 2.x and 3.x.
[0] Fix | Delete
[1] Fix | Delete
# Note: Changing the grammar specified in this file will most likely
[2] Fix | Delete
# require corresponding changes in the parser module
[3] Fix | Delete
# (../Modules/parsermodule.c). If you can't make the changes to
[4] Fix | Delete
# that module yourself, please co-ordinate the required changes
[5] Fix | Delete
# with someone who can; ask around on python-dev for help. Fred
[6] Fix | Delete
# Drake <fdrake@acm.org> will probably be listening there.
[7] Fix | Delete
[8] Fix | Delete
# NOTE WELL: You should also follow all the steps listed in PEP 306,
[9] Fix | Delete
# "How to Change Python's Grammar"
[10] Fix | Delete
[11] Fix | Delete
# Commands for Kees Blom's railroad program
[12] Fix | Delete
#diagram:token NAME
[13] Fix | Delete
#diagram:token NUMBER
[14] Fix | Delete
#diagram:token STRING
[15] Fix | Delete
#diagram:token NEWLINE
[16] Fix | Delete
#diagram:token ENDMARKER
[17] Fix | Delete
#diagram:token INDENT
[18] Fix | Delete
#diagram:output\input python.bla
[19] Fix | Delete
#diagram:token DEDENT
[20] Fix | Delete
#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm
[21] Fix | Delete
#diagram:rules
[22] Fix | Delete
[23] Fix | Delete
# Start symbols for the grammar:
[24] Fix | Delete
# file_input is a module or sequence of commands read from an input file;
[25] Fix | Delete
# single_input is a single interactive statement;
[26] Fix | Delete
# eval_input is the input for the eval() and input() functions.
[27] Fix | Delete
# NB: compound_stmt in single_input is followed by extra NEWLINE!
[28] Fix | Delete
file_input: (NEWLINE | stmt)* ENDMARKER
[29] Fix | Delete
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
[30] Fix | Delete
eval_input: testlist NEWLINE* ENDMARKER
[31] Fix | Delete
[32] Fix | Delete
decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
[33] Fix | Delete
decorators: decorator+
[34] Fix | Delete
decorated: decorators (classdef | funcdef)
[35] Fix | Delete
funcdef: 'def' NAME parameters ['->' test] ':' suite
[36] Fix | Delete
parameters: '(' [typedargslist] ')'
[37] Fix | Delete
typedargslist: ((tfpdef ['=' test] ',')*
[38] Fix | Delete
('*' [tname] (',' tname ['=' test])* [',' '**' tname] | '**' tname)
[39] Fix | Delete
| tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
[40] Fix | Delete
tname: NAME [':' test]
[41] Fix | Delete
tfpdef: tname | '(' tfplist ')'
[42] Fix | Delete
tfplist: tfpdef (',' tfpdef)* [',']
[43] Fix | Delete
varargslist: ((vfpdef ['=' test] ',')*
[44] Fix | Delete
('*' [vname] (',' vname ['=' test])* [',' '**' vname] | '**' vname)
[45] Fix | Delete
| vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
[46] Fix | Delete
vname: NAME
[47] Fix | Delete
vfpdef: vname | '(' vfplist ')'
[48] Fix | Delete
vfplist: vfpdef (',' vfpdef)* [',']
[49] Fix | Delete
[50] Fix | Delete
stmt: simple_stmt | compound_stmt
[51] Fix | Delete
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
[52] Fix | Delete
small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
[53] Fix | Delete
import_stmt | global_stmt | exec_stmt | assert_stmt)
[54] Fix | Delete
expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) |
[55] Fix | Delete
('=' (yield_expr|testlist_star_expr))*)
[56] Fix | Delete
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
[57] Fix | Delete
augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
[58] Fix | Delete
'<<=' | '>>=' | '**=' | '//=')
[59] Fix | Delete
# For normal assignments, additional restrictions enforced by the interpreter
[60] Fix | Delete
print_stmt: 'print' ( [ test (',' test)* [','] ] |
[61] Fix | Delete
'>>' test [ (',' test)+ [','] ] )
[62] Fix | Delete
del_stmt: 'del' exprlist
[63] Fix | Delete
pass_stmt: 'pass'
[64] Fix | Delete
flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt
[65] Fix | Delete
break_stmt: 'break'
[66] Fix | Delete
continue_stmt: 'continue'
[67] Fix | Delete
return_stmt: 'return' [testlist]
[68] Fix | Delete
yield_stmt: yield_expr
[69] Fix | Delete
raise_stmt: 'raise' [test ['from' test | ',' test [',' test]]]
[70] Fix | Delete
import_stmt: import_name | import_from
[71] Fix | Delete
import_name: 'import' dotted_as_names
[72] Fix | Delete
import_from: ('from' ('.'* dotted_name | '.'+)
[73] Fix | Delete
'import' ('*' | '(' import_as_names ')' | import_as_names))
[74] Fix | Delete
import_as_name: NAME ['as' NAME]
[75] Fix | Delete
dotted_as_name: dotted_name ['as' NAME]
[76] Fix | Delete
import_as_names: import_as_name (',' import_as_name)* [',']
[77] Fix | Delete
dotted_as_names: dotted_as_name (',' dotted_as_name)*
[78] Fix | Delete
dotted_name: NAME ('.' NAME)*
[79] Fix | Delete
global_stmt: ('global' | 'nonlocal') NAME (',' NAME)*
[80] Fix | Delete
exec_stmt: 'exec' expr ['in' test [',' test]]
[81] Fix | Delete
assert_stmt: 'assert' test [',' test]
[82] Fix | Delete
[83] Fix | Delete
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
[84] Fix | Delete
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
[85] Fix | Delete
while_stmt: 'while' test ':' suite ['else' ':' suite]
[86] Fix | Delete
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
[87] Fix | Delete
try_stmt: ('try' ':' suite
[88] Fix | Delete
((except_clause ':' suite)+
[89] Fix | Delete
['else' ':' suite]
[90] Fix | Delete
['finally' ':' suite] |
[91] Fix | Delete
'finally' ':' suite))
[92] Fix | Delete
with_stmt: 'with' with_item (',' with_item)* ':' suite
[93] Fix | Delete
with_item: test ['as' expr]
[94] Fix | Delete
with_var: 'as' expr
[95] Fix | Delete
# NB compile.c makes sure that the default except clause is last
[96] Fix | Delete
except_clause: 'except' [test [(',' | 'as') test]]
[97] Fix | Delete
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
[98] Fix | Delete
[99] Fix | Delete
# Backward compatibility cruft to support:
[100] Fix | Delete
# [ x for x in lambda: True, lambda: False if x() ]
[101] Fix | Delete
# even while also allowing:
[102] Fix | Delete
# lambda x: 5 if x else 2
[103] Fix | Delete
# (But not a mix of the two)
[104] Fix | Delete
testlist_safe: old_test [(',' old_test)+ [',']]
[105] Fix | Delete
old_test: or_test | old_lambdef
[106] Fix | Delete
old_lambdef: 'lambda' [varargslist] ':' old_test
[107] Fix | Delete
[108] Fix | Delete
test: or_test ['if' or_test 'else' test] | lambdef
[109] Fix | Delete
or_test: and_test ('or' and_test)*
[110] Fix | Delete
and_test: not_test ('and' not_test)*
[111] Fix | Delete
not_test: 'not' not_test | comparison
[112] Fix | Delete
comparison: expr (comp_op expr)*
[113] Fix | Delete
comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
[114] Fix | Delete
star_expr: '*' expr
[115] Fix | Delete
expr: xor_expr ('|' xor_expr)*
[116] Fix | Delete
xor_expr: and_expr ('^' and_expr)*
[117] Fix | Delete
and_expr: shift_expr ('&' shift_expr)*
[118] Fix | Delete
shift_expr: arith_expr (('<<'|'>>') arith_expr)*
[119] Fix | Delete
arith_expr: term (('+'|'-') term)*
[120] Fix | Delete
term: factor (('*'|'@'|'/'|'%'|'//') factor)*
[121] Fix | Delete
factor: ('+'|'-'|'~') factor | power
[122] Fix | Delete
power: atom trailer* ['**' factor]
[123] Fix | Delete
atom: ('(' [yield_expr|testlist_gexp] ')' |
[124] Fix | Delete
'[' [listmaker] ']' |
[125] Fix | Delete
'{' [dictsetmaker] '}' |
[126] Fix | Delete
'`' testlist1 '`' |
[127] Fix | Delete
NAME | NUMBER | STRING+ | '.' '.' '.')
[128] Fix | Delete
listmaker: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
[129] Fix | Delete
testlist_gexp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
[130] Fix | Delete
lambdef: 'lambda' [varargslist] ':' test
[131] Fix | Delete
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
[132] Fix | Delete
subscriptlist: subscript (',' subscript)* [',']
[133] Fix | Delete
subscript: test | [test] ':' [test] [sliceop]
[134] Fix | Delete
sliceop: ':' [test]
[135] Fix | Delete
exprlist: (expr|star_expr) (',' (expr|star_expr))* [',']
[136] Fix | Delete
testlist: test (',' test)* [',']
[137] Fix | Delete
dictsetmaker: ( ((test ':' test | '**' expr)
[138] Fix | Delete
(comp_for | (',' (test ':' test | '**' expr))* [','])) |
[139] Fix | Delete
((test | star_expr)
[140] Fix | Delete
(comp_for | (',' (test | star_expr))* [','])) )
[141] Fix | Delete
[142] Fix | Delete
classdef: 'class' NAME ['(' [arglist] ')'] ':' suite
[143] Fix | Delete
[144] Fix | Delete
arglist: argument (',' argument)* [',']
[145] Fix | Delete
[146] Fix | Delete
# "test '=' test" is really "keyword '=' test", but we have no such token.
[147] Fix | Delete
# These need to be in a single rule to avoid grammar that is ambiguous
[148] Fix | Delete
# to our LL(1) parser. Even though 'test' includes '*expr' in star_expr,
[149] Fix | Delete
# we explicitly match '*' here, too, to give it proper precedence.
[150] Fix | Delete
# Illegal combinations and orderings are blocked in ast.c:
[151] Fix | Delete
# multiple (test comp_for) arguments are blocked; keyword unpackings
[152] Fix | Delete
# that precede iterable unpackings are blocked; etc.
[153] Fix | Delete
argument: ( test [comp_for] |
[154] Fix | Delete
test '=' test |
[155] Fix | Delete
'**' expr |
[156] Fix | Delete
star_expr )
[157] Fix | Delete
[158] Fix | Delete
comp_iter: comp_for | comp_if
[159] Fix | Delete
comp_for: 'for' exprlist 'in' testlist_safe [comp_iter]
[160] Fix | Delete
comp_if: 'if' old_test [comp_iter]
[161] Fix | Delete
[162] Fix | Delete
testlist1: test (',' test)*
[163] Fix | Delete
[164] Fix | Delete
# not used in grammar, but may appear in "node" passed from Parser to Compiler
[165] Fix | Delete
encoding_decl: NAME
[166] Fix | Delete
[167] Fix | Delete
yield_expr: 'yield' [yield_arg]
[168] Fix | Delete
yield_arg: 'from' test | testlist
[169] Fix | Delete
[170] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function