diff --git a/docs/api-guide/errors/ErrorBuilder.md b/docs/api-guide/errors/ErrorBuilder.md index c5245a649..de9173911 100644 --- a/docs/api-guide/errors/ErrorBuilder.md +++ b/docs/api-guide/errors/ErrorBuilder.md @@ -44,7 +44,7 @@ testing generated error messages. Error messages within `parsley` take two different forms: *vanilla* or *specialised*. The error chosen depends on the combinators used to produce it: `empty`, `unexpected`, `char`, `string`, etc all produce vanilla errors; and `fail` and its derivatives produce -specialised errors. An `ErrorBuilder` must describe how to format +specialised errors. An `ErrorBuilder` must describe how to build both kinds of error; their structure is explained below. ### Vanilla Errors @@ -134,8 +134,8 @@ exposing unnecessary information into the rest of the system. After these types are specified, the methods of the typeclass can be implemented. These put together the primtive-most components and compose them into the larger whole. The documentation of the -typeclass details the role of these well enough, however. For example's sake, however, these are the two shapes of call that will -be made for the different types of error messages: +typeclass details the role of these well enough, however. For example's sake, however, these +are the two shapes of call that will be made for the different types of error messages: #### Vanilla ``` @@ -148,7 +148,7 @@ be made for the different types of error messages: ``` ```scala mdoc:silent:nest val builder = implicitly[ErrorBuilder[String]] -builder.format ( +builder.build ( builder.pos(1, 5), builder.source(None), builder.vanillaError ( @@ -164,7 +164,7 @@ builder.format ( builder.combineMessages(List( builder.reason("'-' is a binary operator") )), - builder.lineInfo("3+4-", Nil, Nil, 4, 4) + builder.lineInfo("3+4-", Nil, Nil, 1, 4, 4) ) ) ``` @@ -185,7 +185,7 @@ In file 'foo.txt' (line 2, column 6): ``` ```scala mdoc:silent:nest val builder = implicitly[ErrorBuilder[String]] -builder.format ( +builder.build ( builder.pos(2, 6), builder.source(Some("foo.txt")), builder.specializedError ( @@ -196,6 +196,7 @@ builder.format ( builder.lineInfo("second line", List("first line of input"), List("third line", "fourth line"), + 2, 5, 3) ) @@ -222,7 +223,7 @@ case class TestNamed(item: String) extends TestErrorItem case object TestEndOfInput extends TestErrorItem ``` -This type, as will become evident from the formatter derived +This type, as will become evident from the builder derived from it, is lossy and does not perfectly encode all the information available. Notice that `TestErrorItem` is a supertype of `TestRaw`, `TestNamed`, and `TestEndOfInput`: this is @@ -257,8 +258,8 @@ methods make it very easy to fill in the gaps: ```scala class TestErrorBuilder extends ErrorBuilder[TestError] { //... - def format(pos: (Int, Int), source: Unit, - lines: TestErrorLines): TestError = TestError(pos, lines) + def build(pos: (Int, Int), source: Unit, + lines: TestErrorLines): TestError = TestError(pos, lines) def vanillaError( unexpected: Option[TestErrorItem], expected: Set[TestErrorItem], @@ -287,7 +288,7 @@ class TestErrorBuilder extends ErrorBuilder[TestError] { line: String, linesBefore: Seq[String], linesAfter: Seq[String], - errorPointsAt: Int, errorWidth: Int + lineNum: Int, errorPointsAt: Int, errorWidth: Int ): Unit = () // The implementation of this is usually provided by a mixed-in