Questions tagged [compilers]

Questions about programs that read code in one language (source language) and translate it into an equivalent program in another language (target language).

Filter by
Sorted by
Tagged with
0
votes
0answers
131 views

Can inherited attibutes be evaluated in bottom up parsing?

I have come across the following question in an exam: Can inherited attributes be evaluated in bottom-up parsing? My approach went like this: Inherited attributes can never be evaluated in ...
0
votes
1answer
470 views

Not getting the clear picture of Goto actions , reduce and shift actions in SLR Parsing

I am going through the following lecture notes on LR parsing : https://www3.nd.edu/~dthain/courses/cse40243/fall2016/chapter4b.pdf For the following grammar : The following LR automation has been ...
0
votes
1answer
90 views

Do we need regular expression first or finite state automata in lexical anlysing? [closed]

I'm a bit confused about the concept of finite state automata (FSA) and regular expression (RE) in lexical analysis. I have reading some books about compiler construction. At the part of tokenization, ...
0
votes
0answers
89 views

Motivation behind the computational way of language translation

As I am going through learning about compilation , what I see is the approach to the subject through machines , known as automata , which change from one state to another depending on the input ...
0
votes
0answers
641 views

Intermediate code generation and three address code

I have a Compiler Design course this semester but unfortunately the professor teaching this course have some issues with text book which is ...
0
votes
1answer
10k views

LL(1) parsing table construction

i have the following CFG E -> ABC A-> a|Cb|epsilon B-> c|xA|epsilon C-> y|z and the First of the Non-Terminal : ...
0
votes
0answers
20 views

Is XSL-Transformation a type of compiling? [duplicate]

I am currently working on a paper based on the topic of creating a source-to-source compiler from an existing application to C#. The existing application is actually just based on XML files, which ...
0
votes
0answers
273 views

What is the difference between Moore's algorithm and partition refinement algorithm for DFA minimization?

Both the algorithms use the partition method to minimize the DFA. I cannot understand the difference between them. Can someone give an example where we can see the difference between them.
0
votes
0answers
36 views

What semantical is there in attribute grammars?

I've been reading about attribute grammars since I'm trying to extend CFGs to semantics. What I'm finding difficult to grasp is the use of the word "semantics" in the context of attribute ...
0
votes
0answers
74 views

How to get 2-LOOKAHEAD results in this grammar?

G: S -> bRS | RcSa | @(epsilon) R -> acR | b .... 2-LOOKAHEAD(S->@) = {$,a,aa} 2-LOOKAHEAD(R->b) = {b,ba,bb,bc} I don't understand a result of these ...
0
votes
0answers
355 views

How to generate intermediate code in more than 1 pass in compiler design?

I'm taking a compiler-design class where we have to implement our own compiler (using flex and bison). In dragon book by V.Aho et al. They have mentioned backpatching to backpatch forward references ...
0
votes
0answers
32 views

How to create a context-free grammar? [duplicate]

I am learning compilers and I am troubled by how to create the context-free grammar of a language. Is there a method I can follow to create the context-free grammar for most language ? I'm new to this ...
0
votes
1answer
329 views

How does a Single Pass Compiler does parsing,analyzing and generating code all at once?

I would like to know how a single pass compiler does parsing,analyzing and generating code all at once as said in P.14 of SIngle Pass Compilers.Is it possible to do all these at once since you can't ...
0
votes
2answers
111 views

Which Type of Grammar is this?

I am learning Compiler Design. Can somebody explain what type of Grammar this is? The answer given is $LL(1)$ but there exists a left recursion in the grammar so it cannot be $LL(1)$. I derived the ...
0
votes
1answer
626 views

Construct SLR Parse table problems

Consider the augmented grammar G is: S` -> S S -> a S -> (T) T -> T,S T -> S I have tried to construct parse table. But, when I read '(' ...
-1
votes
1answer
70 views

How to find FOLLOW for variables which has next value ε

Its very easy to find FIRST in compiler design. Im finding difficult to find follow , suppose if we have one variable(say B) then we need to search the variable in the whole question .If there was a ...
-1
votes
1answer
4k views

Convert RE to DFA [duplicate]

I've been trying to convert a regular expression to a non-deterministic finite automata (NFA) first using Thompson's construction, giving: , which looks correct. I am then using subset construction ...
-1
votes
2answers
183 views

Are there any educational virtual machines?

There is plenty of machine/assembly languages such as LC-3, DLX, etc. designed for educational purposes. I am looking for an educational VM, by VM I mean stack virtual machine that has instructions ...
-1
votes
1answer
872 views

What is the time complexity of LR parsers?

Bottom up parsers in worst case take O($n^3$) time, and i believe that LR parser being a bottom up parser should also take O($n^3$) time, but i read on wiki that they are able to solve problems in ...
-1
votes
1answer
43 views

Is it safe to assume that there would be no high level languages without existence of compilers/interpreters?

I am relatively new to computer science. There,s been something that i have been thinking now that i am studying how to make actual compilers. We are past the days of programming with binary and ...
-1
votes
1answer
148 views

Does checking for correctness belong predominantly to "semantic analysis"?

Does checking for correctness belong predominantly to "semantic analysis"? Or is it reasonable to be done in earlier phases (in a compiler like construction) as well? Mainly in syntax ...
-1
votes
1answer
34 views

Compilers: how to find first and follow sets?

I sort of know how to solve the problem but I am not sure how to do it in a systematic way. Could someone provide a step-by-step solution especially for the follow set one? Thanks!
-1
votes
1answer
287 views

c compiler source code for compiler construction [closed]

Could anyone tell me from where could I get the c compiler source code.In particular the lexical analyzer for c.I searched the web but no links show how a compiler is defined.
-1
votes
1answer
47 views

Syntax checking expressed mathematically

1) Set B is the finite set of all rules for a particular programming language. 2) Set A is the infinite set of all valid strings of that language and is defined by Set B. I'm having a problem ...
-1
votes
1answer
25 views

Identify the type of the grammar

I have found the following question from internet. They have even given the answer as option c. But i am confused because the grammar also does not looks like a Regular. Please help me to understand ...
-1
votes
2answers
514 views

Find the Unambiguous Grammar [closed]

Consider the following grammar: S->A. A->A+A|B++. B->y Check whether grammar is Ambiguous or not? Also ,unambiguate the grammar.Now please tell me what will be the grammar after removing the ...
-1
votes
2answers
8k views

In a bottom-up evaluation of a syntax directed definition, inherited attributes can

In a bottom-up evaluation of a syntax directed definition, inherited attributes can always be evaluated be evaluated only if the definition is L-attributed be evaluated only if the definition has ...
-2
votes
3answers
729 views

Is badly written code derogatory to the compiler?

I was having a heated debate with a friend of mine (who considers me an idiot, mind you) and we were arguing about whether a compiler has an index, or coefficient, that judges how poorly code is ...
-2
votes
1answer
37 views

Computing FIRST and FOLLOW

Given the following grammar with terminals $VT=\{[,],a,b,c,+,-\}:$ $S \rightarrow [SX]|a$ $X \rightarrow +SY|Yb|\epsilon$ $Y \rightarrow -SXc|\epsilon$ This should be the FIRST function: $first(S) =...

1
8 9 10 11
12