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:
parent
bb8ddfac0c
commit
37d5f5071c
@ -239,18 +239,10 @@ default_template() ::= <<
|
|||||||
default:
|
default:
|
||||||
>>
|
>>
|
||||||
|
|
||||||
lock(comments,exp,block, indent) ::= <<
|
synchstat(comments,exp,stat) ::= <<
|
||||||
<comments; separator=""\n"">
|
|
||||||
lock(<exp>)
|
|
||||||
<block(statements = block, indent = indent)>
|
|
||||||
>>
|
|
||||||
|
|
||||||
synchstat(comments,exp,stats) ::= <<
|
|
||||||
<comments; separator=""\n"">
|
<comments; separator=""\n"">
|
||||||
synchronized (<exp>)
|
synchronized (<exp>)
|
||||||
{
|
<block(statements = stat, indent = indent)>
|
||||||
<stats>
|
|
||||||
}
|
|
||||||
>>
|
>>
|
||||||
|
|
||||||
yield(comments,exp) ::= <<
|
yield(comments,exp) ::= <<
|
||||||
|
@ -2050,8 +2050,13 @@ checked_statement:
|
|||||||
'checked' block ;
|
'checked' block ;
|
||||||
unchecked_statement:
|
unchecked_statement:
|
||||||
'unchecked' block -> ^(UNCHECKED block);
|
'unchecked' block -> ^(UNCHECKED block);
|
||||||
lock_statement:
|
lock_statement
|
||||||
'lock' '(' expression ')' embedded_statement[/* isStatementListCtxt */ false] ;
|
@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?
|
// TODO: Can we avoid surrounding this with braces if not needed?
|
||||||
using_statement[bool isStatementListCtxt]
|
using_statement[bool isStatementListCtxt]
|
||||||
@init {
|
@init {
|
||||||
|
@ -1580,7 +1580,6 @@ embedded_statement returns [bool isSemi, bool isIf, bool indent]
|
|||||||
| checked_statement -> { $checked_statement.st }
|
| checked_statement -> { $checked_statement.st }
|
||||||
| unchecked_statement -> { $unchecked_statement.st }
|
| unchecked_statement -> { $unchecked_statement.st }
|
||||||
| synchronized_statement -> { $synchronized_statement.st }
|
| synchronized_statement -> { $synchronized_statement.st }
|
||||||
| lock_statement -> { $lock_statement.st }
|
|
||||||
| yield_statement -> { $yield_statement.st }
|
| yield_statement -> { $yield_statement.st }
|
||||||
| ^('unsafe' { preComments = CollectedComments; } block { someText = %op(); %{someText}.op="unsafe"; %{someText}.post = $block.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 } )
|
-> 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 });
|
^('finally' block) -> fin(block = {$block.st}, blockindent = { $block.isSemi });
|
||||||
|
|
||||||
synchronized_statement:
|
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
|
checked_statement
|
||||||
@init {
|
@init {
|
||||||
@ -1703,16 +1702,6 @@ unchecked_statement
|
|||||||
%{someText}.block = $block.st;
|
%{someText}.block = $block.st;
|
||||||
%{someText}.indent = $block.isSemi; } -> unsupported(reason = {"checked statements are not supported"}, text = { someText } )
|
%{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
|
yield_statement
|
||||||
@init {
|
@init {
|
||||||
StringTemplate someText = null;
|
StringTemplate someText = null;
|
||||||
|
@ -3133,8 +3133,7 @@ embedded_statement[bool isStatementListCtxt]
|
|||||||
| ^('try' block catch_clauses? finally_clause?)
|
| ^('try' block catch_clauses? finally_clause?)
|
||||||
| checked_statement
|
| checked_statement
|
||||||
| unchecked_statement
|
| unchecked_statement
|
||||||
| synchronized_statement // Java: synchronized(obj) {}
|
| synchronized_statement
|
||||||
| lock_statement
|
|
||||||
| yield_statement
|
| yield_statement
|
||||||
| ^('unsafe' block)
|
| ^('unsafe' block)
|
||||||
| fixed_statement
|
| fixed_statement
|
||||||
@ -3434,10 +3433,7 @@ unchecked_statement:
|
|||||||
^(UNCHECKED block) ;
|
^(UNCHECKED block) ;
|
||||||
|
|
||||||
synchronized_statement:
|
synchronized_statement:
|
||||||
^(SYNCHRONIZED expression[ObjectType] '{' statement_list '}') ;
|
^(SYNCHRONIZED expression[ObjectType] embedded_statement[/* isStatementListCtxt */ false]) ;
|
||||||
|
|
||||||
lock_statement:
|
|
||||||
'lock' '(' expression[ObjectType] ')' embedded_statement[/* isStatementListCtxt */ false] ;
|
|
||||||
|
|
||||||
yield_statement:
|
yield_statement:
|
||||||
^(YIELD_RETURN expression[ObjectType])
|
^(YIELD_RETURN expression[ObjectType])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user