From 4a9b5b593946fb965d0e51dabad3244be26f6f0c Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 21 Sep 2012 15:12:39 -0400 Subject: [PATCH] Remove directives. Fixes #157 --- lib/carto/index.js | 4 ++-- lib/carto/tree/directive.js | 39 ------------------------------------- 2 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 lib/carto/tree/directive.js diff --git a/lib/carto/index.js b/lib/carto/index.js index 9e73bcd..13de4b8 100644 --- a/lib/carto/index.js +++ b/lib/carto/index.js @@ -38,7 +38,7 @@ var carto = { error = options.indent + error.join('\n' + options.indent) + '\033[0m\n'; message = options.indent + message + stylize(ctx.message, 'red'); - ctx.filename && (message += stylize(' in ', 'red') + ctx.filename); + if (ctx.filename) (message += stylize(' in ', 'red') + ctx.filename); util.error(message, error); @@ -51,7 +51,7 @@ var carto = { }; [ 'call', 'color', 'comment', 'definition', 'dimension', - 'directive', 'element', 'expression', 'filterset', 'filter', 'field', + 'element', 'expression', 'filterset', 'filter', 'field', 'keyword', 'layer', 'literal', 'operation', 'quoted', 'imagefilter', 'reference', 'rule', 'ruleset', 'selector', 'style', 'url', 'value', 'variable', 'zoom', 'invalid', 'fontset' diff --git a/lib/carto/tree/directive.js b/lib/carto/tree/directive.js deleted file mode 100644 index 9fb4aba..0000000 --- a/lib/carto/tree/directive.js +++ /dev/null @@ -1,39 +0,0 @@ -(function(tree) { - -tree.Directive = function Directive(name, value) { - this.name = name; - if (Array.isArray(value)) { - this.ruleset = new tree.Ruleset([], value); - } else { - this.value = value; - } -}; -tree.Directive.prototype = { - toString: function(ctx, env) { - if (this.ruleset) { - this.ruleset.root = true; - return this.name + ' {\n ' + - this.ruleset.toString(ctx, env).trim().replace(/\n/g, '\n ') + - '\n}\n'; - } else { - return this.name + ' ' + this.value.toString() + ';\n'; - } - }, - eval: function(env) { - env.frames.unshift(this); - this.ruleset = this.ruleset && this.ruleset.eval(env); - env.frames.shift(); - return this; - }, - variable: function(name) { - return tree.Ruleset.prototype.variable.call(this.ruleset, name); - }, - find: function() { - return tree.Ruleset.prototype.find.apply(this.ruleset, arguments); - }, - rulesets: function() { - return tree.Ruleset.prototype.rulesets.apply(this.ruleset); - } -}; - -})(require('../tree'));