[Pkg-javascript-commits] [node-regjsgen] 02/02: Add a small example
Julien Puydt
julien.puydt at laposte.net
Mon Aug 21 21:20:15 UTC 2017
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-regjsgen.
commit 0fd856c2faf201a2ada25a1d94b6fa4b097ee9fd
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Mon Aug 21 23:19:12 2017 +0200
Add a small example
---
debian/docs | 1 +
debian/example.js | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/debian/docs b/debian/docs
index b43bf86..d60d857 100644
--- a/debian/docs
+++ b/debian/docs
@@ -1 +1,2 @@
README.md
+debian/example.js
diff --git a/debian/example.js b/debian/example.js
new file mode 100644
index 0000000..bd8312e
--- /dev/null
+++ b/debian/example.js
@@ -0,0 +1,12 @@
+// the parser goes from the regex-string to the regex-AST
+parse = require('regjsparser').parse
+// the generator goes the other way around
+gen = require('regjsgen').generate
+// we start from a trivial regex-string
+orig = 'abc+'
+console.log ('Original regex: ' + orig)
+// turn the regex-string to regex-AST
+ast = parse(orig)
+// turn the regex-AST back to regex-string
+final = gen(ast)
+console.log('Regex after two inverse transforms : ' + final)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-regjsgen.git
More information about the Pkg-javascript-commits
mailing list