| 854 | }; |
| 855 | |
| 856 | function function_(in_statement) { |
| 857 | var name = is("name") ? prog1(S.token.value, next) : null; |
| 858 | if (in_statement && !name) |
| 859 | unexpected(); |
| 860 | expect("("); |
| 861 | return as(in_statement ? "defun" : "function", |
| 862 | name, |
| 863 | // arguments |
| 864 | (function(first, a){ |
| 865 | while (!is("punc", ")")) { |
| 866 | if (first) first = false; else expect(","); |
| 867 | if (!is("name")) unexpected(); |
| 868 | a.push(S.token.value); |
| 869 | next(); |
| 870 | } |
| 871 | next(); |
| 872 | return a; |
| 873 | })(true, []), |
| 874 | // body |
| 875 | (function(){ |
| 876 | ++S.in_function; |
| 877 | var loop = S.in_loop; |
| 878 | S.in_loop = 0; |
| 879 | var a = block_(); |
| 880 | --S.in_function; |
| 881 | S.in_loop = loop; |
| 882 | return a; |
| 883 | })()); |
| 884 | }; |
| 885 | |
| 886 | function if_() { |
| 887 | var cond = parenthesised(), body = statement(), belse; |