Solution required urgently

I have a problem to write a code in C/C++ that will count:
1.No. of tokens
2.No. of diff identifiers
3.No. of Blocked codes
4.No. of weighted blocked codes
in a C/C++/Java source code.I am confused a lot in this.. Plz sumbody mail me d solution.. my email id : kunal.shrivastav@gmail.com,kunal101_2006@yahoo.co.in.
ASAP.

We don't do people's homework for them.
But we do help people who have written some code and are stuck.
Or who have a problem and need suggestions on how to start.
Eitehr way we woudl need a lot more info on the problem from you.
I'm not the most eloquent guy myself, but ASAP sounds a little bit harsh in this context...
sorry guys... if i sounded harsh..bt its just i m stuck in it for quite sum time now..
i'be been able to do the BC and WBC count.
THe main prob is with counting tokens...i mean tken is everything in a source code... so m confused on how to think of a logic to count the number of tokens... even a punctuation is a token... i hav to use a file handling and open the source code and chech and count the number of tokens in it...
If u could just help me with the logic... i could try to implement it in d prog and den could ask abt it further
Hmm, well, if a token's class is identifiable by its initial letter (as is often the case with source code, for example, C and C++):
(isdigit(c) or (c == '.')) --> a number
(isalpha(c) or (c == '_')) --> an identifier or reserved word/keyword
ispunct(c) --> potential symbolic operator

then you can write yourself a little class that identifies itself as a specific kind of token and override the >> operator,

OR

you can write yourself a little function that reads tokens from a stream or string into a list or vector.

Hope this helps.

PS. You need to give it a go now. In the early stages of software development, it is not uncommon to try things a number of different ways to see which is best suited for the task.

[edit] I just saw your other post with the stack. I'll take a look at it and see what I can help you with... :-)
Last edited on
Topic archived. No new replies allowed.