-
Notifications
You must be signed in to change notification settings - Fork 56
Number of Tokens
Ori Roth edited this page Apr 2, 2017
·
3 revisions
The Number of Tokens (NOT) is a complexity metrics, computed is defined as the total number of language lexical tokens that are in the unit. For example, consider this famous starter program of the C programming language:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
The program comprises of the following tokens: 2 identifiers (printf
and main
, one string literal ("Hello, World!\n") and one integer literal (0), two keywords (int
and return
), two semicolons, two pairs of parentheses and one pair of curly brackets. The total token complexity of the program is therefore 14 (ignoring pre-processor directives).
Spartan programming dictates that software unit should be simplified to as to minimize their token count complexity, while suggesting specific techniques for doing so, including:
- Curly brackets elimination
- Parentheses elimination