scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit dae1b4a5808e4853b8907af3bfd0de54a56693ea
parent 635c6920665bc0ebcda4f15d85c1f3a56c476b29
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 21 Sep 2017 09:00:14 +0100

[cc2] Simplifies the error generation script

Diffstat:
cc2/generror.awk | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/cc2/generror.awk b/cc2/generror.awk @@ -1,11 +1,9 @@ -BEGIN { - print "char *errlist[] = {" -} -/^enum nerrors \{/ {inhome = 1} +/^enum nerrors \{/ {print "char *errlist[] = {"; inhome = 1} + inhome && /E[A-Z]*, / {sub(/,/, "", $1) printf("\t[%s] = \"", $1) - for (i = 3; i < NF-1; ++i) - printf("%s ", $i) - printf("%s\",\n", $(NF-1));} -inhome && /^}/ {print "};" ; inhome = 0} + for (i = 3; i <= NF-1; ++i) + printf("%s%s", $i, (i == NF-1) ? "\"" : " ") + print ","} +inhome && /^}/ {print "};" ; inhome = 0}