unycorn / lolcode-dot-net

Automatically exported from code.google.com/p/lolcode-dot-net
0 stars 0 forks source link

Improve parsing of string constants #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently, the compiler doesn't handle anything other than simple string
constants. It needs to be enhanced to handle backslash-escaping for quotes,
control characters, and hex/octal values.

Original issue reported on code.google.com by arachnid...@gmail.com on 5 Jun 2007 at 2:29

GoogleCodeExporter commented 8 years ago
Here's coco/r's C# grammar string constant token definition:
stringCon =
    "\""  { regularStringChar
          | "\\\'" | "\\\"" | "\\\\" | "\\0" | "\\a" | "\\b" | "\\f" | "\\n" | "\\r"
| "\\t" | "\\v"
          | "\\x" hexDigit [hexDigit] [hexDigit] [hexDigit]
          | "\\u" hexDigit hexDigit hexDigit hexDigit
          | "\\U" hexDigit hexDigit hexDigit hexDigit hexDigit hexDigit hexDigit hexDigit
          } 
    "\""
  | "@\"" {verbatimStringChar | "\"\""} "\"".

This could be used to replace the existing string constant. Then, we just need 
to
write a function to interpret escape sequences correctly.

Original comment by arachnid...@gmail.com on 5 Jun 2007 at 10:13

GoogleCodeExporter commented 8 years ago
Fixed in revision 27

Original comment by arachnid...@gmail.com on 6 Jun 2007 at 8:56