diff options
author | Martin Odersky <odersky@gmail.com> | 2017-02-05 15:55:44 +1100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-04 13:20:45 +0200 |
commit | 669c5a8ed52f77942ee1ed7cf5813451d3762579 (patch) | |
tree | 7d48c11969725bba472005c68e068bba90a0f791 /docs | |
parent | 0a4891153f65315473cac4294b0427a071efa70a (diff) | |
download | dotty-669c5a8ed52f77942ee1ed7cf5813451d3762579.tar.gz dotty-669c5a8ed52f77942ee1ed7cf5813451d3762579.tar.bz2 dotty-669c5a8ed52f77942ee1ed7cf5813451d3762579.zip |
Add enum syntax
Modify syntax.md and Tokens/Parser/untpd to support enums.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/docs/internals/syntax.md | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index 7f06cdc2a..804a0f57a 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -289,7 +289,9 @@ TemplateBody ::= [nl] ‘{’ [SelfType] TemplateStat {semi TemplateStat} TemplateStat ::= Import | {Annotation [nl]} {Modifier} Def | {Annotation [nl]} {Modifier} Dcl + | EnumCaseStat | Expr1 + | SelfType ::= id [‘:’ InfixType] ‘=>’ ValDef(_, name, tpt, _) | ‘this’ ‘:’ InfixType ‘=>’ @@ -328,13 +330,20 @@ DefDef ::= DefSig [‘:’ Type] ‘=’ Expr | ‘this’ DefParamClause DefParamClauses DefDef(_, <init>, Nil, vparamss, EmptyTree, expr | Block) (‘=’ ConstrExpr | [nl] ConstrBlock) -TmplDef ::= ([‘case’] ‘class’ | ‘trait’) ClassDef - | [‘case’] ‘object’ ObjectDef -ClassDef ::= id [ClsTypeParamClause] ClassDef(mods, name, tparams, templ) - [ConstrMods] ClsParamClauses TemplateOpt with DefDef(_, <init>, Nil, vparamss, EmptyTree, EmptyTree) as first stat +TmplDef ::= ([‘case’ | `enum'] ‘class’ | [`enum'] trait’) ClassDef + | [‘case’ | `enum'] ‘object’ ObjectDef + | `enum' EnumDef +ClassDef ::= id ClassConstr TemplateOpt ClassDef(mods, name, tparams, templ) +ClassConstr ::= [ClsTypeParamClause] [ConstrMods] ClsParamClauses with DefDef(_, <init>, Nil, vparamss, EmptyTree, EmptyTree) as first stat ConstrMods ::= AccessModifier | Annotation {Annotation} (AccessModifier | ‘this’) ObjectDef ::= id TemplateOpt ModuleDef(mods, name, template) // no constructor +EnumDef ::= id ClassConstr [`extends' [ConstrApps]] EnumDef(mods, name, tparams, template) + [nl] ‘{’ EnumCaseStat {semi EnumCaseStat ‘}’ +EnumCaseStat ::= {Annotation [nl]} {Modifier} EnumCase +EnumCase ::= `case' (EnumClassDef | ObjectDef) +EnumClassDef ::= id [ClsTpeParamClause | ClsParamClause] ClassDef(mods, name, tparams, templ) + ClsParamClauses TemplateOpt TemplateOpt ::= [‘extends’ Template | [nl] TemplateBody] Template ::= ConstrApps [TemplateBody] | TemplateBody Template(constr, parents, self, stats) ConstrApps ::= ConstrApp {‘with’ ConstrApp} |