Search
lxdream.org :: lxdream/src/tools/gendec.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/tools/gendec.c
changeset 979:2cc7b486ea6c
prev969:3f178ca1398c
next1084:852412cf56e0
author nkeynes
date Wed Feb 04 00:58:54 2009 +0000 (11 years ago)
permissions -rw-r--r--
last change Emit #line directives in output to make debugging a little easier
file annotate diff log raw
1.1 --- a/src/tools/gendec.c Thu Jan 22 00:45:15 2009 +0000
1.2 +++ b/src/tools/gendec.c Wed Feb 04 00:58:54 2009 +0000
1.3 @@ -98,10 +98,10 @@
1.4 }
1.5 }
1.6
1.7 -static void fprint_indent( char *action, int depth, FILE *f )
1.8 +static void fprint_indent( const char *action, int depth, FILE *f )
1.9 {
1.10 int spaces = 0, needed = depth*8, i;
1.11 - char *text = action;
1.12 + const char *text = action;
1.13
1.14 /* Determine number of spaces in first line of input */
1.15 for( i=0; isspace(action[i]); i++ ) {
1.16 @@ -126,7 +126,7 @@
1.17 }
1.18 }
1.19
1.20 -static void fprint_action( struct rule *rule, char *action, int depth, FILE *f )
1.21 +static void fprint_action( struct rule *rule, const struct action *action, int depth, FILE *f )
1.22 {
1.23 int i;
1.24 if( action == NULL ) {
1.25 @@ -154,14 +154,15 @@
1.26 }
1.27 }
1.28 fputs( "\n", f );
1.29 - if( action[0] != '\0' ) {
1.30 - fprint_indent( action, depth, f );
1.31 + if( action->text && action->text[0] != '\0' ) {
1.32 + fprintf( f, "#line %d \"%s\"\n", action->lineno, action->filename );
1.33 + fprint_indent( action->text, depth, f );
1.34 }
1.35 fprintf( f, "%*c}\n", depth*8, ' ' );
1.36 }
1.37 }
1.38
1.39 -static void split_and_generate( struct ruleset *rules, char **actions,
1.40 +static void split_and_generate( struct ruleset *rules, const struct action *actions,
1.41 int ruleidx[], int rule_count, int input_mask,
1.42 int depth, FILE *f ) {
1.43 uint32_t mask;
1.44 @@ -170,7 +171,7 @@
1.45 if( rule_count == 0 ) {
1.46 fprintf( f, "%*cUNDEF(ir);\n", depth*8, ' ' );
1.47 } else if( rule_count == 1 ) {
1.48 - fprint_action( rules->rules[ruleidx[0]], actions[ruleidx[0]], depth, f );
1.49 + fprint_action( rules->rules[ruleidx[0]], &actions[ruleidx[0]], depth, f );
1.50 } else {
1.51
1.52 mask = find_mask(rules, ruleidx, rule_count, input_mask);
1.53 @@ -235,6 +236,7 @@
1.54 actiontoken_t token = action_file_next(af);
1.55 while( token->symbol != END ) {
1.56 if( token->symbol == TEXT ) {
1.57 + fprintf( out, "#line %d \"%s\"\n", token->lineno, token->filename );
1.58 fputs( token->text, out );
1.59 } else if( token->symbol == ERROR ) {
1.60 fprintf( stderr, "Error parsing action file" );
1.61 @@ -262,7 +264,7 @@
1.62 fputs( "%%\n", out );
1.63 for( i=0; i<rules->rule_count; i++ ) {
1.64 fprintf( out, "%s {: %s :}\n", rules->rules[i]->format,
1.65 - token->actions[i] == NULL ? "" : token->actions[i] );
1.66 + token->actions[i].text == NULL ? "" : token->actions[i].text );
1.67 }
1.68 fputs( "%%\n", out );
1.69 }
.