diff --git a/gulpfile.js b/gulpfile.js index 5c5c054..628807b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -68,7 +68,7 @@ gulp.task('browserify', function() { bundler.add([file.path, es6ify.runtime]); bundler.transform(require('./lib/canopy-transform')); - bundler.transform(es6ify); + bundler.transform(es6ify.configure(/^(?!.*node_modules)+.+\.js$/)); file.contents = bundler.bundle(); })) diff --git a/karma.conf.js b/karma.conf.js index 81f1b87..1930756 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -23,7 +23,7 @@ module.exports = function(karma) { bundle.add([es6ify.runtime]); bundle.transform(require('./lib/canopy-transform')); - bundle.transform(es6ify); + bundle.transform(es6ify.configure(/^(?!.*node_modules)+.+\.js$/)); } }) }); diff --git a/package.json b/package.json index ba9de71..df95ca1 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "karma-notify-reporter": "^0.1.1", "karma-phantomjs-launcher": "^0.1.4", "lodash": "^2.4.1", + "snapsvg": "git://github.com/adobe-webplatform/Snap.svg#dev", "through": "^2.3.6", "vinyl-transform": "^1.0.0" } diff --git a/src/index.html b/src/index.html index 37ecd1c..9b60486 100644 --- a/src/index.html +++ b/src/index.html @@ -20,5 +20,7 @@
-
+
+ +
diff --git a/src/js/main.js b/src/js/main.js index fdfaec1..816b46a 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -1,3 +1,17 @@ import parser from './parser/javascript.js'; +import Snap from 'snapsvg'; -window.parser = parser; +// Testing code +(function() { + var result = parser.parse('test expr'), + container = Snap('#regexp-render svg'); + + if (container) { + document.body.className = 'has-results'; + result.render(container); + + setTimeout(() => { + result.position(); + }); + } +}()); diff --git a/src/js/parser/javascript/grammar.peg b/src/js/parser/javascript/grammar.peg index 92ef7b1..79a023c 100644 --- a/src/js/parser/javascript/grammar.peg +++ b/src/js/parser/javascript/grammar.peg @@ -1,6 +1,6 @@ grammar JavascriptRegexp root <- ( ( "/" regexp "/" fl:[igm]* ) / regexp ) - regexp <- match ( "|" regexp )? + regexp <- match ( "|" match )* match <- anchor_start? ( ( subexp / charset / terminal ) repeat? )* anchor_end? anchor_start <- "^" anchor_end <- "$" diff --git a/src/js/parser/javascript/root.js b/src/js/parser/javascript/root.js index a14847c..65699b1 100644 --- a/src/js/parser/javascript/root.js +++ b/src/js/parser/javascript/root.js @@ -1,4 +1,37 @@ export default { + render(container) { + this.rect = this.container.rect().attr({ + x: 5, + y: 5, + rx: 10, + ry: 10, + fill: '#f00' + }); + this.text = this.container.text(0, 0, this.textValue).attr({ + fill: '#fff', + fontWeight: 'bold' + }); + }, + + position() { + var box = this.text.getBBox(); + + this.container.attr({ + width: box.width + 20, + height: box.height + 20 + }); + + this.text.attr({ + x: 10, + y: box.height + 5 + }); + + this.rect.attr({ + width: box.width + 10, + height: box.height + 10 + }); + }, + flags() { var flags;