Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

0
votes
0answers
19 views

Alternatives to phi nodes in static single assignment

I have read somewhere about an alternative SSA representation that doesn't use phi nodes but instead uses parameterized basic blocks. Something like this in an SSA with phi: ...
-2
votes
0answers
17 views

What is syntax directed translation?

Syntax directed translation consists of attributes and syntax translation. Please describe further about it.
0
votes
0answers
14 views

Counting number of control flow path

I know the answer that it will be 1024(2^10). But iam not able to understand why, I have looked the answer but still don't find it compelling My reason, it says ten if are there in the language and ...
0
votes
1answer
28 views

Counting tokens in compilers, lexical analyser

Let's start with the question. Say I have a C language statements follows it 458cat 2.01 = 96.87abc a.2 ; -my question is how many tokens are there in the above statements. Secondly does white ...
1
vote
1answer
33 views

What is handle in bottom up LR parsing?

I was taking course on compilers by Alex Aiken. You can find the slide discussing handles on this page. On the page of the slide, the instructor defines handle as follows: Assume a rightmost ...
4
votes
1answer
144 views

How to generate branch tables from SSA form?

Branch tables are usually described as an efficient way a compiler can implement a switch statement, and that actually seems how GCC and Clang do it (and LLVM even has an opcode just for that). If a ...
1
vote
1answer
79 views

Why I can't parse factorial? [closed]

Given that I have a simplified Bison BNF grammar: ...
0
votes
0answers
28 views

A problem with understanding handles

This is the definition of a handle: 1.A “handle” of a string is a substring that matches the RHS of a production. And 2.Whose reduction to the non-terminal (on the LHS of the production) represents ...
0
votes
3answers
68 views

Is it 100% OK to say “All software doesn't need to know the system lower than the architecture level”?

Most of you know this diagram. If this diagram is true, all software is free to not know the levels lower than ISA. But it's not true. Softwares like performance-critical programs or system softwares ...
5
votes
1answer
149 views

How to transpile generic functions into language that do not support generics?

Currently, I am developing a transpiler for my own language, however, I find difficulties to transpile generic functions. For example, how would you translate the following Java-like code in to C? <...
0
votes
1answer
54 views

Compilation speed dependent on CPU?

Is the speed of compiling software very dependent on the CPU? I know this question is a bit broad, but I'm to find an answer to the case described below. If I download a software project that makes ...
2
votes
1answer
17 views

Unclear logic notation for PFX program rules

I'm very new to this so please bear with me. I found this document describing the PFX language, a stack-oriented language where the instructions act on a stack and replace the arguments with the ...
1
vote
2answers
406 views

Difference between dynamic loading and dynamic linking in the OS

First of all, I saw many answers of this topic in Quora, Stackoverflow, and this site. But, I couldn't definitely understand the difference between dynamic loading and dynamic linking. What I ...
0
votes
0answers
22 views

Translation from Intermediate Language into 'three-address' machine instructions

I am unsure where to start with this. From what I understand so far, 'VAR(x)' corresponds to Rule 2, ':= VAR(x) ' refers to Rule 5 and '+ NUM (1) refers to link 3. ...
0
votes
0answers
13 views

Do you have any SDD(syntax directed defenition) practice example?

I follow Compilers Principle, Technique and Tools by Alfred V.Aho. I learnt SDD from this book. But, I don't get enough example or practice problem to check how my learning stage is. I also search ...
2
votes
1answer
80 views

Assertion of Type Inference Rules/Type Checking

I have a problem in a book I am trying to accomplish. I understand the overall type of the expression is boolean and how it derives. (y * x) will be rule 4 (counting from top right). (y * x) + x when ...
0
votes
0answers
38 views

High Level Assemblers vs Compilers?

I'm reading the "Art of Assembly" 2nd Edition by Randall Hyde. In the book the author seems uses his own language called High Level Assembly (HLA). Coming from a C Background, I question how useful ...
3
votes
2answers
89 views

Why can't a compiler create universal N-bit code (e.g. 32-bit, 64-bit, etc.)

It is my understanding from what I have read that you need to compile separate executables for 32 bit and 64 bit machines. So if I compile a C program for example I need to compile 2 different ...
0
votes
1answer
25 views

Can we use Operator precedence parsing with this grammar?

This Grammar: A-->Bbab|aa B-->b I think we can't because basically there is no relation between terminals? like no relation between a and b! or am i missing something? and the language of this ...
1
vote
1answer
72 views

Why use a CFG instead of a DFG

I just realized a Control-Flow Graph (CFG) is composed of basic blocks, which is a set of instructions. It is mentioned that you can still do stuff like dead code elimination and whatnot, with the CFG,...
0
votes
0answers
65 views

What token does a “peek” operation refer to in Lexical analysis?

Given a grammar for a space delimited list of words: S -> word { space word } word -> [a-zA-Z]+ space -> [ \t]+ And given the input "Hello World", ...
2
votes
1answer
27 views

Extended grammar form (backus-naur) and simple grammar forms equivalence

Square braces around a grammar symbol or symbols denote that these constructs are optional. Thus, production A -> X[Y]Z has the same effect as the two productions A -> XYZ and A -> XZ. Curly braces ...
0
votes
1answer
222 views

CFG With unambiguous if-else statement

I am writting a small compiler for a compilers' class. The algorithm is having a shift/reduce conflict when I try to enclose if-else with braces '{', '}'. The non-ambiguous if-else statement I took ...
1
vote
1answer
104 views

What is the usage of CYK algorithm in the real world considering we have algorithms with a much better Time complexity?

So considering CYK is O(n^3) and since we can just use LR(k) algorithms for DCFG's which they can check if a string is in the language in O(n) then whats the usage of CYK? is it being used anywhere? ...
0
votes
2answers
35 views

Definition of InLeft and InRight

So in reading I have come across the terms "InLeft" and "InRight" and I am unable to find a concrete definition for it. I have found it used in the specification for COQ, and in some notes on ...
3
votes
1answer
99 views

Is there a name for this tree traversal?

This came when I was looking at block scoping in compiler design. { A { B } { C {D} {E} } } For the above pseudo code, the order in which the scope ...
1
vote
0answers
81 views

Can a YACC parse an ambiguous grammar

I found a question while studying compilers :- Given a grammar E->E+E/E×E/number The above grammar is fed to a YACC with semantic rules for parsing. What will be the action of the YACC. 1) it ...
0
votes
0answers
15 views

When is local and when global register allocation used

I am reading about register allocation performed by the compiler and I cannot understand what are the benefits/necessities of one over the other? In terms of local register allocation algorithms, I ...
0
votes
0answers
52 views

Calculation of Gen and Kill set for data flow analys

I'm currently preparing for an exam in compiler construction. The course is mainly about optimization in the backend of the compiler. For the optimization we have to do data flow analysis by hand. In ...
3
votes
2answers
82 views

Is it possible to tell if two sequences of assembly instructions are semantically equivalent?

In a modern instruction set like x86-64 there are many many many ways to accomplish the same task using a series of old simple instructions all the way up to the complex SIMD instructions. If one ...
2
votes
1answer
86 views

Why doesn't the C/C++ compilers create different tokens for different types of numbers?

Based on GeeksforGeeks and many other sites, the C/C++ compilers will create the same token for float/int etc. However if we ...
0
votes
0answers
17 views

Difference between local and global instruction scheduling

I am still unaware why would I use global scheduling for the instructions over the local one. From what I know, the difference between the two is, that the local scheduling is performed in the basic ...
2
votes
1answer
76 views

Why is it better to do the data flow analysis in the basic blocks

I have been reading about compilers and it is said that doing the data flow analysis in the basic blocks is more optimal. Sadly, quoting the exact source, would be slightly hard as it is not in ...
4
votes
1answer
65 views

SAT Solver Front-End: Strategy to order Quantifiers

I am working on a small project. The goal is to implement a compiler from a quite simple, custom syntax of logical formulae (including variables over finite domains) to conjunctive normal form (CNF). ...
2
votes
3answers
38 views

Automatic softcore configuration based on intermediate representation (IR) compiler output

When compiling a piece of software (with LLVM for exmple), you first transform your code into some kind of intermediate representation (IR code). This IR code needs to be converted to your target ...
0
votes
1answer
23 views

Saving information from reaching definition

I am learning about compilers at the moment and in my textbook it is briefly mentioned that UD/DU (Use-Def, Def-Use Chains) a way of saving information from the reaching definition is. It is just said ...
1
vote
1answer
52 views

Coalescing by register allocation

I have a rough idea of what coalescing in terms of memory access by threads is, but now, when learning about compilers, the term coalescing also appears when talking about register allocation. In my ...
1
vote
1answer
29 views

Thompson Regular Expression Search Algorithm 3rd Stage

My professor assigned us to read Thompson' Regular Expression Search Algorithm paper. I am struggling to understand the third stage of the compiler. The first two stages are as follows: Check that ...
1
vote
1answer
65 views

CFG - Left factoring in recursive nested productions

I'm attempting to convert a CFG into an LL(1) grammar for predictive parsing in a compiler. I've been able to left factor and eliminate left recursion and ambiguity for every case in the grammar, with ...
0
votes
1answer
66 views

Big-O complexity of finding exception handler for zero-cost exceptions

I am wondering what the time complexity of finding the most appropriate exception handler for dispatching zero-cost exceptions is. For zero-cost (this refers to execution under the assumption that no ...
1
vote
3answers
291 views

Dangling else problem

I was reading a book about compiler design, then in the CFG section, they introduced the dangling-else problem. They offered to match the the else with the last <...
0
votes
0answers
31 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 ...
3
votes
1answer
87 views

interference graph: assigning variable to itself

I'm studying the theory behind compiler design, and was assigned with building an Interference graph for a certain code 3-address code. We were taught to first divide the code into blocks (according ...
0
votes
0answers
13 views

what Modifications done to the symbol table by each of the compiler phases?

i have been reading about parsing and semantic analysis phases but I am confused about the modifications each phase does to the symbol table can anyone brief me about what modifications each phase in ...
1
vote
1answer
61 views

can every LR(k) grammer be transformed to LR(1)

when i was studying compilers i came across this in Wikipedia every DCFL has a corresponding unambiguous grammar and hence can be parsed by an LR(1) parser which is the most powerful parser then what ...
0
votes
0answers
72 views

How do we evaluate semantic actions in L attributed SDT?

I came across following problem: $S→ER$ $R→∗E\{print(′∗′);\}R∣ε$ $E→F+E\{print(′+′);\}∣F$ $F→(S)∣id\{print(id.value);\}$ Here $id$ is a token that represents an integer and $id.value$ ...
0
votes
1answer
59 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 ...
1
vote
2answers
69 views

Dynamic list for frame pointers and static list of nested activation frames

I am going through the book Compiler Construction by Niklaus Wirth. The following is what I feel to be stated summarily by his lesson on procedure calls: The compilation of a procedure call is the ...
3
votes
1answer
97 views

In describing the tokens of a programming language using RE, it is not necessary to have the $\epsilon$ or t. Why is this?

In describing the tokens of a programming language using regular expressions, it is not necessary to have the $\epsilon$, (for the empty set) or t (for the empty string). Why is this? Please tell me ...
1
vote
0answers
35 views

Variable assignment in which compiler phase

If I have a statement int a=5, in which phase will symbol table be updated with value of a (which is 5) ? Different websites have different answers to it. In some of the websites it is written that ...