From 2c1eee7b2a99985bbe92426368ea32360a4cc0b2 Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Wed, 14 Sep 2016 15:14:39 -0400 Subject: Implement functions/calls --- lib/doml.js | 15 +++++++++++++++ prog/function.html | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 prog/function.html diff --git a/lib/doml.js b/lib/doml.js index 332a17e..c813db9 100644 --- a/lib/doml.js +++ b/lib/doml.js @@ -136,6 +136,21 @@ return me.evaluate(child, context); }); console.log.apply(this, args); + }, + + 'function': function(dataset, children, context) { + var argNames = dataset.args.split(','); + return function(argValues) { + for (var idx = 0; idx < argNames.length; idx++) { + var argName = argNames[idx]; + context[argName] = me.evaluate(argValues[idx], context); + } + me.evaluate(children[0], context); + } + }, + + 'call': function(dataset, children, context) { + return context[dataset.name](children); } }; diff --git a/prog/function.html b/prog/function.html new file mode 100644 index 0000000..2fe8d40 --- /dev/null +++ b/prog/function.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3