The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+1 vote

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.

asked in Compiler Design by Boss (42.2k points) | 434 views


author is clearly saying "the use of identifier elipseSize" that means it detected as identifier already.

But I also don't have a good reason why it is a lexical error, but Lexical analyzer also use symbol table while processing and I think some DFA also, so maybe by the help of DFA it will recognize that something is a valid token or not and so misspell of id, keyword will become a lexical error.[not so sure]

Lexical Analyzer is not worried about the usage of tokens, its job is only to read source program character by character and if it matches a lexeme, then it creates a token and stores it in the symbol table.
You must find "How it matches lexeme to a pattern(description) to form a valid token?"
yes it reads the token charecter by charecter it doesnt care about anything else even if u have recorded it once as ellipsesize and next time there is a spelling mistake it makes a new entry for this new one so no lexical error
this is clearly a wrong definition. elipseSize and ellipseSize both are valid.

1 Answer

+1 vote
Compiler is all about impementation.

If an automata is already defined for your statement, then it will be counted as a valid token ,Otherwise it will show lexical error.

Here, mis-spelling of keywords or identifier means error while identifying lexemes(longest common sequence).
answered by (217 points)

Related questions

+3 votes
3 answers
asked Dec 15, 2016 in Compiler Design by prasitamukherjee Active (2.1k points) | 1.8k views

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

47,139 questions
51,388 answers
66,700 users