pakmanaged.js
function() {
        var CompArray = function() {
          this.mode = "use";
          this.variables = [];
        };
        var _carrays = [];
        var _current;
        function declare(v) {
          var l = _current.variables.filter(function(elt) {
            // if it has, change its undef state
            if (elt.value === v) {
              elt.undef = false;
              return v;
            }
          }).length;
          return l !== 0;
        }
        function use(v) {
          var l = _current.variables.filter(function(elt) {
            // and if it has been defined
            if (elt.value === v && !elt.undef) {
              if (elt.unused === true) {
                elt.unused = false;
              }
              return v;
            }
          }).length;
          // otherwise we warn about it
          return (l === 0);
        }
        return { stack: function() {
              _current = new CompArray();
              _carrays.push(_current);
            },
            unstack: function() {
              _current.variables.filter(function(v) {
                if (v.unused)
                  warning("W098", v.token, v.raw_text || v.value);
                if (v.undef)
                  isundef(v.funct, "W117", v.token, v.value);
              });
              _carrays.splice(-1, 1);
              _current = _carrays[_carrays.length - 1];
            },
            setState: function(s) {
              if (_.contains(["use", "define", "generate", "filter"], s))
                _current.mode = s;
            },
            check: function(v) {
              if (!_current) {
                return;
              }
              // When we are in "use" state of the list comp, we enqueue that var
              if (_current && _current.mode === "use") {
                if (use(v)) {
                  _current.variables.push({
                    funct: funct,
                    token: state.tokens.curr,
                    value: v,
                    undef: true,
                    unused: false
                  });
                }
                return true;
              // When we are in "define" state of the list comp,
              } else if (_current && _current.mode === "define") {
                // check if the variable has been used previously
                if (!declare(v)) {
                  _current.variables.push({
                    funct: funct,
                    token: state.tokens.curr,
                    value: v,
                    undef: false,
                    unused: true
                  });
                }
                return true;
              // When we are in the "generate" state of the list comp,
              } else if (_current && _current.mode === "generate") {
                isundef(funct, "W117", state.tokens.curr, v);
                return true;
              // When we are in "filter" state,
              } else if (_current && _current.mode === "filter") {
                // we check whether current variable has been declared
                if (use(v)) {
                  // if not we warn about it
                  isundef(funct, "W117", state.tokens.curr, v);
                }
                return true;
              }
              return false;
            }
            };
      }
function() {
        var CompArray = function() {
          this.mode = "use";
          this.variables = [];
        };
        var _carrays = [];
        var _current;
        function declare(v) {
          var l = _current.variables.filter(function(elt) {
            // if it has, change its undef state
            if (elt.value === v) {
              elt.undef = false;
              return v;
            }
          }).length;
          return l !== 0;
        }
        function use(v) {
          var l = _current.variables.filter(function(elt) {
            // and if it has been defined
            if (elt.value === v && !elt.undef) {
              if (elt.unused === true) {
                elt.unused = false;
              }
              return v;
            }
          }).length;
          // otherwise we warn about it
          return (l === 0);
        }
        return { stack: function() {
              _current = new CompArray();
              _carrays.push(_current);
            },
            unstack: function() {
              _current.variables.filter(function(v) {
                if (v.unused)
                  warning("W098", v.token, v.raw_text || v.value);
                if (v.undef)
                  isundef(v.funct, "W117", v.token, v.value);
              });
              _carrays.splice(-1, 1);
              _current = _carrays[_carrays.length - 1];
            },
            setState: function(s) {
              if (_.contains(["use", "define", "generate", "filter"], s))
                _current.mode = s;
            },
            check: function(v) {
              if (!_current) {
                return;
              }
              // When we are in "use" state of the list comp, we enqueue that var
              if (_current && _current.mode === "use") {
                if (use(v)) {
                  _current.variables.push({
                    funct: funct,
                    token: state.tokens.curr,
                    value: v,
                    undef: true,
                    unused: false
                  });
                }
                return true;
              // When we are in "define" state of the list comp,
              } else if (_current && _current.mode === "define") {
                // check if the variable has been used previously
                if (!declare(v)) {
                  _current.variables.push({
                    funct: funct,
                    token: state.tokens.curr,
                    value: v,
                    undef: false,
                    unused: true
                  });
                }
                return true;
              // When we are in the "generate" state of the list comp,
              } else if (_current && _current.mode === "generate") {
                isundef(funct, "W117", state.tokens.curr, v);
                return true;
              // When we are in "filter" state,
              } else if (_current && _current.mode === "filter") {
                // we check whether current variable has been declared
                if (use(v)) {
                  // if not we warn about it
                  isundef(funct, "W117", state.tokens.curr, v);
                }
                return true;
              }
              return false;
            }
            };
      }
array comprehension parsing function parses and defines the three states of the list comprehension in order to avoid defining global variables, but keeping them to the list comprehension scope only. The order of the states are as follows: * "use" which will be the returned iterative part of the list comprehension * "define" which will define the variables local to the list comprehension * "filter" which will help filter out values