Closed xu-zhiwei closed 2 years ago
For example, if I have a C code snippet:
int main() { int i = 0; return 0; }
How to tokenize this code snippet and get the result like:
['int', 'main', '(', ')', 'int', 'i', '=', '0', ';', 'return', '0', ';', '}']
Use the CLexer class from https://github.com/eliben/pycparser/blob/master/pycparser/c_lexer.py#L15
CLexer
You can use the tests as inspiration: https://github.com/eliben/pycparser/blob/master/tests/test_c_lexer.py
For example, if I have a C code snippet:
How to tokenize this code snippet and get the result like:
['int', 'main', '(', ')', 'int', 'i', '=', '0', ';', 'return', '0', ';', '}']