Skip to content

Commit

Permalink
Merge branch '1.4.7' of http://10.73.97.24/oecloud.io/feel
Browse files Browse the repository at this point in the history
  • Loading branch information
vamsee committed Oct 5, 2020
2 parents b2818c1 + 157bf9d commit 4a5c83b
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 227 deletions.
40 changes: 22 additions & 18 deletions dist/feel.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 22 additions & 18 deletions grammar/feel-initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@

// ast nodes are the constructors used to construct the ast for the parsed grammar
const ast = require('./feel-ast');
const { enableLexerLogging } = require('../settings');
// const { enableLexerLogging } = require('../settings');

const {logger} = require('../logger');
// const {logger} = require('../logger');
// adding build methods to prototype of each constructor
require('./feel-ast-parser')(ast);
const _log = logger('feel-grammer-parser');
let loggerOptions;
function log(msg) {
loggerOptions = options.loggerOptions || {};
if (enableLexerLogging) {
_log.debug(loggerOptions, msg)
}
};
// const _log = logger('feel-grammer-parser');
// let loggerOptions;
// function log(msg) {
// loggerOptions = options.loggerOptions || {};
// if (enableLexerLogging) {
// _log.debug(loggerOptions, msg)
// }
// };

function log() {
// empty function
}

let initialized = false;
let ruleName = 'default';
Expand All @@ -34,12 +38,12 @@ function rule() {
}

function extractOptional(optional, index) {
log('_extractOptional');
//log('_extractOptional');
return optional ? optional[index] : null;
}

function flatten(list) {
log('_flatten');
//log('_flatten');
return list.filter( d => d && d.length).reduce((recur, next) => {
if(next && Array.isArray(next)) {
return [].concat.call(recur, flatten(next));
Expand All @@ -49,36 +53,36 @@ function flatten(list) {
}

function extractList(list, index) {
log('_extractList');
//log('_extractList');
return list.map(element => element[index]);
}

function buildList(head, tail, index) {
log('_buildList')
//log('_buildList')
return [head].concat(extractList(tail, index));
}

function buildName(head, tail, index) {
log('_buildName');
//log('_buildName');
return tail && tail.length ? [...head, ...flatten(tail)].join("") : head.join("");
}


function buildBinaryExpression(head, tail, loc, text, rule) {
log('_buildBinaryExpression');
//log('_buildBinaryExpression');
return tail.reduce((result, element) => new ast.ArithmeticExpressionNode(element[1], result, element[3], loc, text, rule), head);
}

function buildComparisionExpression(head, tail, loc, text, rule) {
log('_buildComparisionExpression');
//log('_buildComparisionExpression');
return tail.reduce((result, element) => {
const operator = Array.isArray(element[1]) ? element[1][0] : element[1];
return new ast.ComparisionExpressionNode(operator, result, element[3], null, loc, text, rule);
}, head);
}

function buildLogicalExpression(head, tail, loc, text, rule) {
log('_buildLogicalExpression');
//log('_buildLogicalExpression');
return tail.reduce((result, element) => {
let operator = element[1];
if (operator === 'and') {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-feel",
"version": "1.4.5",
"version": "1.4.7",
"description": "FEEL(Friendly Enough Expression Language) based on DMN specification 1.1 for conformance level 3",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -35,10 +35,10 @@
"dependencies": {
"big.js": "3.2.0",
"bunyan": "1.8.12",
"lodash": "4.17.15",
"lodash": "4.17.20",
"moment": "2.24.0",
"moment-timezone": "0.5.27",
"xlsx": "0.8.8"
"xlsx": "0.15.6"
},
"devDependencies": {
"chai": "3.4.1",
Expand Down
Loading

0 comments on commit 4a5c83b

Please sign in to comment.