bifcl: Keep zeekygen comments close to their definitions

The Yacc grammar treats comments like other whitespace and when seeing
the first definition in a file would previously emit all whitespace
before emitting the `export` section containing the definition. This
lead to the first definition being separated from their zeekygen
documention (separated by `export {`).

With this patch we start the export section before emitting whitespace.
While this might now pull more "whitespace" into the exported part, it
avoids breaking the association between zeekygen comments and
definitions.

Closes #15.
This commit is contained in:
Benjamin Bannier 2022-09-25 22:28:54 +02:00 committed by Tim Wojtulewicz
parent e080c5c6b2
commit 09d3268740

View file

@ -327,8 +327,8 @@ definitions: definitions definition opt_ws
} }
| opt_ws | opt_ws
{ {
fprintf(fp_zeek_init, "%s", $1);
fprintf(fp_zeek_init, "export {\n"); fprintf(fp_zeek_init, "export {\n");
fprintf(fp_zeek_init, "%s", $1);
} }
; ;