Skip to content

Commit

Permalink
add strategic cuts in scalaparse to narrow error messages further and f…
Browse files Browse the repository at this point in the history
…ix com-lihaoyi/Ammonite#343, since Ammonite relies on end-of-line error messages to be properly placed to allow continuation-lines
  • Loading branch information
Li Haoyi committed Feb 19, 2016
1 parent 5a78470 commit fe16537
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion project/Constants.scala
@@ -1,4 +1,4 @@
package fastparse
object Constants{
val version = "0.3.4"
val version = "0.3.5-SNAPSHOT"
}
4 changes: 2 additions & 2 deletions scalaparse/shared/src/main/scala/scalaparse/Types.scala
Expand Up @@ -29,7 +29,7 @@ trait Types extends Core{
val InfixType = P( CompoundType ~~ (NotNewline ~ Id ~~ OneNLMax ~ CompoundType).repX )

val CompoundType = {
val Refinement = P( OneNLMax ~ `{` ~ Dcl.repX(sep=Semis) ~ `}` )
val Refinement = P( OneNLMax ~ `{` ~/ Dcl.repX(sep=Semis) ~ `}` )
val NamedType = P( (Pass ~ AnnotType).rep(1, `with`.~/) )
P( NamedType ~~ Refinement.? | Refinement )
}
Expand All @@ -40,7 +40,7 @@ trait Types extends Core{
val SimpleType: P0 = {
// Can't `cut` after the opening paren, because we might be trying to parse `()`
// or `() => T`! only cut after parsing one type
val TupleType = P( "(" ~ Type.rep(sep= ",".~/) ~ ")" )
val TupleType = P( "(" ~/ Type.rep(sep= ",".~/) ~ ")" )
val BasicType = P( TupleType | TypeId ~ ("." ~ `type`).? | `_` )
P( BasicType ~ (Pass ~ (TypeArgs | `#` ~/ Id)).rep )
}
Expand Down
Expand Up @@ -35,8 +35,8 @@ object FailureTests extends TestSuite{
| type T = (A B)
|}
""".stripMargin,
expected = """NamedType ~ Refinement.? | Refinement""",
found = "(A B)"
expected = """ "," | ")" """,
found = "B)"
)
* - checkNeg(
"""object O{
Expand Down Expand Up @@ -90,8 +90,8 @@ object FailureTests extends TestSuite{
| new (1)
|}
""".stripMargin,
expected = """EarlyDefTmpl | NamedTmpl | TmplBody""",
found = "(1)"
expected = """NamedType ~ Refinement.? | Refinement | ")" """,
found = "1)"
)
* - checkNeg(
"""
Expand Down

0 comments on commit fe16537

Please sign in to comment.