Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0bfd6c3

Browse files
committed
Added power (**) operator
1 parent 5990592 commit 0bfd6c3

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Grammar/Grammar

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ eval_input: testlist NEWLINE* ENDMARKER
2323

2424
funcdef: 'def' NAME parameters ':' suite
2525
parameters: '(' [varargslist] ')'
26-
varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '*' '*' NAME] | '*' '*' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']
26+
varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME] | ('**'|'*' '*') NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']
2727
fpdef: NAME | '(' fplist ')'
2828
fplist: fpdef (',' fpdef)* [',']
2929

@@ -70,11 +70,12 @@ and_expr: shift_expr ('&' shift_expr)*
7070
shift_expr: arith_expr (('<<'|'>>') arith_expr)*
7171
arith_expr: term (('+'|'-') term)*
7272
term: factor (('*'|'/'|'%') factor)*
73-
factor: ('+'|'-'|'~') factor | atom trailer*
73+
factor: ('+'|'-'|'~') factor | power
74+
power: atom trailer* ('**' factor)*
7475
atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+
7576
lambdef: 'lambda' [varargslist] ':' test
7677
trailer: '(' [arglist] ')' | '[' subscript ']' | '.' NAME
77-
subscript: test | [test] ':' [test]
78+
subscript: test (',' test)* [','] | [test] ':' [test]
7879
exprlist: expr (',' expr)* [',']
7980
testlist: test (',' test)* [',']
8081
dictmaker: test ':' test (',' test ':' test)* [',']

0 commit comments

Comments
 (0)