mkkeywords 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. # Generate a keywords.txt for the library that is suitable for the Arduino IDE.
  3. # Expects to run from the top directory of the library.
  4. # Set the locale for sorting
  5. export LC_ALL=C
  6. cat << EndOfTextEndOfTextEndOfText
  7. #########################################
  8. # Syntax Coloring Map For IRremoteESP8266
  9. #########################################
  10. ################################################
  11. # WARNING: Do NOT edit this file directly.
  12. # It is generated by 'tools/mkkeywords'
  13. # e.g. tools/mkkeywords > keywords.txt
  14. ################################################
  15. #######################################################
  16. # The Arduino IDE requires the use of a tab separator
  17. # between the name and identifier. Without this tab the
  18. # keyword is not highlighted.
  19. #
  20. # Reference: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keywords
  21. #######################################################
  22. #######################################
  23. # Datatypes & Classes (KEYWORD1)
  24. #######################################
  25. EndOfTextEndOfTextEndOfText
  26. CLASSES=$(grep "^class " src/*.h | cut -d' ' -f2 | sort -u)
  27. # Manually add typedefs as they are hard to parse out.
  28. CLASSES="${CLASSES} ir_params_t match_result_t"
  29. for i in ${CLASSES}; do
  30. echo -e "${i}\tKEYWORD1"
  31. done | sort -du
  32. cat << EndOfTextEndOfTextEndOfText
  33. #######################################
  34. # Methods and Functions (KEYWORD2)
  35. #######################################
  36. EndOfTextEndOfTextEndOfText
  37. METHODS=$(egrep "^(u?int|void|bool|String|static|match_result_t).*\(" src/*.cpp|
  38. cut -d' ' -f2- | sed 's/^.*:://' | cut -d'(' -f1 | sort -u |
  39. grep -v ICACHE_RAM_ATTR)
  40. for i in ${METHODS}; do
  41. echo -e "${i}\tKEYWORD2"
  42. done | sort -u
  43. cat << EndOfTextEndOfTextEndOfText
  44. #######################################
  45. # Constants (LITERAL1)
  46. #######################################
  47. EndOfTextEndOfTextEndOfText
  48. LITERALS=$(grep "^#define [A-Z]" src/*.cpp src/*.h |
  49. while read ignore define ignore; do
  50. echo ${define};
  51. done | sort -u |
  52. grep -v [\(\)] | grep -v ^_ | grep -v _\$ | grep -v VIRTUAL)
  53. CONSTS=$(grep "^const " src/*.cpp src/*.h |
  54. sed 's/\[.*\] =.*//;s/ =.*//;s/^.* k/k/')
  55. ENUMS=$(cat src/*.h | while read a b; do
  56. if [[ ${a} == "};" ]]; then
  57. ENUM=0;
  58. fi;
  59. if [[ ${ENUM} -eq 1 ]]; then
  60. echo $a | sed 's/,//g';
  61. fi;
  62. if [[ ${a} == "enum" ]]; then
  63. ENUM=1;
  64. fi;
  65. done)
  66. for i in ${LITERALS} ${CONSTS} ${ENUMS}; do
  67. echo -e "${i}\tLITERAL1"
  68. done | sort -u