customFuncCall method

bool customFuncCall (String name, List<Node> args)

Parsing rules for functions with non-standard args, e.g.:

boolean(not(2 > 1))

Receives the custom function name and returns the result in args. The bool result is null if not custom function is found or true/false if it is needed to search for more arguments.

Implementation

// This is a quick prototype, to be modified/improved when
// more custom-parsed funcs come (e.g. `selector(...)`)
//
// Differs from js implementation and interface
bool customFuncCall(String name, List<Node> args) {
  Node result;
  switch (name) {
    case 'alpha':
    case 'Alpha':
      result = ieAlpha();
      if (result != null) args.add(result);
      return true; // stop = true
      break;
    case 'boolean':
    case 'if':
      result = parserInput.expect(parsers.condition, 'expected condition');
      if (result != null) args.add(result);
      return false; //look for more arguments
      break;
  }
  return null; //function not defined

//3.0.0 20170607
// customFuncCall: function (name) {
//     /* Ideally the table is to be moved out of here for faster perf.,
//        but it's quite tricky since it relies on all these `parsers`
//        and `expect` available only here */
//     return {
//         alpha:   f(parsers.ieAlpha, true),
//         boolean: f(condition),
//         'if':    f(condition)
//     }[name.toLowerCase()];
//
//     function f(parse, stop) {
//         return {
//             parse: parse, // parsing function
//             stop:  stop   // when true - stop after parse() and return its result,
//                           // otherwise continue for plain args
//         };
//     }
//
//     function condition() {
//         return [expect(parsers.condition, 'expected condition')];
//     }
// },
}