1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

simplify catch parsing so that we can easily get hold of exception name

This commit is contained in:
Kevin Glynn 2010-12-13 09:26:44 +01:00
parent 4aa87128e7
commit 16dad136d8

View File

@ -1200,14 +1200,15 @@ try_statement:
// We rewrite the catch clauses so that they all have the form "(catch Type Var)" by introducing // We rewrite the catch clauses so that they all have the form "(catch Type Var)" by introducing
// Throwable and dummy vars as necessary // Throwable and dummy vars as necessary
catch_clauses: catch_clauses:
'catch'^ general_catch_clause catch_clause+;
| c='catch' specific_catch_clause catch_clauses* -> ^($c specific_catch_clause) catch_clauses*; catch_clause
specific_catch_clauses: @init {
specific_catch_clause ('catch' (specific_catch_clause | general_catch_clause))*; CommonTree ty = null, var = null;
specific_catch_clause: }:
'(' class_type (identifier|magicCatchVar) ')' block -> class_type identifier? magicCatchVar? block ; c='catch' ('(' given_t=class_type { ty = $given_t.tree; } (given_v=identifier { var = $given_v.tree; } | magic_v=magicCatchVar { var = $magic_v.tree; } ) ')'
general_catch_clause: | magic_t=magicThrowableType magic_v=magicCatchVar { ty = $magic_t.tree; var = $magic_v.tree; }) block
block magicThrowableType magicCatchVar -> magicThrowableType magicCatchVar block; -> ^($c { ty } { var } block)
;
finally_clause: finally_clause:
'finally'^ block ; 'finally'^ block ;
checked_statement: checked_statement: