Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

Token, Compiler and Interpreter C Tutorial

Token, Compiler and Interpreter C Tutorial

Token :  A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.

C language Supports Six Types of Tokens:

  1. Identifiers (Identifiers are names given to different names given to entities such as constants, variables, structures, functions etc.)
  2. Keywords (C has 32 reserved keywords)
  3. Constants (Constants are like a variable, except that their value never changes during execution once defined)
  4. Strings (The string can be defined as the one-dimensional array of characters terminated by a null (‘\0’).
  5. Operators (C operators are symbols that are used to perform mathematical or logical manipulations like =,>=,+,/,* ….)
  6. Special Symbols

For example, the following C statement consists of five tokens −

printf(“Hello, World! \n”);

  1. printf
  2. (
  3. “Hello, World! \n”
  4. )
  5. ;

Compiler :  A computer program which converts a program written in high level language (Source Language) to low level language (Object/Target/Machine Language).

Interpreter :  In computer science, an interpreter is a computer program that directly executes, i.e. performs, instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program.

The difference between an interpreter and a compiler

Translates program one statement at a time.Scans the entire program and translates it as a whole into machine code.
It takes less amount of time to analyze the source code but the overall execution time is slower.It takes large amount of time to analyze the source code but the overall execution time is comparatively faster.
No intermediate object code is generated, hence are memory efficient.Generates intermediate object code which further requires linking, hence requires more memory.
Continues translating the program until the first error is met, in which case it stops. Hence debugging is easy.It generates the error message only after scanning the whole program. Hence debugging is comparatively hard.
Programming language like Python, Ruby, Java use interpreters.Programming language like C, C++, Java use compilers.


0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments

This is an awesome post. Really very informative and creative contents. This concept is a good way to enhance knowledge. I like it and help me to development very well. Thank you for this brief explanation and very nice information. Well, got good knowledge.