Curly bracelet in StringTemplate

The following StringTemplate gives me an "invalid character"} '' exception due to the closing curly brace after return null;

:

$StatementList:{statement | 
public T $statement$(X x) { return null; }  }$

      

I want to have an output like:

public T statement1(X x) {return null; }
public T statement2(X x) {return null; }

      

How do I avoid this closing curly brace?

+3


source to share


1 answer


I couldn't find a way to escape characters, but I managed to get it to work using the unicode character for the curly braces.

statementTemplate(StatementList) ::= <<
<StatementList:{statement | 
public T <statement>(X x) <\u007B> return null; <\u007D> }>
>>

      



which produced:

public T statement1(X x) { return null; } 
public T statement2(X x) { return null; } 
public T statement3(X x) { return null; }

      

+5


source







All Articles