Rewritting lexer.coffee to accept nested string interpolations.

This commit is contained in:
Stan Angeloff
2010-03-07 14:56:27 +02:00
committed by Jeremy Ashkenas
parent 1602e0e823
commit f74fae58e3
3 changed files with 99 additions and 74 deletions

View File

@@ -14,22 +14,23 @@ ok "$hello ${ 1 + 2 } $world" is "Hello 3 World"
[s, t, r, i, n, g]: ['s', 't', 'r', 'i', 'n', 'g']
ok "$s$t$r$i$n$g" is 'string'
ok "${s}${t}${r}${i}${n}${g}" is 'string'
ok "\\$s\\$t\\$r\\$i\\$n\\$g" is '$s$t$r$i$n$g'
ok "\\${s}\\${t}\\${r}\\${i}\\${n}\\${g}" is '${s}${t}${r}${i}${n}${g}'
ok "\\$string" is '$string'
ok "\\${string}" is '${string}'
ok "\$s\$t\$r\$i\$n\$g" is '$s$t$r$i$n$g'
ok "\\$s\\$t\\$r\\$i\\$n\\$g" is '\\s\\t\\r\\i\\n\\g'
ok "\${s}\${t}\${r}\${i}\${n}\${g}" is '${s}${t}${r}${i}${n}${g}'
ok "\$string" is '$string'
ok "\${string}" is '${string}'
ok "\\$Escaping first" is '$Escaping first'
ok "\\${Escaping} first" is '${Escaping} first'
ok "Escaping \\$in middle" is 'Escaping $in middle'
ok "Escaping \\${in} middle" is 'Escaping ${in} middle'
ok "Escaping \\$last" is 'Escaping $last'
ok "Escaping \\${last}" is 'Escaping ${last}'
ok "\$Escaping first" is '$Escaping first'
ok "\${Escaping} first" is '${Escaping} first'
ok "Escaping \$in middle" is 'Escaping $in middle'
ok "Escaping \${in} middle" is 'Escaping ${in} middle'
ok "Escaping \$last" is 'Escaping $last'
ok "Escaping \${last}" is 'Escaping ${last}'
ok "$$" is '$$'
ok "${}" is '${}'
ok "\\\\$$" is '\\\\$$'
ok "\\\\${}" is '\\\\${}'
ok "\\\\\$$" is '\\\\\$$'
ok "\\\${}" is '\\${}'
ok "I won $20 last night." is 'I won $20 last night.'
ok "I won $${20} last night." is 'I won $20 last night.'
@@ -53,3 +54,8 @@ ok "I can has ${"cheeze"}" is 'I can has cheeze'
ok 'I can has ${"cheeze"}' is 'I can has ${"cheeze"}'
ok "Where is ${obj["name"] + '?'}" is 'Where is Joe?'
ok "Where is ${"the new ${obj["name"]}"}?" is 'Where is the new Joe?'
ok "Hello ${world ? "$hello"}" is 'Hello World'
ok "Hello ${"${"${obj["name"]}" + '!'}"}" is 'Hello Joe!'