Skip to content

Commit

Permalink
Parse 'binarize'
Browse files Browse the repository at this point in the history
  • Loading branch information
bratseth committed Oct 4, 2024
1 parent 2a06213 commit c7a6e1d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
11 changes: 6 additions & 5 deletions indexinglanguage/src/main/javacc/IndexingParser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,8 @@ String identifier() :
( <ATTRIBUTE> |
<BASE64_DECODE> |
<BASE64_ENCODE> |
<BUSY_WAIT> |
<BINARIZE> |
<BUSY_WAIT> |
<CASE> |
<CASE_DEFAULT> |
<CLEAR_STATE> |
Expand All @@ -831,15 +832,15 @@ String identifier() :
<GET_VAR> |
<GUARD> |
<HASH> |
<HEX_DECODE> |
<HEX_ENCODE> |
<HOST_NAME> |
<HEX_DECODE> |
<HEX_ENCODE> |
<HOST_NAME> |
<IDENTIFIER> |
<IF> |
<INDEX> |
<INPUT> |
<JOIN> |
<LOWER_CASE> |
<LOWER_CASE> |
<MAX_LENGTH> |
<NGRAM> |
<NORMALIZE> |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,26 @@ INJECT IndexingParser:
return this;
}

private static FieldValue parseDouble(String str) {
private static DoubleFieldValue parseDouble(String str) {
return new DoubleFieldValue(new BigDecimal(str).doubleValue());
}

private static FieldValue parseFloat(String str) {
private static FloatFieldValue parseFloat(String str) {
if (str.endsWith("f") || str.endsWith("F")) {
str = str.substring(0, str.length() - 1);
}
return new FloatFieldValue(new BigDecimal(str).floatValue());
}

private static FieldValue parseInteger(String str) {
private static IntegerFieldValue parseInteger(String str) {
if (str.startsWith("0x")) {
return new IntegerFieldValue(new BigInteger(str.substring(2), 16).intValue());
} else {
return new IntegerFieldValue(new BigInteger(str).intValue());
}
}

private static FieldValue parseLong(String str) {
private static LongFieldValue parseLong(String str) {
if (str.endsWith("l") || str.endsWith("L")) {
str = str.substring(0, str.length() - 1);
}
Expand Down Expand Up @@ -174,6 +174,7 @@ TOKEN :
<ATTRIBUTE: "attribute"> |
<BASE64_DECODE: "base64decode"> |
<BASE64_ENCODE: "base64encode"> |
<BINARIZE: "binarize"> |
<BUSY_WAIT: "busy_wait"> |
<CASE: "case"> |
<CASE_DEFAULT: "default"> |
Expand Down Expand Up @@ -330,6 +331,7 @@ Expression value() :
( val = attributeExp() |
val = base64DecodeExp() |
val = base64EncodeExp() |
val = binarizeExp() |
val = busy_waitExp() |
val = clearStateExp() |
val = echoExp() |
Expand Down Expand Up @@ -407,6 +409,14 @@ Expression base64EncodeExp() : { }
{ return new Base64EncodeExpression(); }
;

Expression binarizeExp() :
{
NumericFieldValue threshold = new DoubleFieldValue(0);
}
( <BINARIZE> [ threshold = numericValue() ] )
{ return new BinarizeExpression(threshold.getNumber().doubleValue()); }
;

Expression busy_waitExp() : { }

( <BUSY_WAIT> )
Expand Down Expand Up @@ -835,11 +845,12 @@ String identifierStr() :
String val;
}

( val = stringLiteral() |
( val = stringLiteral() |
( <ATTRIBUTE> |
<BASE64_DECODE> |
<BASE64_ENCODE> |
<BUSY_WAIT> |
<BINARIZE> |
<BUSY_WAIT> |
<CASE> |
<CASE_DEFAULT> |
<CLEAR_STATE> |
Expand Down Expand Up @@ -920,9 +931,9 @@ FieldValue fieldValue() :
{ return val; }
;

FieldValue numericValue() :
NumericFieldValue numericValue() :
{
FieldValue val;
NumericFieldValue val;
String pre = "";
}

Expand Down

0 comments on commit c7a6e1d

Please sign in to comment.