'use strict';

const rpv = require('rpv'), create = rpv.create,
                            render = rpv.render,
                            Value = rpv.Value;

let tokens = module.exports = {};

tokens.Variable = create(function(name, value){
  this.name = name;
  if (typeof this.name !== 'string')
    throw new TypeError('name nust be a string');

  this.value = value;
  if (!(this.value instanceof Value))
    throw new TypeError('value must be a RPV Value object.');

}, {

  resolve: function(){ return render(this.value); }

});

@@ -59,104 +59,8 @@
 eate
-,%0A                            render = rpv.render,%0A                            Value = rpv.Value
 ;%0A%0Al
@@ -93,16 +93,34 @@
  = %7B%7D;%0A%0A
+%0Aconst Variable = 
 tokens.V
@@ -151,20 +151,19 @@
 n(name, 
-valu
+typ
 e)%7B%0A  th
@@ -169,21 +169,26 @@
 his.
-name = name
+set('variable')
 ;%0A
+%0A
   if
@@ -206,17 +206,17 @@
 is.name 
-!
+=
 == 'stri
@@ -220,16 +220,45 @@
 tring')%0A
+    this.name = name;%0A  else%0A
     thro
@@ -311,60 +311,287 @@
 his.
-value = value;%0A  if (!(this.value instanceof Value))
+set(type === 'function' ? 'call' : 'substitute');%0A%7D, %7B%7D);%0A%0Aconst Definition = tokens.Definition = create(function(name, value)%7B%0A  this.set('definition');%0A%0A  if (name instanceof Variable)%0A    this.name = name.name;%0A  else if (typeof name === 'string')%0A    this.name = name;%0A  else
 %0A   
@@ -612,20 +612,19 @@
 eError('
-valu
+nam
 e must b
@@ -631,24 +631,33 @@
 e a 
-RPV Valu
+string or Variabl
 e object
 .');
@@ -656,73 +656,16 @@
 ject
-.
 ');%0A
-%0A
 %7D, %7B
-%0A%0A  resolve: function()%7B return render(this.value); %7D%0A%0A
 %7D);%0A

Add Variable and Definition tokens.