summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-01-14 22:32:15 -0800
committerOri Bernstein <ori@eigenstate.org>2017-01-14 22:52:31 -0800
commit0eb1435e594590054c25ebc9c674c397553d8393 (patch)
tree6823a53c3e8da247bdb513ca5b4957753c3553d5 /doc
parent4f9a890e8007fc30b768415c42dfa8cd76057055 (diff)
downloadmc-0eb1435e594590054c25ebc9c674c397553d8393.tar.gz
Clarify block scoping.
Diffstat (limited to 'doc')
-rw-r--r--doc/lang.txt29
1 files changed, 24 insertions, 5 deletions
diff --git a/doc/lang.txt b/doc/lang.txt
index 8cafcdf..97684b4 100644
--- a/doc/lang.txt
+++ b/doc/lang.txt
@@ -381,14 +381,33 @@ TABLE OF CONTENTS:
stmt: goto | break | continue | retexpr | label |
ifstmt | forstmt | whilestmt | matchstmt
- Blocks are the basic building block of functionality in Myrddin.
- They are simply sequences of statements that are completed one after
- the
+ Blocks are the basic building block of functionality in Myrddin. They
+ are simply sequences of statements that are completed one after the
+ other. They are generally terminated by a double semicolon (";;"),
+ although they may be terminated by keywords if they are part of a more
+ complex control flow construct.
+
+ Any declarations within the block are scoped to within the block,
+ and are not accessible outside of it. Their storage duration is
+ limited to within the block, and any attempts to access the associated
+ storage (via pointer, for example) is not valid.
4.3. Control Constructs:
- if for
- while match
+ ifstmt: "if" cond "\n" blockbody
+ ("elif" blockbody)*
+ ["else" blockbody] ";;"
+
+ forstmt: foriter | foreach
+ foreach: "for" pattern "in" expr "\n" block
+ foriter: "for" init "\n" cond "\n" step "\n" block
+
+ whilestmt: "while" cond "\n" block
+
+ matchstmt: "match" expr "\n" matchpat* ";;"
+ matchpat: "|" pat ":" blockbody
+
+
goto
The control statements in Myrddin are similar to those in many other