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

-4
votes
0answers
25 views

Build a recursive descent parser for a given grammar

Write a recursive descent parser for the following grammar: ...
1
vote
2answers
45 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 ...
1
vote
1answer
27 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 ...
33
votes
7answers
6k 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 ...
0
votes
0answers
47 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 ...
2
votes
1answer
81 views

Why multiple return values is not a common thing?

I would like to ask a question about multiple return values, why this construct is not preferrable in programming languages (conceptual and/or technical difficulties). I've heard something about stack ...
3
votes
2answers
64 views

Is it possible to go from code to circuit?

I am wondering if it is possible to have a program that interprets programming code and is capable of turning that code into an optimized circuit. Is this possible, and if so, does it exist?
-1
votes
1answer
54 views

What are the tradeoffs in compiler development effort related to CISC vs. RISC?

What advantages and disadvantages does a CISC instruction set have relative to a RISC instruction set with respect to the ease of developing a functioning compiler and the ease of developing a highly ...
2
votes
2answers
44 views

Lexing and parsing a language with juxtaposition as an operator

Normal human math notation treats juxtaposition as implied multiplication, e.g., $2x$ means $2$ multiplied by $x$. This does not seem to be a common feature of computer languages, although it was, for ...
6
votes
1answer
69 views

Tag-free garbage collection for object oriented languages

I'm looking around for a good garbage collection technique for my language and found this paper, where Benjamin Goldberg describes a garbage collection technique for strongly typed languages, which ...
-1
votes
1answer
25 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 ...
0
votes
0answers
15 views

How would i design a PDA that accepts order of sentence? [duplicate]

How would i design a PDA that accepts order of sentence. In Natural Language Processing, context free grammars are used to identify valid English sentences from invalid once. For instance, ‘Lorem ...
3
votes
0answers
75 views

Recursive-descent parser for the grammar S -> S(S)S | ε

I'm studying (for self-betterment - I don't go to school) the 2nd edition of Compilers: Principles, Techniques and Tools by Aho et al. I'm not sure how to do Exercise 2.4.1 (b), which is to construct ...
2
votes
1answer
215 views

Numerical stability of C++: will a C++ program using a float or double library return the same arithmetical results on two different computers?

Say I am using boost or the built-in float or double mathematical libraries of my C++ compiler. I distribute the program. Will the execution of my C++ program on different machines given different ...
1
vote
1answer
28 views

Effective computation on linear data without random access

recently I've started thinking about caching problems in modern CPUs, where they struggle to adequately fetch program data (not instructions) in time, so that it can be computed further. So then I ...
1
vote
0answers
16 views

How does supercompilers relate to macro tree transducers?

Supercompilers can be used as a generalisation of deforestation of a functional program. Macro Tree Transducers composition can be used to the same effect, using a completely different approach. What ...
3
votes
1answer
61 views

Why are dependently typed languages such as Agda used for proofs, if supercompilers for simpler typed languages can do the same?

Proof assistants such as Agda can be used to assert properties about programs, such as the double of a number is even. Interestingly, supercompilers can be used for ...
0
votes
1answer
60 views

Computing FOLLOW sets for a LL(1) grammar

I am trying to learn compiler design. But I get confused when I have to deal with Follow set specifically for the empty word. I am trying to figure this out please help me with the same. ...
4
votes
0answers
49 views

Type of a return satement

I'm creating a experimental toy language for my own education purposes (an impure typed Lisp based on Clojure - https://github.com/mikera/kiss) I think I understand the concept of each expression in ...
2
votes
1answer
163 views

Is there C++ code that takes infinite time to compile?

Is C++ as a formal language recursively enumerable? If yes, is there any invalid C++ code that takes "infinite" time to compile?
1
vote
1answer
37 views

Algorithm to find Dominance Frontiers

The algorithm that is used by gcc and llvm is that of Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy (page 9). We start with the immediate dominators of each control-flow graph node ...
0
votes
2answers
199 views

How does an operating system implement the C library?

I have an idea of how a C program is turned into machine code by the compiler. I also know how the processor processes the instructions (https://www.youtube.com/watch?v=cNN_tTXABUA this video has a ...
1
vote
1answer
48 views

Why does left recursion have to be eliminated? [closed]

For example, Let the Grammar be: S->Sa|B Thus, S->Sa->Saa->...->Saa...aaa->Baa...aaa What's wrong with ...
4
votes
1answer
137 views

How are REGEXP implemented in programming languages?

Is there a good general paper about the interpretation or compilation of REGEXP in programming languages for pattern matching, with or without variables? I am not looking for a quick explanation about ...
4
votes
2answers
67 views

Does the OS create its own bootstrapped stack frame when running a program?

I've been doing nand2tetris exercises and I'm quite interested in how compilation actually works. In nand2tetris when creating the VM language I had to create a "bootstrap" which called the main ...
32
votes
5answers
3k views

Time complexity of a compiler

I am interested in the time complexity of a compiler. Clearly this is a very complicated question as there are many compilers, compiler options and variables to consider. Specifically, I am interested ...
3
votes
2answers
138 views

Mathematical background for programming languages, compilers and formal methods in software engineering [closed]

Can you tell me what mathematical background (concrete themes) should I have for studying and doing some investigations (in future) in programming languages, compilers and formal methods in software ...
1
vote
1answer
129 views

When do type systems start needing a logic engine?

I've noticed that some languages include a logic engine as part of their type system (e.g. Shen, Typed Clojure). Other languages have a much more direct type checking algorithm (e.g. Haskell / ...
0
votes
3answers
144 views

What data is stored in the symbol table for a number token?

I'm reading the Dragon Book. The following is from the start of Section 3.1.3. When more than one lexeme can match a pattern, the lexical analyzer must provide the subsequent compiler phases ...
0
votes
2answers
55 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 ...
1
vote
3answers
43 views

What do assemblers translate macros into during assembling? [closed]

I have dug in simple binaries, such as though like x86 bootloaders, sega video game binaries, etc. I know that these files tend to use assembler macros to define data, etc. What I am having trouble ...
0
votes
1answer
91 views

Is this grammar LL(1)?

Consider following grammar: $$X\to Yc|ZY$$ $$Y\to ab|cX$$ $$Z\to d|\epsilon$$ Can this be converted to LL(1)? Cleary, its not LL(1) because of First/First conflict at first production. Can anyone ...
1
vote
1answer
34 views

Indentation based Grammars

Considering programming languages with significant whitespace for indentation, such as Python or Haskell. How does this whitespace fit into the grand schemes of programming language grammars. I can ...
0
votes
2answers
534 views

Drawing Annotated Parse Tree for Syntax Directed Definition [closed]

Im trying to draw an annotated parse tree for 3*5+4n, the text book shows the following: [Compilers - Principles, techniques and tools (Dragon Book) by Aho, p308] ...
1
vote
1answer
130 views

Is this grammar LR(1)

I am reading parser chapter from dragon book and I found a grammar over there - $ S \rightarrow L=R $ $ S \rightarrow R $ $L \rightarrow *R $ $L \rightarrow id $ $R \rightarrow L $ Now I have ...
0
votes
1answer
55 views

Eliminating $\varepsilon$-productions during elimination of left recursion

I'm following the algorithm for left recursion elimination from a grammar. It says remove the epsilon production if there is any. I have the grammar $\qquad S \to Aa \mid b$ $\qquad A \to Ac \mid Sd ...
1
vote
1answer
36 views

Has there been a lexer that takes in much more than a regular language?

I understand the restrictions, because a regular language is expressive enough to allow all types of tokens. And even if some context is needed in many languages to tokenize properly, they all seem to ...
0
votes
1answer
65 views

compiler interaction with OS [closed]

I want know if compiler interacts with operating system during compilation process.And if yes then which part of compiler interacts with which part of operating system
3
votes
1answer
128 views

Confusion about compiler and assembler

I have two questions. After compilation of any C program result is assembly language code which should depend on processor. So my question is: how do different computers with different processor ...
0
votes
3answers
55 views

How are image files, sounds, data, etc. compiled/linked in to a single file?

I'm both asking for me & future readers as to how pictures, sounds, textures, assets, and such are compiled and linked in to one binary/program, and how that process works. I have seen this in ...
1
vote
0answers
51 views

what does “Configuration is valid for a viable prefix ” actually means?

I am learning LR(1) parsing from the Dragon Book. I am really confused with this sentence. Formally we say that a configuration $[A \to u•v, a]$ is valid for a viable prefix $α$ if there is a ...
2
votes
4answers
491 views

What information do we get from a compiler's parse tree?

In the compiler course by Alex Aiken on Coursera, more specifically lecture 05-02 Context Free Grammars, the professor says that CFGs give answers of the type yes/no, i.e. whether the given string of ...
3
votes
1answer
46 views

Say that a stack frame only contains total functions: could the maximum stack size be statically determined?

Say that you have a program with only total functions, or if that is impossible, consider a subset of the program with only total functions. Is it theoretically possible to statically determine the ...
4
votes
1answer
118 views

Is the Syntax of C Language completely defined by CFGs?

I think the Question is self sufficient. Is the syntax of C Language completely defined through Context Free Grammars or do we have Language Constructs which may require non-Context Free definitions ...
2
votes
3answers
408 views

Compile a programming language with itself

I'm a computer science student. I want to create my own programming language (A basic language with few instructions). I know how to do a syntactic analyser, I already did it in Perl. In an article, ...
3
votes
1answer
46 views

Compiler backend generated from declarative description of the architecture

Is it possible, given a declarative description of an architecture's register layout and instruction semantics and machine code encodings, to autogenerate a compiler back-end? If so, has anyone ever ...
4
votes
2answers
96 views

How are the web based compilers designed? [closed]

Is it possible to design a compiler that can safely compile and run untrusted code? As a practical example, I want to know how the online compilers are designed/programmed?(Like the one on ...
5
votes
3answers
629 views

Why do compilers produce assembly code?

Assembly language is converted in to machine language by assembler. Why would a compiler convert high-level language to assembly? Can't it directly convert from the high-level language to machine ...
1
vote
1answer
111 views

Pros and cons of representing strings as lists of characters

I am writing a compiler for my programming language (both almost complete), but they are stuck in the, I would call, "String vs List-of-Char dilemma". Maybe some more experienced compiler programmer ...
3
votes
2answers
373 views

What is the job of Syntax Analyzer in Compiler?

What exactly is the job of a syntax analyzer? Suppose I have a mathematical expression. Is it true that the order of execution of the operations is found with the help of syntax analyzer? Any ...