refactor: remove offset property from position
This commit is contained in:
parent
c547a2a37f
commit
1f2adf4b82
@ -187,46 +187,46 @@ object ast {
|
||||
object Snd extends ParserBridgePos1[LValue, Snd]
|
||||
|
||||
// Parser bridges
|
||||
case class Position(line: Int, column: Int, offset: Int)
|
||||
case class Position(line: Int, column: Int)
|
||||
|
||||
trait ParserSingletonBridgePos[+A] extends ErrorBridge {
|
||||
protected def con(pos: (Int, Int), offset: Int): A
|
||||
infix def from(op: Parsley[?]): Parsley[A] = error((pos, offset).zipped(con) <~ op)
|
||||
protected def con(pos: (Int, Int)): A
|
||||
infix def from(op: Parsley[?]): Parsley[A] = error(pos.map(con) <~ op)
|
||||
final def <#(op: Parsley[?]): Parsley[A] = this from op
|
||||
}
|
||||
|
||||
trait ParserBridgePos0[+A] extends ParserSingletonBridgePos[A] {
|
||||
def apply()(pos: Position): A
|
||||
|
||||
override final def con(pos: (Int, Int), offset: Int): A =
|
||||
apply()(Position(pos._1, pos._2, offset))
|
||||
override final def con(pos: (Int, Int)): A =
|
||||
apply()(Position(pos._1, pos._2))
|
||||
}
|
||||
|
||||
trait ParserBridgePos1[-A, +B] extends ParserSingletonBridgePos[A => B] {
|
||||
def apply(a: A)(pos: Position): B
|
||||
def apply(a: Parsley[A]): Parsley[B] = error(ap1((pos, offset).zipped(con), a))
|
||||
def apply(a: Parsley[A]): Parsley[B] = error(ap1(pos.map(con), a))
|
||||
|
||||
override final def con(pos: (Int, Int), offset: Int): A => B =
|
||||
this.apply(_)(Position(pos._1, pos._2, offset))
|
||||
override final def con(pos: (Int, Int)): A => B =
|
||||
this.apply(_)(Position(pos._1, pos._2))
|
||||
}
|
||||
|
||||
trait ParserBridgePos2[-A, -B, +C] extends ParserSingletonBridgePos[(A, B) => C] {
|
||||
def apply(a: A, b: B)(pos: Position): C
|
||||
def apply(a: Parsley[A], b: => Parsley[B]): Parsley[C] = error(
|
||||
ap2((pos, offset).zipped(con), a, b)
|
||||
ap2(pos.map(con), a, b)
|
||||
)
|
||||
|
||||
override final def con(pos: (Int, Int), offset: Int): (A, B) => C =
|
||||
apply(_, _)(Position(pos._1, pos._2, offset))
|
||||
override final def con(pos: (Int, Int)): (A, B) => C =
|
||||
apply(_, _)(Position(pos._1, pos._2))
|
||||
}
|
||||
|
||||
trait ParserBridgePos3[-A, -B, -C, +D] extends ParserSingletonBridgePos[(A, B, C) => D] {
|
||||
def apply(a: A, b: B, c: C)(pos: Position): D
|
||||
def apply(a: Parsley[A], b: => Parsley[B], c: => Parsley[C]): Parsley[D] = error(
|
||||
ap3((pos, offset).zipped(con), a, b, c)
|
||||
ap3(pos.map(con), a, b, c)
|
||||
)
|
||||
|
||||
override final def con(pos: (Int, Int), offset: Int): (A, B, C) => D =
|
||||
apply(_, _, _)(Position(pos._1, pos._2, offset))
|
||||
override final def con(pos: (Int, Int)): (A, B, C) => D =
|
||||
apply(_, _, _)(Position(pos._1, pos._2))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user