Guest User

Untitled

a guest
Oct 17th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. COMMENT_STYLE="\x1b[37;2m"
  4. KEYWORD_STYLE="\x1b[33;1m"
  5. TYPES_STYLE="\x1b[36;6m"
  6. STRING_STYLE="\x1b[32;6m"
  7. NUMBER_STYLE="\x1b[32;6m"
  8. RST="\x1b[0m"
  9.  
  10. COMMENT_REGEX="/\\*(.|[\\n\\r])*?\\*/|//.*|^\\#include\\s+[\\<\"].*?[\\>\"]$|^\\#define .*$"
  11. KEYWORD_REGEX="\\b(attribute|const|goto|case|break|continue|do|for|while|if|else|bool|true|false|struct|reinterpret_cast|static_cast|NULL)\\b"
  12. TYPES_REGEX="\\b(int|float|double|bool|u?int[0-9]{2}_t|char|void|byte)\\b"
  13. STRING_REGEX="\".+?\""
  14. NUMBER_REGEX="\\b(0x[A-Za-z0-9]+?|[0-9]+)\\b"
  15.  
  16. sed -E "s#$NUMBER_REGEX#$NUMBER_STYLE\0$RST#g" | \
  17. sed -E "s#$KEYWORD_REGEX#$KEYWORD_STYLE\0$RST#g" | \
  18. sed -E "s#$TYPES_REGEX#$TYPES_STYLE\0$RST#g" | \
  19. sed -E "s#$COMMENT_REGEX#$COMMENT_STYLE\0$RST#g" | \
  20. sed -E "s#$STRING_REGEX#$STRING_STYLE\0$RST#g"
Add Comment
Please, Sign In to add comment