From dev-return-5548-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Mon Oct 22 22:35:01 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 737D318064A for ; Mon, 22 Oct 2018 22:35:00 +0200 (CEST) Received: (qmail 61164 invoked by uid 500); 22 Oct 2018 20:34:59 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 61154 invoked by uid 99); 22 Oct 2018 20:34:58 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2018 20:34:58 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 76873CE212 for ; Mon, 22 Oct 2018 20:34:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.963 X-Spam-Level: *** X-Spam-Status: No, score=3.963 tagged_above=-999 required=6.31 tests=[DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, KAM_INFOUSMEBIZ=0.75, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Kbjb2VQgqeOe for ; Mon, 22 Oct 2018 20:34:57 +0000 (UTC) Received: from mail-yw1-f66.google.com (mail-yw1-f66.google.com [209.85.161.66]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id CCD695F16F for ; Mon, 22 Oct 2018 20:34:56 +0000 (UTC) Received: by mail-yw1-f66.google.com with SMTP id y76-v6so16563991ywd.2 for ; Mon, 22 Oct 2018 13:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=129k7siJY24n+S5beIe/ZopucbbjJKNA7luiI0E6pV8=; b=CiQm6rrJZdrU5HdklDkgglCXWZnGrYL7vqbCe+KV0OeCvGM8SIUtUJfhjVW1p/6hvm VkGj2B9++gXjIxK8DiqEI19E4wRzHbz7CiT13MEHAni3sDY/3eqfJ5oagNZ+4TlS+2Yn iGQXpwfbEmRghsU0njMiUfcdikoujX2qekwauv4u9QQ5GGLPmUcazo0od4iZ1c12WOxg otRI9SS+OLyOXIUz4bxv0Dmqlr5uSuA6caq7X5ux8XhnDUu1Bpewy17iiM8YyNvomhSk nqsiJvyvNwbAqLhLbGADhk8DSxsREVAJ54/hKTuLnNn7m/fOxgiFTm+Y8QNMz+C8Gcje kJig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=129k7siJY24n+S5beIe/ZopucbbjJKNA7luiI0E6pV8=; b=L5Cy/Znn1ns0dqo5gzhTyiIpvYFe+m5EyOzZQh6MaVBRiz6rbI00WSNhuLxQyj2vq5 rS/tBXc23N4EtOTOXuD+kAE3bbFu0D5sKJJ1Ble1no9tHLIP7SA5T/RTr4ijPH+V2nHG q9emS8l/6ajO16Pf6pepCMr9UuKkXov3KBe9rh3VJ3a/hKyWJ1bsih80DoPMS1uM3Ubo OT7R8qtLLQ++2RG/Tz4MYg0D0uAlf5gmbRhnEeUV653w8L5vGuGp3n4qGGSVUf7jvAWs DHw1jKQhiEwlW4lHW4SuivhKHwXtOEaWwqS9K0o0X2zdZFtjtY8NPdiHGv5QdH1RxGmy e1MQ== X-Gm-Message-State: ABuFfoiy/kBoTZ7YqG9AZc/diEgB40jKExBRgZPH7Bg5k8VGmAAAGyHG KVt2G6Q2D+ohZHIk3is9hCmKoUgjXQUHxldl16522Q== X-Google-Smtp-Source: ACcGV61aCH+DAImJLWvDHm6m0O3A84hgRMeUVscQ6asIdC7B8tyNHFgAUdjoigFS4dCNOsZyWsxRwuKRwJpLzA43+Qc= X-Received: by 2002:a81:a1c6:: with SMTP id y189-v6mr16212201ywg.344.1540240489337; Mon, 22 Oct 2018 13:34:49 -0700 (PDT) MIME-Version: 1.0 References: <1540231254746-0.post@n5.nabble.com> In-Reply-To: <1540231254746-0.post@n5.nabble.com> From: Guillaume Laforge Date: Mon, 22 Oct 2018 22:34:36 +0200 Message-ID: Subject: Re: About refining regex literal syntax To: dev@groovy.apache.org Cc: Groovy_Developers , codevise@me.com Content-Type: multipart/alternative; boundary="0000000000003c5a2e0578d72f1d" --0000000000003c5a2e0578d72f1d Content-Type: text/plain; charset="UTF-8" Damn, MG will tell me again I'm reacting negatively to Daniel's ideas but... :-) Interestingly, the multiline support in regex was kind of a highlight of Groovy's support of regexes as they allowed making more readable regular expressions. If you have it, have a look at some of the examples in Groovy in Action which highlighted this. The most intuitive human parsing here is certainly (m / ab) then (c / d), and not the command chain expression, and indeed the parser currently parses it as the intuitive human approach. Command chain expressions would have been parsed though if indeed we had use the triple (single/double) quote syntax, which would also be an intuitive human parsing. Expecting the parse to be a command chain with the slashy strings would seem counter intuitive to me. So call me resistant to change if you will MG ;-) but I quite like the current behavior. Guillaume On Mon, Oct 22, 2018 at 8:00 PM Daniel.Sun wrote: > 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 > -- Guillaume Laforge Apache Groovy committer & PMC Vice-President Developer Advocate @ Google Cloud Platform Blog: http://glaforge.appspot.com/ Twitter: @glaforge --0000000000003c5a2e0578d72f1d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Damn, MG will tell me again I'm reacting negative= ly to Daniel's ideas but... :-)

Interestingly, the = multiline support in regex was kind of a highlight of Groovy's support = of regexes as they allowed making more readable regular expressions.
If= you have it, have a look at some of the examples in Groovy in Action which= highlighted this.

The most intuitive human parsin= g here is certainly (m / ab) then (c / d), and not the command chain expres= sion, and indeed the parser currently parses it as the intuitive human appr= oach.

Command chain expressions would have been pa= rsed though if indeed we had use the triple (single/double) quote syntax, w= hich would also be an intuitive human parsing.

Exp= ecting the parse to be a command chain with the slashy strings would seem c= ounter intuitive to me.

So call me resistant to ch= ange if you will MG ;-) but I quite like the current behavior.
Guillaume

On Mon, Oct 22, 2018 at 8:00 PM Daniel.Sun <sunlan@apache.org> wrote:
Hi all,

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

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

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

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

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

=C2=A0 =C2=A0 =C2=A0 I propose to forbidden new lines in one version of reg= ex literal since
Groovy 3.0.0:

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

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

=C2=A0 =C2=A0 =C2=A0 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


--
<= div dir=3D"ltr">
Gui= llaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

=
--0000000000003c5a2e0578d72f1d--