Computer Science, asked by ppsingh7653, 1 year ago

Difference between lexical phase error and syntactic phase error in compiler

Answers

Answered by Tushar161
0
Both declarations are invalid, so you are rightfully confused, but for different reasons:

A lexical error occurs when the compiler does not recognize a sequence of characters as a proper lexical token. 2ab is not a valid C token. (Note that 2ab is a valid C preprocessing token that can be used in token pasting macros, but this seems beyond your current skill level).

A syntax error occurs when a sequence of tokens does not match a C construction: statement, expression, preprocessing directive...int 2; is a syntax error because a type starts a definition and a number is not an expected token in such a context: an identifier or possibly a *, a (, a specifier or a qualifier is expected.

Note that qualifiers and type or storage specifiers can appear in pretty much any order in C declarations:




please mark me as branelist
Similar questions