Skip to content

Commit

Permalink
[#4] Add FEEL lexer and parser for DMN 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
opatrascoiu committed Feb 19, 2025
1 parent 77bdcd9 commit cac9083
Show file tree
Hide file tree
Showing 9 changed files with 1,619 additions and 826 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<properties>
<antlr.version>4.10.1</antlr.version>
<dmn.version>1.3</dmn.version>
<dmn.version>1.4</dmn.version>
<package.name>jdmn-js-runtime</package.name>

<antlr.source.directory>${project.basedir}/src/${package.name}/resources/dmn/${dmn.version}</antlr.source.directory>
Expand Down
8 changes: 8 additions & 0 deletions spec/parser/Lexer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ describe("Lexer", () => {
token = checkToken("\"a\\U01F40Eb\"", FEELLexer.STRING, "\"a\uD83D\uDC0Eb\"");
checkPosition(token, 1, 1, 1, 6, 0, 12);

// multiline string
token = checkToken("\"l1\\\nl2\"", FEELLexer.STRING, "\"l1\\\nl2\"");
checkPosition(token, 1, 1, 2, 4, 0, 8);

token = checkToken("\".\"", FEELLexer.STRING, "\".\"");
checkPosition(token, 1, 1, 1, 3, 0, 3);
});
Expand Down Expand Up @@ -216,6 +220,7 @@ describe("Lexer", () => {
checkToken("substring after", FEELLexer.NAME, "substring after");
checkToken("starts with", FEELLexer.NAME, "starts with");
checkToken("ends with", FEELLexer.NAME, "ends with");
checkToken("string join", FEELLexer.NAME, "string join");
checkToken("list contains", FEELLexer.NAME, "list contains");
checkToken("insert before", FEELLexer.NAME, "insert before");
checkToken("index of", FEELLexer.NAME, "index of");
Expand Down Expand Up @@ -249,6 +254,7 @@ const SPECIAL_NAMES = [
"substring after",
"starts with",
"ends with",
"string join",
// list functions
"start position",
"list contains",
Expand All @@ -258,6 +264,8 @@ const SPECIAL_NAMES = [
// context functions
"get entries",
"get value",
"context put",
"context merge",
// range functions
"met by",
"overlaps before",
Expand Down
19 changes: 19 additions & 0 deletions spec/parser/Parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,23 @@ describe("Parser", () => {
// Temporal literals
validateOutputEntry("@\"2019-03-31\" instance of date");
});

it("Expressions - Instance Of", () => {
validateOutputEntry("3 instance of number");
validateOutputEntry("123 instance of function <number, number> -> number");
validateOutputEntry("\"abc\" instance of string");
validateOutputEntry("true instance of boolean");
validateOutputEntry("date(\"2011-01-03\") instance of date");
validateOutputEntry("time(\"12:00:00Z\") instance of time");
validateOutputEntry("date and time(\"2016-03-01T12:00:00Z\") instance of date and time");
validateOutputEntry("duration(\"P1Y1M\") instance of years and months duration");
validateOutputEntry("duration(\"P1DT1H\") instance of days and time duration");
validateOutputEntry("x instance of number");
validateOutputEntry("x instance of context<x: number, y:string>");
validateOutputEntry("x instance of range<number>");
validateOutputEntry("x instance of function<number, string> -> number");
validateOutputEntry("x instance of list<number>");
// Temporal literals
validateOutputEntry("@\"2019-03-31\" instance of date");
});
});
2 changes: 1 addition & 1 deletion src/jdmn-js-runtime/parser/FEELLexer.interp

Large diffs are not rendered by default.

763 changes: 397 additions & 366 deletions src/jdmn-js-runtime/parser/FEELLexer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/jdmn-js-runtime/parser/FEELParser.interp

Large diffs are not rendered by default.

892 changes: 435 additions & 457 deletions src/jdmn-js-runtime/parser/FEELParser.js

Large diffs are not rendered by default.

Loading

0 comments on commit cac9083

Please sign in to comment.