5,870 questions
0
votes
0
answers
24
views
Designing a resource-constrained programming language (“BILA Core”): how to parse bit-level tokens, build a tiny VM, and expose hardware I/O?
Background
I’m prototyping BILA Core, an ultra-light language for micro-controllers (ESP32, RP2040).
• Each instruction is 1-4 bits (borrowed from Morse/Huffman).
• Source code is literally a bit-...
0
votes
0
answers
39
views
`IN[BB] = ∅` for all BB instead of `IN[BB] = U , for all other BB != BB_EXIT` in Init of Anticipated Expression Dataflow analysis in SSA form
I am implementing an LLVM pass for anticipated expressions using dataflow analysis and code hoisting. The reference I am following is the Purple Dragon Book (Compilers: Principles, Techniques, and ...
-1
votes
1
answer
72
views
How do I manipulate this dynamic vector for fold operations
I am working with flex/bison to create an interpreter for a class. The problem that I am encountering seems to be related to using/converting a dynamic vector. I am trying to create a function to ...
1
vote
1
answer
37
views
if the symbol table is created at compile time how can it know the stack frame depth and offset in procedures depending on user input
I have looked for suggested question that answer mine but did not find any related ones.
I am studying compiler design and have come across the feature that a language supports nested lexical scopes. ...
-4
votes
1
answer
147
views
How to add keyword to a C++ compiler [closed]
I need to simply add a compile-time check to a compiler in the form of a keyword. (similiar to const)
It would change nothing about how the compiler function, only give compile-time errors when ...
0
votes
1
answer
75
views
Use flex to parse ":" and ".:" in expressions
I have a lex file, and based on the original, I would like to add support for recognizing (.:). My modifications are as follows:
%option caseless
ALP [a-z]+
NUM [0-9]+
REF {ALP}{NUM}
...
0
votes
0
answers
28
views
How do I fix AccessViolationException occurring when calling LLVM.TargetMachineEmitToFile?
I have been working on a project for a little while now and have run into an issue repeatedly over the past several weeks. I am writing a compiler and have chosen to use LLVM to try to convert my IR ...
0
votes
0
answers
73
views
I am seeking a practical algorithm for a compiler to compress string literal data
I'm writing a hobby compiler and I'm looking for a sensible way to compress string constants. For a larger program, it isn't practical to try every possible permutation (then checking whether each new ...
1
vote
1
answer
73
views
An algorithm to match associative and commutative patterns
Background
For simplicity, just using ADD as an example.
In compiler backend, multiple addition is organized by combinations of multiple ADD instructions. For example ADD(1, ADD(1,3)).
But since it is ...
1
vote
1
answer
121
views
What is the correct way in assembly to push a value stored in stack to the stack again?
I am writing a small compiler for my language. Currently the way I am handling variables is by pushing their values to stack and storing their offset. Whenever a variable is needed I push [rsp+offset] ...
1
vote
1
answer
70
views
Why do lexers usually define a var as not being able to start with a number?
What's the difference between the token _123jh and 123jh that makes most lexers not include a number-starting identifier? I suppose one reason might be that a number-only token might be confusing, and ...
0
votes
1
answer
65
views
Parsing extended lambda calculus using recursive descent
I'm writing interpreter for simple lambda calculus based language in C. EBNF for language is
S ::= E
E ::= 'fn' var '->' E | T {'+' T} | T {'-' T}
T ::= F {'*' F} | F {'/' F}
F ::= P {P}
P ::= var |...
0
votes
1
answer
26
views
Issue with LL(1) Grammar Transformation – Parser Generator Error
I am working on transforming a grammar into LL(1) form, but when I try to use an online LL(1) Parser Generator, it reports an error. I have followed the standard procedure for the transformation, but ...
1
vote
1
answer
126
views
How to write a context free grammar in Haskell? Also, Am I going in the right direction in making this compiler?
For reference, I am learning from the book "Compilers principles: Techniques and Tools"(also known as "the dragon book").
I am making a language where you can add two natural ...
0
votes
1
answer
81
views
How to handle forward references with type inference
Making a compiler for oop language, with the same language. The compiler currently traverse the ast 4 times, first two are used for resolving type chain, the 3rd is used to populate symbol table for ...