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
2 answers
50 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 ...
user avatar
  • 1,163
0 votes
2 answers
1k 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 <...
user avatar
  • 259
2 votes
1 answer
660 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, 8, ...
user avatar
-2 votes
3 answers
738 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 ...
user avatar
6 votes
2 answers
121 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: ...
user avatar
1 vote
1 answer
2k 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 ...
user avatar
3 votes
1 answer
1k 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 ...
user avatar
  • 133
3 votes
3 answers
1k 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 ...
user avatar
  • 143
1 vote
1 answer
1k 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 ...
user avatar
1 vote
1 answer
437 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 ...
user avatar
  • 1,163
3 votes
1 answer
286 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, ...
user avatar
  • 131
15 votes
2 answers
3k 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 non-...
user avatar
0 votes
2 answers
316 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 ...
user avatar
  • 103
3 votes
1 answer
4k 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?
user avatar
1 vote
1 answer
128 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 ...
user avatar
  • 11
-1 votes
1 answer
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 ...
user avatar
3 votes
2 answers
859 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 ...
user avatar
3 votes
1 answer
376 views

How to build a label flow graph for static analysis

I'm new to world of static analysis and am trying to build a new analysis of C programs for llvm compiler. I've started with the build of the graph of the constraints of the program: The edges ...
user avatar
0 votes
0 answers
362 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 ...
user avatar
  • 97
4 votes
3 answers
168 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 ...
user avatar
0 votes
1 answer
73 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 ...
user avatar
40 votes
8 answers
11k 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? ...
user avatar
16 votes
1 answer
5k 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 ...
user avatar
  • 2,477
0 votes
1 answer
78 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 research/notes/...
user avatar
2 votes
1 answer
196 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 ...
user avatar
  • 29.2k
9 votes
1 answer
354 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: ...
user avatar
2 votes
1 answer
168 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 ...
user avatar
2 votes
1 answer
2k 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?
user avatar
0 votes
2 answers
3k 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 aDx \...
user avatar
2 votes
2 answers
1k 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 ...
user avatar
  • 175
1 vote
2 answers
157 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?
user avatar
  • 165
1 vote
2 answers
103 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 ...
user avatar
0 votes
1 answer
598 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 inner-...
user avatar
4 votes
0 answers
59 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 evaluation ...
user avatar
  • 213
0 votes
0 answers
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 ...
user avatar
1 vote
2 answers
169 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 ...
user avatar
11 votes
4 answers
9k 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 ...
user avatar
  • 143
6 votes
1 answer
1k 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 ...
user avatar
2 votes
1 answer
52 views

Passing parameters to threads

in Programming language course my professor take an example. Suppose the following code: ...
user avatar
3 votes
2 answers
1k 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 ?
user avatar
0 votes
1 answer
4k 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 ...
user avatar
  • 421
9 votes
3 answers
971 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 ...
user avatar
7 votes
3 answers
194 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 ...
user avatar
  • 205
1 vote
3 answers
314 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 ...
user avatar
  • 129
5 votes
0 answers
984 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 ...
user avatar
  • 363
-1 votes
1 answer
291 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.
user avatar
  • 339
4 votes
2 answers
1k views

How are Signed integers different from unsigned integers once compiled

How are Signed integers different from unsigned integers once compiled? I already know about twos compliment and the like but my question is how can you tell the difference when looking at 8 bit ...
user avatar
2 votes
1 answer
1k views

Which hazards are solved by instruction reordering?

I am not clear on whether it's data and control hazards, or control hazards only. Also, the "solved" word confuses me - technically, instruction reordering is used to solve dependences and thus ...
user avatar
75 votes
9 answers
11k views

What properties of a programming language make compilation impossible?

Question: "Certain properties of a programming language may require that the only way to get the code written in it be executed is by interpretation. In other words, compilation to a native machine ...
user avatar
1 vote
0 answers
219 views

LALAR vs SLR Table for Given SLR Grammar

i'm so glad that ask my first question on my favorite site. Infact i ran into multiple choice question in recent exam on Compiler Course. Suppose T1, T2 is created with SLR(1) and LALR(1) for ...
user avatar

1
9
10
11 12 13