]> git.draconx.ca Git - cdecl99.git/blobdiff - test/gen-typegen.awk
Rename "test" directory to "t".
[cdecl99.git] / test / gen-typegen.awk
diff --git a/test/gen-typegen.awk b/test/gen-typegen.awk
deleted file mode 100755 (executable)
index 0ae20f5..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/awk -f
-#
-# Copyright © 2021 Nick Bowler
-#
-# Generate a mapping from a (random) integer to a list of type specifiers
-# represented by struct cdecl_declspec.  Used internally by declgen to
-# produce random valid declarations.
-#
-# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
-# This is free software: you are free to do what the fuck you want to.
-# There is NO WARRANTY, to the extent permitted by law.
-
-END {
-  print "/*"
-  if (FILENAME) {
-    print " * Automatically generated by gen-typegen.awk from " FILENAME
-  } else {
-    print " * Automatically generated by gen-typegen.awk"
-  }
-  print " * Do not edit."
-  print " */"
-}
-
-BEGIN {
-  count = 0
-}
-
-$0 ~ /^[abcdefghijklmnopqrstuvwxyz_]/ {
-  for (i = 1; i <= NF; i++) {
-    sub(/_/, "", $i)
-    $i = "CDECL_TYPE_" toupper($i)
-  }
-  specs[count++] = $0
-}
-
-END {
-  print "static inline struct cdecl_declspec *"
-  print "gen_raw_typespec_(unsigned type, struct cdecl_declspec *next)\n{"
-  print "\tstruct cdecl_declspec *s = malloc_nofail(sizeof *s);"
-  print "\t*s = (struct cdecl_declspec) { .next = next, .type = type };"
-  print "\treturn s;\n}\n"
-
-  print "static inline struct cdecl_declspec *"
-  print "gen_raw_typespecs(unsigned rngval)\n{"
-  print "\tswitch (rngval) {"
-
-  for (i = 0; i < count; i++) {
-    print "\tcase " i ":"
-    $0 = specs[i]
-
-    for (j = 1; j <= NF; j++) {
-      prefix = j == 1 ? "return" : "";
-
-      printf "\t\t%6s gen_raw_typespec_(%s,\n", prefix, $j
-    }
-    printf "\t\t%25sNULL%.*s;\n", "", NF, "))))))))"
-  }
-  print "\tdefault:\n\t\tassert(0);\n\t}"
-  print "}\n"
-  print "enum { GEN_TOTAL_TYPES = " count " };"
-}