[antlr-interest] Newbie ANTLR C++

Thierry Miceli tmiceli at sympatico.ca
Wed Oct 6 15:58:02 PDT 2004


 
>But at any rate, my question is to know how I would take each token I 
>scan and put it into an array. My problem is is that
>getText() returns a string, and in C/C++ there's no string datatype.

Wrong, there is a 'string' type that is part of the STL (standard template
library) that should come with your C++ compiler.

> How do I get around this problem?

This way:

std::string tokenText = token->getText();

If you want to store token text in an array, it is better to use a vector
object.

// Definition of the vector of strings object std::vector< std::string >
tokenTexts;

// Add a token text string at the end of the vector tokenTexts.push_back(
token->getText() );

For more take the time to read a good C++ manual.


Cheers,

Thierry
www.ideat-solutions.com



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list