[ 
https://issues.apache.org/jira/browse/GROOVY-8131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15942356#comment-15942356
 ] 

Jochen Theodorou commented on GROOVY-8131:
------------------------------------------

When you make newline treated as whitespace, you cannot make it part of the 
syntax of the language. That is why for example in Java you have to use the 
semicolon to tell the compiler the statement is done. In Groovy the semicolon 
is optional, thus the newline character significant and you cannot treat it as 
whitespace anymore and it becomes a possible terminator. But it is still no 
terminator like the semicolon. That means 
{code:Java}
static final SimpleDateFormat s3
= new SimpleDateFormat( "yyyy-MM-dd_hh:mm:ss" );
{code}
has a valid final  first line. That is why in Groovy we suggested the logic 
that the code line should end with the operator to be more easily be able to 
tell the compiler that the next line belongs to the same statement.  Such 
operators are for the compiler = and of course \ too. Which is why s2 and s3m 
are no problem. 
So terminate implicitly sounds right to me, even though I would not call that 
semantic recognition, since it is still only the parser that tells the compiler 
if a statement ends or not. We are for example not having both lines as 
possibly valid by their own in the parser and then combine them into a single 
statement somehow.

Anyway... I think this kind of bug can be fixed in the antlr grammar

> Statement continued onto next line is flagged when first character is "="
> -------------------------------------------------------------------------
>
>                 Key: GROOVY-8131
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8131
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.5
>         Environment: Ubuntu Linux
> `uname -a`:
> Linux biostar 4.4.0-69-generic #90-Ubuntu SMP Thu Mar 16 16:52:31 UTC 2017 
> x86_64 x86_64 x86_64 GNU/Linux
>            Reporter: Richard Elkins
>            Priority: Minor
>         Attachments: grbug.java
>
>
> Source code attached (grbug.java).
> `javac` v8 compiles variable declarations s1, s2, and s3 successfully.
> `groovyc` flags s3:
> "unexpected token: = @ line 9, column 3."



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to