I would like to know if it is possible to write a program that creates regexes from an entire C++ source code. what i mean by this, is that the program reads the code, and then creates regexes for parts of the code. i want to create something that keeps the type then uses (w+) for the variable name. I know that it is simple to code for easy cases but i wonder if it even is possible for more complicated code. i also want that the regex that is created a specific regex is that i can access later or so like for example (w+)1.
example:
code to be read:
int main(){int a = 10; int b = 12; int sum = a + b;}
i want it to be a regex like:
int((w+)1)=10;int((w+)2)=20;int((w+)3)=((w+)1)+((w+)2)
but now i want to know if it is possible to get this done with somewhat more difficult types of code like if statements (like the i that can be initialised inside the if statement), loops etc. also how do i get the types (because sometimes a type can also be a struct, class, … defined elsewhere so it cant be added to a vector off all types) without having to write all the types into a vector or so.
is this even possible and if it is how does one start with this?
(if it sounds stupid im sorry for wasting your time, im new to pragramming)
i have tried to create it for each type by adding all the types to a vector but i cannot seem to get it dynamically. because if there are more difficult types in front of a variable like a struct that was defined elsewhere i cannot choose it from a list of types. also i cant seem to be able to get loops and if statements to work
OrdinaryGuy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.