diff --git a/README.md b/README.md index 62ea3a33..8a3c35bb 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ or simply download the latest JAR file from the [releases](https://github.com/fl It requires `java` to run Aqua compiler from the command line: ```commandline -java -jar aqua-hll.jar path/to/input/dir path/to/output/dir +java -jar aqua-cli-%version_number%.jar -i path/to/input/dir -o path/to/output/dir ``` Input directory should contain files with `aqua` scripts. diff --git a/aqua-src/demo.aqua b/aqua-src/demo.aqua index 88c744a7..de501f03 100644 --- a/aqua-src/demo.aqua +++ b/aqua-src/demo.aqua @@ -1,5 +1,20 @@ -import "print.aqua" +service OpH("op"): + puk(s: string) -> string + pek(s: string, -- trgtr + c: string) -> string -func iterateAndPrint(strings: []string): - for s <- strings: - print(s) \ No newline at end of file +func a( -- ferkjn + b: string, -- fr + c: string, -- asdf + g: string + ) -> string: -- rgtr + + try: + f = "world" + OpH "planet" + OpH.pek("TRY THIS", -- gtrg + c) + catch err: + OpH.puk(err.msg) + <- f + -- hello \ No newline at end of file diff --git a/cli/src/main/scala/aqua/AppOps.scala b/cli/src/main/scala/aqua/AppOps.scala index b4a154b8..ba691809 100644 --- a/cli/src/main/scala/aqua/AppOps.scala +++ b/cli/src/main/scala/aqua/AppOps.scala @@ -100,7 +100,7 @@ object AppOps { .options[String]("const", "Constant that will be used in an aqua code", "c") .mapValidated { strs => val parsed = strs.map(s => ConstantExpr.onlyLiteral.parseAll(s)) - println(parsed) + val errors = parsed.collect { case Left(er) => er } diff --git a/cli/src/main/scala/aqua/AquaCompiler.scala b/cli/src/main/scala/aqua/AquaCompiler.scala index 42a301e0..1f11b3a3 100644 --- a/cli/src/main/scala/aqua/AquaCompiler.scala +++ b/cli/src/main/scala/aqua/AquaCompiler.scala @@ -1,11 +1,11 @@ package aqua import aqua.backend.air.FuncAirGen -import aqua.backend.ts.TypescriptFile import aqua.backend.js.JavaScriptFile +import aqua.backend.ts.TypescriptFile import aqua.io.{AquaFileError, AquaFiles, FileModuleId, Unresolvable} import aqua.linker.Linker -import aqua.model.{AquaContext, VarModel} +import aqua.model.AquaContext import aqua.model.transform.BodyConfig import aqua.parser.lift.FileSpan import aqua.semantics.{RulesViolated, SemanticError, Semantics} @@ -129,7 +129,7 @@ object AquaCompiler extends LogSupport { prepareFiles(srcPath, imports, targetPath) .map(_.map(_.filter { p => val hasOutput = p.hasOutput(compileTo) - if (!hasOutput) info(s"Source ${p.srcPath}: compilation OK (nothing to emit)") + if (!hasOutput) info(s"Source ${p.modFile}: compilation OK (nothing to emit)") hasOutput })) .flatMap[ValidatedNec[String, Chain[String]]] { diff --git a/cli/src/main/scala/aqua/io/AquaFile.scala b/cli/src/main/scala/aqua/io/AquaFile.scala index 99730ad6..7c61510e 100644 --- a/cli/src/main/scala/aqua/io/AquaFile.scala +++ b/cli/src/main/scala/aqua/io/AquaFile.scala @@ -60,6 +60,9 @@ object AquaFile { Files[F] .readAll(file, 4096) .fold(Vector.empty[Byte])((acc, b) => acc :+ b) + // TODO fix for comment on last line in air + // TODO should be fixed by parser + .map(_.appendedAll("\n\r".getBytes)) .flatMap(fs2.Stream.emits) .through(text.utf8Decode) .attempt diff --git a/parser/src/main/scala/aqua/parser/lexer/Token.scala b/parser/src/main/scala/aqua/parser/lexer/Token.scala index 58aaed0d..1d1b9d54 100644 --- a/parser/src/main/scala/aqua/parser/lexer/Token.scala +++ b/parser/src/main/scala/aqua/parser/lexer/Token.scala @@ -55,6 +55,7 @@ object Token { val ` \n` : P[Unit] = (` `.?.void *> (`--` *> P.charsWhile(_ != '\n')).?.void).with1 *> `\n` + val ` \n+` : P[Unit] = P.repAs[Unit, Unit](` \n`.backtrack, 1)(Accumulator0.unitAccumulator0) val ` : \n+` : P[Unit] = ` `.?.with1 *> `:` *> ` \n+` val `,` : P[Unit] = P.char(',') <* ` `.?