Merge pull request #90 from edsrzf/binary-strings

lexer: implement binary strings
This commit is contained in:
Ryan Chandler 2022-09-16 08:32:19 +01:00 committed by GitHub
commit 9c6beffdb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -202,10 +202,18 @@ impl Lexer {
self.next();
self.tokenize_single_quote_string()?
}
[b'b' | b'B', b'\'', ..] => {
self.skip(2);
self.tokenize_single_quote_string()?
}
[b'"', ..] => {
self.next();
self.tokenize_double_quote_string()?
}
[b'b' | b'B', b'"', ..] => {
self.skip(2);
self.tokenize_double_quote_string()?
}
[b'$', ..] => {
self.next();
self.tokenize_variable()
@ -909,6 +917,18 @@ string.'"#,
);
}
#[test]
fn binary_strings() {
assert_tokens(
r#"<?php b'single' b"double" "#,
&[
open!(),
TokenKind::ConstantString("single".into()),
TokenKind::ConstantString("double".into()),
],
)
}
#[test]
fn string_escapes() {
assert_tokens(