Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix parsing of \xHH and \uHHHH #6

Closed
wants to merge 2 commits into from

2 participants

@veged

After 23e66f4 Ometa/JS serialize escaped chars, but still can't parse it back.

@alexwarth
Owner

Thanks for pointing this out. I didn't realize that this was a pull request, so I wrote my own fix and committed it. :) (My commit also fixes this issue in the OMeta parser, and restricts the digits after the \x and \u to hexadecimal digits, not just any character.)

@alexwarth alexwarth closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +6 −1 bs-js-compiler.txt
View
7 bs-js-compiler.txt
@@ -11,7 +11,12 @@ ometa BSJSParser {
| hexDigit,
number = ``0x'' hexLit:n -> [#number, n]
| <digit+ ('.' digit+)?>:f -> [#number, parseFloat(f)],
- escapeChar = '\\' char:c -> unescape('\\' + c),
+ escapeChar = '\\' (
+ '"' | "'" | '\\'
+ | 'n' | 'r' | 't'
+ | 'b' | 'f'
+ | <'u' char char char char> | <'x' char char>
+ | char ):c -> unescape('\\' + c),
str = seq('"""') (escapeChar | ~seq('"""') char)*:cs seq('"""') -> [#string, cs.join('')]
| '\'' (escapeChar | ~'\'' char)*:cs '\'' -> [#string, cs.join('')]
| '"' (escapeChar | ~'"' char)*:cs '"' -> [#string, cs.join('')]
Something went wrong with that request. Please try again.