Ezlanding
Ezlanding
CC#
Created by Ezlanding on 1/10/2023 in #help
❔ Optimize Compiler Code Generation
I am writing a compiler and I am almost done with all the base syntax/functionality, and am up to optimization. Right now, the compiler isn’t optimized at all. No constant folding, no function inlining, and dead code is still emitted Where can I learn about the optimization steps above and other optimizations for my compiler’s code generation? How helpful is the Dragon Book? (I already have the book, but am not up to a point where it talked about optimization yet). Any good articles/videos/resources?
12 replies
CC#
Created by Ezlanding on 10/25/2022 in #help
What's the best way to not require forward declaration when traversing an AST [Answered]
I'm making a programming language, and I don't want to force forward declaration. I also would like to traverse the AST for analysis in a single pass (unless it is better have two passes in my case). Some ways to resolve this issue are 1. adding all undefined function calls to a list and when a function is declared check the undefined calls list. 2. When the Parser sees a function expr, hold a reference to it that will be used by the analyzer. Should I do a different implementation than these two? should I do two passes of the AST instead (if so, how will this affect speed)? How is this usually done by other languages?
15 replies
CC#
Created by Ezlanding on 10/9/2022 in #help
Best way to implement a regex based lexer [Answered]
In a regex lexer, you can loop over every pattern and do something like this:
if (match.Success && (match.Index - currentIndex) == 0)
//Token Found
if (match.Success && (match.Index - currentIndex) == 0)
//Token Found
The problem with this is that, unlike other Regex implementations, if c# regex sees that the first char does not match the pattern, instead of returning null/false, it keeps going until a match is found, meaning the if statement is needed and extra match calls are made. Is there any way to get this to work without the extra calls? I could use the index of each match and add them into a list in order based off the match's index position, but that seems needlessly complicated if there is a better way
26 replies
CC#
Created by Ezlanding on 9/6/2022 in #help
SendKeys.SendWait not working
.
26 replies
CC#
Created by Ezlanding on 9/5/2022 in #help
.NET Program that runs in the background [Answered]
How would I make an .exe program in c# .NET that runs in the background (It will have a tray icon instead). It will be used for capturing certain hotkey presses
50 replies