Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions common/src/main/java/dev/cel/common/CelOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public enum ProtoUnsetFieldOptions {

public abstract boolean enableQuotedIdentifierSyntax();

public abstract boolean enablePrattParser();

// Type-Checker related options

public abstract boolean enableCompileTimeOverloadResolution();
Expand Down Expand Up @@ -144,6 +146,7 @@ public static Builder newBuilder() {
.retainUnbalancedLogicalExpressions(false)
.enableHiddenAccumulatorVar(true)
.enableQuotedIdentifierSyntax(true)
.enablePrattParser(false)
// Type-Checker options
.enableCompileTimeOverloadResolution(false)
.enableHomogeneousLiterals(false)
Expand Down Expand Up @@ -279,6 +282,14 @@ public abstract static class Builder {
*/
public abstract Builder enableQuotedIdentifierSyntax(boolean value);

/**
* Enables Pratt parser implementation over ANTLR parser.
*
* <p>The Pratt parser provides improved parsing performance (typically 4x–11x speedup over
* ANTLR) and lower memory overhead while producing an equivalent abstract syntax tree.
*/
public abstract Builder enablePrattParser(boolean value);

// Type-Checker related options

/**
Expand Down
1 change: 1 addition & 0 deletions common/src/test/java/dev/cel/common/CelOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ public void current_defaults() {
// Defaults that aren't represented in deprecated CelOptions
assertThat(CelOptions.current().build().enableUnknownTracking()).isFalse();
assertThat(CelOptions.current().build().resolveTypeDependencies()).isTrue();
assertThat(CelOptions.current().build().enablePrattParser()).isFalse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ public void abs_overflow_throwsException() {

assertThat(e)
.hasMessageThat()
.contains("ERROR: <input>:1:10: For input string: \"-9223372036854775809\"");
.contains("ERROR: <input>:1:10: invalid int literal: -9223372036854775809");
}

@Test
Expand Down Expand Up @@ -917,7 +917,7 @@ public void bitAnd_maxValArg_throwsException() {

assertThat(e)
.hasMessageThat()
.contains("ERROR: <input>:1:33: For input string: \"9223372036854775809\"");
.contains("ERROR: <input>:1:33: invalid int literal: 9223372036854775809");
}

@Test
Expand Down
Loading
Loading