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

lock(obj) <stat> -> synchronized(obj) { <stat> }

This commit is contained in:
Kevin Glynn 2012-02-07 13:50:01 +01:00
parent bb8ddfac0c
commit 37d5f5071c
4 changed files with 12 additions and 30 deletions

View File

@ -239,18 +239,10 @@ default_template() ::= <<
default:
>>
lock(comments,exp,block, indent) ::= <<
<comments; separator=""\n"">
lock(<exp>)
<block(statements = block, indent = indent)>
>>
synchstat(comments,exp,stats) ::= <<
synchstat(comments,exp,stat) ::= <<
<comments; separator=""\n"">
synchronized (<exp>)
{
<stats>
}
<block(statements = stat, indent = indent)>
>>
yield(comments,exp) ::= <<

View File

@ -2050,8 +2050,13 @@ checked_statement:
'checked' block ;
unchecked_statement:
'unchecked' block -> ^(UNCHECKED block);
lock_statement:
'lock' '(' expression ')' embedded_statement[/* isStatementListCtxt */ false] ;
lock_statement
@init {
CommonTree statAsBlock = null;
}:
l='lock' '(' expression p=')' embedded_statement[/* isStatementListCtxt */ false]
{ statAsBlock = dupTree(embeddedStatementToBlock($p.token, $embedded_statement.tree)); }
-> ^(SYNCHRONIZED[$l.token, "synchronized"] expression { statAsBlock });
// TODO: Can we avoid surrounding this with braces if not needed?
using_statement[bool isStatementListCtxt]
@init {

View File

@ -1580,7 +1580,6 @@ embedded_statement returns [bool isSemi, bool isIf, bool indent]
| checked_statement -> { $checked_statement.st }
| unchecked_statement -> { $unchecked_statement.st }
| synchronized_statement -> { $synchronized_statement.st }
| lock_statement -> { $lock_statement.st }
| yield_statement -> { $yield_statement.st }
| ^('unsafe' { preComments = CollectedComments; } block { someText = %op(); %{someText}.op="unsafe"; %{someText}.post = $block.st; })
-> unsupported(comments = { preComments }, reason = {"unsafe blocks are not supported"}, text = { someText } )
@ -1681,7 +1680,7 @@ finally_clause:
^('finally' block) -> fin(block = {$block.st}, blockindent = { $block.isSemi });
synchronized_statement:
^(SYNCHRONIZED expression '{' s+=statement* '}') -> synchstat(exp={ $expression.st }, stats = { $s });
^(SYNCHRONIZED expression embedded_statement) -> synchstat(exp={ $expression.st }, stat = { $embedded_statement.st }, indent = { $embedded_statement.indent });
checked_statement
@init {
@ -1703,16 +1702,6 @@ unchecked_statement
%{someText}.block = $block.st;
%{someText}.indent = $block.isSemi; } -> unsupported(reason = {"checked statements are not supported"}, text = { someText } )
;
lock_statement
@init {
StringTemplate someText = null;
}:
'lock' '(' expression ')' embedded_statement
{ someText = %lock();
%{someText}.exp = $expression.st;
%{someText}.block = $embedded_statement.st;
%{someText}.indent = $embedded_statement.indent; } -> unsupported(reason = {"lock() statements are not supported"}, text = { someText } )
;
yield_statement
@init {
StringTemplate someText = null;

View File

@ -3133,8 +3133,7 @@ embedded_statement[bool isStatementListCtxt]
| ^('try' block catch_clauses? finally_clause?)
| checked_statement
| unchecked_statement
| synchronized_statement // Java: synchronized(obj) {}
| lock_statement
| synchronized_statement
| yield_statement
| ^('unsafe' block)
| fixed_statement
@ -3434,10 +3433,7 @@ unchecked_statement:
^(UNCHECKED block) ;
synchronized_statement:
^(SYNCHRONIZED expression[ObjectType] '{' statement_list '}') ;
lock_statement:
'lock' '(' expression[ObjectType] ')' embedded_statement[/* isStatementListCtxt */ false] ;
^(SYNCHRONIZED expression[ObjectType] embedded_statement[/* isStatementListCtxt */ false]) ;
yield_statement:
^(YIELD_RETURN expression[ObjectType])