bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function of nexttoken()


From: Shigio YAMAGUCHI
Subject: Re: Function of nexttoken()
Date: Mon, 9 Mar 2015 11:48:40 +0900

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

2015-03-08 12:16 GMT+09:00 Abdillah Fa'iz Hernawan <address@hidden>:
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?
2. And surely, why we need a list of `const char`, "interested" chars?
What's the relation between interested chars and a token?

Well, I have observing the source, but not yet understand of it.

Thanks.

Note : Sorry, as I don't find any mailing list suitable for a question
like this, I use a bug-mail to sent this to.

_______________________________________________
Bug-global mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/bug-global



--
Shigio YAMAGUCHI <address@hidden>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3

reply via email to

[Prev in Thread] Current Thread [Next in Thread]