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

learn more… | top users | synonyms

1
vote
1answer
17 views

How profiling is done in trace scheduling?

I'm trying to understand how trace scheduling works. The book that I'm reading, Engineering a Compiler by Keith D. Cooper & Linda Torczon, states that this method is using profiling. Profiling ...
6
votes
2answers
121 views

Eliminate non-local references from closure

For a code similarity detection framework I need to eliminate references to non-local variables, for example having the following closure: ...
2
votes
2answers
19 views

What are transitive successor and transitive predecessor in the graph?

I'm reading a book on compilers, Engineering a Compiler, 2nd ed. by Keith D. Cooper & Linda Torczon and I came a across two new terms that I can't understand, they are: transitive successor ...
0
votes
2answers
27 views

Unable to understand a definition of an instruction in a compiler schedule [closed]

Recently I've accepted a job offer to work on compiler design. To be properly prepared I've decided to review the material. The book that is being used for that is Cooper and Torczon's Engineering a ...
1
vote
2answers
18 views

Number of operations performed in increment operators [closed]

How many operations are performed in the following in order to get a running time function of an algorithm: x = x + 1 x += 1 ...
1
vote
1answer
64 views

Parse DAG into task tree

Suppose we have a DAG of tasks: Arrows represent flow (reversed dependencies: 8 must be run after 7). Some of the tasks (like 4, 5, 6) can be run in parallel (Par block). Dependent tasks (like 7, ...
-3
votes
3answers
167 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
0answers
12 views

Program transformations for numeric stability

There's tons of research on program transformations for optimization. Is there any research on transformations that improve numeric stability? Examples of such transformations might include: ...
1
vote
1answer
35 views

Converting Regular expression to DFA by building syntax tree

There is a way to convert regular expression to DFA (deterministic finite automata) which is to build a syntax tree and then compute first pos, last pos, follow pos, and then use a Transition ...
3
votes
1answer
70 views

Help in understanding the implementation/application of scope trees

I’m learning (self-taught) about language implementation and compiler design, and I’m implementing a toy language to cement the concepts in my mind. However, I’m having trouble understanding how scope ...
1
vote
3answers
77 views

What techniques can I use to hand-write a parser for an ambiguous grammar?

I'm writing a compiler, and I've built a recursive-descent parser to handle the syntax analysis. I'd like to enhance the type system to support functions as a valid variable type, but I'm building a ...
0
votes
1answer
52 views

Computing FIRST and FOLLOW sets

Suppose we have the following grammar: S -> A ( S ) B | ε A -> S | S B | x | ε B -> S B | y where S is the start ...
-1
votes
1answer
54 views

Why the given lexical specification will not process the following strings?

I'm taking a Compiler MOOC on my own time. The class is self paced. An answer was given to a question but I can't understand the answer. In fact I'm not even sure how to interpret the question. Here ...
3
votes
1answer
42 views

Top-down typing strategy - is there a name for this?

In most statically typed languages, each expression has an intrinsic type. E.g. in Java, 3 is an int, 3.0 is a double, ...
3
votes
1answer
55 views

Removing left-recursion in grammar while maintaining left-association of operator

I have a problem with this exercise: Let G be the following ambiguous grammar for the λ-calculus: E → v | λv.E | EE | (E) where E is the single ...
0
votes
2answers
35 views

Why doesn't my object code/machine code contain 1's and 0's

I know when I compile my C program to machine code it gets compiled into something that specific computer can understand But I thought computers can only understand 1's and 0's (high/low) so why ...
-1
votes
1answer
29 views

What are GEN and KILL statements in dataflow analysis?

In data flow analysis, is GEN statement where a variable is used and KILL statement is where variable is redefined?
0
votes
0answers
12 views

Assigning one variable to another in 3 address code?

3 address code is a very common topic in many of the CS theories. I encountered it while studying Compiler Design. According to the wikipedia article, it says - "Each TAC instruction has at most three ...
-2
votes
1answer
107 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 ...
2
votes
2answers
157 views

Automatic translation between formal languages

There are parser generators (some of which are limited to certain classes of grammars) which, given a grammar, automatically generate a parser for that grammar. Would it be possible to make a ...
0
votes
0answers
49 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 ...
3
votes
2answers
46 views

What does it mean to be “closed” under beta reduction?

I am reading the paper Compiling with Continuations, Continued, and in section 2.4, Comparison with ANF, the author draws attention to the fact that ANF is not closed under beta reduction. The snippet ...
0
votes
1answer
34 views

New Assembler in compiler [closed]

I'm currently developing my degree thesis, and the lab's idea is to design a new micro architecture, and then, be able to compile stuff for this architecture. So the question is, how do you instruct a ...
22
votes
8answers
3k views

What determines the “speed” of a programming language?

Suppose a program was written in two distinct languages, let them be language X and language Y, if their compilers generate the same byte code, why I should use language X instead of the language Y? ...
9
votes
1answer
255 views

Why separate lexing and parsing?

It's possible to parse a document using a single pass from a state machine. What is the benefit of having two passes, ie. having a lexer to convert text to tokens, and having a parser to test ...
0
votes
1answer
45 views

LL(k) Prediction Techniques (and Insight on method applied)

I'm requesting references for LL(k) in situations where k > 1 for reasons described below. I'm looking for ...
2
votes
1answer
38 views

Monotone Frameworks: Transfer functions for flow edges instead of labels

So, in generic program analysis, we have a lattice $L$ with a join operation $\sqcup$, program with statements labelled, and for each label $b$, a transfer function $F_b : L \rightarrow L$. The goal ...
7
votes
1answer
95 views

What is a non-contrived example of static type-checking being too conservative?

In Concepts in Programming Languages, John Mitchell writes that static type checking is necessarily conservative (overly strict) because of the Halting Problem. He gives as an example: ...
1
vote
1answer
46 views

Three-address code versus JSON, XML, etc

I'm working on a compiler. The textbooks I have say to output a 3-address intermediate code. This can be translated into the target language of choice. I don't have a problem with the bulk of the ...
0
votes
0answers
38 views

Which kind of intermediate representation ensures maximum portability?

I'm very new to compilers. When building a compiler for a new language, which Intermediate Representation should I choose so as to achieve maximum possible portability across ...
1
vote
1answer
99 views

Why we use context-free grammar for parsing?

Why we use context-free grammar for parsing? Why not regular expression and not context-sensitive grammar?
0
votes
2answers
117 views

Computing FOLLOW sets for LL(1) grammar. Stuck on question

Calculate the FOLLOW sets for all the non terminals: $S \rightarrow bEx \mid Db \mid b \mid F$ $D \rightarrow EDc \mid Y$ $E \rightarrow dED \mid dDY$ $Y \rightarrow ab \mid ...
2
votes
2answers
124 views

What do I need to study in order to understand and design a programming language? [closed]

What do I need to read in in order to : understand the specs of an already made programming language Design a programming language Design a compiler and assembler for that language make an ...
1
vote
2answers
89 views

Min-Max number of shifts and reductions in bottom-up parser [closed]

Given the Grammar has no unit or ɛ-productions, What is minimum & maximum number of shifts and reduce needed by bottom-up parser?
1
vote
2answers
51 views

How can this grammar parse such an input?

I've an example which I simply don't get at all. Implement an attributed grammar that checks that either the word ends in $b$ or each prefix of the word contains at least as many $b$s ...
0
votes
1answer
72 views

Conversion from assembly program to low-level machine language

While studying COMPILER-DESIGN through an online book from Google Books, referenced as Compiler Design by A.A.Puntambekar, I got stuck across a line. Actually, I am more curious to know the ...
4
votes
0answers
31 views

Substituting “remaining variables” during partial evaluation?

In "Partial Evaluation of Computation Process—An Approach to a Compiler-Compiler" Yoshihiko Futamura wrote: "[Some] portions of a computation process [...] are not evaluated at partial ...
0
votes
0answers
17 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 ...
1
vote
2answers
66 views

Is it possible to write an HTML compiler with no mutable state?

That's probably a vague question but allow me to try and give an example: My compiler does transformations on HTML (from HTML to HTML). It scans a flattened DOM tree, and relies on lookbehinds (on ...
3
votes
2answers
402 views

Recursive descent parser with backtracking for the grammar $S \rightarrow aSa\ |\ aa$

Can someone enlighten me why a recursive descent parser with backtracking that tries the productions $S \rightarrow aSa$ and $S \rightarrow aa$ (in that order) does not recognize the language formed ...
0
votes
0answers
17 views

While writing out the cores (to make parsing table) for SLR(1) and CLR(1) grammars why do we write lookaheads for only CLR?

I mean both SLR(1) and CLR(1) can look 1 symbol ahead. Why do we consider that lookahead only in CLR and not in SLR while drawing cores to make the table
4
votes
1answer
498 views

Is CYK still relevant today?

I've come across the CYK algorithm and was wondering, as it's quite old, if it is still relevant today. Is it or an extension of it still being used in compilers (for example), or have other ...
1
vote
1answer
46 views

Passing parameters to threads

in Programming language course my professor take an example. Suppose the following code: ...
3
votes
3answers
452 views

is there any hardware device to convert source code into machine language? [closed]

Is there any hardware device inside computer that helps to convert high level language into machine, like compiler and assembler ?
-1
votes
1answer
102 views

What are activation records?

What are the open activation records of a recursive algorithm ? Edit: Activation records are the number of times that we call a function that is not finished yet. Correct? So we can find the number ...
2
votes
0answers
46 views

Equivalence of data-flow analysis, abstract interpretation and type inference?

@Babou's answer to a recent question reminds me that at one time I think I read a paper about the equivalence (in terms both of the facts that can be inferred or proved and the time complexity of ...
4
votes
3answers
70 views

Is there a technique for statically checking that a function is only called at a particular rate?

I was reading this article about types, and started wondering how static type checkers could enforce other properties in programs. For example, say I wanted to create a language which would allow ...
1
vote
3answers
225 views

Should compilers automatically translate operations into shortcuts?

There are several coding operations that (I suspect) most compilers will change into more efficient operations at the assembly or machine code level. I have several questions about whether or not the ...
5
votes
0answers
134 views

Convert source code from one language to an other? [closed]

Say I have a full application written in Python. Is it feasible to convert the source code into C? If such a tool doesn't exist, why doesn't it? What are the constraints? I ask this since I have been ...
-1
votes
1answer
45 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.