What is the output of a lexer for the following invalid C++ code?
x double = 5.0;
The c++ will give us an error, as the syntax of the code x double = 5.0 is wrong.
double will come before x as double is a data type and x is a variable, so it should be -> double x = 5.0
now, if we talk about lexer ->
Lexer tokenizes the stream to turn characters into tokens.
so, x double = 5.0 will be -->
x KEYWORD
double IDENT
= ASSIGN
5.0 DOUBLE
x becomes the keyword here, and double becomes variable, = is assignment operator and 5.0 is double value.
Get Answers For Free
Most questions answered within 1 hours.