Mercurial > hg > octave-lyh
comparison src/parse.y @ 3485:e5d5848370c9
[project @ 2000-01-28 02:07:35 by jwe]
author | jwe |
---|---|
date | Fri, 28 Jan 2000 02:07:38 +0000 |
parents | 8b1f46ac2b64 |
children | cbee5fbb696d |
comparison
equal
deleted
inserted
replaced
3484:8b1f46ac2b64 | 3485:e5d5848370c9 |
---|---|
183 | 183 |
184 // Build a while command. | 184 // Build a while command. |
185 static tree_command * | 185 static tree_command * |
186 make_while_command (token *while_tok, tree_expression *expr, | 186 make_while_command (token *while_tok, tree_expression *expr, |
187 tree_statement_list *body, token *end_tok); | 187 tree_statement_list *body, token *end_tok); |
188 | |
189 // Build a do-while command. | |
190 static tree_command * | |
191 make_do_while_command (token *do_tok, tree_statement_list *body, | |
192 tree_expression *expr); | |
193 | 188 |
194 // Build a do-until command. | 189 // Build a do-until command. |
195 static tree_command * | 190 static tree_command * |
196 make_do_until_command (token *do_tok, tree_statement_list *body, | 191 make_do_until_command (token *do_tok, tree_statement_list *body, |
197 tree_expression *expr); | 192 tree_expression *expr); |
957 loop_command : WHILE expression opt_sep opt_list END | 952 loop_command : WHILE expression opt_sep opt_list END |
958 { | 953 { |
959 if (! ($$ = make_while_command ($1, $2, $4, $5))) | 954 if (! ($$ = make_while_command ($1, $2, $4, $5))) |
960 ABORT_PARSE; | 955 ABORT_PARSE; |
961 } | 956 } |
962 | DO opt_sep opt_list WHILE expression | |
963 { | |
964 if (! ($$ = make_do_while_command ($1, $3, $5))) | |
965 ABORT_PARSE; | |
966 } | |
967 | DO opt_sep opt_list UNTIL expression | 957 | DO opt_sep opt_list UNTIL expression |
968 { | 958 { |
969 if (! ($$ = make_do_until_command ($1, $3, $5))) | 959 if (! ($$ = make_do_until_command ($1, $3, $5))) |
970 ABORT_PARSE; | 960 ABORT_PARSE; |
971 } | 961 } |
2086 int l = while_tok->line (); | 2076 int l = while_tok->line (); |
2087 int c = while_tok->column (); | 2077 int c = while_tok->column (); |
2088 | 2078 |
2089 retval = new tree_while_command (expr, body, l, c); | 2079 retval = new tree_while_command (expr, body, l, c); |
2090 } | 2080 } |
2091 | |
2092 return retval; | |
2093 } | |
2094 | |
2095 // Build a do-while command. | |
2096 | |
2097 static tree_command * | |
2098 make_do_while_command (token *do_tok, tree_statement_list *body, | |
2099 tree_expression *expr) | |
2100 { | |
2101 tree_command *retval = 0; | |
2102 | |
2103 maybe_warn_assign_as_truth_value (expr); | |
2104 | |
2105 // We have to do this because while can also be used to begin a loop. | |
2106 lexer_flags.looping -= 2; | |
2107 promptflag++; | |
2108 | |
2109 int l = do_tok->line (); | |
2110 int c = do_tok->column (); | |
2111 | |
2112 retval = new tree_do_while_command (expr, body, l, c); | |
2113 | 2081 |
2114 return retval; | 2082 return retval; |
2115 } | 2083 } |
2116 | 2084 |
2117 // Build a do-until command. | 2085 // Build a do-until command. |