Skip to content
Snippets Groups Projects
Commit 3d749f20 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

[doc] try another approach for grammar.rst, not convinced neither

parent 4354c85f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -43,6 +43,9 @@ Python 3.3 or earlier
 
Already done since the start.
 
This is handle at the parser initialisation level, is activate or not the
print_function rule.
TODO
----
 
Loading
Loading
@@ -53,6 +56,45 @@ Python 3.3 or earlier
 
.. image:: ./grammar_diff/typed_args.png
 
Action:
::
# parameters
# this is mixed with the removal of def a((b, c)): style
# which will probably need to continue supporting
CHANGE parameters: '(' [varargslist] ')'
^
TO parameters: '(' [typedargslist] ')'
^
::
# CHANGE
varargslist: ((fpdef ['=' test] ',')*
('*' NAME [',' '**' NAME] | '**' NAME) |
fpdef ['=' test] (',' fpdef ['=' test])* [','])
fpdef: NAME | '(' fplist ')'
fplist: fpdef (',' fpdef)* [',']
# TO
typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [',' [
'*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]
| '**' tfpdef [',']]]
| '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]
| '**' tfpdef [','])
tfpdef: NAME [':' test]
varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' [
'*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]
| '**' vfpdef [',']]]
| '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]
| '**' vfpdef [',']
)
vfpdef: NAME
Function return type
~~~~~~~~~~~~~~~~~~~~
 
Loading
Loading
@@ -60,6 +102,14 @@ Python 3.3 or earlier
 
.. image:: ./grammar_diff/function_return_type.png
 
Action:
::
ADD '->' to the lexer
ADD ['->' test] to funcdef rule
funcdef: 'def' NAME parameters ['->' test] ':' suite
Nonlocal statement
~~~~~~~~~~~~~~~~~~
 
Loading
Loading
@@ -67,6 +117,16 @@ Python 3.3 or earlier
 
.. image:: ./grammar_diff/nonlocal_statement.png
 
Action:
::
ADD 'nonlocal' to lexer
ADD 'nonlocal_stmt' to 'small_stmt'
ADD new rule:
nonlocal_stmt: 'nonlocal' NAME (',' NAME)*
Exec function
~~~~~~~~~~~~~
 
Loading
Loading
@@ -74,6 +134,10 @@ Python 3.3 or earlier
 
.. image:: ./grammar_diff/exec_function.png
 
Like print_function but for 'exec'.
No one seems to be using that.
*var generalisation
~~~~~~~~~~~~~~~~~~~
 
Loading
Loading
@@ -81,10 +145,16 @@ Python 3.3 or earlier
 
.. image:: ./grammar_diff/testlist_start_expressiong.png
 
.
.. image:: ./grammar_diff/star_expr.png
 
.
.. image:: ./grammar_diff/star_expr_in_testlist_comp.png
 
.
.. image:: ./grammar_diff/star_expr_in_expr_list.png
 
Raise from
Loading
Loading
@@ -94,6 +164,19 @@ Python 3.3 or earlier
 
.. image:: ./grammar_diff/raise_from.png
 
Action:
::
# 2.7
raise_stmt: 'raise' [test [',' test [',' test]]]
# 3.3
raise_stmt: 'raise' [test ['from' test]]
# merge
raise_stmt: 'raise' [test [(',' test [',' test]] | 'from' test)]
Ellipsis in from import
~~~~~~~~~~~~~~~~~~~~~~~
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment