element_types.awk 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright 2014, 2015 Free Software Foundation, Inc.
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License,
  6. # or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. #
  16. BEGIN {
  17. print "/* This file automatically generated by element_types.awk */"
  18. print "enum element_type {"
  19. print "ET_NONE,"
  20. }
  21. !/^$/ && !/^#/ {
  22. print "ET_" $1 ","
  23. array = array "\"" $1 "\",\n"
  24. }
  25. END {
  26. print "};"
  27. print
  28. print "extern char *element_type_names[];"
  29. print "char *element_type_names[] = {" > "element_types.c"
  30. print "0," > "element_types.c"
  31. print array > "element_types.c"
  32. print "};" > "element_types.c"
  33. }
  34. function output_array (string)
  35. {
  36. print string > "element_types.c"
  37. }