diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-11-28 05:53:12 -0800 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-11-28 05:53:12 -0800 |
commit | 097b5f24938bfb59471da7415be6523a7dfa03f9 (patch) | |
tree | 7c35807ee3b3d65a26c3ce6503af53e38e6cb1f6 | |
parent | c2b5d4125f2b868399828281fb8e53e35be6e0f6 (diff) | |
download | hands-on-scala-js-097b5f24938bfb59471da7415be6523a7dfa03f9.tar.gz hands-on-scala-js-097b5f24938bfb59471da7415be6523a7dfa03f9.tar.bz2 hands-on-scala-js-097b5f24938bfb59471da7415be6523a7dfa03f9.zip |
Down to js.Function...
4 files changed, 33 insertions, 14 deletions
diff --git a/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala b/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala index 9909e8f..7770bca 100644 --- a/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala +++ b/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala @@ -112,7 +112,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif } } def AnnotType = rule { - SimpleType ~ zeroOrMore(Annotation) + SimpleType ~ optional(NotNewline ~ oneOrMore(Annotation)) } def SimpleType: R0 = { def BasicType: R0 = rule { @@ -132,8 +132,11 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif def TypePat = rule { CompoundType } + def FunctionArgTypes = rule { + InfixType | '(' ~ optional(oneOrMore(ParamType) separatedBy ',') ~ ')' + } def Ascription = rule { - ":" ~ ("_" ~ "*" | InfixType | oneOrMore(Annotation)) + ":" ~ ("_" ~ "*" | InfixType | oneOrMore(Annotation)) } def ParamType = rule { K.O("=>") ~ Type | Type ~ "*" | Type } @@ -147,7 +150,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif ( Bindings | optional(K.W("implicit")) ~ Id ~ optional(Ascription) | - "_" ~ optional(Ascription) + K.W("_") ~ optional(Ascription) ) ~ K.O("=>") } @@ -224,7 +227,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif rule { SimpleExpr1 ~ zeroOrMore('.' ~ Id | TypeArgs | ArgumentExprs) ~ - optional( "_") + optional(K.W("_")) } } @@ -360,7 +363,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif def Import: R0 = { def ImportExpr: R0 = rule { - StableId ~ optional('.' ~ ("_" | ImportSelectors)) + StableId ~ optional('.' ~ (K.W("_") | ImportSelectors)) } def ImportSelectors: R0 = rule { '{' ~ zeroOrMore(ImportSelector ~ ',') ~ (ImportSelector | K.W("_")) ~ "}" } def ImportSelector: R0 = rule { Id ~ optional(K.O("=>") ~ (Id | K.W("_"))) } diff --git a/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala b/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala index dc12e46..5456d16 100644 --- a/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala +++ b/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala @@ -13,7 +13,7 @@ trait Identifiers { self: Parser with Basic => def Id = rule { !Keywords ~ PlainId | ("`" ~ oneOrMore(noneOf("`")) ~ "`") } def IdRest = rule { zeroOrMore(zeroOrMore("_") ~ oneOrMore(!"_" ~ Letter | Digit)) ~ - optional(oneOrMore("_") ~ optional(Operator)) + optional(oneOrMore("_") ~ zeroOrMore(OperatorChar)) } diff --git a/scalaParser/src/test/resources/test.scala b/scalaParser/src/test/resources/test.scala index 55e43c2..32bac45 100644 --- a/scalaParser/src/test/resources/test.scala +++ b/scalaParser/src/test/resources/test.scala @@ -1,3 +1,10 @@ -class A { - null: T forSome { type T <: V } -}
\ No newline at end of file +object K{ + + def newBuilder = + new B + + @inline def a = 1 + + +} + diff --git a/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala b/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala index 90a08e2..997d8e0 100644 --- a/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala +++ b/scalaParser/src/test/scala/scalaParser/SyntaxTest.scala @@ -547,15 +547,24 @@ object SyntaxTest extends TestSuite{ """.stripMargin ) * - check( - """class A { - | null: T forSome { type T <: V } + """object U{ + | private val _fragment = fld(Fragment) + | _fld = null |} """.stripMargin ) * - check( - """object U{ - | private val _fragment = fld(Fragment) - | _fld = null + """class Array{ + | def length_= = 1 + |} + """.stripMargin + ) + * - check( + """object K{ + | def newBuilder = + | new B + | + | @inline def a = 1 |} """.stripMargin ) |