Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 9671 invoked from network); 2 Sep 2009 10:32:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Sep 2009 10:32:19 -0000 Received: (qmail 95422 invoked by uid 500); 2 Sep 2009 10:32:19 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 95293 invoked by uid 500); 2 Sep 2009 10:32:18 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 95283 invoked by uid 99); 2 Sep 2009 10:32:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 10:32:18 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 209.85.219.213 as permitted sender) Received: from [209.85.219.213] (HELO mail-ew0-f213.google.com) (209.85.219.213) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 10:32:10 +0000 Received: by ewy9 with SMTP id 9so619886ewy.25 for ; Wed, 02 Sep 2009 03:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=cjc2ze4OfaxQQdR1A16gwF6N6lXazKG7P62othTUdPE=; b=NYjyaoTE1prYp7873cNKrMQVRfMNrfSWDenR1CdJiFJXAtb44O60f4E3iczqUqRN81 Di9OQ9EihpLqTg+aR8JgPqNgDkeQfUXeWTfkGAko8tbijSPzaoQpXMYfXuvN1aQfv/TF v6P/knlSOxbHYYBE5z2XSaWeBiJ4syh19q1Pk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=PKw61JVEOTbBPfg+VPJ9duRuOFIrAZUfrWT0Tqx1oz1/+NRnzYgOiS4/m2VWtv0OL3 tbIDyN0dQ+DWzTPGhh5LxKoT8Xq5mwHZAnKbCFwVMBbR3Bx2MfDmOKRUn6n4eVCVmA8I CvwDFOpuPYqLxAZT7i9ul28TnAWUIlgcSU7nQ= MIME-Version: 1.0 Received: by 10.216.53.199 with SMTP id g49mr108548wec.49.1251887508829; Wed, 02 Sep 2009 03:31:48 -0700 (PDT) In-Reply-To: <20090902102303.EBA3723888E9@eris.apache.org> References: <20090902102303.EBA3723888E9@eris.apache.org> Date: Wed, 2 Sep 2009 11:31:48 +0100 Message-ID: <25aac9fc0909020331g391d546ek9e55953a717e94dd@mail.gmail.com> Subject: Re: svn commit: r810445 - in /commons/proper/jexl/branches/2.0/src: main/java/org/apache/commons/jexl/ main/java/org/apache/commons/jexl/parser/ test/java/org/apache/commons/jexl/ From: sebb To: dev@commons.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org On 02/09/2009, henrib@apache.org wrote: > Author: henrib > Date: Wed Sep 2 10:23:03 2009 > New Revision: 810445 > > URL: http://svn.apache.org/viewvc?rev=810445&view=rev > Log: > JEXL-90: fix in Parser, enforce 2 expressions are separated by a semi-colon (';') in StatementExpression. > > Modified: > commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Debugger.java > commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java > commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt > commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/IssuesTest.java > > Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Debugger.java > URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Debugger.java?rev=810445&r1=810444&r2=810445&view=diff > ============================================================================== > --- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Debugger.java (original) > +++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Debugger.java Wed Sep 2 10:23:03 2009 > @@ -19,6 +19,7 @@ > import org.apache.commons.jexl.parser.ASTAdditiveNode; > import org.apache.commons.jexl.parser.ASTAdditiveOperator; > import org.apache.commons.jexl.parser.ASTAndNode; > +import org.apache.commons.jexl.parser.ASTAmbiguous; > import org.apache.commons.jexl.parser.ASTArrayAccess; > import org.apache.commons.jexl.parser.ASTArrayLiteral; > import org.apache.commons.jexl.parser.ASTAssignment; > @@ -617,4 +618,9 @@ > public Object visit(SimpleNode node, Object data) { > throw new UnsupportedOperationException("unexpected type of node"); > } > + > + /** {@inheritDoc} */ > + public Object visit(ASTAmbiguous node, Object data) { > + throw new UnsupportedOperationException("unexpected type of node"); > + } > } > \ No newline at end of file > > Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java > URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java?rev=810445&r1=810444&r2=810445&view=diff > ============================================================================== > --- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java (original) > +++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java Wed Sep 2 10:23:03 2009 > @@ -33,6 +33,7 @@ > import org.apache.commons.jexl.parser.ASTAdditiveNode; > import org.apache.commons.jexl.parser.ASTAdditiveOperator; > import org.apache.commons.jexl.parser.ASTAndNode; > +import org.apache.commons.jexl.parser.ASTAmbiguous; > import org.apache.commons.jexl.parser.ASTArrayAccess; > import org.apache.commons.jexl.parser.ASTArrayLiteral; > import org.apache.commons.jexl.parser.ASTAssignment; > @@ -1287,4 +1288,14 @@ > public Object visit(SimpleNode node, Object data) { > throw new UnsupportedOperationException("Not supported yet."); > } > + > + /** > + * Unused, should throw in Parser. > + * @param node a node > + * @param data the data > + * @return does not return > + */ > + public Object visit(ASTAmbiguous node, Object data) { > + throw new UnsupportedOperationException("unexpected type of node"); > + } > } > > Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt > URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt?rev=810445&r1=810444&r2=810445&view=diff > ============================================================================== > --- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt (original) > +++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/parser/Parser.jjt Wed Sep 2 10:23:03 2009 > @@ -29,6 +29,7 @@ > MULTI=true; > STATIC=false; > VISITOR=true; > + NODE_SCOPE_HOOK=true; > NODE_CLASS="JexlNode"; > UNICODE_INPUT=true; > } > @@ -55,6 +56,22 @@ > tree.value = info; > return tree; > } > + > + void jjtreeOpenNodeScope(Node n) {} > + void jjtreeCloseNodeScope(Node n) throws ParseException { > + if (n instanceof ASTAmbiguous && n.jjtGetNumChildren() > 0) { > + Token tok = this.getToken(0); > + StringBuilder strb = new StringBuilder("Ambiguous statement "); > + if (tok != null) { > + strb.append("@"); > + strb.append(tok.beginLine); > + strb.append(":"); > + strb.append(tok.beginColumn); > + } > + strb.append(", missing ';' between expressions"); > + throw new ParseException(strb.toString()); > + } > + } > } > > PARSER_END(Parser) > @@ -113,7 +130,7 @@ > > void ExpressionStatement() #void : {} > { > - Expression() (LOOKAHEAD(2) ";")? > + Expression() (LOOKAHEAD(1) Expression() #Ambiguous())* (LOOKAHEAD(2) ";")? > } > Seems like a complicated way of fixing the problem; I would have thought it was simpler to ensure that multiple statements are separated by ";" instead. i.e. a script consists of Statement ( ";" Statement )* So long as "Statement" includes a null statement, this would allow for a trailing ";". But I don't know JavaCC all that well. > > Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/IssuesTest.java > URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/IssuesTest.java?rev=810445&r1=810444&r2=810445&view=diff > ============================================================================== > --- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/IssuesTest.java (original) > +++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/IssuesTest.java Wed Sep 2 10:23:03 2009 > @@ -16,6 +16,7 @@ > */ > > package org.apache.commons.jexl; > +import org.apache.commons.jexl.parser.ParseException; > import java.util.Map; > > /** > @@ -26,7 +27,7 @@ > @Override > public void setUp() throws Exception { > // ensure jul logging is only error to avoid warning in silent mode > - java.util.logging.Logger.getLogger(JexlEngine.class.getName()).setLevel(java.util.logging.Level.SEVERE); > + //java.util.logging.Logger.getLogger(JexlEngine.class.getName()).setLevel(java.util.logging.Level.SEVERE); > } > > // JEXL-49: blocks not parsed (fixed) > @@ -238,4 +239,31 @@ > } > > } > + > + // JEXL-90: ';' is necessary between expressions > + public void test90() throws Exception { > + JexlContext ctxt = JexlHelper.createContext(); > + JexlEngine jexl = new JexlEngine(); > + jexl.setSilent(false); > + jexl.setLenient(false); > + String[] exprs = { > + "a=3 b=4", > + "while(a) while(a)", > + "1 2", > + "if (true) 2; 3 {}" > + }; > + for(int s = 0; s < exprs.length; ++s) { > + boolean fail = true; > + try { > + Script e = jexl.createScript(exprs[s]); > + } > + catch(ParseException xany) { > + // expected to fail in parse > + fail = false; > + } > + if (fail) { > + fail(exprs[s] + ": Should have failed in parse"); > + } > + } > + } > } > \ No newline at end of file > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org