summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-16 19:36:20 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-16 19:36:20 -0800
commit9b15aa91bd6d75e492c3872f7d6efe1dba25030b (patch)
treed533b92653dfcc0229aa1403c47ff434cf203cbc
parent498585ce96837f815233be946902e8fd4802f9c9 (diff)
downloadhands-on-scala-js-9b15aa91bd6d75e492c3872f7d6efe1dba25030b.tar.gz
hands-on-scala-js-9b15aa91bd6d75e492c3872f7d6efe1dba25030b.tar.bz2
hands-on-scala-js-9b15aa91bd6d75e492c3872f7d6efe1dba25030b.zip
opened up two more file-tests
-rw-r--r--scalatexApi/src/main/scala/scalaparser/ScalaSyntax.scala4
-rw-r--r--scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala57
2 files changed, 21 insertions, 40 deletions
diff --git a/scalatexApi/src/main/scala/scalaparser/ScalaSyntax.scala b/scalatexApi/src/main/scala/scalaparser/ScalaSyntax.scala
index 0e183a1..029ed22 100644
--- a/scalatexApi/src/main/scala/scalaparser/ScalaSyntax.scala
+++ b/scalatexApi/src/main/scala/scalaparser/ScalaSyntax.scala
@@ -119,7 +119,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
def Refinement = rule { optional(Newline) ~ '{' ~ oneOrMore(RefineStat).separatedBy(Semi) ~ '}' }
def RefineStat = rule { "type" ~ TypeDef | Dcl | MATCH }
def TypePat = rule { Type }
- def Ascription = rule { ":" ~ (InfixType | oneOrMore(Annotation) | "_" ~ "*") }
+ def Ascription(G: B = t) = rule { ":" ~ (InfixType | oneOrMore(Annotation) | "_" ~ StrW("*", G)) }
def ParamType = rule { "=>" ~ Type | Type ~ "*" | Type }
@@ -134,7 +134,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
"return" ~ optional(Expr(G)) |
SimpleExpr() ~ ArgumentExprs() ~ '=' ~ Expr(G) |
optional(SimpleExpr() ~ '.') ~ Id() ~ '=' ~ Expr(G) |
- PostfixExpr(G) ~ optional("match" ~ '{' ~ CaseClauses ~ '}' | Ascription)
+ PostfixExpr(false) ~ optional("match" ~ '{' ~ CaseClauses ~ StrW("}", false) | Ascription(false)) ~ W(G)
}
def IfCFlow(G: B = t) = rule { "if" ~ '(' ~ Expr() ~ ')' ~ zeroOrMore(Newline) ~ Expr(G) ~ optional(optional(Semi) ~ "else" ~ Expr(G)) }
diff --git a/scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala b/scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala
index 6378eb0..b278b49 100644
--- a/scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala
+++ b/scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala
@@ -180,41 +180,22 @@ object SyntaxTest extends TestSuite{
|}
""".stripMargin
)
-// * - check(io.Source.fromFile("scalatexApi/src/main/scala/scalatex/stages/Trim.scala").mkString)
-// * - check(
-// """
-// |package scalatex.stages
-// |import acyclic.file
-// |
-// |/**
-// | * Preprocesses the input string to normalize things related to whitespace
-// | *
-// | * Find the "first" non-whitespace-line of the text and remove the front
-// | * of every line to align that first line with the left margin.
-// | *
-// | * Remove all trailing whitespace from each line.
-// | */
-// |object Trim extends (String => (String, Int)){
-// | def apply(str: String) = {
-// | val lines = str.split("\n", -1)
-// | val offset = lines.iterator
-// | .filter(_.length > 0)
-// | .next()
-// | .takeWhile(_ == ' ')
-// | .length
-// | val res = lines.iterator
-// | .map(_.replaceFirst("\\s+$", ""))
-// | .mkString("\n")
-// | (res, offset)
-// | }
-// | def old(str: String) = {
-// | val (res, offset) = this.apply(str)
-// | res.split("\n", -1).map(_.drop(offset)).mkString("\n")
-// | }
-// |}
-// |
-// """.stripMargin
-// )
+ * - check(
+ """
+ |object Compiler{
+ |
+ | def apply = {
+ | def rec = t match {
+ | case 0 => 0
+ | }
+ |
+ | rec(tree)
+ | }
+ |}
+ |
+ """.stripMargin
+ )
+
}
'file{
def checkFile(path: String) =
@@ -225,15 +206,15 @@ object SyntaxTest extends TestSuite{
* - checkFile("scalatexApi/src/main/scala/scalaparser/syntax/Literals.scala")
// All the commented files seem to make the parser run forever. There's probably
// some exponential performance somewhere in there, but I can't see it =/
- // * - check(io.Source.fromFile("scalatexApi/src/main/scala/scalaparser/ScalaSyntax.scala").mkString)
+ * - checkFile("scalatexApi/src/main/scala/scalaparser/ScalaSyntax.scala")
* - checkFile("scalatexApi/src/test/scala/scalatex/TestUtil.scala")
- // * - check(io.Source.fromFile("scalatexApi/src/main/scala/scalatex/stages/Compiler.scala").mkString)
+ * - checkFile("scalatexApi/src/main/scala/scalatex/stages/Compiler.scala")
* - checkFile("scalatexApi/src/main/scala/scalatex/stages/Parser.scala")
// * - check(io.Source.fromFile("scalatexApi/src/test/scala/scalatex/ParserTests.scala").mkString)
* - checkFile("scalatexApi/src/main/scala/scalatex/stages/Trim.scala")
- // * - check(io.Source.fromFile("scalatexApi/src/main/scala/scalatex/package.scala").mkString)
+ * - checkFile("scalatexApi/src/main/scala/scalatex/package.scala")
}
}