jscpd
Version:
Copy/paste detector for programming code, support JavaScript, CoffeeScript, PHP, Ruby, Python, Less, Go, Java, Yaml, C#, C++, C languages
50 lines (38 loc) • 1.6 kB
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
var CoffeeTokens, TokenizerBase, TokenizerCoffee,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
TokenizerBase = require('./TokenizerBase');
CoffeeTokens = require('coffee-script').tokens;
TokenizerCoffee = (function(superClass) {
extend(TokenizerCoffee, superClass);
function TokenizerCoffee() {
return TokenizerCoffee.__super__.constructor.apply(this, arguments);
}
TokenizerCoffee.prototype.tokenize = function(code) {
this.tokens = CoffeeTokens(code);
return this;
};
TokenizerCoffee.prototype.getType = function() {
return 'coffee';
};
TokenizerCoffee.prototype.generateMap = function() {
var currentMap, i, len, options, ref, ref1, tokensPositions, type, value;
currentMap = "";
tokensPositions = [];
ref = this.tokens;
for (i = 0, len = ref.length; i < len; i++) {
ref1 = ref[i], type = ref1[0], value = ref1[1], options = ref1[2];
tokensPositions.push(options.first_line);
currentMap = currentMap + this.createMap(type, value);
}
return {
tokensPositions: tokensPositions,
currentMap: currentMap
};
};
return TokenizerCoffee;
})(TokenizerBase);
module.exports = TokenizerCoffee;
}).call(this);