3 # Copyright © 2021 Nick Bowler
5 # Generate a function to return the C keyword corresponding to a specifier
6 # type as a string, for internal use by the output routines.
8 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
9 # This is free software: you are free to do what the fuck you want to.
10 # There is NO WARRANTY, to the extent permitted by law.
15 print " * Automatically generated by gen-specstr.awk from " FILENAME
17 print " * Automatically generated by gen-specstr.awk"
19 print " * Do not edit."
24 kinds["TYPE"] = kinds["STOR"] = kinds["QUAL"] = kinds["FUNC"] = 1
25 underscore["BOOL"] = underscore["COMPLEX"] = underscore["IMAGINARY"] = 1
29 sub(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ_].*/, "", $1)
32 if (parts[2] in kinds) {
33 if (parts[3] == "IDENT") {
35 } else if (parts[3] in underscore) {
36 s = "_" substr(parts[3], 1, 1) tolower(substr(parts[3], 2))
45 print "static inline const char *spec_string(unsigned type)\n{"
46 print "\tswitch (type) {"
49 print "\tcase " s ": return \"" specs[s] "\";"
53 print "\n\tassert(0);"