Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compiler)!: Force aqua header [LNG-308] #1028

Merged
merged 27 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3a5ce54
Refactor
InversionSpaces Dec 20, 2023
d5076c9
deprecate `module`, force `aqua`, fix integration and unit tests
DieMyst Dec 20, 2023
0bf76f3
fix ImportFromSpec
DieMyst Dec 20, 2023
962802f
Savepoint
InversionSpaces Dec 20, 2023
7d58c38
Merge branch 'LNG-308-deprecate-module-word' into feat/force-header-L…
InversionSpaces Dec 20, 2023
9ffb17a
Fix
InversionSpaces Dec 20, 2023
7be4870
Semantic error on module header
InversionSpaces Dec 20, 2023
a37895e
Refactor
InversionSpaces Dec 21, 2023
e29bb6d
Add begin token
InversionSpaces Dec 21, 2023
854b09f
Fix tests
InversionSpaces Dec 21, 2023
5fd26f0
Remove DHT examples
InversionSpaces Dec 21, 2023
1f5e9ea
Use git aqua-lib
InversionSpaces Dec 21, 2023
91884f6
Fix headers
InversionSpaces Dec 21, 2023
5c71081
Merge branch 'main' into feat/force-header-LNG-308
InversionSpaces Dec 21, 2023
413adc4
Fix headers
InversionSpaces Dec 21, 2023
f10b769
Fix headers
InversionSpaces Dec 21, 2023
3375092
Fix headers
InversionSpaces Dec 21, 2023
9e894f6
Fix headers
InversionSpaces Dec 21, 2023
c2618c8
Fix headers
InversionSpaces Dec 21, 2023
f6659d4
Fix headers
InversionSpaces Dec 21, 2023
092ee13
Fix test
InversionSpaces Dec 21, 2023
d16a361
Unignore tests
InversionSpaces Dec 21, 2023
e8b3e03
Update aqua-lib
InversionSpaces Dec 21, 2023
d9e455b
Merge branch 'main' into feat/force-header-LNG-308
InversionSpaces Dec 21, 2023
f2e16b5
Merge branch 'main' into feat/force-header-LNG-308
InversionSpaces Jan 4, 2024
bf3496c
Merge branch 'main' into feat/force-header-LNG-308
InversionSpaces Jan 12, 2024
e442b59
Merge branch 'main' into feat/force-header-LNG-308
InversionSpaces Jan 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions api/api/.js/src/main/scala/api/AquaAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import aqua.logging.{LogFormatter, LogLevels}
import aqua.model.AquaContext
import aqua.model.transform.{Transform, TransformConfig}
import aqua.parser.lexer.{LiteralToken, Token}
import aqua.parser.lift.FileSpan.F
import aqua.parser.lift.{FileSpan, Span}
import aqua.parser.{ArrowReturnError, BlockIndentError, LexerError, ParserError}
import aqua.raw.ops.Call
import aqua.raw.ops.CallArrowRawTag
Expand Down
2 changes: 1 addition & 1 deletion api/api/src/main/scala/aqua/api/APICompilation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import aqua.parser.expr.AbilityExpr.p
import aqua.parser.lexer.{LiteralToken, Token}
import aqua.parser.lift.FileSpan.F
import aqua.parser.lift.{FileSpan, Span}
import aqua.parser.{ArrowReturnError, BlockIndentError, LexerError, ParserError}
import aqua.parser.{ArrowReturnError, LexerError, ParserError}
import aqua.raw.ConstantRaw
import aqua.raw.ops.Call
import aqua.raw.value.ValueRaw
Expand Down
5 changes: 2 additions & 3 deletions aqua-run/src/main/scala/aqua/run/RunPreparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package aqua.run

import aqua.backend.air.FuncAirGen
import aqua.definitions.{FunctionDef, TypeDefinition}
import aqua.io.OutputPrinter
import aqua.model.transform.{Transform, TransformConfig}
import aqua.model.{FuncArrow, ValueModel, VarModel}
import aqua.parser.lexer.CallArrowToken
import aqua.parser.lift.Span
import aqua.raw.ops.{Call, CallArrowRawTag, SeqTag}
import aqua.raw.value.{LiteralRaw, ValueRaw, VarRaw}
import aqua.types.*

import cats.data.Validated.{invalid, invalidNec, invalidNel, validNec, validNel}
import cats.data.{NonEmptyList, Validated, ValidatedNec}
import cats.effect.kernel.Async
Expand All @@ -18,8 +18,7 @@ import cats.syntax.flatMap.*
import cats.syntax.partialOrder.*
import cats.syntax.show.*
import cats.syntax.traverse.*
import cats.{~>, Id}

import cats.{Id, ~>}
import scala.collection.immutable.SortedMap
import scala.concurrent.ExecutionContext

Expand Down
2 changes: 1 addition & 1 deletion aqua-src/antithesis.aqua
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ func bugLng317() -> []string:
worker_job = WorkerJob(runOnSingleWorker = clos())
subnet_job <- disjoint_run{worker_job}()
finalRes <- runJob(subnet_job)
<- finalRes
<- finalRes
15 changes: 7 additions & 8 deletions compiler/src/main/scala/aqua/compiler/AquaParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ import aqua.parser.head.{FilenameExpr, ImportExpr}
import aqua.parser.lift.{LiftParser, Span}
import aqua.parser.{Ast, ParserError}

import cats.data.Chain.*
import cats.data.Validated.*
import cats.data.{Chain, EitherNec, EitherT, NonEmptyChain, Validated, ValidatedNec}
import cats.parse.Parser0
import cats.syntax.either.*
import cats.syntax.applicative.*
import cats.syntax.either.*
import cats.syntax.flatMap.*
import cats.syntax.foldable.*
import cats.syntax.functor.*
import cats.syntax.monad.*
import cats.syntax.foldable.*
import cats.syntax.traverse.*
import cats.syntax.validated.*
import cats.data.Chain.*
import cats.data.Validated.*
import cats.syntax.traverse.*
import cats.{~>, Comonad, Monad}
import cats.{Comonad, Monad, ~>}
import scribe.Logging

// TODO: add tests
Expand Down Expand Up @@ -48,9 +47,9 @@ class AquaParser[F[_]: Monad, E, I, S[_]: Comonad](

// Resolve imports (not parse, just resolve) of the given file
private def resolveImports(id: I, ast: Body): F[ValidatedNec[Err, AquaModule[I, Err, Body]]] =
ast.collectHead { case fe: FilenameExpr[S] =>
ast.head.collect { case fe: FilenameExpr[S] =>
fe.fileValue -> fe.token
}.value.traverse { case (filename, token) =>
}.traverse { case (filename, token) =>
sources
.resolveImport(id, filename)
.map(
Expand Down
28 changes: 19 additions & 9 deletions compiler/src/test/scala/aqua/compiler/AquaCompilerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers with Inside {

val src = Map(
"index.aqua" ->
"""module Foo declares X
"""aqua Foo declares X
|
|export foo, foo2 as foo_two, X
|
Expand Down Expand Up @@ -135,7 +135,11 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers with Inside {
it should "create right topology" in {
val src = Map(
"index.aqua" ->
"""service Op("op"):
"""aqua Test
|
|export exec
|
|service Op("op"):
| identity(s: string) -> string
|
|func exec(peers: []string) -> []string:
Expand Down Expand Up @@ -224,7 +228,11 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers with Inside {
it should "not generate hop back with empty response" in {
val src = Map(
"index.aqua" ->
"""service Op("op"):
"""aqua HopBackTest
|
|export exec
|
|service Op("op"):
| call(s: string)
|
|func exec(peers: []string):
Expand Down Expand Up @@ -288,7 +296,7 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers with Inside {

val src = Map(
"index.aqua" ->
"""module Import
"""aqua Import
|import foobar from "export2.aqua"
|
|use foo as f from "export2.aqua" as Exp
Expand All @@ -307,7 +315,7 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers with Inside {
)
val imports = Map(
"export2.aqua" ->
"""module Export declares foobar, foo
"""aqua Export declares foobar, foo
|
|func bar() -> string:
| <- " I am MyFooBar bar"
Expand All @@ -323,7 +331,7 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers with Inside {
|
|""".stripMargin,
"../gen/OneMore.aqua" ->
"""
"""aqua Test declares OneMore
|service OneMore:
| more_call()
| consume(s: string)
Expand Down Expand Up @@ -379,7 +387,10 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers with Inside {

it should "optimize math inside stream join" in {
val src = Map(
"main.aqua" -> """
"main.aqua" -> """aqua Test
|
|export main
|
|func main(i: i32):
| stream: *string
| stream <<- "a"
Expand Down Expand Up @@ -434,8 +445,7 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers with Inside {

it should "allow returning and passing services as abilities" in {
val src = Map(
"main.aqua" -> """
|aqua Test
"main.aqua" -> """aqua Test
|
|export test
|
Expand Down
16 changes: 0 additions & 16 deletions integration-tests/aqua/dht/dht-example.aqua

This file was deleted.

4 changes: 2 additions & 2 deletions integration-tests/aqua/examples/abilities.aqua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
aqua Main

use DECLARE_CONST, decl_bar from "imports_exports/declare.aqua" as Declare

export handleAb, SomeService, bug214, checkAbCalls, bugLNG258_1, bugLNG258_2, bugLNG258_3, multipleAbilityWithClosure, MySrv, returnSrvAsAbility

use DECLARE_CONST, decl_bar from "imports_exports/declare.aqua" as Declare

service SomeService("wed"):
getStr(s: string) -> string

Expand Down
24 changes: 0 additions & 24 deletions integration-tests/aqua/examples/aliases.aqua

This file was deleted.

4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/assignment.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua Assignment

export doSmth

data Prod:
value: string

Expand Down
5 changes: 5 additions & 0 deletions integration-tests/aqua/examples/callArrow.aqua
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
aqua CallArrow

export passFunctionAsArg, reproArgsBug426

import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"


-- functions like `c` are called an 'arrow function' in Aqua
-- `c` passed to a function from a client, so, it could be called only on a client
func passFunctionAsArg(node: string, str: string, c: string -> string):
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/canon.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua Canon

export Ser, bugLng79

data Record:
relay_id: []string
peer_id: string
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/aqua/examples/closures.aqua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Closure declares *

import "@fluencelabs/aqua-lib/builtin.aqua"
aqua Closure declares *

export LocalSrv, closureIn, closureOut, closureBig, closureOut2, lng58Bug, multipleClosuresBugLNG262, lng317Bug

import "@fluencelabs/aqua-lib/builtin.aqua"

service MyOp("op"):
identity(s: string) -> string

Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/co.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua Co

export CoService, coFunc

import "@fluencelabs/aqua-lib/builtin.aqua"

service CoService("coservice-id"):
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/collectionSugar.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua CollectionSugar

export arraySugar, streamSugar, optionSugar, GetArr, bugLNG59

import "@fluencelabs/aqua-lib/builtin.aqua"

func arraySugar(n: u32, m: u32) -> []u32, []u32:
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/complex.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua Complex

export TestS, doStuff

import "helloWorld.aqua"
import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/constants.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua Constants

export Getter, callConstant, timestampAndTtl

import "@fluencelabs/aqua-lib/builtin.aqua"

service Getter("test"):
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/dataAlias.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua DataAlias

export NodeIdGetter, getAliasedData

-- set `PeerId` name to be a type alias for `string` type
alias PeerId : string

Expand Down
2 changes: 2 additions & 0 deletions integration-tests/aqua/examples/example.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
aqua Example

service Peer("peer"):
is_connected: string -> bool

Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/fold.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua Fold

export iterateAndPrint, iterateAndPrintParallel, forBug499

import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/aqua/examples/foldJoin.aqua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module FoldJoin

import "@fluencelabs/aqua-lib/builtin.aqua"
aqua FoldJoin

export getTwoResults

import "@fluencelabs/aqua-lib/builtin.aqua"

service Op2("op"):
identity(s: u64)

Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/func.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua Func

export TestSrv, testFunc

service TestSrv("test-service-id"):
str: -> string

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/aqua/examples/funcs.aqua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Funcs declares main, A, calc
aqua Funcs declares main, A, calc

export main, A, calc, calc2, ifCalc, bugLNG260

Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/functors.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua Functors

export lng119Bug

func lng119Bug() -> []u32:
nums = [1,2,3,4,5]
results: *u32
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/helloWorld.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua HelloWorld

export StringExtra, helloWorld

service StringExtra("service-id"):
addNameToHello: string -> string

Expand Down
4 changes: 4 additions & 0 deletions integration-tests/aqua/examples/if.aqua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aqua If

export ifElseCall, ifElseNumCall, ifCorrectXorWrap, bugLNG69

import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FooBars declares decl_foo, decl_bar, SuperFoo, DECLARE_CONST, DECLARE_CONST2
aqua FooBars declares decl_foo, decl_bar, SuperFoo, DECLARE_CONST, DECLARE_CONST2
export SuperFoo

const DECLARE_CONST = "declare_const"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Export declares foobar, foo
aqua Export declares foobar, foo

import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- exports3.aqua
module Export3 declares *
aqua Export3 declares *

import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Exports declares some_string, MyExportSrv, EXPORT_CONST, some_random_func
aqua Exports declares some_string, MyExportSrv, EXPORT_CONST, some_random_func

import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"

Expand Down
Loading
Loading