Tokens In C Language.

922 views 1 minutes read
A+A-
Reset

The smallest parts of program which are recognized as atomic unit by compiler during parsing are tokens. All a C program contain is bunch of tokens. Each and Individual words and punctuation marks are called tokens which are also called lexical units. Similarly, the smallest individual unit in a c program is known as a token or a lexical unit. C tokens can be of following types:

  1. Keywords
  2. Identifiers
  3. Operators
  4. Constants
  5. Special Symbols(punctuators)
  6. Strings

Every thing in a c program are tokens. Lets do anatomy of following code.

int fact(int n){
if(n <=1){
return 1;
}
else {
return n * fact(n-1);
}

You Might Be Interested In
  • int, if, else, return :- Keywords
  • fact, n :- Identifiers
  • (, {, ;, ), } :- symbol, punctuation
  • <=, *, – :- Operators
  • 1 :- Constant

In this way compiler recognize each token from a program.

Related Posts

Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.