LintCode
You can see a C lexer built on typescript here!
Input Code
#include <stdio.h>
int main() {
printf("hello world!");
return 0;
}
Output Tokens
[
[
"OPERATOR",
"#"
],
[
"IDENTIFIER",
"include"
],
[
"OPERATOR",
"<"
],
[
"IDENTIFIER",
"stdio"
],
[
"OPERATOR",
"."
],
[
"IDENTIFIER",
"h"
],
[
"OPERATOR",
">"
],
[
"KEYWORD",
"int"
],
[
"IDENTIFIER",
"main"
],
[
"OPERATOR",
"("
],
[
"OPERATOR",
")"
],
[
"OPERATOR",
"{"
],
[
"IDENTIFIER",
"printf"
],
[
"OPERATOR",
"("
],
[
"STRING",
"hello world!"
],
[
"OPERATOR",
")"
],
[
"OPERATOR",
";"
],
[
"IDENTIFIER",
"return"
],
[
"NUMBER",
"0"
],
[
"OPERATOR",
";"
],
[
"OPERATOR",
"}"
]
]