39
39
*/
40
40
interface RubyLexer extends JFlexJointLexer {
41
41
void maybeIntraState ();
42
+ void popHelper ();
42
43
}
43
44
44
45
/**
@@ -188,6 +189,12 @@ public void qop(String op, int namelength, boolean nointerp)
188
189
*/
189
190
public void qop (boolean doWrite , String capture , int namelength ,
190
191
boolean nointerp ) throws IOException {
192
+
193
+ // N.b. the following will write anyway -- despite any `doWrite'
194
+ // setting -- if interpolation is truly ending, but that is OK as a
195
+ // quote-like operator is not starting in that case.
196
+ if (maybeEndInterpolation (capture )) return ;
197
+
191
198
// If namelength is positive, allow that a non-zero-width word boundary
192
199
// character may have needed to be matched since jflex does not conform
193
200
// with \b as a zero-width simple word boundary. Excise it into
@@ -272,6 +279,8 @@ private void setEndQuoteChar(char opener) {
272
279
* to output.
273
280
*/
274
281
public void hqopPunc (String capture ) throws IOException {
282
+ if (maybeEndInterpolation (capture )) return ;
283
+
275
284
// `preceding' is everything before the '/'; 'lede' is the initial part
276
285
// before any whitespace; and `intervening' is any whitespace.
277
286
String preceding = capture .substring (0 , capture .length () - 1 );
@@ -293,6 +302,8 @@ public void hqopPunc(String capture) throws IOException {
293
302
* parts to output.
294
303
*/
295
304
public void hqopSymbol (String capture ) throws IOException {
305
+ if (maybeEndInterpolation (capture )) return ;
306
+
296
307
// `preceding' is everything before the '/'; 'lede' is the initial part
297
308
// before any whitespace; and `intervening' is any whitespace.
298
309
String preceding = capture .substring (0 , capture .length () - 1 );
@@ -452,12 +463,19 @@ public void interpop() {
452
463
* {@code nendbrace}.
453
464
* @return true if the interpolation state should end
454
465
*/
455
- public boolean maybeEndInterpolation (String capture ) {
466
+ public boolean maybeEndInterpolation (String capture ) throws IOException {
456
467
if (nendbrace <= 0 ) {
457
468
return false ;
458
469
}
459
470
if (capture .startsWith ("}" )) {
460
471
if (--nendbrace <= 0 ) {
472
+ int rem = capture .length () - 1 ;
473
+ String opener = capture .substring (0 , 1 );
474
+ lexer .popHelper ();
475
+ lexer .yypop ();
476
+ lexer .disjointSpan (HtmlConsts .STRING_CLASS );
477
+ lexer .offerNonword (opener );
478
+ if (rem > 0 ) lexer .yypushback (rem );
461
479
return true ;
462
480
}
463
481
} else if (capture .startsWith ("{" )) {
0 commit comments