Skip to content

Commit 19e0fd0

Browse files
committed
minor cleanup
1 parent 24721a2 commit 19e0fd0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

demo/src/demo/DemoMain.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ object DemoMain {
133133
tr(td("Failure!")),
134134
tr(td("at index:"), td(code(index))),
135135
tr(td("found:"), td("...", code(pretty))),
136-
tr(td("expected:"), td(code(extra.trace().failureLabel)))
136+
tr(td("expected:"), td(code(extra.trace().label)))
137137
)
138138
}
139139
outputBox.innerHTML = ""

fastparse/src/fastparse/Parsed.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,25 @@ object Parsed{
4141
/**
4242
* The outcome of a failed parse
4343
*
44-
* @param failureLabel A hint as to why the parse failed. Defaults to "",
44+
* @param label A hint as to why the parse failed. Defaults to "",
4545
* unless you set `verboseFailures = true` or call
4646
* `.trace()` on an existing failure
4747
* @param index The index at which the parse failed
4848
* @param extra Metadata about the parse; useful for re-running the parse
4949
* to trace out a more detailed error report
5050
*/
51-
final case class Failure(failureLabel: String,
51+
final case class Failure(label: String,
5252
index: Int,
5353
extra: Extra) extends Parsed[Nothing](false){
5454
def get = throw new Exception("Parse Error, " + msg)
55-
def fold[V](onFailure: (String, Int, Extra) => V, onSuccess: (Nothing, Int) => V) = onFailure(failureLabel, index, extra)
55+
def fold[V](onFailure: (String, Int, Extra) => V, onSuccess: (Nothing, Int) => V) = onFailure(label, index, extra)
5656
override def toString() = s"Parsed.Failure($msg)"
5757

5858
/**
5959
* Displays the failure message excluding the parse stack
6060
*/
6161
def msg = {
62-
failureLabel match{
62+
label match{
6363
case "" =>
6464
"Position " + extra.input.prettyIndex(index) +
6565
", found " + Failure.formatTrailing(extra.input, index)
@@ -72,7 +72,7 @@ object Parsed{
7272
*/
7373
def longMsg = {
7474
if (extra.stack.nonEmpty) {
75-
Failure.formatMsg(extra.input, extra.stack ++ List(failureLabel -> index), index)
75+
Failure.formatMsg(extra.input, extra.stack ++ List(label -> index), index)
7676
} else throw new Exception(
7777
"`.longMsg` requires the parser to be run with `verboseFailures = true`, " +
7878
"or to be called via `.trace().longMsg` or `.trace().longAggregateMsg`"
@@ -154,7 +154,7 @@ object Parsed{
154154
*/
155155
case class TracedFailure(failureAggregate: Seq[String],
156156
failure: Failure){
157-
def failureLabel = failure.failureLabel
157+
def label = failure.label
158158
def index = failure.index
159159
def input = failure.extra.input
160160
def stack = failure.extra.stack

fastparse/test/src/fastparse/ExampleTests.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ object ExampleTests extends TestSuite{
1818
val Parsed.Success(value, successIndex) = parse("a", parseA(_))
1919
assert(value == (), successIndex == 1)
2020

21-
val f @ Parsed.Failure(failureLabel, index, extra) = parse("b", parseA(_))
21+
val f @ Parsed.Failure(label, index, extra) = parse("b", parseA(_))
2222
assert(
23-
failureLabel == "",
23+
label == "",
2424
index == 0,
2525
f.msg == """Position 1:1, found "b""""
2626
)
@@ -43,7 +43,7 @@ object ExampleTests extends TestSuite{
4343
// `.msg` records the last parser that failed, which is "c", and
4444
// `.longMsg` also shows the parsing stack at point of failure
4545
assert(
46-
trace.failureLabel == "\"c\"",
46+
trace.label == "\"c\"",
4747
trace.index == 0,
4848
trace.msg == """Expected "c":1:1, found "d"""",
4949
trace.longMsg == """Expected parseA:1:1 / "c":1:1, found "d""""

0 commit comments

Comments
 (0)