101 last line comment (#179)

This commit is contained in:
Dima 2021-06-22 11:32:27 +03:00 committed by GitHub
parent 985309d4eb
commit 3236f91db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 9 deletions

View File

@ -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.

View File

@ -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)
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

View File

@ -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
}

View File

@ -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]]] {

View File

@ -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

View File

@ -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(',') <* ` `.?