Skip to content

Parser returns an inappropriate failure msg when using repsep #233

Closed
@Soya-Onishi

Description

@Soya-Onishi

This issue may be expected operation, but I feel failure msg is inappropriate.

execute below parser in version 1.1.1 and 1.1.2.

import scala.util.parsing.combinator._

object Parser extends JavaTokenParsers {
  def apply(str: String): ParseResult[List[Node]] = parseAll(top, str)

  private def top: Parser[List[Node]] = repsep(node, '\n')

  private def node: Parser[Node] = positioned(ident ~ ":" ~ ident ^^ {
    case v0 ~ _ ~ v1 => Node(v0, v1)
  })
}

parsed text (This text causes failure. An appropriate text is, for example, A : B.) is

A
A : B : C

In version 1.1.1, I got ':' expected but 'A' found. This failure message is expected message.

However, in version 1.1.2, I got end of input expected. This message loses information where is wrong point.

As a result that I checked difference of code between 1.1.1 and 1.1.2 lightly, I suspect that #108's change causes this. In addition, as far as I know, this problem occurs when using repsep (e.g. if parseAll uses node method directly, parser does not cause this problem)

Environment
scala version : 2.12.8
sbt version : 1.2.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions