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,561
questions
0
votes
0
answers
6
views
i'm trying to compile a smart contract in solidity, i'm getting this error, 'expected identifier, but got this '(' instead ' ;right @ require(
uint256 profit = wethAmount.sub(totalAmountOwed);
require(IERC20(WETH).balanceOf(address(this)) >= profit, "Insufficient balance to transfer profits");
IERC20(WETH).transfer(...
0
votes
0
answers
30
views
Does java 8 support to compile wasm? [closed]
Does Java 8 support compilation to WebAssembly?
I'm considering using WebAssembly for a project, and I'd like to know if it's possible to compile my existing Java codebase to run in the browser via ...
0
votes
0
answers
9
views
Where do I include cl / ... /MD files?
I'm trying to communicate with GPIB using NI488.2, in the Programming Instructions they tell me to build the application using:
cl /I"%NIEXTCCOMPILERSUPP%\include" cprog.c "%...
0
votes
0
answers
10
views
How to parse binary message to construct AST using flex+bision?
I only have basic knowledge about compiler construction.
I know how to translate source code to AST representation in 2 steps:
step 1. tokenize or lexical analysis
step 2. parse token stream to ...
0
votes
2
answers
55
views
How to formally verify a compiler (frontend and/or backend)?
For a project I am about to begin, I was exploring formal verification of a compiler. I came across the CompCert C Compiler which is an ACM awarded, formally verified C compiler.
When I read further, ...
0
votes
0
answers
24
views
how to compile or integrate my python code and Cpython code?
here i have a test.py for example
print("hello world")
I've cloned CPython source code, and I learned how to compile a python.exe
how to combine my source code test.py with the compiled ...
0
votes
0
answers
40
views
+150
LAC (Lookahead Correction) corrects bison parser's error recovery into not working
I have a bison parser and I got interested in the option parse.lac full because, according to the documentation, without it the generated error message may be incorrect.
However, when I add the option ...
-4
votes
0
answers
15
views
Construct a deterministic push down automata accepting L [closed]
img
Let G = (V, Σ, R, S) be a context free grammar, where V = {(, ),a, ., S, A}, Σ = {(, ), ., a } and R = {S → (), S → a, S → (A), A →S, A → S.A}
(PART A) Apply Heuristic rules (1) and/or (2) to G. ...
0
votes
1
answer
14
views
How can I get all passes name for O2 level optimization in llvm / clang
How can I get all passes name for O1 ,O2 , O3 level optimization in llvm / clang . I am working with performance analysis with LLVM . So I am trying to find what are the passes are enable for O2 ...
0
votes
0
answers
27
views
why does the compiler performs idiv and cdq for unsigned integers
I'm very curious to know why the following code snippet is compiled with cdq and idiv operations, which belong to signed integers. The code doesn't contain any signed integers, however. I was thinking ...
0
votes
0
answers
46
views
Variable Length Array C++ [duplicate]
This is the code I'm currently using, in C++.
#include <iostream>
using namespace std;
struct Evento {
string nombre;
int frecuencia;
double porcentajeMensual;
double ...
0
votes
0
answers
18
views
pvm installation for python
I learnt that many applications like instagram are developed on python. So my questions are:
if we want to install and run the application, is pvm preinstalled in our device or it gets downloaded ...
2
votes
3
answers
69
views
Nicer way to pattern match window of assembly instructions for peephole w/ Rust?
So I am trying to implement peephole optimisation where I go from a Vec<LLStackInstruction> -> Vec<LLStackInstruction>, where the returned list is optimised. (LL for low level)
Our ...
-2
votes
0
answers
12
views
What is going to happen when running an executable without required dynamic libraries
For example, if someone try to run an executable which was compiled by clang and needs to link some dynamic libraries on running, and he doesn't have these installed (say, he doesn't install LLVM ...
1
vote
0
answers
62
views
Segfault when calling malloc or puts from Cranelift-generated code
I'm working on a small programming language compiled using cranelift. Now, my generated code segfaults whenever I call malloc or even puts. I'll focus on a small example with malloc:
The code I'm ...
1
vote
0
answers
49
views
Is it possible for the assembler to have an impact on the code's performance?
I know that the compiler can have a direct impact, but can the assembler also have any impact? I saw two sources that said the assembler can optimize by rearranging instructions to reduce clock cycles,...
-5
votes
1
answer
85
views
How i can speed up a large python project? [closed]
I have a 2000 line project in python, its a programming language.. Everything is going well, just the speed.. Its take the same runtime as python but there is a slow before starting
1 - i write ...
0
votes
0
answers
14
views
Can gradle compile some java later?
I am using the abstract processor to generate part of the code, but the compilation has been completed in the android component, and I want to hand it over to the app module for processing. Is there a ...
-1
votes
1
answer
95
views
How to allow type conversions in Visual Studio C++ [closed]
I'm working with an old C++ application that has been certified for a certain system. So, I'm not allowed to make any changes. However, I have to make a new build in Visual Studio 2019. I am running ...
1
vote
1
answer
45
views
If statement inside loop ID string name instead of value in Antlr4 based Interpreter
Good day can really appreciate if some one would help. I am working on interpreter based on Antlr4 now i am having challenge after implementation of Visitor class. The implementation is working ...
1
vote
2
answers
109
views
How does a C compiler read this operation?
How does a C compiler read this operation i.e. what is the order of the operations?
z = (x*x + r*r) - (y*y + w*w)
I'm confused whether it starts with the left parentheses first or it works on both ...
0
votes
0
answers
29
views
Structures and arrays in c using for loop [duplicate]
I am practicing structures and arrays in c, programmed a code to take multiple student information and store it in an structure array using for loop. But when i run the code only my 0th i index runs ...
0
votes
0
answers
32
views
ARMv7 assembler merges two constant strings for no reason
I have the following ARMv7 code:
.section .text
.global main
main:
ldr r1, =str1 // load only the first string
ldr r2, =_len0 // load the length of str1
mov r0, #1 // sets ...
1
vote
1
answer
70
views
Rules precedence in Menhir
I've written a subset of C and there is a little ambiguous piece of grammar about the declaration of array of pointers. Indeed, a declaration like
int *A[10];
may be seen both as an array of ...
1
vote
2
answers
50
views
How to properly tokenize over whitespaces with ocamllex/Menhir?
I am writing a simple shell in OCaml. My grammar looks a little like this at the moment
/*
program: command*
command: WORD WORD* redirection*
redirection: NUMBER? > FILENAME | < FILENAME
*/...
-1
votes
2
answers
62
views
How can I match tokens while listening to an Antlr4 grammar?
I've been working on a language implementation based on a very large grammar that someone else wrote. I'm using Antlr 4.12 and targeting C#. Everything is going quite well and I make lots of progress. ...
0
votes
0
answers
18
views
Using PLY to parse C header files
As a means to an end in a larger project, I am trying to write a simple C compiler using the python PLY library. I'm really struggling to understand how the parser terminates(?) after successfully ...
0
votes
0
answers
15
views
What is the alternative of .dtors section in modern compilers
So guys I was working on an old gcc compiler 3.3.6 which generated an .dtors section with no code even when I did not use the destructor function. But now in new compilers there is no section like ....
1
vote
2
answers
69
views
C / Compile / Linkage -- extern and inline keywords
Consider:
Makefile
OPT = -O3
CFLAGS = $(OPT) -Wall -Wextra
CC = gcc
default: main.c a.c b.c
$(CC) $(OPT) $^ -o exec
a.h
#ifndef A_H
#define A_H
inline
int f()
{
return 0;
}
#endif
a.c
#include ...
0
votes
0
answers
13
views
NMT Compiler OOM
spring boot service always oom killer
NMT info here
Comilper is OOM
I need advice
enter image description here
Currently, I use "- Djava.compiler=NONE" to solve the problem
The problem was ...
-1
votes
0
answers
21
views
How to understand Knuth's definition of LR(k) grammar?
I have trouble understanding LR(k) grammar definition in Knuth's paper
On the Translate of Languages from Left to Right
I found the definition of LR(k) grammar is hard to understand (page 610, ...
1
vote
0
answers
80
views
Why does the compiler need the intermediate representations for link time optimization?
My professor mentioned that gcc can be run with -flto. I am wondering why the intermediary (GIMPLE in GCC case) are needed.
Why is the assembly not sufficient?
He mentioned that this allows the ...
0
votes
1
answer
55
views
How to access a pointer in a function with llvm api for c++
I want to write a dedicated language for some purpose. Basically it will be a bunch of functions that I will call from C code. Meaning I will pass a C pointer to struct to them. I want to experiment ...
0
votes
0
answers
19
views
LLVM: how to replace "_mulsf3" with a specific instruction?
I wrote a test.c file below trying to select my own float mul instruction:
int main(){
float a = 1;
float b =2 ;
float res = a * b;
return 0;
}
However, the output asm file uses the load ...
0
votes
0
answers
11
views
if non terminal is present only at the right hand side of the production then should i take it Terminal or non terminal
S -> CC
C -> cC |D
what will be the first of the question
Unable to figured it out that what to do with D , should i take that a terminal or non terminal
0
votes
0
answers
17
views
Resolving reduce-reduce conflicts
Following is the part of the grammar that I have written,
constant_declaration
: unann_type variable_declarator_list ';'
| constant_modifier_one_or_more unann_type ...
2
votes
1
answer
30
views
Fixing Register Spilling in Your Program
I see through CLANG's optimization report that my hot loop has register spills in regalloc pass. Are there any general programming techniques on how to avoid the spills, or how to suggest the compiler ...
7
votes
3
answers
278
views
Why does the standard have to address division by zero?
I was trying to understand the differences between res1 and res2 in the code below:
#include <iostream>
int main()
{
int x = 1;
int y = 0;
double res1 = double(x)/y; // ...
1
vote
2
answers
110
views
Do modern compilers need assembler? [duplicate]
If I am not wrong, all compilers have an assembler(ml, as, etc..) and they use it to translate high-level code into machine language in the background(c/c++ code -> asm code -> machine code). ...
2
votes
1
answer
43
views
Emit ASM from Cranelift
Is there the possibility to emit ASM when compiling something using Cranelift? By "ASM" I mean the assembler text-representation, in e.g. Intel-Syntax or similar
Now I was planing on ...
0
votes
0
answers
13
views
The compiler generated default constructor is not used if we create a user-defined default constructor, this process is called as..?
The compiler generated default constructor is not used if we create a user defined default constructor, this process is called as..? Like how we have constructor overloading, function overriding.. ...
0
votes
0
answers
12
views
Why Path-convergence criterion Requirement 6 is necessary?
The path-convergence criterion states that there should be a φ-function for variable
a at node z of the flow graph exactly when all of the following are true:
There is a block x containing a ...
-1
votes
1
answer
73
views
Does code alignment make a difference in compiler output?
Let's say I got some code written in C++ and I compile it with gcc.
Now let's say I push everything in one line and compile it again.
Does the output bytes of the compiler change?
If so, what changes ...
0
votes
1
answer
29
views
How to limit the range of jump instructions
I am writing my own LLVM backend and have an instruction set designed with various jump instructions which have jump range restrictions, for example, the range should be within [-128,127]. After ...
0
votes
1
answer
33
views
How can I make a label begin with a dot
As we know, a dot preceding a name is either an assembler directive or a local label.
When I use my own LLVM backend to emit assembler, I find that all the labels are missing a preceding dot, which is ...
0
votes
0
answers
25
views
Angular compiler, preparse some TS file
There is a way to preparse some TS file during build or serve like we are using a custom loader?
I ask that because, despite is possible to add a custom webpack config, each custom rules and loader ...
0
votes
0
answers
28
views
Change python default compiler to MSC
I earlier had python installed from python.org ( MSC). Recently I installed MSYS2 and by default, python has installed again (GCC). If I check my python version in command prompt I will get this :
&...
0
votes
1
answer
73
views
Adding additional parameters to data constructors using infix operators
I have written a data constructor like
data Expr = IntL Integer | Expr :*: Expr
and would like to annotate it with extra constructor parameters (such as positional information) like this:
data Expr = ...
0
votes
0
answers
31
views
Java compiler ignores source files generated by annotations processor
I'm messing up with an annotations processor. It should be able to generate source files with Java classes, but for some reason when I start a compilation, compiler ends with an error that it can not ...
0
votes
2
answers
80
views
Making live python compiler inside a HTML page using PyScript
I want to build a live Pythonn compiler similar to those at w3schools for Python, for some examples on my blog. I tried different approaches, and would like to hear different oppinions, but as of ...