Tokens



A token is the smallest element of a program that is meaningful to the compiler. In Java, there are five categories of tokens: identifiers, keywords, literals, operators, and separators

Identifiers

Identifiers are tokens that represent names. These names can be assigned to variables, methods, and classes to uniquely identify them.

Different programming languages have different rules about the use of Identifiers. In C/C++, all identifiers are case sensitive (i.e.. temp and Temp are not the same). Identifiers must begin with a letter. You can include numbers in an identifier but not as the first character. In addition, identifiers cannot have any spaces in them (i.e.. Celsius Temp is invalid).


Keywords

Keywords are predefined identifiers reserved by languages for a specific purpose and are used only in a limited, specified manner. You cannot use keywords for any other purpose. Listed below are Keywords reserved by the C++ language.
 



Literals

Literals are character constants that have a special meaning in a language. Listed below are several literals used in C++.


Operators

Operators specify an evaluation or computation to be performed on data. Indicated below are several operators and their meaning as used in C++.


Separators

Separators are used to inform the compiler of how things are grouped in the code. Listed below are examples of  separators supported by C++.

 

    {    }    ;


Comments and Whitespaces

All comments written within the source code of a program are ignored. To notify the compiler that the text is in fact a comment, several symbols are used. These symbols are indicated below.


Last Updated Jan.8/99