Skip to content

Commit

Permalink
[ regex macro ]
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Rothstein committed Nov 11, 2010
1 parent 986ebcb commit 2183f86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/macros.lisp
Expand Up @@ -56,6 +56,9 @@
(defmacro new (fn)
(concat "(new " (translate fn) ")"))

(defmacro regex (string &optional glim)
(macros.new (macros.call "RegExp" string (or glim "undefined"))))

(defmacro timestamp ()
(concat "\"" (send (new (-date)) to-string) "\""))

Expand Down
2 changes: 2 additions & 0 deletions test/test.lisp
Expand Up @@ -47,6 +47,8 @@

(assert-translation "/regex/" "/regex/")

(assert-translation "(regex \"regex\")" "(new RegExp(\"regex\", undefined))")
(assert-translation "(regex \"regex\" 'g)" "(new RegExp(\"regex\", \"g\"))")

(assert-translation "(pow a b)" "Math.pow(a, b)")
(assert-translation "(incr x)" "((x)++)")
Expand Down

0 comments on commit 2183f86

Please sign in to comment.