forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpretty_rule.c
More file actions
58 lines (49 loc) · 1.22 KB
/
pretty_rule.c
File metadata and controls
58 lines (49 loc) · 1.22 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
52
53
54
55
56
57
58
/** \file pretty_rule.c
* split out of exppp.c 9/21/13
*/
#include "pp.h"
#include "exppp.h"
#include "pretty_alg.h"
#include "pretty_stmt.h"
#include "pretty_where.h"
#include "pretty_rule.h"
char * RULEto_string( Rule r ) {
if( prep_string() ) {
return placeholder;
}
RULE_out( r, 0 );
return ( finish_string() );
}
/** return length of buffer used */
int RULEto_buffer( Rule e, char * buffer, int length ) {
if( prep_buffer( buffer, length ) ) {
return -1;
}
RULE_out( e, 0 );
return( finish_buffer() );
}
void RULEout( Rule r ) {
prep_file();
RULE_out( r, 0 );
finish_file();
}
void RULE_out( Rule r, int level ) {
int i = 0;
first_newline();
exppp_ref_info( &r->symbol );
raw( "%*sRULE %s FOR ( ", level, "", r->symbol.name );
LISTdo( r->u.rule->parameters, p, Variable )
i++;
if( i != 1 ) {
raw( ", " );
}
wrap( p->name->symbol.name );
LISTod;
raw( " );\n" );
ALGscope_out( r, level + exppp_nesting_indent );
STMTlist_out( r->u.rule->body, level + exppp_nesting_indent );
raw( "\n" );
WHERE_out( RULEget_where( r ), level );
raw( "\n%*sEND_RULE;", level, "" );
tail_comment( r->symbol.name );
}