Skip to content

Commit

Permalink
[incubator-kie-drools-5988] [new-parser] Merge dev-new-parser to main
Browse files Browse the repository at this point in the history
- new parser is disabled by default
  • Loading branch information
tkobayas committed Jun 11, 2024
1 parent aaef430 commit 7da9750
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pr-downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ on:

jobs:
kogito-downstream-build:
if false: # Temporally disabled because downstream build doesn't work with the feature branch dev-new-parser
concurrency:
group: pr-${{ matrix.job_name }}_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }}
cancel-in-progress: true
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pr-drools-ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ on:

jobs:
drools-ansible:
if false: # Temporally disabled because downstream build doesn't work with the feature branch dev-new-parser
concurrency:
group: pr-drools_ansible_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }}
cancel-in-progress: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<logger name="org.kie" level="warn"/>
<logger name="org.drools" level="warn"/>
<logger name="org.drools.drl.parser.DrlParser" level="debug"/>

<root level="warn">
<appender-ref ref="consoleAppender" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class DrlParser {

// TODO: REMOVE THIS GENERIC MESSAGE ASAP
private static final String GENERIC_ERROR_MESSAGE = "Unexpected exception raised while parsing. This is a bug. Please contact the Development team :\n";
private static final String DEBUG_PARSER_LOG = "parse : ANTLR4_PARSER_ENABLED = {}";
private final List<DroolsError> results = new ArrayList<>();
private List<DroolsSentence> editorSentences = null;
private Location location = new Location( Location.LOCATION_UNKNOWN );
Expand All @@ -61,8 +62,8 @@ public class DrlParser {

public static final String ANTLR4_PARSER_ENABLED_PROPERTY = "drools.drl.antlr4.parser.enabled";

// TODO: temporarily removed 'final' for testing purposes. This should be final
public static boolean ANTLR4_PARSER_ENABLED = Boolean.parseBoolean(System.getProperty(ANTLR4_PARSER_ENABLED_PROPERTY, "true")); // default is true
// temporarily removed 'final' for testing purposes. This should be final when the feature gets stable
public static boolean ANTLR4_PARSER_ENABLED = Boolean.parseBoolean(System.getProperty(ANTLR4_PARSER_ENABLED_PROPERTY, "false")); // default is false

public static final LanguageLevelOption DEFAULT_LANGUAGE_LEVEL = LanguageLevelOption.DRL6;
private final LanguageLevelOption languageLevel;
Expand All @@ -83,7 +84,7 @@ public PackageDescr parse(final Resource resource, final String text) throws Dro

public PackageDescr parse(final boolean isEditor,
final String text) throws DroolsParserException {
System.out.println("### parse : ANTLR4_PARSER_ENABLED = " + ANTLR4_PARSER_ENABLED);
LOG.debug(DEBUG_PARSER_LOG, ANTLR4_PARSER_ENABLED);
if (ANTLR4_PARSER_ENABLED) {
// new parser based on antlr4
return compileWithAntlr4Parser(parser -> parser.parse(new StringReader(text)));
Expand All @@ -96,7 +97,7 @@ public PackageDescr parse(final boolean isEditor,

public PackageDescr parse(final boolean isEditor,
final Reader reader) throws DroolsParserException {
System.out.println("### parse : ANTLR4_PARSER_ENABLED = " + ANTLR4_PARSER_ENABLED);
LOG.debug(DEBUG_PARSER_LOG, ANTLR4_PARSER_ENABLED);
if (ANTLR4_PARSER_ENABLED) {
// new parser based on antlr4
return compileWithAntlr4Parser(parser -> parser.parse(reader));
Expand Down Expand Up @@ -185,7 +186,7 @@ public PackageDescr parse(final boolean isEditor,
final InputStream is) throws DroolsParserException, IOException {
this.resource = resource;
String encoding = resource instanceof InternalResource ? ((InternalResource) resource).getEncoding() : null;
System.out.println("### parse : ANTLR4_PARSER_ENABLED = " + ANTLR4_PARSER_ENABLED);
LOG.debug(DEBUG_PARSER_LOG, ANTLR4_PARSER_ENABLED);
if (ANTLR4_PARSER_ENABLED) {
// new parser based on antlr4
return compileWithAntlr4Parser(parser -> parser.parse(is, encoding));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<!--<logger name="org.drools.model.codegen.execmodel.generator.expressiontyper" level="debug"/>-->
<!-- <logger name="org.drools.model.codegen.execmodel" level="debug"/>-->
<logger name="org.drools.ancompiler" level="info"/>
<!-- <logger name="org.drools.drl.parser.DrlParser" level="debug"/>-->

<root level="warn">
<appender-ref ref="consoleAppender" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<!-- <logger name="org.drools.core.management" level="debug"/> -->
<!-- <logger name="org.drools.modelcompiler.builder" level="debug"/>-->
<!-- <logger name="org.drools.ancompiler" level="debug"/>-->
<!-- <logger name="org.drools.drl.parser.DrlParser" level="debug"/>-->

<root level="warn">
<appender-ref ref="consoleAppender" />
Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@
</profile>

<profile>
<id>disableNewParser</id>
<id>enableNewParser</id>
<activation>
<property>
<name>disableNewParser</name>
<name>enableNewParser</name>
</property>
</activation>
<build>
Expand All @@ -286,7 +286,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<drools.drl.antlr4.parser.enabled>false</drools.drl.antlr4.parser.enabled>
<!-- false by default. Activate this profile when you test the new parser -->
<drools.drl.antlr4.parser.enabled>true</drools.drl.antlr4.parser.enabled>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down

0 comments on commit 7da9750

Please sign in to comment.