Skip to content

Commit

Permalink
Escaping in strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Jul 23, 2017
1 parent cc073ae commit 15e98a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion expreduce/tokenizer.go
Expand Up @@ -639,7 +639,12 @@ yyrule5: // {S}
{

tmps := string(y.buf)
lval.val = &String{tmps[1 : len(tmps)-1]}
tmps = tmps[1 : len(tmps)-1]
// Handle some escape characters
tmps = strings.Replace(tmps, "\\\"", "\"", -1)
tmps = strings.Replace(tmps, "\\n", "\n", -1)
tmps = strings.Replace(tmps, "\\t", "\t", -1)
lval.val = &String{tmps}
return STRING
}
yyrule6: // \(
Expand Down
7 changes: 6 additions & 1 deletion expreduce/tokenizer.l
Expand Up @@ -97,7 +97,12 @@ comment "(*"([^*\x80]|\*+[^*)\x80])*\*+\)
{S}
tmps := string(y.buf)
lval.val = &String{tmps[1:len(tmps)-1]}
tmps = tmps[1:len(tmps)-1]
// Handle some escape characters
tmps = strings.Replace(tmps, "\\\"", "\"", -1)
tmps = strings.Replace(tmps, "\\n", "\n", -1)
tmps = strings.Replace(tmps, "\\t", "\t", -1)
lval.val = &String{tmps}
return STRING

\( return LPARSYM /* skipped */
Expand Down

0 comments on commit 15e98a5

Please sign in to comment.