Luoay
yes, 🙏
AlanCcE
Good evening, everyone! I'm currently facing difficulties with a recent project I've been developing. I'm aiming to implement a terminal calculator entirely in C. So far, I've created a lexer that generates tokens for operators and numbers provided in the formula by the user. However, I'm struggling with implementing the parser. My intention is to develop the parser in a way that it 'processes' these tokens and creates an Abstract Syntax Tree (AST) which is gonna be used by an interpreter to calculate the result. Despite numerous failed attempts, I haven't been able to arrive at an implementation that works. Even after searching for references, I couldn't find anything specific enough to help solve my problem. I'd greatly appreciate it if anyone in the group could assist me with this implementation or provide any useful references. Below is the code related to the application: https://gist.github.com/Anthhon/06e5cd4d19f0c7b271526384e6dfbcf0
Rose
yes, 🙏
User Luoay has 1/2 warnings; be careful! Reason: homework
Danya🔥
Except using C
Danya🔥
What is the problem?
Danya🔥
The implementation of a parser should be pretty straight forward with recursive decent
Danya🔥
I bet there are a lot of material out there on the matter
Danya🔥
You can also use bison parser generator to generate the parser for you
AlanCcE
I bet there are a lot of material out there on the matter
The main issue lies in the logic behind generating the AST. Currently, the calculator stores all tokens in a list without a specific form or order. I'm struggling in devising a method to generate the AST structure efficiently. My struggle is in creating and arranging the AST nodes in accordance with the mathematical order of operations. I attempted to review other C-based calculators on GitHub, but most of them are not implemented in a similar manner or are quite challenging to comprehend. I also tried to make a solution by myself and my approach involved categorizing all operations and assigning them distinct "priority values." Then, I planned to organize them within a Tree Structure. (but this would need a double check to avoid duplicate values and etc.) However, I'm concerned that this approach might overly complicate the solution.
AlanCcE
You can also use bison parser generator to generate the parser for you
I'm gonna search about that to see if it's useful, thanks!
Danya🔥
I'm gonna search about that to see if it's useful, thanks!
If it's not, you should revise the way you're implementing the project
Danya🔥
You can take a look into https://craftinginterpreters.com It's a nice book that is gonna dive you into a programming language implementation, which is the next step after the calculator
Ludovic 'Archivist'
Do you know any free alternative?
you can read it on the website for free
Ludovic 'Archivist'
it is fun as the topic comes up when I am writing an interpreter
Ludovic 'Archivist'
(another one)
Ludovic 'Archivist'
Yet another one?
yeah to have something fun to do when I am not working on the compiler
Ludovic 'Archivist'
The compiler works btw, but I have found a memory corruption bug somewhere that forces me to waste a lot of memory to circumvent
Ludovic 'Archivist'
I need to fix the underlying library, and I am not doing that today
Danya🔥
I'm lost, which compiler?
Ludovic 'Archivist'
I'm lost, which compiler?
The one I am working on (not the thing for fun), because more than an interpreter, it is a JIT that can generate actual executables. even ELF ones if you define the stencils for ELF
Ludovic 'Archivist'
Architecture dependent generation details are implemented in the language itself
Ludovic 'Archivist'
I am basing myself of the 2021 paper on the Copy-and-Patch baseline compiler pattern, with a twist to implement the optimizer within the program itself
Ludovic 'Archivist'
A bit like Rust proc-macros
Ludovic 'Archivist'
The program introspecs itself while being JIT-compiled to generate its executable
Danya🔥
This is crazy
Ludovic 'Archivist'
This is crazy
Well, I am the infinite source of my own insanity, academics also help sometimes
Danya🔥
Do you use an "of-the-shelf" JIT?
Ludovic 'Archivist'
Do you use an "of-the-shelf" JIT?
Ahahahahaha, no, I am even removing the standard library of C++ from the dependencies
Danya🔥
Well, I am the infinite source of my own insanity, academics also help sometimes
Do you have a job?😂 (This is getting pretty offtopic)
Ludovic 'Archivist'
Do you have a job?😂 (This is getting pretty offtopic)
As a teacher, I had some down time waiting for my class to get on level on the basics, the season just starts now
Ludovic 'Archivist'
Maniac
The language doesn't even come with addition pre-baked, you have to run this to get the + operator barely working x86_64-pushq-rax %% 0x50 x86_64-popq-rax %% 0x58 x86_64-popq-rbx %% 0x5b x86_64-addq-rax-rbx %% 0x48 0x01 0xd8 x86_64-addq %% x86_64-popq-rax x86_64-popq-rbx x86_64-addq-rax-rbx x86_64-pushq-rax + ( i64 i64 ) ( i64 ) -- x86_64-addq
Ludovic 'Archivist'
of course, in a platform specific way
Ludovic 'Archivist'
I will make the repo public so that other C++ devs can go crazy like me when I fix this pesky memory corrupting vector
borealis
will you eventually rewrite your compiler in your own language?
Ludovic 'Archivist'
will you eventually rewrite your compiler in your own language?
possibly, if I have the patience to implement all the list manipulations in the language itself instead of C, which would basically be implementing std::shared_pointer in an assembler of my own design, and on every platform I want it to run on. I will need to at some point since the end game is to implement it for AVR and send a computer running it to space
Ludovic 'Archivist'
And by computer, I mean a cubesat with an arduino taped to a battery and an antenna, maybe a laser pointer to see if the astronauts are like cats and play chase the red dot
Ludovic 'Archivist'
People go to debt to buy a car, I go to debt sending stupid things to space, it is a better investment
𝙼𝚊𝚛𝚔𝚘𝚜 𐂃
Hi guys, i wanna know what's the next step after oop using c#, pls
💰💵⚛️💹⚛️💵💰
Hi guys, i wanna know what's the next step after oop using c#, pls
expand to learnt c# api, example : if someone has done learnt c++ oop, next step is learn c++ api like wxWidgets (GUI API for windows & linux), MFC (GUI api for windows only, there is inside vc++), OpenGL (3d programming windows & linux), QT (gui api for windows & linux), etc, database api as well like mysql, postgre, sql server ,etc
Rose
Welcome harmony5 @ 🇦🇶! Please read the pinned message 🙂 Click the button below to unmute yourself.
Rose
Purge complete.
Ludovic 'Archivist'
https://git.nekoit.xyz/Archivist/UserScript
*yes, the theme is fucked, clone the repo, some CDN borked my theme years ago and I never fixed it*
Ludovic 'Archivist'
I do all the infix handling using a tree that I rotate when the priorities get inverted (a link to a diagram is included in the code for that)
AlanCcE
Thx, I already got some little progress yesterday but I'm gonna take a look
Warren
Develop a Windows-based C++ application with the following specifications: 1. The application should be capable of executing other programs as subprocesses. 2. Before initiating any subprocess, the program must perform a pre-check. Specifically, it should attempt to suspend the Steam.exe process in a case-insensitive manner. 3. If the suspension of Steam.exe is unsuccessful, the software must gracefully exit with error code 1. 4. On successful suspension of Steam.exe, the application should proceed to resume the Steam process. 5. If the application is launched without a valid executable path, it should enter a background state, awaiting executable files. 6. Ensure that only one instance of the software is allowed to run. During the first instance, the application should start in the background, waiting for executable files. 7. In the case of a second instance attempting to run, it should gracefully exit after passing its arguments to the first running instance. The first instance, already in operation and waiting for commands, should receive the arguments and initiate the subprocess corresponding to the provided executable path. Importantly, the second instance should not perform the Steam.exe check and should exit after passing the arguments.
Dima
top kek
Ya deway
Hello guys, i Need some help with Windows10 EPROCESS and ETHREAD kernel strutture, there isnt a good documentation
Ludovic 'Archivist'
Hello guys, i Need some help with Windows10 EPROCESS and ETHREAD kernel strutture, there isnt a good documentation
There is no good documentation on purpose, the point of opaque structures is to not have an explorable structure the API user would mess up with
Ya deway
Ludovic 'Archivist'
ur making a cheat or what
Probably what they are doing
Ludovic 'Archivist'
Or an anticheat, I have done that before
Ludovic 'Archivist'
mine would slowly fill your C mount point with thousands upon thousands of pictures of cats if you cheated
Ludovic 'Archivist'
Yeah im developing a kernel mode driver and i need change data structure of a created thread
I can't find anything in the Orwick/Smith book either, good luck
Ya deway
I found on NirSoft the _KTHREAD struct but Its of Windows Vista😭
imminent
if you want the full struct, https://www.vergiliusproject.com/
Ya deway
Ok i try map driver, BSOD incoming
Ya deway
A bit of a stupid question, the structure _ETHREAD on the vergiliusproject site declares a _CLIENT_ID substructure but the compiler doesn't find it. PETHREAD is a pointer to _ETHREAD struct
Code
Hello, I need c++ projects
Code
For control flow.
Devil
Hello
Devil
Devil
I need computer basics drive link
\Device\NUL
A bit of a stupid question, the structure _ETHREAD on the vergiliusproject site declares a _CLIENT_ID substructure but the compiler doesn't find it. PETHREAD is a pointer to _ETHREAD struct
It has nothing to do with the compiler, It's the header. My recommendation is using this header for Windows Internals Programming https://github.com/MiroKaku/Veil
\Device\NUL
if you want the full struct, https://www.vergiliusproject.com/
This site is just viewing existing ntoskrnl.pdb from ms site