retagged by
466 views
0 votes
0 votes
Set of all lexical error produced by compiler is regular or not. I think it is regular,beacuse it should be finite. Plz explain if anything else.
retagged by

2 Answers

Best answer
2 votes
2 votes
A lexical error corresponds to a particular state of the input token. We have only finite number of possible tokens. Even assuming a token can be of infinite length, to parse it we need only finite state in the automata required. And there should be a one to one correspondence between the number of possible errors and the state in the deterministic FA used for this. i.e., the number of possible lexical errors should be finite and hence regular. (I assume the error message does not output the already seen symbols - because this is already known as regular).
selected by
0 votes
0 votes

There are infinite possible scenarios of lexicals errors. A simple example would be an erroneous identifier. As you might already know an identifer should begin with a charachter followed by any number of charachters or digits. An identifier named as 00abc will not be accepted by any of the DFAs used for accepting tokens. And as you can see there are infinite erroneos ways to name an identifier.

Eg:

0abc,000ABC,11192ABC and so on.

So it is Not Regular.

edited by

Related questions

0 votes
0 votes
1 answer
1
Deepak9000 asked Nov 27, 2023
202 views
Why is C is regular as it non regular as?Please help me with this confusion
0 votes
0 votes
1 answer
2
M_Umair_Khan42900 asked Dec 29, 2022
754 views
Show that the following pairs of regular expressions define the same language over the alphabet I = [a, b].s(a) p(pp)*( A + p)q + q and p*q(b) A +0(0+1)* + (0+1)* 00(0+1)...
0 votes
0 votes
0 answers
4