edited by
602 views

3 Answers

2 votes
2 votes
The main aim of Lexical is to identify token .  each lexeme in source language , it will be categorized into token class .

The following are well known token class 1. Opening braces 2. Closing braces 3. Identifier  4.Keywords 5.Digits 6.Other ( including punctuation marks and all )

now each lexeme is taken and it is matched using a pattern specified for a token class

Remember that white spaces tab etc are used as a seperator . Just like in English lang , these spaces help us to identify words from sentences  . The same thing is applied here

So according to me 'Int ---- Keyword

 a--- identifier

= ---- operator

a--- identifier  

now space is there it mean it was end of one token and begining of other token '

so 10 --- digit

I think its a lexical

And we shouldnt talk about semantic , we will get error at syntax phase only
0 votes
0 votes
In my opinion can int a=a 10 is a lexical why because. There are 3 different types of lexical errors are there. one is 1. unmatched string. So there is no unmatched string 2. illegal character. So there is no illegal character. 3. Exceeding the length of the identifier. There is no such thing here. But can is not derived. But in the lexical phase we are not considering the meaning. We are just evaluating the tokens here. So the given input is lexical.
0 votes
0 votes

int a=a 10 lexical error ,because

after the letter ' a' (rightside) space is there but l(l+d)* this is variable declaration .lettter followed by letter or digit but not any thing in middle

Related questions

0 votes
0 votes
2 answers
1
Mohit Aggarwal asked Dec 1, 2021
1,330 views
what is the difference between lexical error and syntax error?
4 votes
4 votes
2 answers
4
jatin khachane 1 asked Nov 23, 2018
1,211 views
int main() { int a,b; a=10; b=15; printf("a=%d,b=%d",a++,b ); }The number of tokens in the above C program is_________.I am getting 30The answer given is 29