Skip to content

Latest commit

 

History

History
181 lines (157 loc) · 11.7 KB

syntax-summary.md

File metadata and controls

181 lines (157 loc) · 11.7 KB
layout title partof overview-name num permalink
multipage-overview
Syntax summary
quasiquotes
Quasiquotes
7
/overviews/quasiquotes/:title.html

Denys Shabalin EXPERIMENTAL

Expressions

  Quasiquote Type
Empty q"" EmptyTree
Literal q"$value" Literal
Identifier q"$tname" or q"name" Ident
Selection q"$expr.$tname" Select
Super Selection q"$tpname.super[$tpname].$tname" Select
This q"$tpname.this" This
Application q"$expr(...$exprss)" Apply
Type Application q"$expr[..$tpts]" TypeApply
Assign q"$expr = $expr" Assign, AssignOrNamedArg
Update q"$expr(..$exprs) = $expr" Tree
Return q"return $expr" Return
Throw q"throw $expr" Throw
Ascription q"$expr: $tpt" Typed
Annotated q"$expr: @$annot" Annotated
Tuple q"(..$exprs)" Tree
Block q"{ ..$stats }" Block
If q"if ($expr) $expr else $expr" If
Pattern Match q"$expr match { case ..$cases }" Match
Try q"try $expr catch { case ..$cases } finally $expr" Try
Function q"(..$params) => $expr" Function
Partial Function q"{ case ..$cases }" Match
While Loop q"while ($expr) $expr" LabelDef
Do-While Loop q"do $expr while ($expr)" LabelDef
For Loop q"for (..$enums) $expr" Tree
For-Yield Loop q"for (..$enums) yield $expr" Tree
New q"new { ..$earlydefns } with ..$parents { $self => ..$stats }" Tree
XML Literal Not natively supported Tree

Types

  Quasiquote Type
Empty Type tq"" TypeTree
Type Identifier tq"$tpname" or tq"Name" Ident
Singleton Type tq"$ref.type" SingletonTypeTree
Type Projection tq"$tpt#$tpname" SelectFromTypeTree
Type Selection tq"$ref.$tpname" Select
Super Type Selection tq"$tpname.super[$tpname].$tpname" Select
This Type Selection tq"this.$tpname" Select
Applied Type tq"$tpt[..$tpts]" AppliedTypeTree
Annotated Type tq"$tpt @$annots" Annotated
Compound Type tq"..$parents { ..$defns }" CompoundTypeTree
Existential Type tq"$tpt forSome { ..$defns }" ExistentialTypeTree
Tuple Type tq"(..$tpts)" Tree
Function Type tq"(..$tpts) => $tpt" Tree

Patterns

  Quasiquote Type
Wildcard Pattern pq"_" Ident
Literal Pattern pq"$value" Literal
Binding Pattern pq"$name @ $pat" Bind
Extractor Pattern pq"$ref(..$pats)" Apply, UnApply
Type Pattern pq"_: $tpt" Typed
Alternative Pattern pq"$first │ ..$rest" Alternative
Tuple Pattern pq"(..$pats)" Apply, UnApply
XML Pattern Not natively supported Tree

Definitions

  Quasiquote Type
Val q"$mods val $tname: $tpt = $expr" or q"$mods val $pat = $expr" ValDef
Var q"$mods var $tname: $tpt = $expr" or q"$mods var $pat = $expr" ValDef
Val Pattern q"$mods val $pat: $tpt = $expr" Tree
Var Pattern q"$mods var $pat: $tpt = $expr" Tree
Method q"$mods def $tname[..$tparams](...$paramss): $tpt = $expr" DefDef
Secondary Constructor q"$mods def this(...$paramss) = this(..$argss)" DefDef
Type q"$mods type $tpname[..$tparams] = $tpt" TypeDef
Class q"$mods class $tpname[..$tparams] $ctorMods(...$paramss) extends { ..$earlydefns } with ..$parents { $self => ..$stats }" ClassDef
Trait q"$mods trait $tpname[..$tparams] extends { ..$earlydefns } with ..$parents { $self => ..$stats }" TraitDef
Object q"$mods object $tname extends { ..$earlydefns } with ..$parents { $self => ..$body }" ModuleDef
Package q"package $ref { ..$topstats }" PackageDef
Package Object q"package object $tname extends { ..$earlydefns } with ..$parents { $self => ..$stats }" PackageDef

Auxiliary

  Quasiquote Type
Import q"import $ref.{..$sels}" Import
Case Clause cq"$pat if $expr => $expr" CaseDef
Generator Enumerator fq"$pat <- $expr" Tree
Value Definition Enumerator fq"$pat = $expr" Tree
Guard Enumerator fq"if $expr" Tree

Abbreviations

Prefixes of unquotees imply the following:

Whenever a name has suffix s it means that it is a List of something. ss means List of Lists. So for example exprss means a List of Lists of expressions.