Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.8.4
-
Fix Version/s: 4.0
-
Component/s: parser, parser-antlr
-
Labels:None
-
Number of attachments :
Description
When laying our code to be readable, the ability to do:
'name score\ntim 1\ndave 4\ntim 3'.split( /\n/ ) // split on newline .drop( 1 ) // drop header .collect { it.split( / / ) } // split each by space .groupBy { it[ 0 ] } // group by name
Makes code fantastically readable when explaining it to people.
However, if I want to replace the line
.collect { it.split( / / ) } // split each by space
with
*.split( / / ) // split each by space
Then I can't as the parser complains that
unexpected token: *. at line: 3, column: 35
The only workaround is to place all of the operators at the ends of the lines, which to my eyes looks a bit of a mess (and in my experience is confusing to people)
ie:
'name score\ntim 1\ndave 4\ntim 3'.split( /\n/ ). // split on newline drop( 1 )*. // drop header split( / / ). // split each by space groupBy { it[ 0 ] } // group by name
Obviously, I could go for a style of appending the single '.' with appending the '*.', but I feel this makes it more confusing again...
I've had a look at groovy.g, but can't seem to spot the trick to allow this, without causing ambiguity ![]()