Browse files

escape characters are no longer allowed inside triple-quote strings -…

…- this makes it easier to include entire programs in this kind of string
  • Loading branch information...
1 parent 453430a commit cc6f7a0dd1d8b777350dc8136f42da1f2628462f @alexwarth committed Jul 22, 2011
Showing with 2 additions and 2 deletions.
  1. +1 −1 bs-js-compiler.js
  2. +1 −1 bs-js-compiler.txt

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -14,7 +14,7 @@ ometa BSJSParser {
escapeChar = <'\\' ( 'u' hexDigit hexDigit hexDigit hexDigit
| 'x' hexDigit hexDigit
| char )>:s -> unescape(s),
- str = seq('"""') (escapeChar | ~seq('"""') char)*:cs seq('"""') -> [#string, cs.join('')]
+ str = seq('"""') (~seq('"""') char)*:cs seq('"""') -> [#string, cs.join('')]
| '\'' (escapeChar | ~'\'' char)*:cs '\'' -> [#string, cs.join('')]
| '"' (escapeChar | ~'"' char)*:cs '"' -> [#string, cs.join('')]
| ('#' | '`') iName:n -> [#string, n],

3 comments on commit cc6f7a0

what about programs with triple-quote inside? if it's only ometajs syntax, maybe better place for triple-quote rule is ometajs-gramma?


alexwarth replied Jul 22, 2011

What about them?

AFAIK triple-quoted strings are not really part of Javascript. My parser accepts them because they're useful, and IMO they're even more useful if escape characters are not allowed inside. Sure, that means you can't nest triple-quoted strings, but that doesn't bother me. And if you want to be able to escape characters, you can always use single- or double-quoted strings.

I mean, if it is not part of the language, but useful extension of syntax in context of Ometa/JS, is not it would be better to move it to BSOMetaJSParser (instead of BSJSParser). At the same time it explicitly distinguish the two languages​​, and js-programs can be used in Ometa/JS in triple-quotes. Correct me if I'm wrong, the main use case for programs within strings for this.

Please sign in to comment.