groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel.Sun" <sun...@apache.org>
Subject About refining regex literal syntax
Date Mon, 22 Oct 2018 18:00:54 GMT
Hi all,

      Groovy regex literal allows new lines, i.e. 0D0A, which introduces
some ambiguity and breaks consistency in syntax. Let's have a look at some
examples:

1)  Ambiguity example:
```
m /ab
c/ d
```
This can be parsed as a command chain expression or parsed as two arithmetic
expressions.

2)  Consistency breaking in syntax
Single line:
'abc'
"abc"

Multiple lines:
'''
abc
'''
"""
abc
"""
/
abc
/
$/
abc
/$

      As you can see, both two version of regex literal can span multiple
lines... 

      I propose to forbidden new lines in one version of regex literal since
Groovy 3.0.0:

Single line:
'abc'
"abc"
/abc/

Multiple lines:
'''
abc
'''
"""
abc
"""
$/
abc
/$

      Any thoughts?

Cheers,
Daniel.Sun




-----
Daniel Sun 
Apache Groovy committer 
Blog: http://blog.sunlan.me 
Twitter: @daniel_sun 

--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html

Mime
View raw message