Skip to content

Commit a75668f

Browse files
committed
glayzzle#36 fix to be compliant with PHP lexer
1 parent a3934a0 commit a75668f

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/lexer/strings.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,19 @@ module.exports = {
103103
if (ch == '"') {
104104
return this.tok.T_CONSTANT_ENCAPSED_STRING;
105105
} else {
106+
var prefix = 1;
107+
if (this.yytext[0] === 'b' || this.yytext[0] === 'B') {
108+
prefix = 2;
109+
}
106110
if (this.yytext.length > 2) {
107111
this.appendToken(
108112
this.tok.T_ENCAPSED_AND_WHITESPACE,
109-
this.yytext.length - 1
113+
this.yytext.length - prefix
110114
);
111115
}
112-
this.unput(this.yytext.length - 1);
116+
this.unput(this.yytext.length - prefix);
113117
this.begin("ST_DOUBLE_QUOTES");
114-
return '"';
118+
return this.yytext;
115119
}
116120
},
117121

src/lexer/tokens.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ module.exports = {
1717
}
1818
} else {
1919
id = this.tok.T_STRING;
20+
if (token === 'b' || token === 'B') {
21+
var ch = this.input(1);
22+
if (ch === '"') {
23+
return this.ST_DOUBLE_QUOTES();
24+
} else if (ch === '\'') {
25+
return this.T_CONSTANT_ENCAPSED_STRING();
26+
} else {
27+
this.unput(1);
28+
}
29+
}
2030
}
2131
}
2232
return id;

0 commit comments

Comments
 (0)