-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathpretty_loop.c
More file actions
51 lines (40 loc) · 1.18 KB
/
pretty_loop.c
File metadata and controls
51 lines (40 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/** \file pretty_loop.c
* split out of exppp.c 9/21/13
*/
#include <express/variable.h>
#include <express/dict.h>
#include <exppp/exppp.h>
#include "pp.h"
#include "pretty_expr.h"
#include "pretty_stmt.h"
#include "pretty_loop.h"
void LOOPout( struct Loop_ *loop, int level ) {
Variable v;
raw( "%*sREPEAT", level, "" );
/* increment */
/* if (loop->scope->u.incr) {*/
if( loop->scope ) {
DictionaryEntry de;
DICTdo_init( loop->scope->symbol_table, &de );
v = ( Variable )DICTdo( &de );
wrap( " %s := ", v->name->symbol.name );
EXPR_out( loop->scope->u.incr->init, 0 );
wrap( " TO " );
EXPR_out( loop->scope->u.incr->end, 0 );
wrap( " BY " ); /* parser always forces a "by" expr */
EXPR_out( loop->scope->u.incr->increment, 0 );
}
/* while */
if( loop->while_expr ) {
wrap( " WHILE " );
EXPR_out( loop->while_expr, 0 );
}
/* until */
if( loop->until_expr ) {
wrap( " UNTIL " );
EXPR_out( loop->until_expr, 0 );
}
raw( ";\n" );
STMTlist_out( loop->statements, level + exppp_nesting_indent );
raw( "%*sEND_REPEAT;\n", level, "" );
}