Mercurial Hosting > luan
comparison website/src/manual.html.luan @ 1092:a26fbde7ee28
documentation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 08 Jan 2017 17:23:06 -0700 |
parents | 616761e0b9f6 |
children | ad6b3b9fef40 |
comparison
equal
deleted
inserted
replaced
1091:20d5968e65cc | 1092:a26fbde7ee28 |
---|---|
532 and cannot be used as names: | 532 and cannot be used as names: |
533 | 533 |
534 | 534 |
535 <pre> | 535 <pre> |
536 and break do else elseif end | 536 and break do else elseif end |
537 end_do end_for end_function end_if end_while | |
537 false for function goto if in | 538 false for function goto if in |
538 local nil not or repeat return | 539 local nil not or repeat return |
539 then true until while | 540 then true until while |
540 </pre> | 541 </pre> |
541 | 542 |
783 | 784 |
784 <p> | 785 <p> |
785 A block can be explicitly delimited to produce a single statement: | 786 A block can be explicitly delimited to produce a single statement: |
786 | 787 |
787 <pre> | 788 <pre> |
788 stat ::= <b>do</b> block <b>end</b> | 789 stat ::= <b>do</b> block end_do |
790 end_do ::= <b>end_do</b> | <b>end</b> | |
789 </pre> | 791 </pre> |
790 | 792 |
791 <p> | 793 <p> |
792 Explicit blocks are useful | 794 Explicit blocks are useful |
793 to control the scope of variable declarations. | 795 to control the scope of variable declarations. |
919 The control structures | 921 The control structures |
920 <b>if</b>, <b>while</b>, and <b>repeat</b> have the usual meaning and | 922 <b>if</b>, <b>while</b>, and <b>repeat</b> have the usual meaning and |
921 familiar syntax: | 923 familiar syntax: |
922 | 924 |
923 <pre> | 925 <pre> |
924 stat ::= <b>while</b> exp <b>do</b> block <b>end</b> | 926 stat ::= <b>while</b> exp <b>do</b> block end_while |
925 stat ::= <b>repeat</b> block <b>until</b> exp | 927 stat ::= <b>repeat</b> block <b>until</b> exp |
926 stat ::= <b>if</b> exp <b>then</b> block {<b>elseif</b> exp <b>then</b> block} [<b>else</b> block] <b>end</b> | 928 stat ::= <b>if</b> exp <b>then</b> block {<b>elseif</b> exp <b>then</b> block} [<b>else</b> block] end_if |
929 end_while ::= <b>end_while</b> | <b>end</b> | |
930 end_if ::= <b>end_if</b> | <b>end</b> | |
927 </pre> | 931 </pre> |
928 | 932 |
929 <p> | 933 <p> |
930 Luan also has a <b>for</b> statement (see <a href="#for">For Statement</a>). | 934 Luan also has a <b>for</b> statement (see <a href="#for">For Statement</a>). |
931 | 935 |
982 On each iteration, the iterator function is called to produce a new value, | 986 On each iteration, the iterator function is called to produce a new value, |
983 stopping when this new value is <b>nil</b>. | 987 stopping when this new value is <b>nil</b>. |
984 The <b>for</b> loop has the following syntax: | 988 The <b>for</b> loop has the following syntax: |
985 | 989 |
986 <pre> | 990 <pre> |
987 stat ::= <b>for</b> namelist <b>in</b> exp <b>do</b> block <b>end</b> | 991 stat ::= <b>for</b> namelist <b>in</b> exp <b>do</b> block end_for |
988 namelist ::= Name {‘<b>,</b>’ Name} | 992 namelist ::= Name {‘<b>,</b>’ Name} |
993 end_for ::= <b>end_for</b> | <b>end</b> | |
989 </pre> | 994 </pre> |
990 | 995 |
991 <p> | 996 <p> |
992 A <b>for</b> statement like | 997 A <b>for</b> statement like |
993 | 998 |
1517 <p> | 1522 <p> |
1518 The syntax for function definition is | 1523 The syntax for function definition is |
1519 | 1524 |
1520 <pre> | 1525 <pre> |
1521 functiondef ::= <b>function</b> funcbody | 1526 functiondef ::= <b>function</b> funcbody |
1522 funcbody ::= ‘<b>(</b>’ [parlist] ‘<b>)</b>’ block <b>end</b> | 1527 funcbody ::= ‘<b>(</b>’ [parlist] ‘<b>)</b>’ block end_function |
1528 end_function ::= <b>end_function</b> | <b>end</b> | |
1523 </pre> | 1529 </pre> |
1524 | 1530 |
1525 <p> | 1531 <p> |
1526 The following syntactic sugar simplifies function definitions: | 1532 The following syntactic sugar simplifies function definitions: |
1527 | 1533 |