tools/kevoree-kevscript/lib/KevScript.js
function (data, ctxModel, ctxVars) {
    const options = xtend(this.options, { ctxVars, logger: this.logger });
    const parser = new kevs.Parser();
    const ast = parser.parse(data);

    if (ast.type !== 'kevScript') {
      const err = new Error('Unable to parse script');
      err.parser = ast;
      err.warnings = options.warnings || [];
      return Promise.reject(err);
    } else {
      return interpreter(ast, ctxModel, options)
        .then(({ error, warnings, model }) => {
          if (error) {
            error.warnings = warnings;
            throw error;
          } else {
            return { model, warnings };
          }
        });
    }
  }
function (data, ctxModel, ctxVars) {
    const options = xtend(this.options, { ctxVars, logger: this.logger });
    const parser = new kevs.Parser();
    const ast = parser.parse(data);

    if (ast.type !== 'kevScript') {
      const err = new Error('Unable to parse script');
      err.parser = ast;
      err.warnings = options.warnings || [];
      return Promise.reject(err);
    } else {
      return interpreter(ast, ctxModel, options)
        .then(({ error, warnings, model }) => {
          if (error) {
            error.warnings = warnings;
            throw error;
          } else {
            return { model, warnings };
          }
        });
    }
  }
function ( data , ctxModel , ctxVars ) { const options = xtend ( this . options , { ctxVars , logger : this . logger } ) ; const parser = new kevs . Parser ( ) ; const ast = parser . parse ( data ) ; if ( ast . type !== 'kevScript' ) { const err = new Error ( 'Unable to parse script' ) ; err . parser = ast ; err . warnings = options . warnings || [ ] ; return Promise . reject ( err ) ; } else { return interpreter ( ast , ctxModel , options ) . then ( ( { error , warnings , model } ) => { if ( error ) { error . warnings = warnings ; throw error ; } else { return { model , warnings } ; } } ) ; } }
Parses given KevScript source-code in parameter 'data' and returns a ContainerRoot.
@param   {String} data string
@param   {Object|Function} [ctxModel] a model to "start" on (in order not to create a model from scratch)
@param   {Object|Function} [ctxVars] context variables to be accessible from the KevScript
@returns {Promise<{ ContainerRoot, Array<Warning>}} promise
@throws  Error on SyntaxError and on source code validity and such
Parses given KevScript source - code in parameter data and returns a ContainerRoot .