mirror of
https://github.com/danog/parser.git
synced 2025-01-22 21:11:55 +01:00
Merge pull request #90 from edsrzf/binary-strings
lexer: implement binary strings
This commit is contained in:
commit
9c6beffdb7
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user