mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 14:40:17 +00:00
parsr for pub/priv
This commit is contained in:
parent
480720f26e
commit
9d776835f6
@ -13,8 +13,14 @@ import cats.~>
|
|||||||
import aqua.parser.lift.Span
|
import aqua.parser.lift.Span
|
||||||
import aqua.parser.lift.Span.{P0ToSpan, PToSpan}
|
import aqua.parser.lift.Span.{P0ToSpan, PToSpan}
|
||||||
|
|
||||||
|
trait Visibility
|
||||||
|
case object Default extends Visibility
|
||||||
|
case object Pub extends Visibility
|
||||||
|
case object Export extends Visibility
|
||||||
|
|
||||||
case class FuncExpr[F[_]](
|
case class FuncExpr[F[_]](
|
||||||
name: Name[F]
|
name: Name[F],
|
||||||
|
visibility: Visibility
|
||||||
) extends Expr[F](FuncExpr, name) {
|
) extends Expr[F](FuncExpr, name) {
|
||||||
|
|
||||||
override def mapK[K[_]: Comonad](fk: F ~> K): FuncExpr[K] =
|
override def mapK[K[_]: Comonad](fk: F ~> K): FuncExpr[K] =
|
||||||
@ -25,5 +31,7 @@ object FuncExpr extends Expr.Prefix(` `.?) {
|
|||||||
override def continueWith: List[Expr.Lexem] = ArrowExpr :: Nil
|
override def continueWith: List[Expr.Lexem] = ArrowExpr :: Nil
|
||||||
|
|
||||||
override val p: Parser[FuncExpr[Span.S]] =
|
override val p: Parser[FuncExpr[Span.S]] =
|
||||||
(`func` *> ` ` *> Name.p).map(FuncExpr(_))
|
(((`pub`.map(_ => Pub) | `export`.map(_ => Export)).?.with1 <* ` `) ~ (`func` *> ` ` *> Name.p)).map {
|
||||||
|
case (visibility, name) => FuncExpr(name, visibility.getOrElse(Default))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,8 @@ object Token {
|
|||||||
val `try`: P[Unit] = P.string("try")
|
val `try`: P[Unit] = P.string("try")
|
||||||
val `catch`: P[Unit] = P.string("catch")
|
val `catch`: P[Unit] = P.string("catch")
|
||||||
val `par`: P[Unit] = P.string("par")
|
val `par`: P[Unit] = P.string("par")
|
||||||
|
val `pub`: P[Unit] = P.string("pub")
|
||||||
|
val `export`: P[Unit] = P.string("export")
|
||||||
val `co`: P[Unit] = P.string("co")
|
val `co`: P[Unit] = P.string("co")
|
||||||
val `join`: P[Unit] = P.string("join")
|
val `join`: P[Unit] = P.string("join")
|
||||||
val `copy`: P[Unit] = P.string("copy")
|
val `copy`: P[Unit] = P.string("copy")
|
||||||
|
Loading…
Reference in New Issue
Block a user