Added switch statements to spec
This commit is contained in:
parent
3cd3384006
commit
7e05785c09
@ -266,8 +266,15 @@ value. Each case takes the form of a declaration, and an associated expression.
|
||||
If the type of the union matches the type of the declaration in the case, the
|
||||
expression is executed and the value of the union is made available to it
|
||||
through the declaration. If the value of the match expression is used, all
|
||||
possible types in the union must be accounted for. It may be assigned to any
|
||||
type that satisfies the assignment rules of its first case.
|
||||
possible types in the union must be accounted for, or it must have a default
|
||||
case. It may be assigned to any type that satisfies the assignment rules of its
|
||||
first case.
|
||||
### Switch
|
||||
Switch is a control flow branching expression that executes one of several case
|
||||
expressions depending on the value of the input. It accepts any pointer or
|
||||
integer type. If the value of the switch expression is used, a default case must
|
||||
be present. It may be assigned to any type that satisfies the assignment rules
|
||||
of its first case.
|
||||
### Loop
|
||||
Loop is a control flow expression that repeats an expression until a break
|
||||
statement is called from within it. The break statement must be given a value
|
||||
@ -366,7 +373,8 @@ this without hand-writing a parser.
|
||||
<ifelse> -> "if" <expression>
|
||||
"then" <expression>
|
||||
["else" <expression>]
|
||||
<match> -> "match" <expression> <case>*
|
||||
<match> -> "match" <expression> <matchCase>* [<defaultCase>]
|
||||
<switch> -> "switch" <expression> <switchCase>* [<defaultCase>]
|
||||
<loop> -> "loop" <expression>
|
||||
<for> -> "for" <expression> [<expression>] in <expression> <expression>
|
||||
<break> -> "[" "break" [<expression>] "]"
|
||||
@ -384,7 +392,9 @@ this without hand-writing a parser.
|
||||
<booleanLiteral> -> "true" | "false"
|
||||
|
||||
<member> -> <identifier> ":" <expression>
|
||||
<case> -> "|" <declaration> <expression>
|
||||
<matchCase> -> "|" <declaration> <expression>
|
||||
<switchCase> -> "|" <expression> <expression>
|
||||
<defaultCase> -> "*" <expression>
|
||||
<signature> -> "[" <identifier> <declaration>* "]" [":" <type>]
|
||||
<identifier> -> /[a-z][A-Za-z]*/
|
||||
<typeIdentifier> -> /[A-Z][A-Za-z]*/
|
||||
|
Loading…
Reference in New Issue
Block a user