Do you see any counter-indication to a token extractor in the
following form?
typedef int token;
token ExtractToken(co nst char** String, char* Symbol);
If it finds a valid token at the start of *String, it copies it into
Symbol (unless Symbol==NULL, in which case it doesn't copy it
anywhere); it makes *String point to the first character *after* the
token, and returns a token identificator (0 if no valid token found).
Of course, there is also a function
void CreateToken(con st char* Symbol, token Id);
to add tokens to the set.
The only other function I know of that behaves like this (as the
char** is concerned) is strtol(), which can change a pointer to point
to the first character after the number parsed.
by LjL
ljlbox@tiscali. it
following form?
typedef int token;
token ExtractToken(co nst char** String, char* Symbol);
If it finds a valid token at the start of *String, it copies it into
Symbol (unless Symbol==NULL, in which case it doesn't copy it
anywhere); it makes *String point to the first character *after* the
token, and returns a token identificator (0 if no valid token found).
Of course, there is also a function
void CreateToken(con st char* Symbol, token Id);
to add tokens to the set.
The only other function I know of that behaves like this (as the
char** is concerned) is strtol(), which can change a pointer to point
to the first character after the number parsed.
by LjL
ljlbox@tiscali. it
Comment