A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program.
Questions tagged [compiler-theory]
200 questions
0
votes
0 answers
Building and processing a compile graph on a set of watched source files
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 system where you create HTML template files…
user3001
- 3,171
- 3
- 25
- 50
0
votes
1 answer
Type of error in expression evaluating process
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 atoms (numbers and operation).
Convert the set of…
Humam Helfawi
- 17,706
- 12
- 64
- 134
0
votes
1 answer
how to read the header block gcc compiler put to .o .a and an executable
I'd like to read the header block gcc put to the beginning of all .o .a and executables. In those days, on Solaris, there was an utility for this purpose. On linux, is similar utility available?
0
votes
1 answer
how it produce multiple token for each lexeme?
I just started reading The Dragon Book and I'm finding difficulty in understanding some statements.
It says: "lexical analyser produce sequence of token for each lexeme in the source program". Can you please help me to understand the above line? …
Tarun
- 2,917
- 2
- 24
- 40
0
votes
0 answers
Are header files strictly necessary when the code is open source?
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 information to a user and their compiler without…
ThorSummoner
- 12,194
- 11
- 114
- 129
0
votes
3 answers
How does a function caller use a header file to determine what to do with a compiled binary?
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() function, some program that includes the header…
bob
- 1,759
- 2
- 12
- 24
0
votes
1 answer
Getting tree construction with ANTLR
As asked and answered in Removing Left Recursion in ANTLR , I could remove the left recursion
E -> E + T|T
T -> T * F|F
F -> INT | ( E )
After left recursion removal, I get the following one
E -> TE'
E' -> null | + TE'
T -> FT'
T' -> null | *…
prosseek
- 155,475
- 189
- 518
- 818
0
votes
3 answers
Verifying data types/structs in a parser
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 could have some syntax i.e:
int x = 5
int x = 5
And…
metro-man
- 1,563
- 2
- 11
- 24
0
votes
2 answers
Eliminating ambiguity by left factoring
Can you eliminate ambiguity by left factoring?
For example, the dangling else.
Or is left factoring only eliminating left recursion?
Thanks.
James Edwins
- 63
- 1
- 5
0
votes
1 answer
SLR Parsing - with an epsilon production
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 would also include B -> .k and B -> . obviously.
But since B -> ϵ is a…
user1265125
- 2,426
- 6
- 37
- 61
0
votes
4 answers
Why we can't implement polymorphism in C++ without base class pointer or reference?
First of all have a look at the following code (in this code shape is the base class and line is the derived class)
void drawshapes(shape sarray[],int size)
{
for(int i=0;i< size; i++)
sarray[i].draw();
}
main()
{
line larray[10];
…
Zia ur Rahman
- 1,369
- 4
- 18
- 42
0
votes
1 answer
Programming Language Translation
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 Python to C. I feel like I can cheat a bit and just…
user56833
- 109
- 2
0
votes
0 answers
Nondeterministic finite automata with multiple accept/failure states
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 machine only accepts if none of the states are…
dane_cor
- 1
- 1
0
votes
2 answers
Is there any performance gain from using final modifier on non-primitive static data?
Is there any performance gain from using final modifier on non-primitive static data in Java?
For example:
static final Thread t2 = new Thread(new Thread_2());
versus:
static Thread t2 = new Thread(new Thread_2());
I mean, static final for…
pdrak
- 384
- 1
- 3
- 12
0
votes
2 answers
how to manage a compiler project?
I am a CS student and I have a compiler project this year.
I want to know how to manage my project with my three partners.
I know that the compiler has many level and process, and I want to make use of these features to mange my project.
Thanks for…
Radi
- 6,024
- 16
- 57
- 86