]> ocean-lang.org Git - ocean/commitdiff
parsergen: avoid creating extra line in code blocks.
authorNeilBrown <neil@brown.name>
Sat, 20 Nov 2021 00:37:52 +0000 (11:37 +1100)
committerNeilBrown <neil@brown.name>
Sat, 20 Nov 2021 00:37:52 +0000 (11:37 +1100)
When performing coverage analysis, it is important that the line numbers
seen in the .c file are fairly accurate.
Currently we a lines to the end of a code block, and they appear to have
line numbers that correspond to whatever appears after the code block.
This is confusing.

So put all that extra code on the last line (matching the }$).
Also switch back to "gen_reduce" immediately after the code block.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani-tests.mdc
csrc/oceani.mdc
csrc/parsergen.mdc

index 7a408179378b67a59b15062e2ed0946eb417575f..1d7282da7f95babcfc8a342f48ff1748c19da9b4 100644 (file)
@@ -97,7 +97,7 @@ arguments separated from the name by commas.  For each test, there is a section
                ## valgrind test code
                @[ -n "$$SKIP_COVERAGE_CHECK" ] || awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
                    END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \
-                        if (ran < (ran + skip) *0.968) exit(1) }' \
+                        if (ran < (ran + skip) *0.973) exit(1) }' \
                        coverage/oceani.mdc.gcov
 
        coverage_oceani: oceani.c
index c2a19ce0c7744190c2fedba910f7205c851e83db..f41e8fd50f41b7902eadd965ac333b7d6b3abd38 100644 (file)
@@ -2346,7 +2346,7 @@ function will be needed.
                | ERROR ${ tok_err(c, "Syntax error in struct field", &$1); }$
 
        Field -> IDENTIFIER : Type = Expression ${ {
-                       int ok; // UNTESTED
+                       int ok;
 
                        $0 = calloc(1, sizeof(struct fieldlist));
                        $0->f.name = $1.txt;
@@ -2375,9 +2375,9 @@ function will be needed.
        static void structure_print_type(struct type *t, FILE *f);
 
 ###### value functions
-       static void structure_print_type(struct type *t, FILE *f)       // UNTESTED
-       {       // UNTESTED
-               int i;  // UNTESTED
+       static void structure_print_type(struct type *t, FILE *f)
+       {
+               int i;
 
                fprintf(f, "struct %.*s\n", t->name.len, t->name.txt);
 
@@ -2398,8 +2398,8 @@ function will be needed.
        }
 
 ###### print type decls
-       {       // UNTESTED
-               struct type *t; // UNTESTED
+       {
+               struct type *t;
                int target = -1;
 
                while (target != 0) {
index e6dcccbf34bc46f4bcca75dca9cb0d7f325d4d55..02abed32520c18dcaa1d677b81529f25ec040e03 100644 (file)
@@ -2284,17 +2284,17 @@ transformed, and will cause an error when the code is compiled.
                        }
                        c -= 1;
                }
-               fputs("\n", f);
                for (i = 0; i < p->body_size; i++) {
                        if (p->body[i]->struct_name.txt &&
                            used[i]) {
                                // assume this has been copied out
                                if (p->body[i]->isref)
-                                       fprintf(f, "\t\t*(void**)body[%d] = NULL;\n", i);
+                                       fprintf(f, "\t\t*(void**)body[%d] = NULL;", i);
                                else
-                                       fprintf(f, "\t\tmemset(body[%d], 0, sizeof(struct %.*s));\n", i, p->body[i]->struct_name.len, p->body[i]->struct_name.txt);
+                                       fprintf(f, "\t\tmemset(body[%d], 0, sizeof(struct %.*s));", i, p->body[i]->struct_name.len, p->body[i]->struct_name.txt);
                        }
                }
+               fputs("\n", f);
                free(used);
        }
 
@@ -2320,6 +2320,7 @@ transformed, and will cause an error when the code is compiled.
                        if (p->code.txt) {
                                fprintf(f, "#line %d \"%s\"\n", p->code_line, file);
                                gen_code(p, f, g);
+                               fprintf(f, "#line 7 \"gen_reduce\"\n");
                        }
 
                        if (p->head->struct_name.txt)