Need lex not flex for linux

Need lex not flex for linux

Post by Michael Wolf » Thu, 22 Apr 1999 04:00:00



Hey folks,

I need to translate a lex source in which the input function is redefined.
The flex won't work with such a re redefinition. Therefore I'm looking for a
lex, does anybody where I can get a copy of it.

Thanx
Michael

 
 
 

Need lex not flex for linux

Post by James Youngma » Fri, 23 Apr 1999 04:00:00



> Hey folks,

> I need to translate a lex source in which the input function is redefined.
> The flex won't work with such a re redefinition. Therefore I'm looking for a
> lex, does anybody where I can get a copy of it.

It's proprietary.

--


 
 
 

Need lex not flex for linux

Post by Duncan Simps » Sat, 24 Apr 1999 04:00:00



Quote:>Hey folks,
>I need to translate a lex source in which the input function is redefined.
>The flex won't work with such a re redefinition. Therefore I'm looking for a
>lex, does anybody where I can get a copy of it.

If you actually read the docs POSIX says you are not allowed to do
this. You can change the YY_INPUT macro and get the lexer to use
whatever input source you want. (C++ lexing classes and a custom istream
would also be a solution). All this from reading the FM.

Do not ask em abiut the detials right now as I have not read the FM enough yet (and have no plans to do so immediately).

Duncan (-:

--
Duncan (-:
"software industry, the: unique industry where selling substandard goods is
legal and you can charge extra for fixing the problems."

 
 
 

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. SCSI DIED IN 2.1.120 kernel

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

4. ARE YOU READY TO BE RICH TODAY ?????!!!! COOOOOOL !!

5. searching for lex, not flex...

6. .signature file not working

7. Lex/Yacc Substitute (not bison/flex)

8. Access to Solaris via Telnet

9. No X programs work / Need flex or lex

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

11. Object-oriented lex(flex) and yacc(bison) for c++?

12. lex/flex-problem scanning file many times

13. lex/flex problem scanning a file many times