Skip to content

Commit

Permalink
[FIXED JENKINS-8537] expanded the grammer to support binary operator …
Browse files Browse the repository at this point in the history
…sequence
  • Loading branch information
kohsuke committed Mar 29, 2011
1 parent 3a43423 commit 51562a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion changelog.html
Expand Up @@ -60,7 +60,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
Label expression logic wasn't supporting a binary operator sequence like "a || b || c"
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-8537">issue 8537</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
7 changes: 4 additions & 3 deletions core/src/main/grammar/labelExpr.g
Expand Up @@ -41,9 +41,10 @@ returns [Label l]
term1
returns [Label l]
{ Label r; }
: l=term2( IFF r=term2 {l=l.iff(r);} )?
: l=term2( IFF r=term2 {l=l.iff(r);} )*
;

// (a->b)->c != a->(b->c) (for example in case of a=F,b=T,c=F) so don't allow chaining
term2
returns [Label l]
{ Label r; }
Expand All @@ -53,13 +54,13 @@ returns [Label l]
term3
returns [Label l]
{ Label r; }
: l=term4 ( OR r=term4 {l=l.or(r);} )?
: l=term4 ( OR r=term4 {l=l.or(r);} )*
;
term4
returns [Label l]
{ Label r; }
: l=term5 ( AND r=term5 {l=l.and(r);} )?
: l=term5 ( AND r=term5 {l=l.and(r);} )*
;
term5
Expand Down
Expand Up @@ -34,6 +34,7 @@
import hudson.model.Node.Mode;
import hudson.slaves.DumbSlave;
import hudson.slaves.RetentionStrategy;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.SequenceLock;
import org.jvnet.hudson.test.TestBuilder;
Expand Down Expand Up @@ -135,6 +136,11 @@ public void testParser() throws Exception {
parseAndVerify("!foo<->bar", "!foo <-> bar");
}

@Bug(8537)
public void testParser2() throws Exception {
parseAndVerify("aaa&&bbb&&ccc","aaa&&bbb&&ccc");
}

private void parseAndVerify(String expected, String expr) throws ANTLRException {
assertEquals(expected, LabelExpression.parseExpression(expr).getName());
}
Expand Down

0 comments on commit 51562a2

Please sign in to comment.