Questions tagged [compiler-construction]
The tag compiler-construction should be applied to questions concerning the programming of compilers or for questions about the detailed inner workings of compilers. DO NOT USE for questions about *using* specific compilers or compilation errors.
11,412
questions
-2
votes
0
answers
21
views
how to write binary file as executable? { platform specific or not } [closed]
i wonder how ".exe" or linux executable files are structured, so if i wanted my program to write a binary file that could be executed after writing it ?!
i also want to know if it's possible ...
0
votes
0
answers
16
views
PsiElement.firstChild vs PsiElement.children.first()
I expected PsiElement.firstChild and PsiElement.children.first() to always return the same PsiElement, however, it turns out that (considering KtElements):
for KtBlockExpression they are not the same:...
1
vote
1
answer
35
views
Where does CS0012 get its information from?
I have a C# application, based on version 84 of a certain DLL.
I have downgraded that DLL and now I'm using version 83. I have done this by replacing the following line in the .csproj file:
<!-- &...
0
votes
0
answers
55
views
How to manage the source files in intepreters or compilers? [closed]
I'm learning to try to implement a toy interpreter of my own, and so far I've done all the basic functions and things seem to work well.
One thing missing though is that I haven't implemented ...
0
votes
0
answers
68
views
How would I modify the C compiler to work with a different base system other than decimal (heximal, dozenal, etc)?
What functions and features need to be changed in the C compiler and standard library, to be able to write and compile code in a separate base system? Obviously, there's trouble that comes from using ...
-2
votes
1
answer
45
views
Whether I did it right or wrong in 3-address code?
Today, I'm done with my Compiler Construction finals paper at university.
The finals paper included a question that asked me to convert a for loop into 3-address code.
The function it asked me to ...
0
votes
1
answer
40
views
Does the Linker OR the Loader make the necessary relocations of a program?
I want to create my own linker and loader. I know that in the linking stage the linker will take into consideration the relocation data in the ELF header for all the object files.
The linker then will ...
0
votes
0
answers
25
views
What compilelation stage does list scheduling work?
I am learning compilation techniques, and I have read the Dragon Book Chapter 10 instruction scheduling. I'm very confused that the code will be generated to a file line by line, so when will the list ...
1
vote
0
answers
32
views
Online compiler in nodejs [closed]
I am making an online ide using node.js and child processes to interact with the terminal. But I am not able to handle the case where the client submits a code with dead end for eg a code likewhile(...
0
votes
0
answers
57
views
Which crate should I use to develop a compiler that compiles Rust code into a stack-based virtual machine?
I am trying to develop a DSL, which is a strict subset of Rust, and a compiler that compiles the DSL code (= Rust code) into a stack-based VM.
(As for language processors, I have only written small ...
0
votes
1
answer
16
views
How to compile the floating computation of DSPStone on X86 Architecture?
I want to use this benchmark to evaluate my optimization in compiler.
I can compile int computation of DSPStone on X86 architecture, but the other cannot.
The error is the type of main function is ...
1
vote
0
answers
33
views
How to redefine symbol of object file from the arm-none-eabi compile with -flot flag?
I want redefine malloc symbol to own_malloc, so that I can know memory alloc details and print alloc-size.But I found it don't work when I excuting order:
arm-none-eabi-objcopy --redefine-sym malloc=...
0
votes
0
answers
16
views
Unexpected character JFLEX
Hello i was watching a tutorial on youtube. It was the start of tutorial but when i tried to wrote the code and run this flex.l file. The output show unexpected character [a-z] {printf("Single ...
0
votes
0
answers
19
views
ANLTR4 Cpp demo fails to run because of a __gthread problem
I have compiled ANTLR4 runtime in a VirtualBox Ubuntu 20.04, with g++ 9.4.0.
I want to learn how to integrate the ANTLR tool into a Cpp project, So I compiled the antlr4 runtime with demo. The ...
0
votes
0
answers
18
views
Production is never reduced in simple grammar with JIS [duplicate]
I am making a simple analyzer but I have run into a problem. I need to make a grammar for function calls, it can include parameters or it can be empty. I need to prepend the word 'call' before the ...
-2
votes
0
answers
17
views
language to cfg (context free grammer)
I am doing cfg topic. please tell me a cfg of given language
language a^n b^m c^n+m d^d where n >=2; m >=1; d=2
0
votes
0
answers
53
views
Syntax error in JISON with simple grammar
I'm trying to implement a very simple parser, but I'm having a problem. I have the following grammar:
%lex
%options flex case-insensitive
CaracterEscape [\'\"\\bfnrtv]
Escape ...
0
votes
1
answer
36
views
Parsing Tree and Derivation?
I don't understand the relantioship between parsing tree and derivation. The parsing tree is invariant with respect to the derivation, but does this mean that regardless of the derivation (rightmost ...
-2
votes
2
answers
44
views
expected ',' or '...' before '&=' token (C++) [closed]
I am trying to learn c++ and I have come across an exercise that is giving me quite a bit of trouble.
The compiler is giving me a number of errors, in particular the following:
expected ',' or '...' ...
0
votes
0
answers
33
views
Compiler injected code (e.g. for stack protection)
Do any of you know a systematic overview of where the compiler can inject its own code into the binary? An example is the -fstack-protector option - here there is additional code in the binary at the ...
0
votes
2
answers
63
views
Parsing table for LL1 grammar [duplicate]
I have to produce an LL1 grammar that covers the IF, IF-ELSE, IF - ELSE IF - ELSE condition for a C program. I was doing the parsing table and in the AUX_PROG rule I obtain two entries for the same ...
0
votes
0
answers
28
views
How to solve yacc error "... has no declared type"
I have problem on Yacc/Bison.
We use Kotlin grammar.
This is my code :
%token BOOL
%token BREAK
%token CHAR
%token CONTINUE
%token DO
%token ENUM
%token EXTERN
%token FALSE
%token FLOAT
%token FOR
%...
0
votes
1
answer
42
views
How does a shift reduce parser know what rule to apply?
When writing a shift reduce parser, how does a shift reduce figure out what rule to apply efficiently? For example, if I have the following rules
S –> S + S
S –> id
How would the parser ...
0
votes
0
answers
12
views
Building MERN based online compiler. How to handle infinite loop?
I thought of building a online compiler in MERN stack. My project is almost ready except the fact that I haven't handled timeout. I am sending a get request frequently at time gap of 0.5 second from ...
0
votes
1
answer
58
views
__builtin_sinf What is it? Where is it? How do I obtain the dissassembly of it?
I was curious this morning to see if I could obtian and understand the machine instructions generated for calculating a mathematical function such as sin, which as far as I am aware there is no ...
0
votes
1
answer
91
views
LL1 grammar for IF-ELSE condition for a C program
I have to produce an LL1 grammar that covers the IF, IF-ELSE, IF - ELSE IF - ELSE condition for a C program.
I was doing the follow and I wasn't able to solve the recursions so I thought that maybe my ...
1
vote
0
answers
30
views
If you remove left recursions & left factor a CNF grammer, does it remain a CNF?
If we remove only left recursions or only left factor, does the received grammar retain CNF form?
0
votes
1
answer
48
views
Convert NASM assembly to exe without mingw
i need to make a custom simple programing language with assembley(NASM). So i am thinking to use c++ to translate my own language to assembley, then compile it with NASM. in nasm they use ld to link ...
5
votes
2
answers
149
views
How does a compiler store information about an array's size?
Recently I read on IsoCpp about how compiler known size of array created with new. The FAQ describes two ways of implementation, but so basically and without any internal information. I tried to find ...
0
votes
1
answer
39
views
How to implement the parse tree?
I started writing a DBMS as a learning project, and now I'm implementing the lexer/parser for the language used in the DBMS.
I'm learning on my own from various different resources, and managed to ...
1
vote
3
answers
60
views
How would one implement a standard library for a language they've developed?
So for example I have a brand spanking new compiled language in my hands and no standard library. I want to implement a malloc function for this language. An approach that came to my mind is to write ...
0
votes
0
answers
11
views
Algorithms for repairing ssaa form after modifying the call-flow graph
I'm learning about compiler optimizations on ssa form. One difficulty I'm having is how to retain/repair/reconstruct the ssa form after modifying the structure of the call-flow graph.
Suppose I have ...
0
votes
1
answer
62
views
Does the code generation in JIT compiler generate better native code?
I'm researching about JVM and JIT compiler, and want to figure out what difference between traditional compiler like gcc and JIT compiler.
I know JIT compiler will investigate the hotspot of a code, ...
0
votes
0
answers
33
views
About R12 corruption in Arm compiler
The __aeabi_memcpy(standard lib) function provided by arm compiler 6 use r12 as a intermediate variable.
As i know, r12 is not preserved by caller or callee.
If a caller uses r12 for some purpose ...
2
votes
1
answer
59
views
Why does full `constexpr` enabling of a data structure cause the compiled code to be bigger?
At this moment of Jason Turner's 2016 CppCon talk "Practical Performance Practices", he mentions that full constexpr enabling of every data structure that can be (I'm guessing that means ...
0
votes
1
answer
33
views
Do basic block parameters mean code locality?
Most modern compilers use some form of SSA for internal representation, which needs some notation for variables whose values can come from more than one source. The classic version uses phi nodes. ...
0
votes
0
answers
57
views
Parsing Function Calls with `constexpr` library in C++
I'm at the end of the semester and need to get this in, I have been struggling for the last few days to implement function calls into my language. I am using the ctpg library which implements a ...
0
votes
1
answer
38
views
Compiler does not support 64-bit integers on target Architechture
I am new to MPLAB XC8 compiler and don't know why this error is happening as I did not use any number that is of 64 bit in my code.
Code is as follow
#include <pic16f877a.h>
#pragma config FOSC =...
3
votes
1
answer
182
views
Do compilers `constexpr` everything?
Do compilers try to constexpr1 everything? Not just functions/variables/things explicitly marked constexpr by the programmer? Before someone comments
yeah duh, that's what optimization is
A better ...
0
votes
1
answer
45
views
How to visit an array in llvm ir?
I am confused about how llvm visits an array.
For a 2-dimension array, like
int a[5][5];
int func1(){
return a[1][2];
}
The translated llvm-ir is
@a = global [5 x [5 x i32]] zeroinitializer, ...
0
votes
0
answers
67
views
How does the declaration nonassoc work in fsyacc?
I'm trying to figure out how %nonassoc works in fsyacc.
I have this code snippet that I'm trying to figure out how it works.
%nonassoc letprec
%left DEQ LTH
%left PLUS MINUS
DEQ = '=='
LTH = '<'
I'...
1
vote
0
answers
46
views
Bug or Feature? Conversion in case stmt behave differently between versions
The following code works fine with go1.11.13, however for go version above 1.12, it would cause compiler error due to conversion in the case stmt is now allowed. I wonder whether this is a bug or a ...
0
votes
0
answers
31
views
Is there a TypeScript compiler API for general inferred type information from JavaScript code?
I was reading the type inference documentation for TypeScript, which seem to target (quite reasonably) cases where TypeScript can surely identify types. I am curious about whether the compiler can be ...
1
vote
0
answers
48
views
C++ Enable_if and compilers [closed]
Does a compiler front end parse templates for enable_if; or is that
the responsibility of the back end? I'm trying to understand how
enable_if works at the compiler level.
0
votes
1
answer
36
views
How compilers rearranging variables optimizes the code?
So in general if i declare some variables in c and then printout their memory addresses, sometimes they would be out of order with the declaration. And my lecturer seem to imply that's done to ...
0
votes
0
answers
16
views
Return code blocks between curly braces in separate lines using regex and in separate regex groups [duplicate]
I am trying to parse codes inside a function. The code is placed between { and } and it can span several lines obviously.
Coming from a different educational background, I don't have a formal ...
0
votes
0
answers
48
views
Typescript AST: how to distinguish `extends` and `in` clauses in a TypeParameterDeclaration node
I am parsing a typescript source file using a library that provides the typescript Abstract Syntax Tree as processed by the typescript compiler.
In order to verify the correctness I am rebuilding the ...
0
votes
0
answers
26
views
Check Ambiguity of Grammer
I am a beginner in learning theory of computation and there are many problems that are very confusing. Currently, I am studying ambiguous grammar and how to change them into unambiguous and got stuck ...
0
votes
0
answers
100
views
Why does riscv32-gcc use LI and ADDI to put a 32-bit constant in a register, not LI with the full constant?
....
//---------------------------------
// Init State
//---------------------------------
int32_t state[16];
state[0] = 0x61707865;
...
|| c -> asm(riscv32-gcc -S inputcode.c)
|| ...
0
votes
0
answers
39
views
is their any grammar file of flex/bison input file in flex/bison format?
i would like to write a flex and bison which will generate pure-cpp header file so that can platform independ.
actually i have written some code of them.
i parse the flex and bison input file using ...