Permalink
Browse files

Fix constant interpolation in strings. Fixes #125

  • Loading branch information...
ckknight committed Jul 16, 2013
1 parent 10a9df5 commit 309d3ac628a8148b0071e6fe57fa3bb599fda42f
Showing with 19 additions and 7 deletions.
  1. +2 −2 extras/gorillascript.js
  2. +2 −2 extras/gorillascript.min.js
  3. +1 −1 lib/gorilla.js
  4. +1 −1 lib/parser.js
  5. +1 −1 package.json
  6. +1 −0 src/parser.gs
  7. +11 −0 test/consts.gs
View
@@ -11746,7 +11746,7 @@
ExpressionOrAssignmentOrBody = cache(oneOf(ExpressionOrAssignment, Body));
StringInterpolation = sequential(DollarSignChar, NoSpace, SHORT_CIRCUIT, [
"this",
oneOf(Identifier, sequential(
oneOf(CustomConstantLiteral, Identifier, sequential(
OpenParenthesis,
[
"this",
@@ -30564,7 +30564,7 @@
writeFileWithMkdirpSync = _ref.writeFileWithMkdirpSync;
_ref = null;
isAcceptableIdent = require("./jsutils").isAcceptableIdent;
exports.version = "0.9.9";
exports.version = "0.9.10";
exports.ParserError = parser.ParserError;
exports.MacroError = parser.MacroError;
if (require.extensions) {

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -419,7 +419,7 @@
writeFileWithMkdirpSync = _ref.writeFileWithMkdirpSync;
_ref = null;
isAcceptableIdent = require("./jsutils").isAcceptableIdent;
exports.version = "0.9.9";
exports.version = "0.9.10";
exports.ParserError = parser.ParserError;
exports.MacroError = parser.MacroError;
if (require.extensions) {
View
@@ -3144,7 +3144,7 @@
ExpressionOrAssignmentOrBody = cache(oneOf(ExpressionOrAssignment, Body));
StringInterpolation = sequential(DollarSignChar, NoSpace, SHORT_CIRCUIT, [
"this",
oneOf(Identifier, sequential(
oneOf(CustomConstantLiteral, Identifier, sequential(
OpenParenthesis,
[
"this",
View
@@ -1,7 +1,7 @@
{
"name": "gorillascript",
"description": "GorillaScript is a compile-to-JavaScript language designed to empower the user while attempting to prevent some common errors.",
"version": "0.9.9",
"version": "0.9.10",
"author": {
"name": "Cameron Kenneth Knight",
"email": "ckknight@gmail.com"
View
@@ -2361,6 +2361,7 @@ let StringInterpolation = sequential(
NoSpace
SHORT_CIRCUIT
[\this, one-of(
CustomConstantLiteral
Identifier
sequential(
OpenParenthesis
View
@@ -5,6 +5,7 @@ const unfalse = true
const untrue = false
const CONST_OBJECT = { alpha: 1, bravo: 2 }
const CONST_ARRAY = [\alpha, \bravo, \charlie]
const CONST_STRING = "hello"
describe "consts", #
it "work from the top scope", #
@@ -103,3 +104,13 @@ describe "array consts", #
expect(make-code(1)).to.contain "bravo"
expect(make-code(2)).to.contain "charlie"
expect(make-code("length")).to.contain "3"
describe "string consts", #
it "can be used in a concat expression", #
expect(CONST_STRING & ", world").to.equal "hello, world"
it "can be interpolated with parentheses", #
expect("$(CONST_STRING), world").to.equal "hello, world"
it "can be interpolated without parentheses", #
expect("$CONST_STRING, world").to.equal "hello, world"

0 comments on commit 309d3ac

Please sign in to comment.