summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-16 14:51:12 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-16 14:51:12 -0800
commit37adfa72f2658b0859a61f09cae5d400efec123e (patch)
treec88b4183199b47343a5bb952c2e1d16e7859dbdc
parente59178f01ea9944173654ba62f5ecc7852dc7597 (diff)
downloadhands-on-scala-js-37adfa72f2658b0859a61f09cae5d400efec123e.tar.gz
hands-on-scala-js-37adfa72f2658b0859a61f09cae5d400efec123e.tar.bz2
hands-on-scala-js-37adfa72f2658b0859a61f09cae5d400efec123e.zip
All tests pass???
-rw-r--r--scalatexApi/src/main/scala/scalatex/stages/Parser.scala4
-rw-r--r--scalatexApi/src/main/scala/torimatomeru/ScalaSyntax.scala4
-rw-r--r--scalatexApi/src/test/scala/scalatex/ParserTests.scala26
-rw-r--r--scalatexApi/src/test/scala/torimatomeru/SyntaxTest.scala9
4 files changed, 26 insertions, 17 deletions
diff --git a/scalatexApi/src/main/scala/scalatex/stages/Parser.scala b/scalatexApi/src/main/scala/scalatex/stages/Parser.scala
index 9693544..d143463 100644
--- a/scalatexApi/src/main/scala/scalatex/stages/Parser.scala
+++ b/scalatexApi/src/main/scala/scalatex/stages/Parser.scala
@@ -99,7 +99,7 @@ class Parser(input: ParserInput, indent: Int = 0, offset: Int = 0) extends Scala
(push(offsetCursor) ~ capture(ArgumentExprs2) ~> ((x, y) => Ast.Chain.Args(y, x))) |
BraceBlock
}
- def Ws = Whitespace
+ def Ws = WhiteLines
// clones of the version in ScalaSyntax, but without tailing whitespace or newlines
def TypeArgs2 = rule { '[' ~ Ws ~ Types ~ ']' }
def ArgumentExprs2 = rule {
@@ -107,7 +107,7 @@ class Parser(input: ParserInput, indent: Int = 0, offset: Int = 0) extends Scala
(optional(Exprs ~ ',' ~ Ws) ~ PostfixExpr() ~ ':' ~ Ws ~ '_' ~ Ws ~ '*' ~ Ws | optional(Exprs) ) ~
')'
}
- def BlockExpr2: Rule0 = rule { '{' ~ Ws ~ (CaseClauses | Block) ~ '}' }
+ def BlockExpr2: Rule0 = rule { '{' ~ Ws ~ (CaseClauses | Block) ~ Ws ~ '}' }
def BraceBlock: Rule1[Ast.Block] = rule{ '{' ~ BodyNoBrace ~ '}' }
def BodyItem(exclusions: String): Rule1[Seq[Ast.Block.Sub]] = rule{
diff --git a/scalatexApi/src/main/scala/torimatomeru/ScalaSyntax.scala b/scalatexApi/src/main/scala/torimatomeru/ScalaSyntax.scala
index be3b076..283926e 100644
--- a/scalatexApi/src/main/scala/torimatomeru/ScalaSyntax.scala
+++ b/scalatexApi/src/main/scala/torimatomeru/ScalaSyntax.scala
@@ -129,7 +129,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
def SimpleExpr1(G: B = true) = rule{
"new" ~ (ClassTemplate(G) | TemplateBody(G)) |
BlockExpr(G) |
- LiteralS() ~ drop[String] |
+ LiteralS(G) ~ drop[String] |
Path(G) |
'_' |
'(' ~ optional(Exprs) ~ wspStrG(")", G)
@@ -144,7 +144,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
def BlockExpr(G: B = true): Rule0 = rule { '{' ~ (CaseClauses | Block) ~ wspStrG("}", G) }
def Block: Rule0 = rule { zeroOrMore(BlockStat ~ SemiS) ~ optional(ResultExpr()) }
def BlockStat: Rule0 = rule {
- &(SemiS) ~ MATCH | //shortcircuit when Semi is found
+ SemiS |
Import(false) |
zeroOrMore(Annotation) ~ (optional("implicit" | "lazy") ~ Def(false) | zeroOrMore(LocalModifier) ~ TmplDef(false)) |
Expr1(false)
diff --git a/scalatexApi/src/test/scala/scalatex/ParserTests.scala b/scalatexApi/src/test/scala/scalatex/ParserTests.scala
index 016ff37..be24af9 100644
--- a/scalatexApi/src/test/scala/scalatex/ParserTests.scala
+++ b/scalatexApi/src/test/scala/scalatex/ParserTests.scala
@@ -366,15 +366,27 @@ object ParserTests extends utest.TestSuite{
|bbq""".stripMargin,
_.Body.run(),
Block(Seq(
+ Text("\n", 0),
Chain("omg",Seq(
- Args("(\"lol\",\n1,\n 2\n )"),
+ Args("(\"lol\",\n1,\n 2\n )", 5),
Block(Seq(
- Text("\n "), Text("wtf")
- ))
- )),
- Text("\n"),
- Text("bbq")
- ))
+ Text("\n ", 30), Text("wtf", 33)
+ ), 30)
+ ), 1),
+ Text("\n", 36),
+ Text("bbq", 37)
+ ), 0)
+ )
+ 'codeBlock - check(
+ """@{
+ | val omg = "omg"
+ | omg * 2
+ |}""".stripMargin,
+ _.Code.run(),
+ """{
+ | val omg = "omg"
+ | omg * 2
+ |}""".stripMargin
)
'codeBlocks - check(
"""
diff --git a/scalatexApi/src/test/scala/torimatomeru/SyntaxTest.scala b/scalatexApi/src/test/scala/torimatomeru/SyntaxTest.scala
index 7f1794c..17b0d5f 100644
--- a/scalatexApi/src/test/scala/torimatomeru/SyntaxTest.scala
+++ b/scalatexApi/src/test/scala/torimatomeru/SyntaxTest.scala
@@ -31,12 +31,9 @@ object SyntaxTest extends TestSuite{
_.ArgumentExprs().run(), ()
)
* - check(
- """(1, 2,
- |3
- |,
- |4
- |)""".stripMargin,
- _.ArgumentExprs().run(), ()
+ """val omg = "omg"
+ |omg * 2""".stripMargin,
+ _.Block.run(), ()
)
}
}