tkobayas commented on code in PR #5855:
URL: 
https://github.com/apache/incubator-kie-drools/pull/5855#discussion_r1573639971


##########
drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/LexerHelper.java:
##########
@@ -0,0 +1,171 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.drl.parser.antlr4;
+
+import java.util.List;
+
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.IntStream;
+import org.drools.drl.parser.lang.DroolsSoftKeywords;
+
+/**
+ * Helper class for lexer. It requires instance creation to keep track of the 
lookahead counter.
+ */
+public class LexerHelper {
+
+    private static final List<Character> semiAndWS = List.of(';', ' ', '\t', 
'\n', '\r');
+    private static final List<String> statementKeywordsList = 
List.of(ParserHelper.statementKeywords);
+    private static final List<String> attributeKeywordsList = 
List.of(DroolsSoftKeywords.SALIENCE,
+                                                                      
DroolsSoftKeywords.ENABLED,
+                                                                      
DroolsSoftKeywords.NO + "-" + DroolsSoftKeywords.LOOP,
+                                                                      
DroolsSoftKeywords.AUTO + "-" + DroolsSoftKeywords.FOCUS,
+                                                                      
DroolsSoftKeywords.LOCK + "-" + DroolsSoftKeywords.ON + "-" + 
DroolsSoftKeywords.ACTIVE,
+                                                                      
DroolsSoftKeywords.AGENDA + "-" + DroolsSoftKeywords.GROUP,
+                                                                      
DroolsSoftKeywords.ACTIVATION + "-" + DroolsSoftKeywords.GROUP,
+                                                                      
DroolsSoftKeywords.RULEFLOW + "-" + DroolsSoftKeywords.GROUP,
+                                                                      
DroolsSoftKeywords.DATE + "-" + DroolsSoftKeywords.EFFECTIVE,
+                                                                      
DroolsSoftKeywords.DATE + "-" + DroolsSoftKeywords.EXPIRES,
+                                                                      
DroolsSoftKeywords.DIALECT,
+                                                                      
DroolsSoftKeywords.CALENDARS,
+                                                                      
DroolsSoftKeywords.TIMER,
+                                                                      
DroolsSoftKeywords.DURATION,
+                                                                      
DroolsSoftKeywords.REFRACT,
+                                                                      
DroolsSoftKeywords.DIRECT);
+
+    private final CharStream input;
+    private int lookAheadCounter;
+
+    public LexerHelper(CharStream input) {
+        this.input = input;
+        this.lookAheadCounter = 1;
+    }
+
+    /**
+     * Determine if the current token is the end of a RHS DRL by lookahead.
+     * 1. 'end'
+     * 2. skip semi, WS, and comment
+     * 3. next token should be EOF or statement or attribute keyword
+     *
+     * TODO: This method is low-level and may be too complex in order to keep 
backward compatibility.
+     *       This could be refactored by going back to a parser rather than 
the lexer island mode.
+     */
+    boolean isRhsDrlEnd() {

Review Comment:
   `isRhsDrlEnd` is required because we use lexer island mode and `end` has a 
tricky condition (to meet backward compatibility) for a semantic predicate. 
This method is low-level and too complex. I filed 
https://github.com/apache/incubator-kie-drools/issues/5856 to investigate a 
better approach.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to