I have a text file with a proprietary programming language and I want to extract the relevant information about various function calls.
The structure of the function is:
function name(input1, input2) returns (output1, output2) function body
I'm using Python and RegEx to capture this information, but I've hit a snag. I can capture the name, the inputs and the outputs, but I am unable to grab all of the function body.
I use the following line to capture this info:
re.findall("(function)(.*?)\((.*?)\) returns \((.*?)\)(.*)", file_contents)
However, after the first instance of the word, 'function', this fails. Due to nested statements in the function body, I am unable to use a particular keyword (I've tried different approaches, and I cannot fully grab the entire body) to grab the last group (this would be the function body).
How can I group everything after a particular point and then repeat the pattern?
What I want: 'function', 'name', 'input1, input2', 'output1, output2', 'function body' to repeat indefinitely. I want the last group to grab everything after the outputs and then the pattern to restart when it gets to the next occurrence of the word 'function'. I've tried different variations of the (.?) and (.) quantifiers, but I can't seem to get it.
I am not a programmer by trade, so I am not that adept with RegEx or Python. I know just enough to do the very basics.
{ }, by indents, or by a keyword).