Methods which implicitly propagate the context in which they were called: either in a pattern context or not.
Methods which implicitly propagate whether the initial call took place in a context where sequences are allowed.
modes for infix types
Consume one token of the specified type, or signal an error if it is not there.
Consume one token of the specified type, or signal an error if it is not there.
semi = nl {nl} | ;'
nl =
\n' // where allowed
AccessModifier ::= (private | protected) [AccessQualifier]
AccessQualifier ::= "[" (Id | this) "]"
Annotations ::= {@' SimpleType {ArgumentExprs}}
ConsrAnnotations ::= {
@' SimpleType ArgumentExprs}
ArgumentExprs ::= (' [Exprs]
)'
| [nl] BlockExpr
Block ::= BlockStatSeq
BlockExpr ::= {' (CaseClauses | Block)
}'
BlockStatSeq ::= { BlockStat semi } [ResultExpr] BlockStat ::= Import | Annotations [implicit] [lazy] Def | Annotations LocalModifiers TmplDef | Expr1 |
CaseClauses ::= CaseClause {CaseClause}
CaseClause ::= case Pattern [Guard] =>' Block
Check that tree is a legal clause of a forSome
Check that type parameter is not by name or repeated
ClassDef ::= Id [TypeParamClause] {Annotation} [AccessModifier] ClassParamClauses RequiresTypeOpt ClassTemplateOpt TraitDef ::= Id [TypeParamClause] RequiresTypeOpt TraitTemplateOpt
CompilationUnit ::= {package QualId semi} TopStatSeq
ConstrBlock ::= {' SelfInvocation {semi BlockStat}
}'
ConstrExpr ::= SelfInvocation | ConstrBlock
Convert tree to formal parameter
Convert tree to formal parameter list
Convert (qual)ident to type identifier
Def ::= val PatDef | var PatDef | def FunDef | type [nl] TypeDef | TmplDef Dcl ::= val PatDcl | var PatDcl | def FunDcl | type [nl] TypeDcl
Enumerators ::= Generator {semi Enumerator}
Enumerator ::= Generator
| Guard
| val Pattern1 =' Expr
EqualsExpr ::= =' Expr
Expr ::= (Bindings | [implicit'] Id |
_') =>' Expr
| Expr1
ResultExpr ::= (Bindings | Id
:' CompoundType) =>' Block
| Expr1
Expr1 ::= if
(' Expr )' {nl} Expr [[semi] else Expr]
| try (
{' Block }' | Expr) [catch
{' CaseClauses }'] [finally Expr]
| while
(' Expr )' {nl} Expr
| do Expr [semi] while
(' Expr )'
| for (
(' Enumerators )' | '{' Enumerators '}') {nl} [yield] Expr
| throw Expr
| return [Expr]
| [SimpleExpr
.
Expr ::= (Bindings | [implicit'] Id |
_') =>' Expr
| Expr1
ResultExpr ::= (Bindings | Id
:' CompoundType) =>' Block
| Expr1
Expr1 ::= if
(' Expr )' {nl} Expr [[semi] else Expr]
| try (
{' Block }' | Expr) [catch
{' CaseClauses }'] [finally Expr]
| while
(' Expr )' {nl} Expr
| do Expr [semi] while
(' Expr )'
| for (
(' Enumerators )' | '{' Enumerators '}') {nl} [yield] Expr
| throw Expr
| return [Expr]
| [SimpleExpr
.'] Id =' Expr
| SimpleExpr1 ArgumentExprs
=' Expr
| PostfixExpr Ascription
| PostfixExpr match {' CaseClauses
}'
Bindings ::= (' [Binding {
,' Binding}] )'
Binding ::= (Id |
_') [:' Type]
Ascription ::=
:' CompoundType
| :' Annotation {Annotation}
|
:' _'
*'
FunDef ::= FunSig :' Type
=' Expr
| FunSig [nl] {' Block
}'
| this ParamClause ParamClauses (=' ConstrExpr | [nl] ConstrBlock)
FunDcl ::= FunSig [
:' Type]
FunSig ::= id [FunTypeParamClause] ParamClauses
Generator ::= Pattern1 (<-' | '=') Expr [Guard]
Guard ::= if PostfixExpr
Assumed (provisionally) to be TermNames.
For when it's known already to be a type name.
Expr ::= implicit Id => Expr
Import ::= import ImportExpr {,' ImportExpr}
ImportExpr ::= StableId .' (Id |
_' | ImportSelectors)
ImportSelector ::= Id [=>' Id |
=>' _']
ImportSelectors ::= {' {ImportSelector
,'} (ImportSelector | _')
}'
Methods inParensOrError and similar take a second argument which, should the next token not be the expected opener (e.
Methods inParensOrError and similar take a second argument which, should the next token not be the expected opener (e.g. LPAREN) will be returned instead of the contents of the groupers. However in all cases accept(LPAREN) will be called, so a parse error will still result. If the grouping is optional, in.token should be tested before calling these methods.
Join the comment associated with a definition
SimpleExpr ::= literal | symbol | null
overridable IDE hook for local definitions of blockStatSeq Here's an idea how to fill in start and end positions.
overridable IDE hook for local definitions of blockStatSeq Here's an idea how to fill in start and end positions. def localDef : List[Tree] = { atEndPos { atStartPos(in.offset) { val annots = annotations(true) val mods = localModifiers() withAnnotations annots if (!(mods hasFlag ~(Flags.IMPLICIT | Flags.LAZY))) defOrDcl(mods) else List(tmplDef(mods)) } } (in.offset) }
LocalModifiers ::= {LocalModifier} LocalModifier ::= abstract | final | sealed | implicit | lazy
Create a tree representing a package object, converting package object foo { .
Create a tree representing a package object, converting
package object foo { ... }
to
package foo {
object package
{ ... }
}
Create a tree representing a packaging
Creates an actual Parens node (only used during parsing.
Creates an actual Parens node (only used during parsing.)
MixinQualifier ::= [' Id
]'
Modifiers ::= {Modifier} Modifier ::= LocalModifier | AccessModifier | override
A succession of argument lists.
The implementation for parsing inside of patterns at points where sequences are disallowed.
ObjectDef ::= Id ClassTemplateOpt
The implementation of the context sensitive methods for parsing outside of patterns.
Packaging ::= package QualId [nl] {' TopStatSeq
}'
ParamClauses ::= {ParamClause} nl]
ParamType ::= Type | =>' Type | Type
*'
This is the general parse entry point.
PatDef ::= Pattern2 {,' Pattern2} [
:' Type] =' Expr
ValDcl ::= Id {
,' Id} :' Type
VarDef ::= PatDef | Id {
,' Id} :' Type
=' _'
Path ::= StableId
| [Ident .'] this
AnnotType ::= Path [
.
Path ::= StableId
| [Ident .'] this
AnnotType ::= Path [
.' type]
Default entry points into some pattern contexts.
The implicit parameters introduced by _' in the current expression.
Parameters appear in reverse order
The placeholderTypes introduced by _' in the current type.
Parameters appear in reverse order
PostfixExpr ::= InfixExpr [Id [nl]] InfixExpr ::= PrefixExpr | InfixExpr Id [nl] InfixExpr
PrefixExpr ::= [-' |
+' | ~' |
!' | &'] SimpleExpr
QualId ::= Id {.' Id}
RefineStatSeq ::= RefineStat {semi RefineStat} RefineStat ::= Dcl | type TypeDef |
Refinement ::= [nl] {' RefineStat {semi RefineStat}
}'
This is the parse entry point for code which is not self-contained, e.
This is the parse entry point for code which is not self-contained, e.g. a script which is a series of template statements. They will be swaddled in Trees until the AST is equivalent to the one returned by compilationUnit().
SelfInvocation ::= this ArgumentExprs {ArgumentExprs}
The implementation for parsing inside of patterns at points where sequences are allowed.
StableId ::= Id
| Path .' Id
| [id '.'] super [
[' id ]']
.
StableId ::= Id
| Path .' Id
| [id '.'] super [
[' id ]']
.' id
ClassTemplate ::= [EarlyDefs with] ClassParents [TemplateBody]
TraitTemplate ::= [EarlyDefs with] TraitParents [TemplateBody]
EarlyDefs ::= {' [EarlyDef {semi EarlyDef}]
}'
EarlyDef ::= Annotations Modifiers PatDef
TemplateBody ::= [nl] {' TemplateStatSeq
}'
TemplateBody ::= [nl] {' TemplateStatSeq
}'
specifies whether in early initializer (true) or not (false)
ClassTemplateOpt ::= 'extends' ClassTemplate | 'extends']
ClassParents ::= AnnotType {(' [Exprs]
)'} {with AnnotType}
TraitParents ::= AnnotType {with AnnotType}
TemplateStatSeq ::= [id [:' Type]
=>'] TemplateStat {semi TemplateStat}
TemplateStat ::= Import
| Annotations Modifiers Def
| Annotations Modifiers Dcl
| Expr1
| super ArgumentExprs {ArgumentExprs}
|
TemplateStatSeq ::= [id [:' Type]
=>'] TemplateStat {semi TemplateStat}
TemplateStat ::= Import
| Annotations Modifiers Def
| Annotations Modifiers Dcl
| Expr1
| super ArgumentExprs {ArgumentExprs}
|
specifies whether in early initializer (true) or not (false)
TmplDef ::= [case] class ClassDef | [case] object ObjectDef | [override] trait TraitDef
part { sep
part }
Or if sepFirst is true, { sep
part }
Hook for IDE, for top-level classes/objects
TopStatSeq ::= TopStat {semi TopStat} TopStat ::= Annotations Modifiers TmplDef | Packaging | package object objectDef | Import |
These are default entry points into the pattern context sensitive methods: they are all initiated from non-pattern context.
TypeBounds ::= [>:' Type] [
<:' Type]
TypeDef ::= type Id [TypeParamClause] =' Type
TypeDcl ::= type Id [TypeParamClause] TypeBounds
TypeParamClauseOpt ::= [TypeParamClause]
TypeParamClause ::= [' VariantTypeParam {
,' VariantTypeParam} ]']
VariantTypeParam ::= {Annotation} [
+' | -'] TypeParam
FunTypeParamClauseOpt ::= [FunTypeParamClause]
FunTypeParamClause ::=
[' TypeParam {,' TypeParam}
]']
TypeParam ::= Id TypeParamClauseOpt TypeBounds {<% Type} {":" Type}
TypedOpt ::= [:' Type]
WildcardType ::= _' TypeBounds