Skip to content

Commit

Permalink
tweaks the grammar to handle empty files (#18)
Browse files Browse the repository at this point in the history
also adds a tests to prevent regressions.
  • Loading branch information
ivg authored May 4, 2021
1 parent 0524ecd commit d7c9ae5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontc/cparser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,11 @@ AND_EQ PIPE_EQ CIRC_EQ INF_INF_EQ SUP_SUP_EQ

%%

interpret: file EOF {$1};
interpret: file {$1};

file: globals EOF {List.rev $1};
file:
| EOF {[]}
| globals EOF {List.rev $1};

globals:
| global {[$1]}
Expand Down
Empty file added test.t/empty.c
Empty file.
9 changes: 9 additions & 0 deletions test.t/run.t
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
$ ../printc/printc_bin.exe empty.c


$ ../printc/printc_bin.exe volatile.c

typedef int const t1;
Expand Down Expand Up @@ -32,6 +35,8 @@





$ ../printc/printc_bin.exe for.c

void main()
Expand All @@ -53,6 +58,8 @@





$ ../printc/printc_bin.exe from.c

void main()
Expand Down Expand Up @@ -85,6 +92,8 @@





$ ../printc/printc_bin.exe okp.c

typedef int j_decompress_ptr, boolean, my_main_ptr, j_decompress_ptr, size_t,
Expand Down

0 comments on commit d7c9ae5

Please sign in to comment.