Skip to content

Commit

Permalink
escape characters are no longer allowed inside triple-quote strings -…
Browse files Browse the repository at this point in the history
…- this makes it easier to include entire programs in this kind of string
  • Loading branch information
alexwarth committed Jul 22, 2011
1 parent 453430a commit cc6f7a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bs-js-compiler.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bs-js-compiler.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

3 comments on commit cc6f7a0

@veged
Copy link

@veged veged commented on cc6f7a0 Jul 22, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@alexwarth
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@veged
Copy link

@veged veged commented on cc6f7a0 Jul 23, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.