Skip to content

Commit

Permalink
fix parser: icall -> call_method
Browse files Browse the repository at this point in the history
  • Loading branch information
remyhaemmerle-da committed Nov 24, 2021
1 parent fb8e4b9 commit 37000e4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private[parser] class ExprParser[P](parserParameters: ParserParameters[P]) {
)

private lazy val eCallInterface: Parser[ECallInterface] =
`icall` ~! `@` ~> fullIdentifier ~ id ~ expr0 ^^ { case ifaceId ~ name ~ body =>
`call_method` ~! `@` ~> fullIdentifier ~ id ~ expr0 ^^ { case ifaceId ~ name ~ body =>
ECallInterface(interfaceId = ifaceId, methodName = name, value = body)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private[parser] object Lexer extends RegexParsers {
"catch" -> `catch`,
"to_interface" -> `to_interface`,
"from_interface" -> `from_interface`,
"icall" -> `icall`,
"call_method" -> `call_method`,
)

val token: Parser[Token] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private[parser] object Token {
case object `catch` extends Token
case object `to_interface` extends Token
case object `from_interface` extends Token
case object `icall` extends Token
case object `call_method` extends Token

final case class Id(s: String) extends Token
final case class ContractId(s: String) extends Token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ class ParsersSpec extends AnyWordSpec with ScalaCheckPropertyChecks with Matcher
EFromAnyException(E, e"anyException"),
"throw @Unit @Mod:E exception" ->
EThrow(TUnit, E, e"exception"),
"icall @Mod:I method body" ->
"call_method @Mod:I method body" ->
ECallInterface(I.tycon, n"method", e"body"),
"icall @'-pkgId-':Mod:I method body" ->
"call_method @'-pkgId-':Mod:I method body" ->
ECallInterface(I.tycon, n"method", e"body"),
"to_interface @Mod:T @Mod:I body" ->
EToInterface(T.tycon, I.tycon, e"body"),
Expand Down Expand Up @@ -762,10 +762,10 @@ class ParsersSpec extends AnyWordSpec with ScalaCheckPropertyChecks with Matcher
method asParty: Party;
method getName: Text;
choice Sleep (self) (u:Unit) : ContractId Mod:Person
, controllers Cons @Party [icall @Mod:Person asParty this] (Nil @Party)
, controllers Cons @Party [call_method @Mod:Person asParty this] (Nil @Party)
to upure @(ContractId Mod:Person) self;
choice @nonConsuming Nap (self) (i : Int64): Int64
, controllers Cons @Party [icall @Mod:Person asParty this] (Nil @Party)
, controllers Cons @Party [call_method @Mod:Person asParty this] (Nil @Party)
, observers Nil @Party
to upure @Int64 i;
} ;
Expand All @@ -785,7 +785,7 @@ class ParsersSpec extends AnyWordSpec with ScalaCheckPropertyChecks with Matcher
n"Sleep" -> TemplateChoice(
name = n"Sleep",
consuming = true,
controllers = e"Cons @Party [icall @Mod:Person asParty this] (Nil @Party)",
controllers = e"Cons @Party [call_method @Mod:Person asParty this] (Nil @Party)",
choiceObservers = None,
selfBinder = n"self",
argBinder = n"u" -> TUnit,
Expand All @@ -795,7 +795,7 @@ class ParsersSpec extends AnyWordSpec with ScalaCheckPropertyChecks with Matcher
n"Nap" -> TemplateChoice(
name = n"Nap",
consuming = false,
controllers = e"Cons @Party [icall @Mod:Person asParty this] (Nil @Party)",
controllers = e"Cons @Party [call_method @Mod:Person asParty this] (Nil @Party)",
choiceObservers = Some(e"Nil @Party"),
selfBinder = n"self",
argBinder = n"i" -> TInt64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
E"λ (i: Mod:I) → (( from_interface @Mod:I @Mod:Ti i ))" ->
T"Mod:I → Option Mod:Ti",
// ECallInterface
E"λ (i: Mod:I) → (( icall @Mod:I getParties i ))" ->
E"λ (i: Mod:I) → (( call_method @Mod:I getParties i ))" ->
T"Mod:I → List Party",
)

Expand Down Expand Up @@ -893,21 +893,21 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
E"λ (i: Mod:J) → ⸨ from_interface @Mod:I @Mod:Ti i ⸩" -> //
{ case _: ETypeMismatch => },
// ECallInterface
E"λ (i: Mod:U) → ⸨ icall @Mod:U getParties i ⸩" -> //
E"λ (i: Mod:U) → ⸨ call_method @Mod:U getParties i ⸩" -> //
{
case EUnknownDefinition(
_,
LookupError(Reference.Interface(_), Reference.Method(_, _)),
) =>
},
E"λ (i: Mod:I) → ⸨ icall @Mod:I getParty i ⸩" -> //
E"λ (i: Mod:I) → ⸨ call_method @Mod:I getParty i ⸩" -> //
{
case EUnknownDefinition(
_,
LookupError(Reference.Method(_, _), Reference.Method(_, _)),
) =>
},
E"Λ (σ : ⋆). λ (e: σ) → ⸨ icall @Mod:I getParties e ⸩" -> //
E"Λ (σ : ⋆). λ (e: σ) → ⸨ call_method @Mod:I getParties e ⸩" -> //
{ case _: ETypeMismatch => },
//
)
Expand Down Expand Up @@ -1312,12 +1312,12 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
controllers Cons @Party ['Alice'] (Nil @Party)
to upure @Unit ();
choice Ch2 (self) (i : Unit) : Unit,
controllers icall @NegativeTestCase:I getParties this,
controllers call_method @NegativeTestCase:I getParties this,
observers Nil @Party
to upure @Unit ();
choice Ch3 (self) (i : Unit) : Unit,
controllers icall @NegativeTestCase:I getParties this,
observers icall @NegativeTestCase:I getParties this
controllers call_method @NegativeTestCase:I getParties this,
observers call_method @NegativeTestCase:I getParties this
to upure @Unit ();
} ;
}
Expand All @@ -1342,7 +1342,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
precondition True;
method getParties: List Party;
choice Ch (self) (i : Unit) : Unit,
controllers (icall @NegativeTestCase:I getParties this),
controllers (call_method @NegativeTestCase:I getParties this),
observers () // should be of type (List Party)
to upure @Unit ();
} ;
Expand All @@ -1353,7 +1353,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
precondition True;
method getParties: List Party;
choice Ch (self) (i : List) : Unit, // the type of i (here List) should be of kind * (here it is * -> *)
controllers (icall @NegativeTestCase:I getParties this)
controllers (call_method @NegativeTestCase:I getParties this)
to upure @Unit ();
} ;
}
Expand All @@ -1363,7 +1363,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
precondition True;
method getParties: List Party;
choice Ch (self) (i : Unit) : List, // the return type (here List) should be of kind * (here it is * -> *)
controllers (icall @NegativeTestCase:I getParties this)
controllers (call_method @NegativeTestCase:I getParties this)
to upure @(List) (/\ (tau : *). Nil @tau);
} ;
}
Expand Down

0 comments on commit 37000e4

Please sign in to comment.