Playing around with tokenizers

Been playing around with Flex(http://flex.sourceforge.net/ ). It’s a Tokenizer (Lexical Analysis, http://en.wikipedia.org/wiki/Lexical_analysis ), ie, it splits strings into tokens to interpret them. You add a configuration file and get c-code (the „scanner“ – parser would be, at least looking at theoretical computer science), too much.

Closely related and often used in conjunction is Bison.exe (http://www.gnu.org/software/bison/manual/bison.html), a parser generator. It creates parsers from grammars and hurts my brain, a bit.

Well, in 90% of cases, I’m happy with a simple tokenizer. I use the class by vsczc in this stackoverflow thread: http://stackoverflow.com/questions/53849/how-do-i-tokenize-a-string-in-c

but it’s lacking one method, which is easy to figure out. 😉 (well, I like the code. It’s simple, easy to read and works for me.)


const std::string Tokenizer::GetToken() const
{
return m_token;
}

Advertisements

One comment

  1. […] Not macro-hacking (try macros. Please.) or something  trivial (textual replace..), but more powerful stuff. It started with config files, that is parser, parser generators, and so on. I’ve written that I’ve used some of the more popular ones. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: