diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-11-28 00:45:21 -0800 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-11-28 00:45:21 -0800 |
commit | eb384564fae6282d46a251fe8e91034e88c8dda4 (patch) | |
tree | 201aa9edb5e629fd6827150f16f973069fbc04cd /scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala | |
parent | a4f1bb1d021109cce5d0f5ba5e37592b9c66a7cf (diff) | |
download | hands-on-scala-js-eb384564fae6282d46a251fe8e91034e88c8dda4.tar.gz hands-on-scala-js-eb384564fae6282d46a251fe8e91034e88c8dda4.tar.bz2 hands-on-scala-js-eb384564fae6282d46a251fe8e91034e88c8dda4.zip |
More refactorings to standardize identifier/keyword "make sure it can't continue" behavior"
Diffstat (limited to 'scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala')
-rw-r--r-- | scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala b/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala index d9c5d4b..4ba79a8 100644 --- a/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala +++ b/scalaParser/src/main/scala/scalaParser/ScalaSyntax.scala @@ -260,8 +260,6 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif } } - - def ResultExpr: R0 = Expr def CaseClauses: R0 = { @@ -325,9 +323,6 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif rule { zeroOrMore(Param).separatedBy(',') } } - - - def ClassParam: R0 = rule { zeroOrMore(Annotation) ~ optional(zeroOrMore(Modifier) ~ (K.W("val") | K.W("var"))) ~ @@ -337,9 +332,6 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif optional(K.O("=") ~ Expr) } - - - def Modifier: R0 = rule { LocalModifier | AccessModifier | K.W("override") } def LocalModifier: R0 = rule { K.W("abstract") | K.W("final") | K.W("sealed") | K.W("implicit") | K.W("lazy") } def AccessModifier: R0 = { @@ -347,7 +339,6 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif rule { (K.W("private") | K.W("protected")) ~ optional(AccessQualifier) } } - def Annotation: R0 = rule { '@' ~ SimpleType ~ zeroOrMore(WL ~ ArgumentExprs) } def TemplateBody: R0 = rule { @@ -373,10 +364,6 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif rule { K.W("import") ~ oneOrMore(ImportExpr).separatedBy(',') } } - - - - def Dcl: R0 = { def VarDcl: R0 = rule { Ids ~ K.O(":") ~ Type } @@ -384,9 +371,9 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif rule { K.W("val") ~ ValDcl | - K.W("var") ~ VarDcl | - K.W("def") ~ FunDcl | - K.W("type") ~ zeroOrMore(Newline) ~ TypeDcl + K.W("var") ~ VarDcl | + K.W("def") ~ FunDcl | + K.W("type") ~ zeroOrMore(Newline) ~ TypeDcl } } def FunSig: R0 = rule { Id ~ optional(FunTypeParamClause) ~ ParamClauses } @@ -416,8 +403,6 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif rule { K.W("def") ~ FunDef | K.W("type") ~ zeroOrMore(Newline) ~ TypeDef | PatVarDef | TmplDef } } - - def TypeDef: R0 = rule { Id ~ optional(TypeParamClause) ~ K.O("=") ~ Type } def TmplDef: R0 = { @@ -491,7 +476,6 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif rule{ '{' ~ optional(oneOrMore(EarlyDef).separatedBy(Semis)) ~ '}' ~ K.W("with") } } - def ConstrBlock: R0 = rule { '{' ~ SelfInvocation ~ optional(Semis ~ BlockStats) ~ '}' } def SelfInvocation: R0 = rule { K.W("this") ~ oneOrMore(ArgumentExprs) } @@ -500,9 +484,9 @@ class ScalaSyntax(val input: ParserInput) extends Parser with Basic with Identif def Packaging: R0 = rule { K.W("package") ~ QualId ~ '{' ~ TopStatSeq ~ '}' } def TopStat: R0 = rule { Packaging | - PackageObject | - Import | - zeroOrMore(Annotation ~ optional(Newline)) ~ zeroOrMore(Modifier) ~ TmplDef + PackageObject | + Import | + zeroOrMore(Annotation ~ optional(Newline)) ~ zeroOrMore(Modifier) ~ TmplDef } rule { oneOrMore(TopStat).separatedBy(Semis) } } |