1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

[5.4] Add new \e escape sequence (0x1B/27)

This commit is contained in:
nikic 2011-12-04 17:35:30 +01:00
parent 1449cc2092
commit 80065965d3
3 changed files with 5 additions and 3 deletions

View File

@ -13,6 +13,7 @@ class PHPParser_Node_Scalar_String extends PHPParser_Node_Scalar
't' => "\t",
'f' => "\f",
'v' => "\v",
'e' => "\x1B",
);
/**
@ -73,7 +74,7 @@ class PHPParser_Node_Scalar_String extends PHPParser_Node_Scalar
}
return preg_replace_callback(
'~\\\\([\\\\$nrtfv]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~',
'~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~',
array(__CLASS__, 'parseCallback'),
$str
);

View File

@ -28,6 +28,7 @@ class PHPParser_Tests_Node_Scalar_StringTest extends PHPUnit_Framework_TestCase
array('\\"', '\\"', '`'),
array('\\"\\`', '\\"\\`', null),
array("\\\$\n\r\t\f\v", '\\\\\$\n\r\t\f\v', null),
array("\x1B", '\e', null),
array(chr(255), '\xFF', null),
array(chr(255), '\377', null),
array(chr(0), '\400', null),

View File

@ -11,7 +11,7 @@ b'Hi';
"Hi";
b"Hi";
'!\'!\\!\a!';
"!\"!\\!\$!\n!\r!\t!\f!\v!\a";
"!\"!\\!\$!\n!\r!\t!\f!\v!\e!\a";
"!\xFF!\377!\400!\0!";
-----
array(
@ -45,7 +45,7 @@ array(
9: Scalar_String(
value: !"!\!$!
!
! ! ! !\a
!@@{ chr(9) }@@!@@{ chr(12) }@@!@@{ chr(11) }@@!@@{ chr(27) }@@!\a
)
10: Scalar_String(
value: !@@{ chr(255) }@@!@@{ chr(255) }@@!@@{ chr(0) }@@!@@{ chr(0) }@@!