English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to write a scanner for ASCII files. The scanner should recognize (find) three kinds of tokens in the input file. strings of spaces, single new lines, and words (a word is defined to be any sequence of characters not including any spaces or new lines.

The driver should repeatedly call a function called getToken(). getToken reads the next token in the input file, and return to main the token type, the actual string (lexeme) of the token.

For each call to getToken() (for each token returned), main outputs the token type (a unique integer is OK to represent the type), the string (except for new lines – this causes visual problems on the screen) main also outputs the position in the input file for each token: the line number and the char position on the line of the beginning of the token.

The ifstream.get() function within getToken() should read characters one at a time from the input. getToken() will collect them until it has what it needs to return the next token.

??

2006-09-28 13:15:07 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

How would i write this program?

Apparently, regex is out of the question, as it does not come standard with the C++ library. I've been researching the problem all day and can't figure it out!

C++ is apparently not my strong point. :-(

Although specific code would be extraordinarily helpful (and would likely be rewarded with a humble offering of 10 Yahoo! points :-D), even a step-by-step of the logic would be greatly appreciated.

2006-09-28 13:31:34 · update #1

(I apologize for not stating my question in the original message-- I ran out of characters before I could finish)

2006-09-28 13:32:46 · update #2

1 answers

You didnt list a question at all.

2006-09-28 13:21:31 · answer #1 · answered by D 4 · 0 0

fedest.com, questions and answers