retagged by
1,394 views

2 Answers

0 votes
0 votes

@Mohit Aggarwal

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....

A syntax error occurs when a sequence of tokens does not match a C construction: statement, expression, preprocessing directive....

 

1. https://gateoverflow.in/250038/Lexical-vs-syntax-error 

 

2. https://www.techtud.com/doubt/lexical-error-or-syntax-error

 

  3. https://gateoverflow.in/201833/Lexical-syntax-and-semantic-error 

 

4. https://stackoverflow.com/questions/34834926/difference-between-lexical-and-syntax-error 

 

5. https://gateoverflow.in/165048/Lexical-error

 

 

0 votes
0 votes
A lexical error can be error which is encountered by lexical analyser at the time of scanning the stream of tokens.

Whereas the syntactical error is related to validity of the tokens (whether the generated tokens are valid keywords or not).

 

Correct me if I’m wrong ;)

Related questions

12 votes
12 votes
5 answers
1
Shubhanshu asked Jan 31, 2018
7,191 views
int main() { int 1a, b; Printf("\nGate 2018"); Printf("%d",x); }How many types of error are there in this code?
6 votes
6 votes
7 answers
2
Na462 asked Oct 5, 2018
3,499 views
7 votes
7 votes
4 answers
3
itsvkp1 asked Nov 1, 2017
3,266 views
if there is miss spelling in some keyword in a program then this misspelled keyword will be treated as lexical errors or it will be treated as a new identifier and accept...
2 votes
2 votes
1 answer
4
Manu Thakur asked Sep 26, 2017
1,568 views
This screenshot is token from the book Ullman,How can following be a lexical error? because "elipseSize" should have a token recorded as an identifier.