Skip to content

Commit

Permalink
[ properly translate words that include hyphens and also upper case l…
Browse files Browse the repository at this point in the history
…etters ]
  • Loading branch information
Jacob Rothstein committed Dec 5, 2010
1 parent 3027be7 commit fab4221
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/browser.js
Expand Up @@ -553,7 +553,7 @@
})();
} else {
return (function() {
if ((typeof(token) === "string" && token.match(/^\$?[*\.a-z-]+([0-9])*(!|\?)?$/))) {
if ((typeof(token) === "string" && token.match((new RegExp(("^" + sibilant.tokens.literal + "$"), undefined))))) {
return literal(token);
} else {
return (function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/sibilant.js
Expand Up @@ -446,7 +446,7 @@ var translate = (function(token, hint) {
})();
} else {
return (function() {
if ((typeof(token) === "string" && token.match(/^\$?[*\.a-z-]+([0-9])*(!|\?)?$/))) {
if ((typeof(token) === "string" && token.match((new RegExp(("^" + sibilant.tokens.literal + "$"), undefined))))) {
return literal(token);
} else {
return (function() {
Expand Down
3 changes: 2 additions & 1 deletion src/core.lisp
Expand Up @@ -311,7 +311,8 @@
(if (defined? (get macros (translate (first token))))
(apply (get macros (translate (first token))) (token.slice 1))
(apply (get macros (or hint 'call)) token))
(if (and (string? token) (token.match /^\$?[*\.a-z-]+([0-9])*(!|\?)?$/))
(if (and (string? token)
(token.match (regex (concat "^" sibilant.tokens.literal "$"))))
(literal token)
(if (and (string? token) (token.match (regex "^;")))
(token.replace (regex "^;+") "//")
Expand Down
1 change: 1 addition & 0 deletions test/test.lisp
Expand Up @@ -34,6 +34,7 @@
(assert-translation "-10.2" "-10.2")
(assert-translation "hello" "hello")
(assert-translation "hi-world" "hiWorld")
(assert-translation "(Object.to-string)" "Object.toString();")
(assert-translation "1two" "1\ntwo")
(assert-translation "t1" "t1")
(assert-translation "JSON" "JSON")
Expand Down

0 comments on commit fab4221

Please sign in to comment.