Skip to content

Commit

Permalink
Implement comment in compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
romainreuillon committed Feb 21, 2020
1 parent 085941a commit 0603a24
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/src/main/scala/scalatex/stages/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ object Compiler{
case Ast.Block.Text(offset1, str) =>
incPos(q"$str", offset1)

case Ast.Block.Comment(offset1, comment) =>
incPos(q"Seq[$fragType]()", offset1)

case Ast.Chain(offset1, code, parts) =>
compileChain(code, parts, offset1)

Expand Down
15 changes: 15 additions & 0 deletions api/src/test/scala/scalatex/ExampleTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,21 @@ object ExampleTests extends TestSuite{
"""
)
}
'comment {
check(
tw("""
@val x = {1}
@val y = {2}
/* Comment */
@x + @y is @(x + y)
"""),
"""
1 + 2 is 3
"""
)
}
}

}
Expand Down
7 changes: 7 additions & 0 deletions api/src/test/scala/scalatex/ParserTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ object ParserTests extends utest.TestSuite{
File(_),
Block(0,List(Block.Text(0, "\n"), Block.Comment(1,"/* This is a comment */"), Block.Text(24,"\nThis isn't")))
)
'nestedComent - check(
"""
|@b{Comment using /*Test*/}
|""".stripMargin,
File(_),
Block(0,List(Block.Text(0,"\n"), Chain(2,"b",List(Block(4,List(Block.Text(4,"Comment using /*Test*/"))))), Block.Text(27,"\n")))
)
}
//// 'Test{
//// check(
Expand Down
2 changes: 1 addition & 1 deletion project/Constants.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scalatex
object Constants{
val version = "0.4.4"
val version = "0.4.5"
val scalaTags = "0.8.4"
val scala212 = "2.12.10"
val scala213 = "2.13.1"
Expand Down

0 comments on commit 0603a24

Please sign in to comment.