in Compiler Design retagged by
1,070 views
2 votes
2 votes
I came across few Compiler Design Doubts, Please provide your cent.

$Q_1 :$ Can lexical analyser detect some/any type of errors?

I think yes, because while scanning to identify tokens, it may be the cases that a string pattern doesn't match with any keyword (or) entry in symbol table and gives error. But a detailed explaination will be appreciated.

$Q_2:$ In which phase of compilation Scope Checking happens? I guess sematic analyser, but I have no valid explaination

$Q_3: \color{navy}{A \rightarrow Aa}$ (Left linear) $\color{navy}{A \rightarrow aA}$(Right Linear). What can be said about $\color{navy}{A \rightarrow aAb}$
in Compiler Design retagged by
by
1.1k views

4 Comments

yes above grammar both left and right-recursive.
0
0

linear grammar is a context-free grammar that has at most one nonterminal in the right hand side of each of its productions

0
0
There is also left recursion in this grammar.
0
0

1 Answer

5 votes
5 votes

Can lexical analyser detect some type of errors?
Yes it is True. Lexical Analyser detect lex error.

Can lexical analyser detect any type of errors?
No, it cant detect syntax or semantic error.

In which phase of compilation Scope Checking happens?
Semantic Analyser. Generally type checking takes place when output is coming out. It is possible onl if there is no lex and no syntax error. (http://www.cs.virginia.edu/kim/courses/cs471/lec/cs471-11-semantic.pdf)

A→Aa (Left linear),  A→aA (Right Linear).
 A→aAb it is CFG

1 comment

I read in some pdf that semantic checking can also take place in two phase syntax analyser. Is it true?
Who detects following error : {} 0+0 else if enum a = 4[]+3[] + *1 - 4;
0
0

Related questions