Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

feelin

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feelin - npm Package Compare versions

Comparing version 0.17.0 to 0.18.0

src/grammar/expression-parser.js

10

package.json
{
"name": "feelin",
"version": "0.17.0",
"version": "0.18.0",
"description": "A FEEL parser and interpreter",

@@ -41,6 +41,6 @@ "main": "dist/index.js",

"build-parser": "run-s build-parser:*",
"build-parser:expr:watch": "chokidar --initial src/feel.grammar -c \"npm run build-parser:expr -- --names\"",
"build-parser:expr": "lezer-generator src/feel.grammar -o src/parser",
"build-parser:unary:watch": "chokidar --initial src/feel-unary.grammar -c \"npm run build-parser:unary -- --names\"",
"build-parser:unary": "lezer-generator src/feel-unary.grammar -o src/unary-parser",
"build-parser:expr:watch": "chokidar --initial src/grammar/expression.grammar -c \"npm run build-parser:expr -- --names\"",
"build-parser:expr": "lezer-generator src/grammar/expression.grammar -o src/grammar/expression-parser",
"build-parser:unary:watch": "chokidar --initial src/grammar/unary-test.grammar -c \"npm run build-parser:unary -- --names\"",
"build-parser:unary": "lezer-generator src/grammar/unary-test.grammar -o src/grammar/unary-test-parser",
"build": "rollup -c",

@@ -47,0 +47,0 @@ "prepublishOnly": "run-s build-parser build",

@@ -16,4 +16,4 @@ ## Feelin

unaryTest(1, '1'); // true
unaryTest(1, '[1..end]', { end: 10 }); // true
unaryTest('1', { '?': 1 }); // true
unaryTest('[1..end]', { '?': 1, end: 10 }); // true

@@ -36,5 +36,5 @@ evaluate("Mike's dauther.name", {

* [x] Support all FEEL operations
* [x] Support names with spaces
* [x] Recover on errors
* [x] Recognizes full FEEL grammar
* [x] Supports names with spaces
* [x] Recovers on errors
* [ ] Provides built-in functions

@@ -41,0 +41,0 @@ * [ ] Passes all FEEL tests in the [DMN TCK](https://github.com/dmn-tck/tck)

@@ -0,1 +1,5 @@

import {
is
} from './types';
const names = [

@@ -29,3 +33,2 @@

// 10.3.4.4 List functions
'list contains',

@@ -86,3 +89,2 @@ 'count',

// 10.3.4.8 Temporal built-in functions
'day of year',

@@ -94,3 +96,2 @@ 'day of week',

// 10.3.4.9 Sort
'sort',

@@ -142,3 +143,3 @@

'not': fn(function(bool) {
return !bool;
return is(bool, 'Boolean') ? !bool : null;
}, [ 'any' ]),

@@ -145,0 +146,0 @@

@@ -1,29 +0,62 @@

import { interpreter } from './interpreter';
import {
parser as expressionGrammarParser
} from './grammar/expression-parser';
function unaryTest(input, expression, context) {
import {
parser as unaryTestGrammarParser
} from './grammar/unary-test-parser';
return interpreter.unaryTest(expression, {
...context,
'?': input
});
import {
Interpreter
} from './interpreter';
}
import {
Parser
} from './parser';
function evaluate(expression, context) {
return interpreter.evaluate(expression, context);
const unaryTestParser = new Parser(unaryTestGrammarParser);
const expressionParser = new Parser(expressionGrammarParser);
const unaryTester = new Interpreter(unaryTestParser);
const expressionEvaluator = new Interpreter(expressionParser);
export function unaryTest(expression, context={}) {
const value = context['?'] || null;
const {
root,
parsedContext
} = unaryTester.evaluate(expression, context);
// root = fn(ctx) => test(val)
const test = root(parsedContext);
return test(value);
}
function parseExpressions(expression, context={}) {
return interpreter.parseExpressions(expression, context);
export function evaluate(expression, context={}) {
const {
root,
parsedContext
} = expressionEvaluator.evaluate(expression, context);
// root = [ fn(ctx) ]
const results = root(parsedContext);
if (results.length === 1) {
return results[0];
} else {
return results;
}
}
function parseUnaryTests(expression, context={}) {
return interpreter.parseUnaryTests(expression, context);
export function parseExpressions(expression, context={}) {
return expressionParser.parse(expression, context);
}
export {
parseExpressions,
parseUnaryTests,
unaryTest,
evaluate
};
export function parseUnaryTests(expression, context={}) {
return unaryTestParser.parse(expression, context);
}

@@ -1,9 +0,1 @@

import {
parser as expressionParser
} from './parser';
import {
parser as unaryTestParser
} from './unary-parser';
import { builtins } from './builtins';

@@ -14,118 +6,10 @@

function Interpreter() {
export class Interpreter {
constructor(parser) {
this._parser = parser;
}
this.parseName = (name) => {
_buildExecutionTree(tree, input) {
let match;
const pattern = /([./\-'+*]+)|([^\s./\-'+*]+)/g;
const tokens = [];
let lastName = false;
while ((match = pattern.exec(name))) {
const [ _, additionalPart, namePart ] = match;
if (additionalPart) {
lastName = false;
if (tokens.length) {
tokens.push('\\s*');
}
tokens.push(additionalPart.replace(/[+*]/g, '\\$&'));
} else {
if (tokens.length) {
if (lastName) {
tokens.push('\\s+');
} else {
tokens.push('\\s*');
}
}
lastName = true;
tokens.push(namePart);
}
}
return tokens;
};
this.findNames = (context) => {
let uid = 0;
return Object.keys(context).filter(key => /[\s./\-'+*]/.test(key)).map(name => {
const replacement = '_' + uid.toString(36);
const tokens = this.parseName(name);
const replacer = new RegExp(tokens.join(''), 'g');
return {
name,
replacement,
replacer
};
});
};
this.replaceNames = (input, context, names) => {
for (const { name, replacement, replacer } of names) {
input = input.replace(replacer, function(match) {
const placeholder = replacement.padEnd(match.length, '_');
if (!context[placeholder]) {
context = {
...context,
[match]: context[name]
};
}
return placeholder;
});
}
return {
input,
context
};
};
this.parse = (parser, rawInput, rawContext) => {
const names = this.findNames(rawContext);
const {
context,
input
} = this.replaceNames(rawInput, rawContext, names);
const tree = parser.parse(input);
return {
context,
input,
tree
};
};
this.parseExpressions = (input, context) => {
return this.parse(expressionParser, input, context);
};
this.parseUnaryTests = (input, context) => {
return this.parse(unaryTestParser, input, context);
};
this.createExecutionTree = (tree, input) => {
const root = { args: [] };

@@ -174,35 +58,25 @@

return root.args[root.args.length - 1];
};
}
this.evaluate = (expression, context={}) => {
_parse(expression, context) {
return this._parser.parse(expression, context);
}
const {
tree,
context: parsedContext
} = this.parseExpressions(expression, context);
evaluate(expression, context={}) {
const root = this.createExecutionTree(tree, expression);
const results = root(parsedContext);
if (results.length === 1) {
return results[0];
} else {
return results;
}
};
this.unaryTest = (expression, context={}) => {
const value = context['?'] || null;
const {
tree,
context: parsedContext
} = this.parseUnaryTests(expression, context);
tree: parseTree,
parsedContext,
parsedInput
} = this._parse(expression, context);
const root = this.createExecutionTree(tree, expression);
const root = this._buildExecutionTree(parseTree, expression);
return root(parsedContext)(value);
};
return {
parseTree,
parsedContext,
parsedInput,
root
};
}

@@ -834,8 +708,2 @@ }

};
}
const interpreter = new Interpreter();
export {
interpreter
};
}

@@ -1,19 +0,112 @@

// This file was generated by lezer-generator. You probably shouldn't edit it.
import {Parser} from "lezer"
import {NodeProp} from "lezer"
export const parser = Parser.deserialize({
states: "@QOYOPOOO#}OPO(3CiOYOPO'#DOO'eOPO'#DOO*YOPO'#DYO.YOPO'#DpOXOP'#El'#ElO.YOPO'#EsOXOP'#Er'#ErOXOP'#Fw'#FwOXOP'#Fv'#FvO.^OPO'#EwOYOPO'#ExO.}OPO'#EyO.^OPO'#EvOXOP'#Ev'#EvOXOP'#Ff'#FfO1uOPO'#E}OXOP'#Fy'#FyOXOP'#Fe'#FeQYOPOOO2SOPO'#C`OYOPO'#ChO2WOPO'#ClO2[OPO'#DqO2`OPO'#DqO2dOPO'#DqO2hOPO'#DqO2oOPO'#DqO2sOPO'#DqO2wOPO'#DqO2{OPO'#DqO3POPO'#DqO3TOPO'#DqO3XOPO'#DqO3]OPO'#DqO3aOPO'#DqOXOP'#Eo'#EoO3hOPO'#EzOYOPO,59bOYOPO,59jOYOPO,59jOYOPO,59jO3lOPO,5:WOYOPO,5:XO3pOPO'#E`OXOP,5:[,5:[OYOPO,59^OYOPO,59`OYOPO,59bO6qOPO,59bO9fOPO,59pO9jOPO,59jO=jOPO,5;WOEiOPO'#FlOIiOPO'#FZOXOP,59t,59tOXOP,5;_,5;_OImOPO'#ElOXOP'#Fx'#FxOIqOPO,5;cOIuOPO,5;dOJxOPO'#FxOLUOPO'#FxOMbOPO'#FzONhOPO,5;eOXOP,5;b,5;bOXOP'#FQ'#FQONlOPO'#FPONpOPO'#F}ONwOPO,5;iON{OPO'#FROXOP,5;q,5;qO! POPO'#CdO! TOPO'#CcO! [OPO,58zO! `OPO,59SO!!cOPO'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rimrisritri!Pri!Qri!Rri!Tri!Vri!^ri!cri!fri!hri!jri!kri!nri!pri!rri!sri!tri!vri!xri!yri!zri!{ri!}ri#Ori#Pri#_ri#ari#bri#dri#eri#hri#iri#rri$Uriqri$]ri^ri#xriZri$Zri_rieri~o}OwzOy!TO!b|O$a{OTriUriXri]riaribrigriirikrilrimrisritriurivri!Pri!Qri!Rri!Tri!Vri!^ri!cri!fri!hri!jri!kri!nri!pri!rri!sri!tri!vri!xri!yri!zri!{ri!}ri#Ori#Pri#_ri#ari#bri#dri#eri#hri#iri#rri$Uriqri$]ri^ri#xriZri$Zri_rieri~o}Oy!TO!b|O$a{OTriUriXri]riaribrigriirikrilrimrisritriurivriwri!Pri!Qri!Rri!Tri!Vri!^ri!cri!fri!hri!jri!kri!nri!pri!rri!sri!tri!vri!xri!yri!zri!{ri!}ri#Ori#Pri#_ri#ari#bri#dri#eri#hri#iri#rri$Uriqri$]ri^ri#xriZri$Zri_rieri~X!SOg!POi!QOkwOlwOm!ROo}OsxOtxOuyOvyOwzOy!TO!b|O!c$OO$a{O~X!SOg!POi!QOkwOlwOm!ROo}OsxOtxOuyOvyOwzOy!TO!b|O$]#eO$a{Oq$iP~$a!XOX$`Pg$`Pi$`Pk$`Pl$`Pm$`Po$`Pq$`Ps$`Pt$`Pu$`Pv$`Pw$`Py$`P!b$`P$]$`P$b#UX~$b$QO~q$RO~#X$SO~#Z$SO#[$SO~X!SOi!QOkwOlwOm!ROo}OsxOtxOuyOvyOwzOy!TO!b|O$a{OTfiUfi]fiafibfigfi!Pfi!Qfi!Rfi!Tfi!Vfi!^fi!cfi!ffi!hfi!jfi!kfi!nfi!pfi!rfi!sfi!tfi!vfi!xfi!yfi!zfi!{fi!}fi#Ofi#Pfi#_fi#afi#bfi#dfi#efi#hfi#ifi#rfi$Ufiqfi$]fi^fi#xfiZfi$Zfi_fiefi~X!SOkwOlwOm!ROo}OsxOtxOuyOvyOwzOy!TO!b|O$a{OThiUhi]hiahibhighiihi!Phi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T$v$z%T%U%Z%y!kWOQRZ[]^dfwxyz|}!P!Q!R!S#[#b#e#h#n#r#s#t#x$Q$T$v$z%T%U%Z%y!e_OQR[]dfwxyz|}!P!Q!R!S#[#e#h#n#r#s#t#x$Q$T$v$z%T%U%Z%y!ebOQR[]dfwxyz|}!P!Q!R!S#[#e#h#n#r#s#t#x$Q$T$v$z%T%U%Z%yQ#|!vR%X$tQ!gaR$f#jT!fa#jT!ea#jQdOR!jdQ#o!lR$i#oQ#u!pR$n#uQ$y$VR%_$yS!WS#OS#_!W%oR%o%bQ%r%eR%|%rQ%u%gR&P%uQ%[$wR%l%[S#d!b!}R$b#dQ$s#|R%W$sQ#i!gR$e#iSPOdS!UQRQ!_[Q!b]Q!nfQ!wwQ!xxQ!yyQ!zzQ!||Q!}}Q#W!PQ#X!QQ#Y!RS#Z!S$zQ$U#[Q$c#eQ$d#hQ$g#nQ$k#rQ$l#sQ$m#tQ$p#xQ$w$QQ$x$TQ%Y$vQ%i%TQ%j%UQ%k%ZR&S%y!ecOQR[]dfwxyz|}!P!Q!R!S#[#e#h#n#r#s#t#x$Q$T$v$z%T%U%Z%yR#q!lR#w!pR${$VV!YS#O%bR%t%eR%h%RR%w%gR#R}R%^$wQ#f!bR$P!}!^YOQRdfwxyz|}!P!Q!R!S#e#h#n#r#s#t#x$Q$T$v$z%T%U%Z%yU!]Z^#bV!`[]#[W!^Z[]#[Q!d^R$a#bR!c]R#}!vR$u#|R!haR#k!g",
nodeNames: "⚠ Expressions LineComment BlockComment ForExpression Name for InExpressions InExpression in IterationContext return IfExpression if then else QuantifiedExpression some every InExpressions InExpression satisfies Disjunction or Conjunction and Comparison CompareOp CompareOp between PositiveUnaryTest ( PositiveUnaryTests ) ArithmeticExpression ArithOp ArithOp ArithOp ArithOp ArithOp InstanceOf instance of Type QualifiedName SpecialType days time duration years months DateAndTime ListType list < > ContextType context ContextEntryType FunctionType function ArgumentType PathExpression FilterExpression [ ] FunctionInvocation SpecialFunctionName string length upper case lower substring before after starts with ends contains insert index distinct values met by overlaps finished started day year week month get value entries Parameters NamedParameters ParameterName SpecialParameterName start position decimal sep separator grouping PositionalParameters null NumericLiteral Number StringLiteral BooleanLiteral true false DateTimeLiteral DateTimeConstructor date ? SimplePositiveUnaryTest Interval ParenthesizedExpression List FunctionDefinition FormalParameter external Context { ContextEntry Key SpecialKey method signature }",
nodeProps: [
[NodeProp.top, 1,true],
[NodeProp.skipped, 2,"true",3,"true"]
],
repeatNodeCount: 11,
tokenData: "5X~R}XY$OY^$Opq$Oqr$srs%Otu%rxy(Wyz(]z{(b{|(o|}(t}!O(y!O!P)W!P!Q)p!Q![*{![!]+f!^!_+k!_!`$y!`!a+z!a!b%r!c!}%r!}#O,U#P#Q,Z#Q#R(j#R#S%r#T#W%r#W#X,`#X#o%r#o#p4w#q#r4|#y#z$O$f$g$O#BY#BZ$O$IS$I_$O$I`$Ib%r$I|$JO$O$JT$JU$O$KV$KW$O$Kh%#t%r&/x&Et%r&FU&FV$O&FV;'S%r;'S;:j5R?&r?Ah%r?BY?Mn%r~$TY$W~X^$Opq$O#y#z$O$f$g$O#BY#BZ$O$IS$I_$O$I|$JO$O$JT$JU$O$KV$KW$O&FU&FV$O~$vP!_!`$y~%OOk~~%TU#b~OY%OZr%Ors%gs#O%O#O#P%l#P~%O~%lO#b~~%oPO~%O~%w_T~tu&v!Q![&v!a!b&v!c!}&v#R#S&v#T#o&v1p4U&v$I`$Ib&v$Je$Jg&v$Kh%#t&v&/x&Et&v&FV;'S&v;'S;:j(Q?&r?Ah&v?BY?Mn&v~&{_T~tu&v!Q![&v!a!b&v!c!}&v#R#S&v#T#o&v1p4U&v$I`$Ib&v$Je$Jg&v$Kh%#t&v&/x&Et&v&FV;'S&v;'S;:j'z?&r?Ah&v?BY?Mn&v~'}P;=`<%l&v~(TP;=`<%l&v~(]Oo~~(bOq~~(gPu~z{(j~(oOw~~(tOs~~(yO$]~~)OPt~!`!a)R~)WO$f~~)]Q$a~!O!P)c!Q![)h~)hO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^4f~4iP#a#b4l~4oP#X#Y4r~4wO!T~~4|O#r~~5RO#x~~5UP;=`<%l%r",
tokenizers: [0, 1],
specializeTable: 5888,
specializations: [{for:12, in:18, return:23, if:26, then:28, else:30, some:34, every:36, satisfies:43, or:46, and:50, between:58, instance:82, of:85, days:93, time:95, duration:97, years:99, months:101, list:107, context:115, function:120, string:137, length:139, upper:141, case:143, lower:145, substring:147, before:149, after:151, starts:153, with:155, ends:157, contains:159, insert:161, index:163, distinct:165, values:167, met:169, by:171, overlaps:173, finished:175, started:177, day:179, year:181, week:183, month:185, get:187, value:189, entries:191, start:201, position:203, decimal:205, sep:207, separator:209, grouping:211, null:214, true:224, false:226, date:233, "?":234, external:248, method:261, signature:263}],
tokenPrec: 5882
})
/**
* A feel parser for a specific grammar (unary tests / expressions)
*/
export class Parser {
constructor(grammarParser) {
this._grammarParser = grammarParser;
}
parse(rawInput, rawContext) {
const names = this._findNames(rawContext);
const {
context: parsedContext,
input: parsedInput
} = this._replaceNames(rawInput, rawContext, names);
const tree = this._grammarParser.parse(parsedInput);
return {
parsedContext,
parsedInput,
tree
};
}
_parseName(name) {
let match;
const pattern = /([./\-'+*]+)|([^\s./\-'+*]+)/g;
const tokens = [];
let lastName = false;
while ((match = pattern.exec(name))) {
const [ _, additionalPart, namePart ] = match;
if (additionalPart) {
lastName = false;
if (tokens.length) {
tokens.push('\\s*');
}
tokens.push(additionalPart.replace(/[+*]/g, '\\$&'));
} else {
if (tokens.length) {
if (lastName) {
tokens.push('\\s+');
} else {
tokens.push('\\s*');
}
}
lastName = true;
tokens.push(namePart);
}
}
return tokens;
}
_findNames(context) {
let uid = 0;
return Object.keys(context).filter(key => /[\s./\-'+*]/.test(key)).map(name => {
const replacement = '_' + uid.toString(36);
const tokens = this._parseName(name);
const replacer = new RegExp(tokens.join(''), 'g');
return {
name,
replacement,
replacer
};
});
}
_replaceNames(input, context, names) {
for (const { name, replacement, replacer } of names) {
input = input.replace(replacer, function(match) {
const placeholder = replacement.padEnd(match.length, '_');
if (!context[placeholder]) {
context = {
...context,
[match]: context[name]
};
}
return placeholder;
});
}
return {
input,
context
};
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc