Re: Porting lex scanner on EBCDIC machine.

rameshag@herbrand.cs.albany.edu (Anavai G Ramesh)
Mon, 3 Apr 1995 19:46:40 GMT

          From comp.compilers

Related articles
Porting lex scanner on EBCDIC machine. c1veeru@WATSON.IBM.COM (Virendra K. Mehta) (1995-04-01)
Re: Porting lex scanner on EBCDIC machine. gvcormac@plg.uwaterloo.ca (1995-04-03)
Re: Porting lex scanner on EBCDIC machine. mduffy@netcom.com (1995-04-03)
Re: Porting lex scanner on EBCDIC machine. rameshag@herbrand.cs.albany.edu (1995-04-03)
Re: Porting lex scanner on EBCDIC machine. kkaempf@didymus.rmi.de (1995-04-04)
Re: Porting lex scanner on EBCDIC machine. vern@daffy.ee.lbl.gov (1995-04-05)
Re: Porting lex scanner on EBCDIC machine. sasghm@unx.sas.com (1995-04-15)
Re: Porting lex scanner on EBCDIC machine. sasghm@unx.sas.com (1995-04-18)
| List of all articles for this month |
Newsgroups: comp.compilers
From: rameshag@herbrand.cs.albany.edu (Anavai G Ramesh)
Keywords: lex, question
Organization: University At Albany, New York, USA
References: 95-04-035
Date: Mon, 3 Apr 1995 19:46:40 GMT

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.


Simple. There are two ways to do this. If you have the original
lex specs, you can do it using the the %T definition.
Add the following code to the file containing the lex specs.


%T
<EBCDIC value> <symbol>
...
%T




If you don't have the lex specs, then you need a hack in the
generated file. The lex generated file (lex.yy.c) usually has a
routine called input. Modify this routine so that it returns the
ASCII value of the character rather than that EBCDIC value read from
the input file. Lex also uses a unput routine which puts a character
into a buffer so that the input routine can read it again. unput
must be modified to put the EBCDIC value in the buffer.


Lex introduces character constants like 'a' in the generated file (I
cannot understand why). Scan the generated files and replace all
constants by their ASCII values.


This works. I had used this technique to build a COBOL
parser for an IBM machine a few years ago.


Ramesh
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.