diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-11-28 05:38:35 -0800 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-11-28 05:38:35 -0800 |
commit | 3dc34955b3f8287178339a28f7ba3772a27ae08a (patch) | |
tree | b36430c5c5e11eaeacf09878d7286280832a5f22 /scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala | |
parent | 5ef6a1dd630764a1ffa6c3b68fff1649c9d89934 (diff) | |
download | hands-on-scala-js-3dc34955b3f8287178339a28f7ba3772a27ae08a.tar.gz hands-on-scala-js-3dc34955b3f8287178339a28f7ba3772a27ae08a.tar.bz2 hands-on-scala-js-3dc34955b3f8287178339a28f7ba3772a27ae08a.zip |
"omg" goes down to java.net.URI
Diffstat (limited to 'scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala')
-rw-r--r-- | scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala b/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala index fe30606..c2a6ce1 100644 --- a/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala +++ b/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala @@ -82,11 +82,13 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif Id ~ zeroOrMore('.' ~ Id) } } - + def ExistentialDcl = rule { K.W("type") ~ TypeDcl | K.W("val") ~ ValDcl } + def ExistentialClause = rule { + "forSome" ~ '{' ~ oneOrMore(ExistentialDcl).separatedBy(Semi) ~ '}' + } def Type: R0 = { def WildcardType: R0 = rule{ K.W("_") } - def ExistentialDcl = rule { K.W("type") ~ TypeDcl | K.W("val") ~ ValDcl } - def ExistentialClause = rule { "forSome" ~ '{' ~ oneOrMore(ExistentialDcl).separatedBy(Semi) } + def FunctionArgTypes = rule { InfixType | '(' ~ optional(oneOrMore(ParamType) separatedBy ',') ~ ')' } @@ -110,7 +112,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif } } def AnnotType = rule { - SimpleType ~ zeroOrMore(Annotation) + SimpleType ~ zeroOrMore(Annotation) } def SimpleType: R0 = { def BasicType: R0 = rule { @@ -131,7 +133,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif def TypePat = rule { CompoundType } def Ascription = rule { - ":" ~ ("_" ~ "*" | InfixType | oneOrMore(Annotation)) + ":" ~ ("_" ~ "*" | InfixType | oneOrMore(Annotation)) } def ParamType = rule { K.O("=>") ~ Type | Type ~ "*" | Type } @@ -145,7 +147,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("=>") } @@ -216,13 +218,13 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif BlockExpr | Literal | Path | - K.W("_") | + NotNewline ~ K.W("_") | '(' ~ optional(Exprs) ~ ")" } rule { SimpleExpr1 ~ zeroOrMore('.' ~ Id | TypeArgs | ArgumentExprs) ~ - optional( "_") + optional(K.W("_")) } } @@ -302,7 +304,7 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif def VariantTypeParam: R0 = rule { zeroOrMore(Annotation) ~ optional(anyOf("+-")) ~ TypeParam } rule { '[' ~ oneOrMore(VariantTypeParam).separatedBy(',') ~ ']' } } - def FunTypeParamClause: R0 = rule { '[' ~ oneOrMore(TypeParam).separatedBy(',') ~ ']' } + def FunTypeParamClause: R0 = rule { '[' ~ oneOrMore(zeroOrMore(Annotation) ~ TypeParam).separatedBy(',') ~ ']' } def TypeBounds: R0 = rule{ optional(K.O(">:") ~ Type) ~ optional(K.O("<:") ~ Type) |