]> git.draconx.ca Git - cdecl99.git/blobdiff - src/gen-specstr.awk
libcdecl: Use macros for packing tokens into bytes.
[cdecl99.git] / src / gen-specstr.awk
index 68316676714f371a1ec6cba97e9c31a349dc9ea8..c9148f80c22a95efbfed807fb063f52da9f463f0 100755 (executable)
@@ -22,7 +22,7 @@ END {
 
 BEGIN {
   kinds["TYPE"] = kinds["STOR"] = kinds["QUAL"] = kinds["FUNC"] = 1;
-  count = maxwidth = 0;
+  count = 0;
 }
 
 # Locate all the relevant identifiers in cdecl.h.  We assume everything
@@ -48,9 +48,6 @@ $1 ~ /^CDECL_/ {
   if (parts[2] in kinds) {
     kind_counts[parts[2]]++;
     specs[count++] = parts[3];
-
-    if (length(parts[3]) > maxwidth)
-      maxwidth = length(parts[3]);
   }
 }
 
@@ -79,7 +76,7 @@ END {
     if (specs[i] == "IDENT")
       s = "0";
     else
-      s = "T_" substr(specs[i] "                ", 1, maxwidth) " & 0xff";
+      s = "PACK_TOKEN(T_" specs[i] ")";
     offset_table = offset_table s suffix;
   }
 
@@ -93,8 +90,6 @@ END {
   print "\tassert(x < sizeof idx);";
   print "\tif (!(x = idx[x]))";
   print "\t\treturn \"\";";
-  print "\tif (T_" specs[0] " >= 256)";
-  print "\t\tx += 256;";
-  print "\treturn cdecl__token_name(x);";
+  print "\treturn cdecl__token_name(UNPACK_TOKEN(x));";
   print "}";
 }