@@ -314,22 +314,6 @@ object MarkupParsers {
314314 done
315315 }
316316
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-
333317 /** Use a lookahead parser to run speculative body, and return the first char afterward. */
334318 private def charComingAfter (body : => Unit ): Char = {
335319 try {
@@ -343,8 +327,8 @@ object MarkupParsers {
343327 /** xLiteral = element { element }
344328 * @return Scala representation of this xml literal
345329 */
346- def xLiteral : Tree = xLiteralCommon(
347- () => {
330+ def xLiteral : Tree = {
331+ try return {
348332 input = parser.in
349333 handle.isPattern = false
350334
@@ -367,25 +351,43 @@ object MarkupParsers {
367351 assert(ts.length == 1 )
368352 ts(0 )
369353 }
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+ }
373366
374367 /** @see xmlPattern. resynchronizes after successful parse
375368 * @return this xml pattern
376369 */
377- def xLiteralPattern : Tree = xLiteralCommon(
378- () => {
370+ def xLiteralPattern : Tree = {
371+ try return {
379372 input = parser.in
380373 saving[Boolean , Tree ](handle.isPattern, handle.isPattern = _) {
381374 handle.isPattern = true
382375 val tree = xPattern
383376 xSpaceOpt()
384377 tree
385378 }
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+ }
389391
390392 def escapeToScala [A ](op : => A , kind : String ) = {
391393 xEmbeddedBlock = false
0 commit comments