Virendra K. Mehta (c1veeru@WATSON.IBM.COM) wrote:: I have a scanner developed using lex on a Unix machine (ASCII). It is a: front end for a processor that works on COBOL files. The files taken off a: mainframe are processed on the Unix machine and the modified files are: transferred back. To do away with this transfer business, I'm trying to: port the scanner onto the mainframe. However the mainframe uses EBCDIC: while lex generated tables, state machines etc. expect an ASCII input.
...

I don't know about lex but flex scanners contain a table named yy_ec
that functions very much like a 370 TRT instruction. It uses each input
character as an index into this table and retreives a state number from
that location. You can translate this table (by hand) from an ASCII to an
EBCDIC basis by taking the state number in each location of the table
and moving it to the location that code value occupies in EBCDIC. The
new table can replace the old and the scanner can then be compiled
in the EBCDIC environment.

However, for this approach to work, you must tell flex to produce an 8
bit scanner (the default is 7). Scanners built with the 7 bit option have
a yy_ec table that is only 128 bytes. Some versions of flex were built
without the option to produce 8 bit scanners so you may have to try a few
versions or get the sources (any GNU archive) and make flex yourself.

Another approach is to get the source for flex and port that to the
mainframe but that may take you more time than it's worth. If the .l file
changes infrequently I would suggest the first approach.

I wrote a program that performs the transposition in a klugey but
effective way. I can send it to you if you wish. Contact me by email
since I infrequently cruise these mail lists.
--
Mike Duffy
--