Bjarne's Programming book questions

Alright so everything was going good and i had a decent understanding of everything until i reached ch6 where he introduces tokens. What exactly are tokens?I have searched everywhere and i cant seem to find an answer.
Which book? He has at least three books.

As for you question:
http://www.cppforschool.com/tutorial/basic.html

For a more reliable link, MSDN:
http://msdn.microsoft.com/en-us/library/3yx2xe3h.aspx
Programming principles and practice using c++. Didn't know he had three books. And i still dont really understand what a token is.
Yeah Bjarne has:
Tour of C++
Programming Principles and Practice Using C++
The C++ Programming Language

http://www.c4learn.com/cplusplus/cpp-identifiers-tokens/
http://en.wikipedia.org/wiki/Token_%28parser%29#Token


Tokens are basically all the things that make up a statement. Using the example from the wikipedia link:

sum = 2 + 3;

Tokenized and represented by the following table:

Lexeme	Token type
sum	Identifier
=	Assignment operator
3	Integer literal
+	Addition operator
2	Integer literal
;	End of statement


There is probably a better way to explain it, but I'm used to how the books and sites I linked you to explain it so I'm sorry that I'm not much help on that aspect.

[EDIT]
Don't know if this will help, but this is from The C++ Programming Language 4th Edition for the start of a calculator.

1
2
3
4
5
6
7
8
9
enum class Kind : char {
      name, number, end, plus='+', minus='-', mul='*',
      div='/', print=';', assign='=', lp='(', rp=')' };

struct Token{
      Kind kind;
      string string_value;
      double number_value;
};

Representing each token by the integer value of its character is convenient and efficient and can be a help to people using debuggers.
Last edited on
Ok. Thank you. I think i have a distinct idea of what a token is now. Also how long would it take to start making actual applications with gui or games?
Last edited on
Everyone has different opinions on that matter. I think once you have the basics (data types, variables, functions, pointers, references, classes/structs) you are good to jump into experimenting with gui or games because you can learn everything else as you go. Anything that you don't know by then you can always learn as you go.
You can take me for example - I've been learning and playing around with C++ for only a little over a month. As BHX Specter said, I just got the basics down and jumped straight into creating a card game. By now I've got most of its 'brain' code, working on graphics with Qt now, which I still struggle with, but it's a learning curve. And a lot of fun I might add.
What are all the basics i should know before i am able to create my own projects using just my own ideas? So far, i know the basics of input/output, conditional statements, and loops. Right now, im beginning on functions.
Last edited on
i/o, loops, conditional statements, functions, classes, structs, pointers, references should be enough to start on gui and games. You can learn the advanced things as you make games or gui apps.
alrighty. Gonna stop asking questions and start typing up some code. Thank you all.
Topic archived. No new replies allowed.