From 5135bae5a7c2d156dd55dfc0aabf8b41d393f4a2 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Wed, 12 Mar 2014 16:24:33 -0700 Subject: SI-5086 clean up EBNF - sequences of block statements were wrong (btw, note that BlockStat matches the empty sequence of tokens) - lexical syntax was pretty messy: clarified, removed extraneous backslashes --- 08-expressions.md | 85 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) (limited to '08-expressions.md') diff --git a/08-expressions.md b/08-expressions.md index 6ab149cfc1..1eed192cc8 100644 --- a/08-expressions.md +++ b/08-expressions.md @@ -1,44 +1,44 @@ # Expressions ``` - Expr ::= (Bindings | id | `_') `=>' Expr - | Expr1 - Expr1 ::= `if' `(' Expr `)' {nl} Expr [[semi] `else' Expr] - | `while' `(' Expr `)' {nl} Expr - | `try' (`{' Block `}' | Expr) [`catch' `{' CaseClauses `}'] [`finally' Expr] - | `do' Expr [semi] `while' `(' Expr ')' - | `for' (`(' Enumerators `)' | `{' Enumerators `}') {nl} [`yield'] Expr - | `throw' Expr - | `return' [Expr] - | [SimpleExpr `.'] id `=' Expr - | SimpleExpr1 ArgumentExprs `=' Expr - | PostfixExpr - | PostfixExpr Ascription - | PostfixExpr `match' `{' CaseClauses `}' - PostfixExpr ::= InfixExpr [id [nl]] - InfixExpr ::= PrefixExpr - | InfixExpr id [nl] InfixExpr - PrefixExpr ::= [`-' | `+' | `~' | `!'] SimpleExpr - SimpleExpr ::= `new' (ClassTemplate | TemplateBody) - | BlockExpr - | SimpleExpr1 [`_'] - SimpleExpr1 ::= Literal - | Path - | `_' - | `(' [Exprs] `)' - | SimpleExpr `.' id s - | SimpleExpr TypeArgs - | SimpleExpr1 ArgumentExprs - | XmlExpr - Exprs ::= Expr {`,' Expr} - BlockExpr ::= `{' CaseClauses `}' - | `{' Block `}' - Block ::= {BlockStat semi} [ResultExpr] - ResultExpr ::= Expr1 - | (Bindings | ([`implicit'] id | `_') `:' CompoundType) `=>' Block - Ascription ::= `:' InfixType - | `:' Annotation {Annotation} - | `:' `_' `*' +Expr ::= (Bindings | id | `_') `=>' Expr + | Expr1 +Expr1 ::= `if' `(' Expr `)' {nl} Expr [[semi] `else' Expr] + | `while' `(' Expr `)' {nl} Expr + | `try' (`{' Block `}' | Expr) [`catch' `{' CaseClauses `}'] [`finally' Expr] + | `do' Expr [semi] `while' `(' Expr ')' + | `for' (`(' Enumerators `)' | `{' Enumerators `}') {nl} [`yield'] Expr + | `throw' Expr + | `return' [Expr] + | [SimpleExpr `.'] id `=' Expr + | SimpleExpr1 ArgumentExprs `=' Expr + | PostfixExpr + | PostfixExpr Ascription + | PostfixExpr `match' `{' CaseClauses `}' +PostfixExpr ::= InfixExpr [id [nl]] +InfixExpr ::= PrefixExpr + | InfixExpr id [nl] InfixExpr +PrefixExpr ::= [`-' | `+' | `~' | `!'] SimpleExpr +SimpleExpr ::= `new' (ClassTemplate | TemplateBody) + | BlockExpr + | SimpleExpr1 [`_'] +SimpleExpr1 ::= Literal + | Path + | `_' + | `(' [Exprs] `)' + | SimpleExpr `.' id s + | SimpleExpr TypeArgs + | SimpleExpr1 ArgumentExprs + | XmlExpr +Exprs ::= Expr {`,' Expr} +BlockExpr ::= ‘{’ CaseClauses ‘}’ + | ‘{’ Block ‘}’ +Block ::= BlockStat {semi BlockStat} [ResultExpr] +ResultExpr ::= Expr1 + | (Bindings | ([`implicit'] id | `_') `:' CompoundType) `=>' Block +Ascription ::= `:' InfixType + | `:' Annotation {Annotation} + | `:' `_' `*' ``` Expressions are composed of operators and operands. Expression forms are @@ -558,8 +558,9 @@ where `anon\$X` is some freshly created name. ## Blocks ``` -BlockExpr ::= `{' Block `}' -Block ::= {BlockStat semi} [ResultExpr] +BlockExpr ::= ‘{’ CaseClauses ‘}’ + | ‘{’ Block ‘}’ +Block ::= BlockStat {semi BlockStat} [ResultExpr] ``` A block expression `{$s_1$; $\ldots$; $s_n$; $e\,$}` is @@ -1319,10 +1320,10 @@ include at least the expressions of the following forms: ``` BlockStat ::= Import - | {Annotation} [`implicit'] Def + | {Annotation} [‘implicit’ | ‘lazy’] Def | {Annotation} {LocalModifier} TmplDef | Expr1 - | + | TemplateStat ::= Import | {Annotation} {Modifier} Def | {Annotation} {Modifier} Dcl -- cgit v1.2.3