Skip to main content
Filter by
Sorted by
Tagged with
2 votes
2 answers
158 views

I have been writing a compiler and have discussed this situation with a colleague. In the most general case, suppose you have your arguments on the stack (once argument registers are exhausted). If ...
user129393192's user avatar
1 vote
1 answer
931 views

I'm currently studying compiler's and am on the topic of "Chomsky Hierarchy and the 4 languages." But it beats me as to what the practical purpose of all this is? It'd be great if I could ...
jeremy's user avatar
  • 109
1 vote
1 answer
320 views

I am using antlr 'org.antlr:antlr4:4.9.2' and come across the "dangling else" ambiguity problem; see the following grammar IfStat.g4. // file: IfStat.g4 grammar IfStat; stat : 'if' expr '...
hengxin's user avatar
  • 2,011
2 votes
1 answer
552 views

Are all interpreted languages not eventually machine code? I'm curious if the reason is because companies don't think it's worth the effort, if there is an inherit conflict that makes it impossible, ...
user avatar
0 votes
0 answers
47 views

This is my python code and I need to convert this to MIPS Print (“Enter two numbers here:”) a = int (input()) b = int (input()) sum=a+b print(“sum is =” + str (sum)) I am having difficulty in trying ...
Sankha Jayalath's user avatar
1 vote
1 answer
504 views

I have been banging my head on this problem for a while. This is the text of the exercise: The grammar in Fig. 4.7 generates declarations for a sin­gle numerical identifier; these declarations ...
Giuseppe Rossini's user avatar
0 votes
0 answers
228 views

I understood Left Recursive Grammar (LRG) and how to remove it. But i dont know how to remove recursive grammar which combine both left and right recursive: A -> aAb | c The full question is ...
Fallen's user avatar
  • 1
1 vote
1 answer
2k views

Does the local optimization refers to one function only? And the global optimization refers to entire program?
Jitendra Raghuwanshi's user avatar
-2 votes
1 answer
205 views

Can any one help me in figuring out what compilers and interpreters are? And what their difference is ? Appreciate it if explained for Java beginner as I am one.
Amanuel Getachew's user avatar
1 vote
1 answer
176 views

In nearly every functional programming tutorial, a large section is dedicated to teaching you how to convert algorithms to a tail-recursive format, since this can be optimized to a loop. This is fine,...
Tombert's user avatar
  • 530
2 votes
1 answer
266 views

I am having trouble wrapping my head around the concept of calculating array liveness since they are non-scalar values. All books and courses that talk about liveness always use scalar values only but ...
BinaryLust's user avatar
0 votes
0 answers
246 views

In interpreted languages like python I can reduce the size of scripts by defining functions inside it. In the languages like c, c++ can I use the same trick to reduce the size of executable file(not ...
Kavindu Ravishka's user avatar
0 votes
1 answer
146 views

It is known that SLR(1) parsers usually have less states than LR(1). But is it easier or harder because of this to find a string that leads to conflict in a SLR(1) parser compared to a LR(1) and why? ...
Dragonite LvL 100's user avatar
0 votes
1 answer
332 views

Let's say i have this grammar: S -> A C x | u B A A -> z A y | S u | ε B -> C x | y B u C -> B w B | w A This grammar is obviously not LL(1), which i can find constructing the parsing ...
Dragonite LvL 100's user avatar
4 votes
1 answer
1k views

I'm looking into how the v8 compiler works. I read an article which states source code is tokenized, parsed, an AST is constructed, then bytecode is generated (https://medium.com/dailyjs/...
Mr Wannabe's user avatar
0 votes
2 answers
364 views

I am very interested in compilers and how they work so I want to know if there are good sources or books to write a compiler from scratch. As I am a novice C programmer it would be perfect if the ...
Bran Tran's user avatar
  • 187
6 votes
1 answer
3k views

I'm having trouble building the collection of sets of items for LR(1) parsers with a grammar containing epsilon productions. For example, given the following grammar (where eps stands for epsilon) S -...
Astinog's user avatar
  • 1,191
2 votes
1 answer
294 views

I begin to get acquainted with the implementation of algorithms of code-generation and optimizations in gcc and llvm. Can anyone give an advice on where to see materials, articles, lectures about how ...
user avatar
-1 votes
1 answer
38 views

I’m designing a multi-pass compiler for a language and the AST is completely kept in memory. This means that I’m saving the entire AST in memory, no matter how many files the program is composed of. ...
NYG's user avatar
  • 1,807
1 vote
1 answer
101 views

I'm having some trouble in understanding the differences between different errors in the complier phases, for instance this program: int main() { int x = 5; int x = 6; } My guess is that ...
Emil Gelman's user avatar
0 votes
1 answer
590 views

I can't seem to find an equivalent LR grammar for: S → aSbS | bSaS | ε which I think recognize strings with the same number of 'a' than 'b'. What would be a workaround for this? Is it possible to ...
DarK_FirefoX's user avatar
1 vote
1 answer
1k views

Consider this grammar: expr ::= LP expr RP | expr PLUS|MINUS expr | expr STAR|SLASH expr | term term ::= INTEGER|FLOAT Context-free grammar is defined as G = ( V, Σ, R, S )...
lolbas's user avatar
  • 802
0 votes
0 answers
77 views

I think this might be a quite common problem, but somehow it is hard to find suitable answers. Background I'm currently investigating how to speed up the node variant of Patternlab. It is basically a ...
user3001's user avatar
  • 3,507
0 votes
1 answer
238 views

Supposing I want to write module to evaluate e simple string expression like "5+3", "(7*8/2)/6" etc... The process that I am thinking of is: Lexical analysis in order to convert the string to set of ...
Humam Helfawi's user avatar
3 votes
1 answer
496 views

Suppose that we have a language L that is context free,and 'a' among others belongs to its alphabet. How can I prove that the language ERASEa(L),that removes all instances of the character 'a' in the ...
lone luttrell's user avatar
0 votes
0 answers
52 views

It was my understanding that header files were a developed practice, the header files created by copying all the externally-meaningful symbols from a source C file. Thus being able to give the linking ...
ThorSummoner's user avatar
  • 18.6k
3 votes
1 answer
352 views

While reading Guido's reasoning for not adding tail recursion elimination to Python, I concocted this example of almost tail recursion in Haskell: triangle :: Int -> Int triangle 0 = 0 triangle x =...
Bailey Parker's user avatar
4 votes
4 answers
1k views

How does a compiler know if something is allocated on the heap or stack, for instance if I made a variable in a function and returned the address of the variable, the compiler warns me that "function ...
mosmo's user avatar
  • 469
0 votes
3 answers
340 views

My understanding is that C++ (and C, I guess) header files are never compiled, and simply act as an explanation of the interface of the C++ file they describe. So if my header file describes a hello()...
bob's user avatar
  • 1,889
192 votes
13 answers
17k views

The compilers I've been using in C or Java have dead code prevention (warning when a line won't ever be executed). My professor says that this problem can never be fully solved by compilers though. I ...
Learner's user avatar
  • 1,677
3 votes
2 answers
1k views

I'm studying some theory of computation at the moment and, as is implied, it is very theoretical. I can convert from regex to NFAs to DFAs pretty easily, I can understand that. But since all NFAs ...
Greg Peckory's user avatar
  • 8,148
14 votes
2 answers
18k views

What are the minimum pumping length for the following languages ? The empty language (01)* 10(11*0)*0 1011 011 U 0*1* Here are my solutions. Please correct me if I'm wrong. p = 0 because the language ...
user2293062's user avatar
1 vote
2 answers
77 views

I'm writing a Java compiler in C just as a recreational project. But, I've noticed that when we compile files in the command line, such as "gcc example.c", the compiler is able to find example.c in ...
Application Developer's user avatar
1 vote
1 answer
87 views

This is more about compiler theory, given I'm playing around with making one. I'm wondering if it is theoretically safe to always downcast a variable within a subclass. class Car { BodyType ...
ansiart's user avatar
  • 2,601
3 votes
1 answer
607 views

I've taken a side interest to optimizers and how they work, particularly with respect to register allocation. I have somewhat of a background in writing high-level interpreters that didn't bother to ...
user avatar
1 vote
3 answers
716 views

I'm writing a recursive descent parser, and I'm at the point where I'm unsure how to validate everything. I'm not even sure if I should be doing this at the stage of the parser. What I mean is, I ...
metro-man's user avatar
  • 1,813
6 votes
1 answer
3k views

Is it computationally more performant to compare less/greater than over less/greater than or equal to? Intuitively one could think that less/greater than is marginally better. Can a compiler use ...
heikkim's user avatar
  • 2,985
2 votes
1 answer
183 views

at the moment I am writing a scientific expose. A part of the content is about the definition of closures in our developed DSL. However, I was not able to find references of how to formally describe ...
smoes's user avatar
  • 601
4 votes
3 answers
231 views

Sometimes the value of a variable accessed within the control-flow of a program cannot possibly have any effect on a its output. For example: global var_1 global var_2 start program hello(var_3, ...
Raul Bertone's user avatar
9 votes
1 answer
819 views

I'm using this (see below) algorithm(take idea from this answer) to code generation from a tree. I'm targeting x86 arch, now I need to deal with mul/div instructions which uses registers eax/ebx as ...
The Mask's user avatar
  • 17.5k
1 vote
1 answer
349 views

I have the following grammar: A-> AB|CA B-> Bd | ef C-> e|f I removed left recursion as follows and my grammar looks as below: A->CAA' A'-> BA' A'-> epsilon B-> efB' B'->dB' ...
user3638992's user avatar
21 votes
1 answer
6k views

I am trying to create an example using lambda expression in java and i am using offical JDK8. My example was run successfully. But when i trying to check how the compiler translate lambda expression ...
Harmeet Singh Taara's user avatar
0 votes
2 answers
1k views

Can you eliminate ambiguity by left factoring? For example, the dangling else. Or is left factoring only eliminating left recursion? Thanks.
James Edwins's user avatar
0 votes
1 answer
635 views

Say I have: S -> A A -> B C A a | ϵ B -> k | ϵ C -> m Now in the initial state S' -> S, I'm going to include: S' -> .S Then the closure of S: A -> .B C A a , A -> . Closure ...
user1265125's user avatar
  • 2,666
4 votes
1 answer
969 views

I'm having difficulties in understanding the exact differences between Syntax Directed Translation (SDT) and Semantic Analysis. By reading the Dragon Book, I know that SDT is like an extension to CFG....
James Edwins's user avatar
3 votes
1 answer
352 views

So I've been learning about stack machines, interpreters, compilers and a few other things related to programming languages and their general theory. Most of the stuff I find in books and online are ...
David K.'s user avatar
  • 6,411
1 vote
2 answers
250 views

Imagine that we have a been given an Excel spreadsheet with three columns, labeled COND, X and Y. COND = TRUE or FALSE (user input) X = if(COND == TRUE) then 0 else Y Y = if(COND == TRUE) then X else ...
n00b101's user avatar
  • 265
0 votes
1 answer
1k views

I want to translate a simple programming language to another programming language. I only need that the output be syntactically valid so the code-generation part can me ditched. Say, a subset of ...
user56833's user avatar
  • 109
9 votes
2 answers
4k views

I am writing a parser for a pet project, and for educational purposes, would like to do it by hand instead of using a parser generator. Unfortunately, many online resources (and the compiler course I ...
Matt Kline's user avatar
  • 10.6k
0 votes
0 answers
754 views

I'm having trouble making accept states for an NFA for situations that would be easy with a regular expression or an (apparently equivalent) deterministic finite automata. For instance, what if the ...
dane_cor's user avatar