Skip to content

Commit

Permalink
101 last line comment (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
DieMyst authored Jun 22, 2021
1 parent 985309d commit 3236f91
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 19 additions & 4 deletions aqua-src/demo.aqua
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion cli/src/main/scala/aqua/AppOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions cli/src/main/scala/aqua/AquaCompiler.scala
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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]]] {
Expand Down
3 changes: 3 additions & 0 deletions cli/src/main/scala/aqua/io/AquaFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions parser/src/main/scala/aqua/parser/lexer/Token.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(',') <* ` `.?
Expand Down

0 comments on commit 3236f91

Please sign in to comment.