Hi,
> I was exploring gnu global source code and find that it is
> `nexttoken()` function which mostly essential.
> I wonder a few question on it,
> 1. What the definition of token is?
Token means a word or other atomic parse element.
For example, the following statement has 5 tokens.
while ( valxxx ) {
===== = ====== = =
1 2 3 4 5
> 2. And surely, why we need a list of `const char`, "interested" chars?
By default, nexttoken() returns every special character as a token.
However, GLOBAL's parsers have almost no interest in such character.
So, we can use 'interested' array to pick up special characters in which
we are interested. Nexttoken() returns only characters which belong to
the array. If you are interested in only '@' and '#', and are not interested
in other characters then you should write code like follows:
while ((c = nexttoken("@#", c_reserved_word)) != EOF) {
switch (c) {
case '@':
...
break;
case '#':
...
break;
...
default:
break;
}
Thank you for your reading such dirty code.
Good luck!
Shigio