-
Notifications
You must be signed in to change notification settings - Fork 15
/
UnexpectedItem.scala
28 lines (25 loc) · 1.19 KB
/
UnexpectedItem.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
* Copyright 2020 Parsley Contributors <https://github.com/j-mie6/Parsley/graphs/contributors>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package parsley.errors
import parsley.internal.errors.{RigidCaret, UnexpectDesc}
import parsley.internal.machine.errors.{EmptyError, ExpectedError, DefuncError, UnexpectedError}
sealed abstract class UnexpectedItem {
private [parsley] def makeError(offset: Int, line: Int, col: Int, caretWidth: Int): DefuncError
}
object UnexpectedItem {
case object Raw extends UnexpectedItem {
private[parsley] def makeError(offset: Int, line: Int, col: Int, caretWidth: Int): DefuncError =
new ExpectedError(offset, line, col, None, caretWidth)
}
case object Empty extends UnexpectedItem {
private[parsley] def makeError(offset: Int, line: Int, col: Int, caretWidth: Int): DefuncError =
new EmptyError(offset, line, col, caretWidth)
}
final case class Named(name: String) extends UnexpectedItem {
private[parsley] def makeError(offset: Int, line: Int, col: Int, caretWidth: Int): DefuncError =
new UnexpectedError(offset, line, col, None, new UnexpectDesc(name, new RigidCaret(caretWidth)))
}
}