Return-Path: X-Original-To: apmail-groovy-users-archive@minotaur.apache.org Delivered-To: apmail-groovy-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 601321856B for ; Mon, 9 Nov 2015 14:04:44 +0000 (UTC) Received: (qmail 50145 invoked by uid 500); 9 Nov 2015 14:04:44 -0000 Delivered-To: apmail-groovy-users-archive@groovy.apache.org Received: (qmail 50116 invoked by uid 500); 9 Nov 2015 14:04:44 -0000 Mailing-List: contact users-help@groovy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.incubator.apache.org Delivered-To: mailing list users@groovy.incubator.apache.org Received: (qmail 50106 invoked by uid 99); 9 Nov 2015 14:04:44 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Nov 2015 14:04:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 9959CC070B for ; Mon, 9 Nov 2015 14:04:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.002 X-Spam-Level: X-Spam-Status: No, score=-0.002 tagged_above=-999 required=6.31 tests=[RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id p36fgYz2cWWE for ; Mon, 9 Nov 2015 14:04:42 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id B32A524E9B for ; Mon, 9 Nov 2015 14:04:41 +0000 (UTC) Received: from [192.168.1.5] ([85.180.100.23]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0LZiLk-1agv2l01RU-00lRb1 for ; Mon, 09 Nov 2015 15:04:35 +0100 Subject: Re: Command Chain in assert To: users@groovy.incubator.apache.org References: <5C676E6359909E478C7B811BDB48CA3542BFF9@CWWAPP478.windstream.com> <563E320C.4040305@gmx.net> <5C676E6359909E478C7B811BDB48CA3542C522@CWWAPP478.windstream.com> From: Jochen Theodorou Message-ID: <5640A7F2.1040004@gmx.org> Date: Mon, 9 Nov 2015 15:04:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <5C676E6359909E478C7B811BDB48CA3542C522@CWWAPP478.windstream.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:KM+0kRAK920iVEWQQ6gzbz0aMzTF9OszK7MM9S2dHmd0mg9M1pw vEVucxAzcZtJxrKLF3ziVB9NYCMokksue8EaET5l5y/eVPh6jyoeaNcAbTze7D+OwFQMaI6 0IrFHJpYkNa1Gpu7hDin2kiTDaJAgdzP8hFR7hYMq6DbVt2daMkuaXIyHvDei4Mu1a3gQh2 ocDVpcyQjAoY2f5n380/A== X-UI-Out-Filterresults: notjunk:1;V01:K0:69Jy0LnapCY=:CJDnJFQ4G7tQa4ugQ18NFM 5ebDmcX/u9fCnqwrl069zpnioT5AAsyn1TXna1AtW19MeZ87ZIl05VCqJYw9w4ARsDqT6l0pZ TeO6tGi5XQktkFRlesMgtpmvm3aLBZsOBwvG8CyaLSSEmm5gvExlzfEVe7XCZCoEv7Xyx9uMM Y21dtDU8DZtaFfVaMTM2ntRaccV8zsCHcZn5xwYa+WIpYLBQKr6xpSw57rAo2rQ+pKBDcAaKt G9Fm2E+Y1iE7oxbWFk8zIbmngi6P6o5Hi17QLGgRF2rkiD+bMbZaHr5nIac+CEh2eg0LUEK4c Rn9gBRVR0XlCAYVgwD9MG8gkK3IDsQlQZ5Hds2231dg8iOc6MSX4zIcgJ7lYWGn13kd7mZB1C WS8eaYg40eZizGI/3cvuzoHBABTO8tFCDxm3LfaXLqNoxHY23ns2CgrRSo8tEqBZYXsUPKlMz 7a0IHQ582HcxW8QSiPz5ou04K3FSzKVQoazuC1Rmy+ENSn5JSuUfCqL0jx4/a0jGZfUGec/QT a1wb0Bu3JpUHxNYoP5Nr05kc3VNkCI/g0FUH7r7hqnh2/E4z+VjTIFmLXL7ap4JfLPhg0ten3 Jwkp7WHU8rnh/T7PowaMeHiSv8xgQ3x5ODVk6oL5TAgU1uC2HfS3+UgEbuSuXaFsdNHT289G8 p5ac21ez4TlNV/75QQk27gFF/HH3bfX586Ipb+GwwYahEzERNrOgq/p3qbCMlTc5DoUnQGai+ NLOZF0x0tgWIGUScxOpS4f5olwLF++HR2xABJdpna7VCnREpbCNNTalq9/5p5BVjYZ9jpGnFj rzIHTQg On 09.11.2015 14:29, Winnebeck, Jason wrote: > That ticket was useful. Just out of curiosity, is there a way to make > the DSL work if I do provide a function assert? I’m not sure it could, > because you’d need to support operators, and also when I tried to make > such a DSL I was not able to actually declare any symbol assert and be > able to call it how I’d expect. Even if it worked you’d lose power > assert. I wonder (not that I think it would be worth it) if it’s even > possible to implement with an AST? I’m thinking even that is not > possible because Groovy can’t even parse the syntax so you’d never get > to AST stage. transforms still require that the program can be parsed... so no, it would not work with them as for the problem itself... let me try making an example... assert foo x == bar y you interpret that as assert foo(x) == bar(y) but the compiler can interpret that as assert foo(x==bar).y In short the grammar cannot easily know which of those two is the right thing, especially since both variants are valid. We actually had maybe a similar problem with handling of = in asserts. As you may know doing something like "assert x=1" will not be accepted by the compiler. To solve this we basically changed the rule in the grammar from "assert" expression to "assert" assignmentLessExpression with the later one being a sub rule that contains any expression minus assignment. So to solve the issue in a similar way we would need something like this: "assert" assignmentAndEqualsLessExpression ( "==" expression)? where assignmentAndEqualsLessExpression does, in a similar matter, no allow for expressions with directly a == in it. And now the big trouble.... the command chain rules are not of that kind. They allow "==" and such. In short, it is by no simple change and will affect a lot of rules... One of the reasons I would like to simplify the compiler and let it accept more code, which could be wrong, and filter it after parsing... but well... time and money speak against it atm. bye blackdrag