Fix for greedy XOR tags (#412)

This commit is contained in:
Dmitry Kurinskiy 2022-02-02 19:06:35 +03:00 committed by GitHub
parent 740a9ba653
commit d5d7b8b5fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 4 deletions

20
aqua-src/test.aqua Normal file
View File

@ -0,0 +1,20 @@
import "@fluencelabs/aqua-ipfs/ipfs.aqua"
service Console("run-console"):
print(res: IpfsGetResult)
service ConsoleOp("run-console"):
print(arr: []string)
func something(node: string) -> string:
service_id: *string
on HOST_PEER_ID:
res <- Ipfs.get("1234")
if res.error == "":
service_id <<- "0x"
else:
service_id <<- "1x"
ConsoleOp.print(service_id)
Console.print(res)
<- service_id!

View File

@ -129,11 +129,10 @@ object TagInliner extends Logging {
case RestrictionTag(name, isStream) =>
pure(RestrictionModel(name, isStream))
case SeqTag => pure(SeqModel)
case _: SeqGroupTag => pure(SeqModel)
case ParTag.Detach => pure(DetachModel)
case _: ParGroupTag => pure(ParModel)
case XorTag | XorTag.LeftBiased =>
// TODO should we do smth with XorTag.LeftBiased?
pure(XorModel)
case _: NoExecTag => none
case _ =>

View File

@ -42,6 +42,10 @@ sealed trait GroupTag extends RawTag
sealed trait SeqGroupTag extends GroupTag
object SeqGroupTag extends SeqGroupTag {
override def toString: String = "SeqGroup"
}
sealed trait ParGroupTag extends GroupTag
case object SeqTag extends SeqGroupTag {

View File

@ -48,7 +48,7 @@ trait RawTagGivens {
case (XorTag, XorTag) =>
y.copy(tail = (x.tail, y.tail).mapN(_ ++ _))
case (XorTag.LeftBiased, XorTag) =>
SeqTag.wrap(y.copy(tail = (x.tail, y.tail).mapN(_ ++ _)))
SeqGroupTag.wrap(y.copy(tail = (x.tail, y.tail).mapN(_ ++ _)))
case (XorTag, ParTag) => XorParTag(x, y).leaf
case (_, ParTag | XorTag) =>
SeqTag.wrap(y.copy(tail = y.tail.map(_.prepend(x))))

0
npm/error.js Normal file → Executable file
View File

0
npm/index.js Normal file → Executable file
View File

View File

@ -2,7 +2,7 @@ package aqua.semantics
import aqua.raw.RawContext
import aqua.parser.Ast
import aqua.raw.ops.{Call, CallServiceTag, FuncOp, OnTag, ParTag, RawTag, SeqTag}
import aqua.raw.ops.{Call, CallServiceTag, FuncOp, OnTag, ParTag, RawTag, SeqGroupTag, SeqTag}
import aqua.parser.Parser
import aqua.parser.lift.{LiftParser, Span}
import aqua.raw.value.{LiteralRaw, ValueRaw}
@ -11,6 +11,7 @@ import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import cats.~>
import cats.data.Chain
import cats.syntax.show.*
class SemanticsSpec extends AnyFlatSpec with Matchers {