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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

adding optimization passes with LLVM PassBuilder

I am working on a project for which I have to extend the optimizer of a simple compiler in order to improve the quality of the generated LLVM bitcode. The project file I've been given uses LLVM's ...
2007wiiremote's user avatar
6 votes
0 answers
102 views

Why does GCC fail to reduce a loop that increments two locations of the same buffer?

Here is a bounded loop that increments two locations of the same buffer. unsigned int getid(); void foo(unsigned int *counter, unsigned int n) { unsigned int A = getid(); unsigned int ...
AceSrc's user avatar
  • 71
0 votes
0 answers
27 views

In an Excel 365 Macro module, Application.WorksheetFunction.Search() does not compile. Why? [closed]

The compiler gives runtime error 1004, "Unable to get the search property of 'WorksheetFunction' class". The search function is listed as being available as an Excel function in https://...
jimlamb's user avatar
0 votes
0 answers
52 views

bison giving me a syntax error while the syntax is correct?

i am currently doing an assignment where i have to make a mini compiler for a programing language using flex and bison when testing the parser generated by flex and bison with a program test it keeps ...
Lamis Assabat's user avatar
0 votes
0 answers
56 views

Why do assemblers support listings; what are they for? [closed]

What is listing and in which phase of a two-pass assembler does the listing printing take place? With a little bit of googling, I landed upon a definition that "An assembler listing file shows ...
Parth Yadav's user avatar
0 votes
0 answers
14 views

modifying AST as constructed in gcc

I would like to add a few branches to the AST as being constructed by the parser of gcc, https://github.com/gcc-mirror/gcc/blob/master/gcc/cp/parser.cc What is the variable that holds the AST as being ...
0x11111's user avatar
  • 165
-1 votes
1 answer
63 views

Is this grammar LALR(1)?

I have the following grammar: S -> aSb S -> c It can be used for LR(1) parsers are there is no conflict. However, when I combine states with same LR(0) items and different lookaheads, I get a ...
Lobster3221's user avatar
1 vote
2 answers
60 views

I am having syntax error in Flex/Bison for a C- program

I was doing my project for my compilers lessons, I finally finished it and it compilers but I keep getting a syntax error, and I don't know why! I tried using differences sources to see what I can ...
Gabriel Vasile's user avatar
0 votes
0 answers
109 views

Why does accessing an initialised array cause a segfault?

I'm making a compiler for brainfuck and I've made the ELF header and 2 program headers, the relevant header is this: Program_Header dataHeader = { 1, ...
Been's user avatar
  • 9
0 votes
0 answers
42 views

Running the dotnet command to make a compiler on Macbook

I am watching this video Episode 18: Emitting IL Part 1, and at 39:14 minutes, he opens two terminals. In one, he runs the command dotnet run -- ..\..\samples\hello, which generates a hello.exe. After ...
Vagner Wentz's user avatar
0 votes
1 answer
47 views

Declare a Function to use in FunctionPass with New Pass Manager using llvm::PassInfoMixin in LLVM 15

I'm currently working with LLVM 15.0.0 and facing a challenge while using the New Pass Manager and llvm::PassInfoMixin. My goal is to insert calls to a specific function within a FunctionPass, but ...
Orestis Kapar's user avatar
0 votes
1 answer
31 views

JVM: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1

This started happening after switching from kotlin 1.8.22 to 1.9.+ I am using the jvm plugin, not Android as in other questions plugins { kotlin("jvm") version "1.9.20" Errors ...
tonisives's user avatar
  • 2,082
-2 votes
1 answer
70 views

ANTLR4 Visitor Method cannot find symbol Error in Java

I'm working with ANTLR4 in Java to create a custom language parser. I've generated my lexer and parser using a grammar file (CCAL.g4), and I'm implementing a visitor class (EvalVisitor) extending ...
Cian Sullivan's user avatar
0 votes
0 answers
37 views

Does WABT provide complete support for WebAssembly Garbage Collection (WasmGC)?

I can see that wat2wasm does have the option to enable "gc" but when running this example (with all features enabled): (module (type $Node (struct (field $next (ref null $Node)) (field $...
Troels Lund's user avatar
0 votes
0 answers
20 views

How to Properly Implement an Abstract Syntax Tree in PLY?

Hi guys I am relatively new to compiler designing, I am seeking some assistance in regards to creating an AST as well as performing semantic checks and code generation on the tree. Please see the ...
Ackeem Mclennon's user avatar
0 votes
0 answers
53 views

Seeking for QEMU emulable Harvard RISC CPU

I am currently working on a project for my Computer Architecture course at university. The task involves selecting a programming language, in my case, a Lisp-like one, and writing a compiler for it. ...
Vyacheslav's user avatar
-1 votes
1 answer
42 views

ANTLR4 'error: package org.antlr.v4.runtime does not exist' on MacOS

I'm trying to build a compiler using ANTLR4 for a uni project and for now I'm stuck. I tried running javac TestPiinkk.java Piinkk*.java and about 100 errors came up: I've looked at some other ...
Lula's user avatar
  • 1
0 votes
0 answers
13 views

Java compiler API convert TypeMirror to Type

I hardly ever used the Java compiler API before, so I have very little experience with it. I want to get the type of the class my MethodTree is in as a Type. This is what ChatGPT gave me, but it ...
v22's user avatar
  • 15
0 votes
0 answers
57 views

Implementation of a type system in compiler construction [closed]

Im working on a silly little compiler. Im now on AST creation step and I cant figure out how to handle type checking. Compiler 'breaks' down code to fundamental types, like integers and floats. ...
DisplayName's user avatar
1 vote
1 answer
36 views

LLVM code generation from AST memory error

I have this AST structure, which fills in parser.c generated by Bison. First of all, dummy code I try to compile: start int a; a = 5; end AST: struct ASTNode { NodeType type; ...
mantissa's user avatar
  • 152
-1 votes
0 answers
19 views

Finding FIRST of non-terminals in a CFG

Compute the FIRST and FOLLOW of S, A and B: S -> Aa | Bb A -> Sc | epsilon B -> Sd | epsilon Note: S, A and B are non-terminals When I tried to find FIRST(S), it points to ...
Razi Ullah's user avatar
-1 votes
0 answers
48 views

Can't Link a Library to a G++ project... Am I missing something?

So this is kind of bizarre, and I'm certain I'm doing something stupid. I have a project I'm working on, and I've successfully linked several libraries to the project. However, I'm now trying to link ...
Jeremy Hahn's user avatar
-2 votes
1 answer
71 views

Ternary operator in java - not understandin from compiler and jvm perspective

Do i understand correctly this byte b =40; Compiler-type checking whether value belong to within range of datatype(byte) Ok, then JVM allocates memory and keep the value? If i unerstand correct, my ...
Boris Hartiník's user avatar
-1 votes
0 answers
18 views

Operators priority in eBNF grammar

I have the following eBNF grammar: expression = term { add_operator term } term = factor { mul_operator factor } factor = "(" expression ")" | variable | number ...
QuickDzen's user avatar
  • 251
0 votes
0 answers
31 views

A question related to formal language theory and parsing in compiler design

I am trying to extend the grammar of the Tiny language. "reg" represents regular expressions, "&" signifies concatenation, "#" denotes closure, "?" ...
Zzz0522's user avatar
0 votes
1 answer
77 views

How to print a proper parse tree in console using Java?

I am writing a program that simulates the 6 compiler phases using java. Currently, stuck in the printing of the parse tree in the 2nd phase, syntax Analyzer. I already know what my problem is after ...
Seifeldin Elkasrawy's user avatar
0 votes
0 answers
11 views

Solve Code dependency for using a variable which defined at later stage

I have a scrit to help with ThinkOrSWim trading. In the script, there is a tradePL variable which is working, now I need to use its value earlier in the script for stopSignal, problem is that it is ...
PirTrade's user avatar
3 votes
0 answers
54 views

With gcc -O3 optimization, why does the loop index's type affect gcc's internal GIMPLE vector constants (but not the final asm)?

I created a struct array, and here is my source code. #include <stdio.h> #include <stdlib.h> #define N 256 typedef struct arc { int num; } arc_t; typedef double cost_t; typedef ...
Daisy G's user avatar
  • 31
0 votes
1 answer
127 views

C problem about Compiler and Memory Theory [closed]

Without calling any "call" or "jump" function, we need to get a output in order of "this is the first" then "this is the second.". In my opinion we need to use &...
SugarFree's user avatar
2 votes
1 answer
87 views

Why does F# runtime throws a invalid program error when using struct decorated DU with big number of cases?

I'm using a DU type as tags i.e. no trailing data, but at runtime, it throws an exception. like [<Struct>] type Tag = | Case0 : | CaseN when N are getting big enough the runtime ...
kam's user avatar
  • 649
0 votes
0 answers
20 views

Convert a ocamlyacc's Parser.mly file to fsyacc's Parser.fsy got " End of file on lexing stream" error

Parser.fsy: %{ //let env=Hashtbl.create 10 %} %token INT %token SUB %token EOL %token EQUAL %token NAME %left SUB %start main /* the entry point */ %type main %% main: ...
wang kai's user avatar
  • 1,725
1 vote
0 answers
89 views

Wrong dominance frontier

My problem is probably misunderstanding of dominance frontier algorithm. I am implementing SSA form according to this paper: https://c9x.me/compile/bib/ssa.pdf It seems my algorithm for computing ...
weak's user avatar
  • 11
1 vote
0 answers
24 views

Spim MIPS Simulator not launching (Stanford cs143)

Currently trying to do assignments for Stanford's cs143 class. (edx online course) When I try to run spim, I get this error: The file directory shows that that file does in fact exist. I also don't ...
cytocracy's user avatar
0 votes
1 answer
32 views

unbound identifier in Racket

I have this code sample #lang racket (provide parse desugar eval load-defs repl) (struct eq-exp (lhs rhs) #:transparent) (struct and-exp (operands) #:transparent) ...
Ibne Nahian's user avatar
0 votes
1 answer
40 views

How to fix this prog which using ocamlyacc?

parser.mly: %{ let env=Hashtbl.create 10 %} %token INT %token SUB %token EOL %token EQUAL %token NAME %left SUB %start main /* the entry point */ %type main %% main: ...
wang kai's user avatar
  • 1,725
0 votes
0 answers
35 views

How to use ILGenerator got the exe file?

I'm learning how to use ILGenerator,I find some sample(can't find lots): https://devtut.github.io/csharp/ilgenerator.html#creates-a-dynamicassembly-that-contains-a-unixtimestamp-helper-method the ...
wang kai's user avatar
  • 1,725
0 votes
0 answers
42 views

I'm designing a coroutine scheduler, what if the code in the coroutine calls a blocking syscall?

This is a scheduler similar to the one in Golang, implemented in C language, including GC (Garbage Collection). It will be used in the runtime of a programming language. I am using musl libc. In ...
weiwenhao's user avatar
-1 votes
1 answer
45 views

Resolving Errors in a Yacc and Flex Compiler Project | Cannot generate AST from YACC Grammar

I want to display an AST for a given expression, and given below is my code for the same Lex File %{ #include "y.tab.h" #include "ast.h" %} %option yylineno digit [0-9] ...
Kaushik Dey's user avatar
3 votes
1 answer
90 views

Why does regex ^(?:a+)+$ causes catastrophic backtracking?

I'm learning both compiler principles(whose regex can always do task in O(n)) and general regular expressions. I notice that some regex may have catastrophic backtracking, which seems to be in ...
o_oTurtle's user avatar
  • 1,133
6 votes
3 answers
229 views

Why compilers doesn't inline everything, analyze it and then generate their own optimized functions?

Problem summary I'm trying to do an in-memory database with transactions. I'm reaching bottlenecks on compiler level, specifically inlining limit. I don't have much knowledge about compilers and I ...
user1576055's user avatar
0 votes
0 answers
38 views

C type representation in abstract syntax tree (AST)

I am implementing a C compiler and I am struggling to find a good way of representing an expression's type in the AST. Is there a standard way of doing this? I thought about implementing it as a ...
gillo04's user avatar
  • 36
1 vote
1 answer
94 views

yacc-how to write yacc code for checking balanced parentheses

It should give valid for () ()()()() (()()()(())) And Invalid for ( ((( ()()) YACC CODE: %{ #include<stdio.h> int yylex(); int yyerror(char* err); extern FILE* yyin; %} %token OPENING CLOSING %...
Mohammed Khalid Ahmed's user avatar
2 votes
1 answer
74 views

Does the Java compiler do a constant folding optimization and how to check it? [duplicate]

The question have been answered: is there any concept called "Constant Folding" in java?, but the page in this answered I can't find: https://www.javaworld.com/jw-03-2000/jw-03-javaperf_4....
wang kai's user avatar
  • 1,725
0 votes
0 answers
29 views

CFG of declaration of variables and functions with reduce-reduce conflict

I was working on a compiler for certain language similar to C++ with the tools flex and bison. I'm new to them and I found it difficult dealing with the reduce-reduce conflict between variable ...
Acliech Chen's user avatar
0 votes
1 answer
45 views

Parse an expression with non whitespace seperated operators

I am currently working on a compiler. Recently, I stumbled upon an issue concerning the parsing of operators in an expression. Obviously I have not found this to be an issue in other languages, which ...
YayL's user avatar
  • 11
1 vote
2 answers
61 views

What is the basic type that underlies all other Swift types?

I'm currently trying to get a better understanding of Apple's open-source Swift compiler on GitHub. After using Swift for several years, I've gotten used to the philosophy of defining important types ...
Frævik's user avatar
  • 19
0 votes
0 answers
16 views

How to get type metada from typescript compiler api

I need to get information about the types in lib.dom.d.ts so I can check what methods and properties are available in all the different HTML types programmatically. I mean types like HTMLInputElement ...
Shulkmaster's user avatar
0 votes
0 answers
18 views

Which gcc O2 option do this constant folding?

I am not familiar with gcc,this code: int a=145;int b=267+a; printf("%d/n",b); if comiple with no optimize option,will use the "addl" command,but if open O2 option,it will show me ...
wang kai's user avatar
  • 1,725
1 vote
0 answers
71 views

Cobol program does not want to read assigned file

I am currently in a Cobol course and I have an assignment that requires the program to fetch data from two assigned files. However I am receiving an error in my compiler that goes by libcob: error: ...
justinlesn's user avatar
0 votes
0 answers
106 views

LLVM pointers dereference

In my main function, I have allocated an i8 pointer: %a = alloca i8*, align 8 store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @1, i32 0, i32 0), i8** %a, align 8 Is it possible to: assign a ...
Kellan_B's user avatar

1
2 3 4 5
233