@@ -314,22 +314,6 @@ object MarkupParsers {
314
314
done
315
315
}
316
316
317
- /** Some try/catch/finally logic used by xLiteral and xLiteralPattern. */
318
- private def xLiteralCommon (f : () => Tree , ifTruncated : String => Unit ): Tree = {
319
- try return f()
320
- catch {
321
- case c @ TruncatedXMLControl =>
322
- ifTruncated(c.getMessage)
323
- case c @ (MissingEndTagControl | ConfusedAboutBracesControl ) =>
324
- parser.syntaxError(c.getMessage + debugLastElem + " >" , debugLastPos)
325
- case _ : ArrayIndexOutOfBoundsException =>
326
- parser.syntaxError(" missing end tag in XML literal for <%s>" format debugLastElem, debugLastPos)
327
- }
328
- finally parser.in resume Tokens .XMLSTART
329
-
330
- parser.errorTermTree
331
- }
332
-
333
317
/** Use a lookahead parser to run speculative body, and return the first char afterward. */
334
318
private def charComingAfter (body : => Unit ): Char = {
335
319
try {
@@ -343,8 +327,8 @@ object MarkupParsers {
343
327
/** xLiteral = element { element }
344
328
* @return Scala representation of this xml literal
345
329
*/
346
- def xLiteral : Tree = xLiteralCommon(
347
- () => {
330
+ def xLiteral : Tree = {
331
+ try return {
348
332
input = parser.in
349
333
handle.isPattern = false
350
334
@@ -367,25 +351,43 @@ object MarkupParsers {
367
351
assert(ts.length == 1 )
368
352
ts(0 )
369
353
}
370
- },
371
- msg => parser.incompleteInputError(msg)
372
- )
354
+ } catch {
355
+ case c @ TruncatedXMLControl =>
356
+ parser.incompleteInputError(c.getMessage)
357
+ case c @ (MissingEndTagControl | ConfusedAboutBracesControl ) =>
358
+ parser.syntaxError(c.getMessage + debugLastElem + " >" , debugLastPos)
359
+ case _ : ArrayIndexOutOfBoundsException =>
360
+ parser.syntaxError(" missing end tag in XML literal for <%s>" format debugLastElem, debugLastPos)
361
+ }
362
+ finally parser.in resume Tokens .XMLSTART
363
+
364
+ parser.errorTermTree
365
+ }
373
366
374
367
/** @see xmlPattern. resynchronizes after successful parse
375
368
* @return this xml pattern
376
369
*/
377
- def xLiteralPattern : Tree = xLiteralCommon(
378
- () => {
370
+ def xLiteralPattern : Tree = {
371
+ try return {
379
372
input = parser.in
380
373
saving[Boolean , Tree ](handle.isPattern, handle.isPattern = _) {
381
374
handle.isPattern = true
382
375
val tree = xPattern
383
376
xSpaceOpt()
384
377
tree
385
378
}
386
- },
387
- msg => parser.syntaxError(msg, curOffset)
388
- )
379
+ } catch {
380
+ case c @ TruncatedXMLControl =>
381
+ parser.syntaxError(c.getMessage, curOffset)
382
+ case c @ (MissingEndTagControl | ConfusedAboutBracesControl ) =>
383
+ parser.syntaxError(c.getMessage + debugLastElem + " >" , debugLastPos)
384
+ case _ : ArrayIndexOutOfBoundsException =>
385
+ parser.syntaxError(" missing end tag in XML literal for <%s>" format debugLastElem, debugLastPos)
386
+ }
387
+ finally parser.in resume Tokens .XMLSTART
388
+
389
+ parser.errorTermTree
390
+ }
389
391
390
392
def escapeToScala [A ](op : => A , kind : String ) = {
391
393
xEmbeddedBlock = false
0 commit comments