summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-28 23:12:06 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-28 23:12:06 -0800
commitbe290a9471d9e25461a197c828f85d44cf64d633 (patch)
tree841804386c21fa4d06e7e4043f503eee318c0989
parenta2e4a074271890889e8fbafff25010449c06a190 (diff)
downloadhands-on-scala-js-be290a9471d9e25461a197c828f85d44cf64d633.tar.gz
hands-on-scala-js-be290a9471d9e25461a197c828f85d44cf64d633.tar.bz2
hands-on-scala-js-be290a9471d9e25461a197c828f85d44cf64d633.zip
Fails at t8120.scala now
-rw-r--r--scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala16
-rw-r--r--scalaParser/src/test/resources/test.scala5
-rw-r--r--scalaParser/src/test/scala/scalaParser/SyntaxTest.scala10
3 files changed, 19 insertions, 12 deletions
diff --git a/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala b/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala
index cb008c9..ab94372 100644
--- a/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala
+++ b/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala
@@ -103,9 +103,6 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
def Type: R0 = {
def WildcardType: R0 = rule{ `_` }
- def FunctionArgTypes = rule {
- InfixType | '(' ~ optional(oneOrMore(ParamType) separatedBy ',') ~ ')'
- }
rule {
(WildcardType |
FunctionArgTypes ~ `=>` ~ Type |
@@ -114,7 +111,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
}
def InfixType = rule {
- CompoundType ~ zeroOrMore(Id ~ OneNewlineMax ~ CompoundType)
+ CompoundType ~ zeroOrMore(NotNewline ~ Id ~ OneNewlineMax ~ CompoundType)
}
def CompoundType = {
def RefineStat = rule { `type` ~ TypeDef | Dcl | MATCH }
@@ -191,7 +188,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
rule {
"for" ~
- ('(' ~ Enumerators() ~ ')' | '{' ~ Enumerators(G = true) ~ '}') ~
+ ('(' ~ Enumerators() ~ ')' | '{' ~ Enumerators(true) ~ '}') ~
optional(K.W("yield")) ~
Expr0(G)
}
@@ -205,7 +202,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
ForCFlow |
K.W("throw") ~ Expr0(G) |
K.W("return") ~ optional(Expr0(G)) |
- SimpleExpr ~ `=` ~ Expr0(G) |
+ SimpleExpr() ~ `=` ~ Expr0(G) |
PostfixExpr(G) ~ optional("match" ~ '{' ~ CaseClauses ~ "}" | Ascription)
)
}
@@ -213,7 +210,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
def PostfixExpr(G: Boolean = false): R0 = {
def PrefixExpr = rule {
- optional(WL ~ anyOf("-+~!") ~ WS ~ !(Basic.OperatorChar)) ~ SimpleExpr
+ optional(WL ~ anyOf("-+~!") ~ WS ~ !(Basic.OperatorChar)) ~ SimpleExpr(G)
}
def Check = if (G) OneNewlineMax else MATCH
def Check0 = if (G) NotNewline else MATCH
@@ -230,11 +227,12 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
rule { InfixExpr ~ optional(NotNewline ~ Id ~ optional(Newline)) }
}
- def SimpleExpr: R0 = {
+ def SimpleExpr(G: Boolean = false): R0 = {
def Path: R0 = rule {
zeroOrMore(Id ~ '.') ~ `this` ~ zeroOrMore('.' ~ Id) |
StableId
}
+ def Check0 = if (G) NotNewline else MATCH
def SimpleExpr1 = rule{
K.W("new") ~ (ClassTemplate | TemplateBody) |
BlockExpr |
@@ -246,7 +244,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif
rule {
SimpleExpr1 ~
zeroOrMore('.' ~ Id | TypeArgs | NotNewline ~ ArgumentExprs) ~
- optional(`_`)
+ optional(Check0 ~ `_`)
}
}
diff --git a/scalaParser/src/test/resources/test.scala b/scalaParser/src/test/resources/test.scala
index 2313257..bd9f504 100644
--- a/scalaParser/src/test/resources/test.scala
+++ b/scalaParser/src/test/resources/test.scala
@@ -1,5 +1,4 @@
-class Test {
+object A {
- f: A
- g(og): B
+ A.m(1: Any => Any)
} \ No newline at end of file
diff --git a/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala b/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala
index 072fc7b..4bb3c6e 100644
--- a/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala
+++ b/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala
@@ -768,6 +768,16 @@ object SyntaxTest extends TestSuite{
|}
""".stripMargin
)
+ * - check(
+ """object test {
+ | for {
+ | n <- A
+ | a <- B
+ | _ <- C
+ | } yield n
+ |}
+ """.stripMargin
+ )
}
'neg{
* - checkNeg(