Lex code to divide C program into Functions and signatures
<p>I was trying to create a Lex program that does the following:</p>

<p><strong>INPUT</strong></p>

<p>float hey1(int a, int  b);</p>

<p><strong>OUTPUT</strong></p>

<p>Function: hey1</p>

<p>it returns: float</p>

<p>Signature:</p>

<p>a - float</p>

<p>b - float</p>

<p>With the current knowledge I have of LEX, I decided to input the test file and output the 1st part to another file, which would become the input for the next part. Kindly guide me forward, as I have come to a dead end, and can't proceed forward.</p>

<p>My attempt :-</p>

<pre><code>%{
   FILE *out;
%}

letter    [A-Za-z0-9]

%%
("float"|"void"|"int")" "{letter}*"("       fprintf(out,"Function: %s", yytext) ;
%%

int main()
{
    yyin = fopen("test.c","r") ;
    out=fopen("out.c","w");
    yylex() ;
    fclose(yyin) ;
}
</code></pre>

<p>Thanks </p>