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:
- Identifiers (Identifiers are names given to different names given to entities such as constants, variables, structures, functions etc.)
- Keywords (C has 32 reserved keywords)
- Constants (Constants are like a variable, except that their value never changes during execution once defined)
- Strings (The string can be defined as the one-dimensional array of characters terminated by a null (‘\0’).
- Operators (C operators are symbols that are used to perform mathematical or logical manipulations like =,>=,+,/,* ….)
- Special Symbols
For example, the following C statement consists of five tokens −
printf(“Hello, World! \n”);
- “Hello, World! \n”
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.|