Skip to content

Commit

Permalink
JavaScript: String Single Character Escape Sequences (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Penny authored Oct 25, 2020
1 parent 4453913 commit 639fa3a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions lexers/j/javascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var JavascriptRules = Rules{
{"`", LiteralStringBacktick, Pop(1)},
{`\\\\`, LiteralStringBacktick, nil},
{"\\\\`", LiteralStringBacktick, nil},
{"\\\\[^`\\\\]", LiteralStringBacktick, nil},
{`\$\{`, LiteralStringInterpol, Push("interp-inside")},
{`\$`, LiteralStringBacktick, nil},
{"[^`\\\\$]+", LiteralStringBacktick, nil},
Expand Down
3 changes: 2 additions & 1 deletion lexers/testdata/javascript.actual
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sum = parseInt(num1) + parseInt(num2) // "+" means "add"
alert("Sum = " + sum) // "+" means combine into a string
alert("Sum = " + sum) // "+" means combine into a string
const filePath = String.raw`C:\Development\profile\aboutme.html`;
14 changes: 13 additions & 1 deletion lexers/testdata/javascript.expected
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,17 @@
{"type":"NameOther","value":"sum"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":" "},
{"type":"CommentSingle","value":"// \"+\" means combine into a string\n"}
{"type":"CommentSingle","value":"// \"+\" means combine into a string\n"},
{"type":"KeywordReserved","value":"const"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"filePath"},
{"type":"Text","value":" "},
{"type":"Operator","value":"="},
{"type":"Text","value":" "},
{"type":"NameBuiltin","value":"String"},
{"type":"Punctuation","value":"."},
{"type":"NameOther","value":"raw"},
{"type":"LiteralStringBacktick","value":"`C:\\Development\\profile\\aboutme.html`"},
{"type":"Punctuation","value":";"},
{"type":"Text","value":"\n"}
]

0 comments on commit 639fa3a

Please sign in to comment.