Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String: escape forward slashes when parsing #2041

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions compiler/src/Parse/String.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ singleString pos end row col initialPos revChunks =
singleString newPos end row (col + 1) newPos $
addEscape singleQuote initialPos pos revChunks

else if word == 0x2F {- / -} then
let !newPos = plusPtr pos 1 in
singleString newPos end row (col + 1) newPos $
addEscape forwardSlash initialPos pos revChunks

else if word == 0x5C {- \ -} then
case eatEscape (plusPtr pos 1) end row col of
EscapeNormal ->
Expand Down Expand Up @@ -227,6 +232,11 @@ multiString pos end row col initialPos sr sc revChunks =
multiString pos1 end row (col + 1) pos1 sr sc $
addEscape singleQuote initialPos pos revChunks

else if word == 0x2F {- / -} then
let !pos1 = plusPtr pos 1 in
multiString pos1 end row (col + 1) pos1 sr sc $
addEscape forwardSlash initialPos pos revChunks

else if word == 0x0A {- \n -} then
let !pos1 = plusPtr pos 1 in
multiString pos1 end (row + 1) 1 pos1 sr sc $
Expand Down Expand Up @@ -325,6 +335,12 @@ doubleQuote =
ES.Escape 0x22 {-"-}


{-# NOINLINE forwardSlash #-}
forwardSlash :: ES.Chunk
forwardSlash =
ES.Escape 0x2F {-/-}


{-# NOINLINE newline #-}
newline :: ES.Chunk
newline =
Expand Down