Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

support "\015\012" literals

  • Loading branch information...
commit 891989132b58b0a3ba3d460f4ed40f4479baa50d 1 parent 536389f
@tokuhirom authored
Showing with 19 additions and 0 deletions.
  1. +6 −0 t/tra/literal/string.tra
  2. +13 −0 tora/lexer.re
View
6 t/tra/literal/string.tra
@@ -0,0 +1,6 @@
+use Test::More *;
+
+is("\015", "\r");
+is("\012", "\n");
+
+done_testing;
View
13 tora/lexer.re
@@ -595,10 +595,23 @@ string_literal:
tora_add_string_literal('\b');
goto string_literal;
}
+ "\\$" {
+ tora_add_string_literal('$');
+ goto string_literal;
+ }
"\\f" {
tora_add_string_literal('\f');
goto string_literal;
}
+ "\\" [0-7]{3} {
+ char ret = (
+ (octchar2int(*(m_cursor-3)) << 6)
+ + (octchar2int(*(m_cursor-2)) << 3)
+ + octchar2int(*(m_cursor-1))
+ );
+ tora_add_string_literal(static_cast<char>(ret));
+ goto string_literal;
+ }
"\\x" [a-fA-F0-9]{2} {
char ret = hexchar2int(*(m_cursor-2)) * 16 + hexchar2int(*(m_cursor-1));
tora_add_string_literal(static_cast<char>(ret));
Please sign in to comment.
Something went wrong with that request. Please try again.