Help needed in porting AIX lex app to linux flex

Help needed in porting AIX lex app to linux flex

Post by sheadl » Sun, 09 Mar 2003 03:53:40



I have a problem I hope that I might get some clues on how to solve. I
am not as fluent as I should be on flex or lex (just picked up a
little recently as I worked on this problem), so please forgive me.

In the lex program I am trying to convert to flex, I have a
redefinition of the input and unput function:

*****************input()******************************
input(){
        int   i;

        if(mmlen>0) {
           yytchar = *mmptr; mmptr++; mmlen--;
           if((yytchar >= 'a') && (yytchar <='z'))
               yytchar = yytchar -'a'+'A';
           }
        else
           yytchar = 0;
        return(yytchar);
        }

*******************unput()***************************************

unput(c)
int c; {
        mmlen++;
        mmptr--;
        *mmptr = c;
        yytchar= c;
        }

**********************************************************************

Easy enough. It seems like the input function is turning all
characters from lower case to upper case. Problem is that I can't
redefine the input and unput functions in flex as I can in lex. Some
research on the web produced the following workaround:

Macro Redefinition:

#undef YY_INPUT
#define YY_INPUT(buf, result, max)  (generic_input(buf, result,
max_size))

code:
**********************generic_input()***********************************
generic_input( char *buf, int result, int max_size)
{

    for (result = 0; *mmptr && result < max_size; result++)
    {
      if((*mmptr >= 'a') && (*mmptr <='z'))
        buf[result] = *mmptr -'a'+'A';
    }

Quote:}

********************************************************************

My question is is this the right approach. Also what do i do about
unput. I found no information as to how to handle unput or if I need
to handle it.

Any help would be appreciated,

Steven Headley

 
 
 

1. Help needed in porting AIX lex app to Linux flex

I have a problem I hope that I might get some clues on how to solve. I
am not as fluent as I should be on flex or lex (just picked up a
little recently as I worked on this problem), so please forgive me.

In the lex program I am trying to convert to flex, I have a
redefinition of the input and unput function:

*****************input()******************************
input(){
        int   i;

        if(mmlen>0) {
           yytchar = *mmptr; mmptr++; mmlen--;
           if((yytchar >= 'a') && (yytchar <='z'))
               yytchar = yytchar -'a'+'A';
           }
        else
           yytchar = 0;
        return(yytchar);
        }

*******************unput()***************************************

unput(c)
int c; {
        mmlen++;
        mmptr--;
        *mmptr = c;
        yytchar= c;
        }

**********************************************************************

Easy enough. It seems like the input function is turning all
characters from lower case to upper case. Problem is that I can't
redefine the input and unput functions in flex as I can in lex. Some
research on the web produced the following workaround:

Macro Redefinition:

#undef YY_INPUT
#define YY_INPUT(buf, result, max)  (generic_input(buf, result,
max_size))

code:
**********************generic_input()***********************************
generic_input( char *buf, int result, int max_size)
{

    for (result = 0; *mmptr && result < max_size; result++)
    {
      if((*mmptr >= 'a') && (*mmptr <='z'))
        buf[result] = *mmptr -'a'+'A';
    }

********************************************************************

My question is is this the right approach. Also what do i do about
unput. I found no information as to how to handle unput or if I need
to handle it.

Any help would be appreciated,

Steven Headley

2. Dell 750 Intel 1G ethernet port--using e1000 source

3. flex/bison(lex/yacc) help needed.

4. Wich mouse should I buy

5. Need lex not flex for linux

6. IDE or off the floppy Tape Backups

7. how to port a lex application to flex

8. Stealth 32 PCI - when if ever ?

9. No X programs work / Need flex or lex

10. HELP ! lex / Flex and and the link library

11. Need help porting DOS app that uses parallel port

12. HELP:Any online tutorials on flex/lex?

13. Need help porting DOS app that uses parallel port (Part II)