Skip to content

Fix #10648: Fixes of syntax documentation #10658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Dec 9, 2020
Prev Previous commit
Next Next commit
Officialize syntax
 - cleanup rules
 - drop sidebar with tree node info
 - put in reference directory and link with sidebar
  • Loading branch information
odersky committed Dec 9, 2020
commit e5be3e7cc27f0716e1be467cb423eaafb39c680d
20 changes: 8 additions & 12 deletions docs/docs/internals/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ FunArgType ::= Type
| ‘=>’ Type PrefixOp(=>, t)
ParamType ::= [‘=>’] ParamValueType
ParamValueType ::= Type [‘*’] PostfixOp(t, "*")
TypeArgs ::= ‘[’ Types ‘]’ ts
TypeArgs ::= ‘[’ Types ‘]’ ts
Refinement ::= ‘{’ [RefineDcl] {semi [RefineDcl]} ‘}’ ds
TypeBounds ::= [‘>:’ Type] [‘<:’ Type] TypeBoundsTree(lo, hi)
TypeParamBounds ::= TypeBounds {‘:’ Type} ContextBounds(typeBounds, tps)
Expand Down Expand Up @@ -219,7 +219,7 @@ SimpleExpr ::= SimpleRef
| BlockExpr
| ‘$’ ‘{’ Block ‘}’
| Quoted
| quoteId // only inside splices
| quoteId -- only inside splices
| ‘new’ ConstrApp {‘with’ ConstrApp} New(constr | templ)
[[colonEol] TemplateBody
| ‘new’ [colonEol] TemplateBody
Expand All @@ -228,8 +228,8 @@ SimpleExpr ::= SimpleRef
| SimpleExpr ‘.’ MatchClause
| SimpleExpr TypeArgs TypeApply(expr, args)
| SimpleExpr ArgumentExprs Apply(expr, args)
| SimpleExpr ‘_’ PostfixOp(expr, _)
| XmlExpr
| SimpleExpr ‘_’ PostfixOp(expr, _) (to be dropped)
| XmlExpr (to be dropped)
Quoted ::= ‘'’ ‘{’ Block ‘}’
| ‘'’ ‘[’ Type ‘]’
ExprsInParens ::= ExprInParens {‘,’ ExprInParens}
Expand Down Expand Up @@ -272,7 +272,7 @@ SimplePattern ::= PatVar
| Literal Bind(name, Ident(wildcard))
| ‘(’ [Patterns] ‘)’ Parens(pats) Tuple(pats)
| Quoted
| XmlPattern
| XmlPattern (to be dropped)
| SimplePattern1 [TypeArgs] [ArgumentPatterns]
| ‘given’ RefinedType
SimplePattern1 ::= SimpleRef
Expand Down Expand Up @@ -307,14 +307,12 @@ ClsParams ::= ClsParam {‘,’ ClsParam}
ClsParam ::= {Annotation} ValDef(mods, id, tpe, expr) -- point of mods on val/var
[{Modifier} (‘val’ | ‘var’) | ‘inline’] Param
Param ::= id ‘:’ ParamType [‘=’ Expr]
| INT

DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’]
DefParamClause ::= [nl] ‘(’ DefParams ‘)’ | UsingParamClause
UsingParamClause ::= [nl] ‘(’ ‘using’ (DefParams | Types) ‘)’
DefParams ::= DefParam {‘,’ DefParam}
DefParam ::= {Annotation} [‘inline’] Param ValDef(mods, id, tpe, expr) -- point of mods at id.
ClosureMods ::= { ‘implicit’ | ‘given’}
```

### Bindings and Imports
Expand All @@ -336,7 +334,7 @@ LocalModifier ::= ‘abstract’
AccessModifier ::= (‘private’ | ‘protected’) [AccessQualifier]
AccessQualifier ::= ‘[’ id ‘]’

Annotation ::= ‘@’ SimpleType1 {ParArgumentExprs} Apply(tpe, args)
Annotation ::= ‘@’ SimpleType1 {ParArgumentExprs} Apply(tpe, args)

Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec Import(expr, sels)
Expand All @@ -348,7 +346,7 @@ ImportSelectors ::= id [‘=>’ id | ‘=>’ ‘_’] [‘,’ ImportSelect
| WildCardSelector {‘,’ WildCardSelector}
WildCardSelector ::= ‘given’ [InfixType]
| ‘_'
Export ::= [‘given’] ImportExpr {‘,’ ImportExpr}
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr}

EndMarker ::= ‘end’ EndMarkerTag -- when followed by EOL
EndMarkerTag ::= id | ‘if’ | ‘while’ | ‘for’ | ‘match’ | ‘try’
Expand All @@ -367,7 +365,6 @@ ValDcl ::= ids ‘:’ Type
VarDcl ::= ids ‘:’ Type PatDef(_, ids, tpe, EmptyTree)
DefDcl ::= DefSig ‘:’ Type DefDef(_, name, tparams, vparamss, tpe, EmptyTree)
DefSig ::= id [DefTypeParamClause] DefParamClauses
| ExtParamClause {nl} [‘.’] id DefParamClauses
TypeDcl ::= id [TypeParamClause] {FunParamClause} TypeBounds TypeDefTree(_, name, tparams, bound
[‘=’ Type]

Expand All @@ -376,7 +373,6 @@ Def ::= ‘val’ PatDef
| ‘def’ DefDef
| ‘type’ {nl} TypeDcl
| TmplDef
| INT
PatDef ::= ids [‘:’ Type] ‘=’ Expr
| Pattern2 [‘:’ Type | Ascription] ‘=’ Expr PatDef(_, pats, tpe?, expr)
VarDef ::= PatDef
Expand All @@ -402,7 +398,7 @@ ExtMethods ::= ExtMethod | [nl] ‘{’ ExtMethod {semi ExtMethod ‘}
ExtMethod ::= {Annotation [nl]} {Modifier} ‘def’ DefDef
Template ::= InheritClauses [colonEol] [TemplateBody] Template(constr, parents, self, stats)
InheritClauses ::= [‘extends’ ConstrApps] [‘derives’ QualId {‘,’ QualId}]
ConstrApps ::= ConstrApp {(‘,’ | ‘with’) ConstrApp}
ConstrApps ::= ConstrApp ({‘,’ ConstrApp} | {‘with’ ConstrApp})
ConstrApp ::= SimpleType1 {Annotation} {ParArgumentExprs} Apply(tp, args)
ConstrExpr ::= SelfInvocation
| ‘{’ SelfInvocation {semi BlockStat} ‘}’
Expand Down
Loading