summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-09-15 20:20:14 +0000
committerMartin Odersky <odersky@gmail.com>2003-09-15 20:20:14 +0000
commitdc6ec50a08dcd17aa65a73701abd6963b78a00bc (patch)
tree00e884ffbe6776f51be59bb249012190ab757a08 /doc
parent1b77651f90d9b4132e419409295f0d3c6153cf41 (diff)
downloadscala-dc6ec50a08dcd17aa65a73701abd6963b78a00bc.tar.gz
scala-dc6ec50a08dcd17aa65a73701abd6963b78a00bc.tar.bz2
scala-dc6ec50a08dcd17aa65a73701abd6963b78a00bc.zip
*** empty log message ***
Diffstat (limited to 'doc')
-rw-r--r--doc/reference/ScalaReference.tex29
1 files changed, 13 insertions, 16 deletions
diff --git a/doc/reference/ScalaReference.tex b/doc/reference/ScalaReference.tex
index 5954615d5b..a53c8798c5 100644
--- a/doc/reference/ScalaReference.tex
+++ b/doc/reference/ScalaReference.tex
@@ -942,7 +942,7 @@ the type definition
Dcl ::= val ValDcl {`,' ValDcl}
ValDcl ::= id `:' Type
Def ::= val PatDef {`,' PatDef}
- PatDef ::= Pattern `=' Expr
+ PatDef ::= Pattern2 [`:' Type] `=' Expr
\end{lstlisting}
A value declaration ~\lstinline@val $x$: $T$@~ introduces $x$ as a name of a value of
@@ -2915,7 +2915,7 @@ A semicolon preceding the \code{while} symbol of a do loop expression is ignored
Enumerator ::= Generator {`;' Enumerator}
Enumerator ::= Generator
| Expr
- Generator ::= val Pattern `<-' Expr
+ Generator ::= val Pattern1 `<-' Expr
\end{lstlisting}
A comprehension ~\lstinline@for ($\enums\,$) yield $e$@~ evaluates expression $e$ for each
@@ -3241,23 +3241,22 @@ written.
\label{sec:patterns}
\syntax\begin{lstlisting}
-Pattern ::= TreePattern { `|' TreePattern }
-
-TreePattern ::= varid `:' Type
+Pattern ::= Pattern1 { `|' Pattern1 }
+Pattern1 ::= varid `:' Type
| `_' `:' Type
- | SimplePattern [ '*' |'?' | '+' ]
- | SimplePattern { id SimplePattern }
-
+Pattern2 ::= SimplePattern [ '*' |'?' | '+' ]
+ | SimplePattern { id SimplePattern }
SimplePattern ::= varid [ '@' SimplePattern ]
| `_'
| literal
| StableId [ `(' [Patterns] `)' ]
| `(' Patterns `)'
|
-
Patterns ::= Pattern {`,' Pattern}
\end{lstlisting}
+\todo{Why can patterns be empty?}
+
A pattern is built from constants, constructors, variables and regular
operators. Pattern matching tests whether a given value (or sequence
of values) has the shape defined by a pattern, and, if it does, binds
@@ -4172,7 +4171,7 @@ grammar.
Enumerators ::= Generator {`;' Enumerator}
Enumerator ::= Generator
| Expr
- Generator ::= val Pattern `<-' Expr
+ Generator ::= val Pattern1 `<-' Expr
Block ::= {BlockStat `;'} [Expr]
BlockStat ::= Import
| Def
@@ -4184,20 +4183,18 @@ grammar.
Constr ::= StableId [TypeArgs] [`(' [Exprs] `)']
- Pattern ::= TreePattern { `|' TreePattern }
-
- TreePattern ::= varid `:' Type
+ Pattern ::= Pattern1 { `|' Pattern1 }
+ Pattern1 ::= varid `:' Type
| `_' `:' Type
- | SimplePattern [ '*' | '?' | '+' ]
+ | Pattern2
+ Pattern2 ::= SimplePattern [ '*' | '?' | '+' ]
| SimplePattern { id SimplePattern }
-
SimplePattern ::= varid [ '@' SimplePattern ]
| `_'
| literal
| StableId [ `(' [Patterns] `)' ]
| `(' Patterns `)'
|
-
Patterns ::= Pattern {`,' Pattern}
TypeParamClause ::= `[' TypeParam {`,' TypeParam} `]'