Skip to content

Instantly share code, notes, and snippets.

@elbeno
Created October 29, 2025 17:44
Show Gist options
  • Save elbeno/8180c41646c1a77378e2ab9655293533 to your computer and use it in GitHub Desktop.
Save elbeno/8180c41646c1a77378e2ab9655293533 to your computer and use it in GitHub Desktop.
Count C++ keywords
#!/bin/bash
keywords=("alignas" "alignof" "asm" "auto" "break" "case" "catch" "class" "concept" "const" "consteval" "constexpr" "constinit" "continue" "decltype" "default" "delete" "do" "else" "enum" "explicit" "for" "friend" "goto" "if" "inline" "final" "mutable" "namespace" "noexcept" "operator" "override" "private" "protected" "public" "requires" "return" "sizeof" "static" "static"_"assert" "struct" "switch" "template" "this" "thread_local" "throw" "try" "typedef" "typeid" "typename" "union" "using" "virtual" "volatile" "while")
for k in "${keywords[@]}"
do
git grep -c -i "\b$k\b" include/*.hpp | cut -d':' -f2 | awk -v kw="$k" '{sum += $1} END {printf "%s %d\n", kw, sum}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment