From: <fwi...@us...> - 2007-12-09 00:16:29
|
Revision: 3780 http://jython.svn.sourceforge.net/jython/?rev=3780&view=rev Author: fwierzbicki Date: 2007-12-08 16:16:26 -0800 (Sat, 08 Dec 2007) Log Message: ----------- Start of try/except/finally matcing for 2.5. Some reformatting. Modified Paths: -------------- trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/grammar/PythonWalker.g Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-08 23:27:20 UTC (rev 3779) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-09 00:16:26 UTC (rev 3780) @@ -110,7 +110,7 @@ Print; TryExcept; TryFinally; - Except; + ExceptHandler; For; Return; Yield; @@ -166,6 +166,7 @@ GenIf; ListFor; ListIf; + FinalBody; } @header { @@ -448,13 +449,16 @@ -> ^(For ^(Target exprlist) ^(Iter testlist) ^(Body $s1) ^(OrElse $s2)?) ; -//try_stmt: ('try' ':' suite (except_clause ':' suite)+ #diagram:break -// ['else' ':' suite] | 'try' ':' suite 'finally' ':' suite) +//try_stmt: ('try' ':' suite +// ((except_clause ':' suite)+ +// ['else' ':' suite] +// ['finally' ':' suite] | +// 'finally' ':' suite)) try_stmt : 'try' COLON trysuite=suite - ( (except_clause+ ('else' COLON elsesuite=suite)? - -> ^(TryExcept ^(Body $trysuite) except_clause+ ^(OrElse $elsesuite)?)) - | ('finally' COLON suite - -> ^(TryFinally suite)) + ( (except_clause+ ('else' COLON elsesuite=suite)? ('finally' COLON finalsuite=suite)? + -> ^(TryExcept ^(Body $trysuite) except_clause+ ^(OrElse $elsesuite)? ^(FinalBody 'finally' $finalsuite)?)) + | ('finally' COLON finalsuite=suite + -> ^(TryFinally ^(Body $trysuite) ^(FinalBody $finalsuite))) ) ; @@ -469,7 +473,7 @@ //except_clause: 'except' [test [',' test]] except_clause : 'except' (t1=test (COMMA t2=test)?)? COLON suite - -> ^(Except ^(Type $t1)? ^(Name $t2)? ^(Body suite)) + -> ^(ExceptHandler ^(Type $t1)? ^(Name $t2)? ^(Body suite)) ; //suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-08 23:27:20 UTC (rev 3779) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-09 00:16:26 UTC (rev 3780) @@ -384,51 +384,64 @@ | ^(ImportFrom dotted_name ^(Import import_as_name+)) ; -import_as_name : ^(Alias NAME (^(Asname NAME))?) - ; +import_as_name + : ^(Alias NAME (^(Asname NAME))?) + ; -dotted_as_name : ^(Alias dotted_name (^(Asname NAME))?) - ; +dotted_as_name + : ^(Alias dotted_name (^(Asname NAME))?) + ; dotted_name : start=NAME (DOT NAME)* { } ; -global_stmt : ^(Global NAME+) - ; +global_stmt + : ^(Global NAME+) + ; -exec_stmt : ^(Exec test[expr_contextType.Load] (^(Globals test[expr_contextType.Load]))? (^(Locals test[expr_contextType.Load]))?) - ; +exec_stmt + : ^(Exec test[expr_contextType.Load] (^(Globals test[expr_contextType.Load]))? (^(Locals test[expr_contextType.Load]))?) + ; -assert_stmt : ^(Assert ^(Test test[expr_contextType.Load]) (^(Msg test[expr_contextType.Load]))?) - ; +assert_stmt + : ^(Assert ^(Test test[expr_contextType.Load]) (^(Msg test[expr_contextType.Load]))?) + ; -if_stmt: ^(If test[expr_contextType.Load] suite elif_clause* (^(OrElse suite))?) - ; +if_stmt + : ^(If test[expr_contextType.Load] suite elif_clause* (^(OrElse suite))?) + ; -elif_clause : ^(Elif test[expr_contextType.Load] suite) - ; +elif_clause + : ^(Elif test[expr_contextType.Load] suite) + ; -while_stmt : ^(While test[expr_contextType.Load] ^(Body suite) (^(OrElse suite))?) - ; +while_stmt + : ^(While test[expr_contextType.Load] ^(Body suite) (^(OrElse suite))?) + ; -for_stmt : ^(For ^(Target test[expr_contextType.Load]+) ^(Iter test[expr_contextType.Load]) ^(Body suite) (^(OrElse suite))?) - ; +for_stmt + : ^(For ^(Target test[expr_contextType.Load]+) ^(Iter test[expr_contextType.Load]) ^(Body suite) (^(OrElse suite))?) + ; -try_stmt : ^(TryExcept ^(Body suite) except_clause+ (^(OrElse suite))?) - | ^(TryFinally suite) - ; +try_stmt + : ^(TryExcept ^(Body suite) except_clause+ (^(OrElse suite))? (^(FinalBody 'finally' suite))?) + | ^(TryFinally ^(Body suite) ^(FinalBody suite)) + ; -except_clause : ^(Except (^(Type test[expr_contextType.Load]))? (^(Name test[expr_contextType.Load]))? ^(Body suite)) - ; +except_clause + : ^(ExceptHandler (^(Type test[expr_contextType.Load]))? (^(Name test[expr_contextType.Load]))? ^(Body suite)) + ; -with_stmt: ^(With test[expr_contextType.Load] with_var? ^(Body suite)) - ; +with_stmt + : ^(With test[expr_contextType.Load] with_var? ^(Body suite)) + ; -with_var: ('as' | NAME) test[expr_contextType.Load] - ; +with_var + : ('as' | NAME) test[expr_contextType.Load] + ; suite This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |