I need “{” will be single on a line. Therefore I have to use a token that recognize it. This are right examples:
program
{
or
program
{
And this are incorrect examples:
program {
or
program
{ sentence;
Then I have a token like this:
TOKEN: { < openKey: "{" > {System.out.print(image +"\n");}}
SKIP: { < ( " " | "\r" | "\t" | "\n" )+ > }
But I can not think how to make the symbol “{” is exactly between one or more “\n”. And after recognized it I have to write exactly:
program
{
If I try:
TOKEN: { < openKey: ( " " | "\r" | "\t" | "\n" )+ "{" ( " " | "\r" | "\t" | "\n" )+ > {System.out.print(image +"\n");}}
This runs but it writes so many “\n” like there was in the input.
I did it differently:
There were some problems with the carriage return, but this way works well.