Reputation: 1207
For a simple C
program like :
#include<stdio.h>
int main(){
int first,second,sum;
first = 10;
second = 20;
sum = first + second;
printf("%d\n",sum);
}
what will be the output after the first phase of compiler which is Lexcial Analysis ?
Upvotes: 2
Views: 209
Reputation: 310907
There is no output. The first phase may be lexical analysis but that doesn't mean it is an entire distinct pass with an output which forms the input to the next stage. The parser calls the lexical analyser via function calls.
Upvotes: 1
Reputation: 179422
Lexical analysis produces a stream of tokens. Ignoring the preprocessor for now, the output would be something like
KEYWORD int
IDENTIFIER main
LPAREN
RPAREN
LBRACE
KEYWORD int
IDENTIFIER first
COMMA
...
Obviously, the actual output is dependent on your compiler.
Upvotes: 4