Github user jjmeyer0 commented on a diff in the pull request:

    https://github.com/apache/metron/pull/814#discussion_r147556583
  
    --- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/StellarCompiler.java
 ---
    @@ -105,59 +107,77 @@ public Object apply(ExpressionState state) {
           Deque<Token<?>> instanceDeque = new ArrayDeque<>();
           {
             boolean skipElse = false;
    +        boolean skipMatchClauses = false;
             Token<?> token = null;
             for (Iterator<Token<?>> it = getTokenDeque().descendingIterator(); 
it.hasNext(); ) {
               token = it.next();
               //if we've skipped an else previously, then we need to skip the 
deferred tokens associated with the else.
    -          if(skipElse && token.getUnderlyingType() == ElseExpr.class) {
    -            while(it.hasNext()) {
    +          if (skipElse && token.getUnderlyingType() == ElseExpr.class) {
    +            while (it.hasNext()) {
                   token = it.next();
    -              if(token.getUnderlyingType() == EndConditional.class) {
    +              if (token.getUnderlyingType() == EndConditional.class) {
                     break;
                   }
                 }
                 skipElse = false;
               }
    +          if (skipMatchClauses && (token.getUnderlyingType() == 
MatchClauseEnd.class
    +              || token.getUnderlyingType() == MatchClauseCheckExpr.class)) 
{
    +            while (it.hasNext()) {
    --- End diff --
    
    This will only skip one match clause after a true one is found. See below 
test for a stellar statement that fails with a `ParseException`.
    
    ```java
    @Test
    @SuppressWarnings("unchecked")
    public void moreThanTwoConsecutiveTrueCasesWillResultInFailure() {
        Assert.assertEquals("ok",  run("match{ foo < 100 : THROW('oops'), foo > 
200 : 'ok', foo > 300 : 'ok', default : 'works' }",
                new HashMap() {{
                    put("foo", 500);
                }}));
    }
    ```


---

Reply via email to