This blog is under construction

Thursday, 26 December 2013

What is a c token?

What is a token in c language?
Token is the basic fundamental unit that makes up C source code after pre-processing.  

What are the various c tokens?
There are five types of C tokens.  They are
1. keywords
2. identifiers
3. constants
4. operators
5. separators

Identifiers:
Identifiers are nothing but name of the variable, function, macros or enums.  Name of an identifier can be formed using alphabets, numbers, underscore(_) and dollar($).  Please note that name of identifier starting with number is not allowed in C programming language

Keywords:
Its a set of words in C programming language which cannot be used as identifiers and they are reserved by programming language itself to perform specific operation.

Constants:
Any unchanged numeric, character, real value or string is a constant.

Operators:
It is a token which can be used to perform operation like arithmetic, logical, comparison, increment, decrement, bitwise etc.

Separators:
Separators used to separate tokens.

  C Tokens   Examples                         
Keywords auto, do, while, for, struct, break etc
Identifiers num, val, file_name etc
Constants 0x10, 3.14, 'c', "string" etc
Operators +, -, *, / etc
Separators ;  :  ,  .  (  )  [  ]  {  } etc



No comments:

Post a Comment