Migrating C Code from OS2 to Windows

S

skulkrinbait

Hello, I need some help please.

I need to migrate some applications from OS2 to Windows, the source
code is C. I believe this can be done using Lex and Yacc and have
installed Cygwin with Flex and Bison which I believe are compatible but

I'm having trouble getting Flex to process the C file. I assume that
I need to write some rules for Flex to use but as I'm not familiar
with C I've no idea what the rules should be. Apologies for sounding
like a dunce here but any help would be appreciated.
 
P

pemo

Hello, I need some help please.

I need to migrate some applications from OS2 to Windows, the source
code is C. I believe this can be done using Lex and Yacc and have
installed Cygwin with Flex and Bison which I believe are compatible
but

I'm having trouble getting Flex to process the C file. I assume that
I need to write some rules for Flex to use but as I'm not familiar
with C I've no idea what the rules should be. Apologies for sounding
like a dunce here but any help would be appreciated.


What makes you think that you need Flex etc, what does the OS/2 code
do/look-like?
 
C

Chris Dollin

Hello, I need some help please.

I need to migrate some applications from OS2 to Windows, the source
code is C. I believe this can be done using Lex and Yacc

What's wrong with using a C compiler?

If there's something /wrong/ with the C code, you'll get better
help if you tell us what the problem is, rather than what your
attempt at a solution is.

If you're not familiar with C, and the code wasn't written with
portability in mind, moving it from one platform to another could
be rather tricky.
 
J

jacob navia

(e-mail address removed) a écrit :
Hello, I need some help please.

I need to migrate some applications from OS2 to Windows, the source
code is C. I believe this can be done using Lex and Yacc and have
installed Cygwin with Flex and Bison which I believe are compatible but

I'm having trouble getting Flex to process the C file. I assume that
I need to write some rules for Flex to use but as I'm not familiar
with C I've no idea what the rules should be. Apologies for sounding
like a dunce here but any help would be appreciated.

This is a mistake. Lex and Yacc are not needed at all.
What you have to do is

1) Find somebody that has a clue. If you think that lex/yacc
will port a C application from OS2 to Unix it means you
have no clue but really ABSOLUTELY NOTHING!

2) Pay him/her what he/she wants (you have no choice anyway)
 
D

David West

Having no knowledge of migrating applications across OS I was given the
advice (rightly or wrongly) that I needed to use Lex and Yacc or
similar to do the job as well as a C compiler. My understanding, which
could well be wrong is that C differs slightly on the different OS,
hence the need for some kind of "translation".

The code is a compiler for a bespoke language called "AB" which
resembles a form of BASIC. A small excerpt of the code follows (the
whole thing is 42kb), thanks for your help:

BOOL CheckCancel( MODULE_TYPE iCompiler )
{
BOOL bRtn = FALSE;


if ( pShared->RelMechData.bCancelRelease )
{
/*
* The compilation process has been cancelled.
*/

if ( iCompiler == MBuildRelease )
{
/* Do not abort this thread, since this is the Main Build
Release Thread... */

AddStatus( INFORMATION , "Abort !" , "Compilation process
aborted by operator" );
}
else
{
/* Exit this thread, this is the compiler thread... */

AddStatus( FATAL , "Abort !" , "Compilation process
aborted by operator" );
}

bRtn = TRUE;
}

return bRtn;
}
 
C

Chris Dollin

David said:
Having no knowledge of migrating applications across OS I was given the
advice (rightly or wrongly) that I needed to use Lex and Yacc or
similar to do the job as well as a C compiler.

Unless there's something else going on that you haven't mentioned yet,
this seems unlikely.
My understanding, which
could well be wrong is that C differs slightly on the different OS,
hence the need for some kind of "translation".

Such translation is probably best done by people, and done in such a
way as to reduce or eliminate the code that "needs to be different".

Unless you understand what the differences /are/, automated
assistance isn't likely to help.
The code is a compiler for a bespoke language called "AB" which
resembles a form of BASIC.

It's /possible/ that whoever said you needed Lex and Yacc thought
that you'd need to rewrite the code to use them as part of the
migration. (You very likely don't.) Or it's possible that the AB
compiler is written using them (Lex and Yacc, or Flex and Bison,
turn descriptions of languages into C code [well, tables for C code])
and migrating it will need to migrate the lexis and grammar.

If that's so, comp.lang.c is the wrong place to ask about the
Lex and Yacc bits. There are more appropriate newsgroups;
I'd try asking in comp.programming or comp.compilers.

The C code you present looks fine (assuming that all the undefined
names are defined in suitable header files). 42Kb of code isn't
much, unless you really meant 42K /lines/. The problems will
come when you try and compiler it, and then when you try and
run it (hopefully there are tests suites you can run to make
sure it's migrated reasonably safely).
 
R

Richard Tobin

Chris Dollin said:
Or it's possible that the AB
compiler is written using them (Lex and Yacc, or Flex and Bison,
turn descriptions of languages into C code [well, tables for C code])
and migrating it will need to migrate the lexis and grammar.

In this case you will quite likely be able to generate the C code on
the old OS and just copy it over.

-- Richard
 
P

pemo

David said:
Having no knowledge of migrating applications across OS I was given
the advice (rightly or wrongly) that I needed to use Lex and Yacc or
similar to do the job as well as a C compiler. My understanding,
which could well be wrong is that C differs slightly on the different
OS, hence the need for some kind of "translation".

The code is a compiler for a bespoke language called "AB" which
resembles a form of BASIC. A small excerpt of the code follows (the
whole thing is 42kb), thanks for your help:

BOOL CheckCancel( MODULE_TYPE iCompiler )
{
BOOL bRtn = FALSE;


if ( pShared->RelMechData.bCancelRelease )
{
/*
* The compilation process has been cancelled.
*/

if ( iCompiler == MBuildRelease )
{
/* Do not abort this thread, since this is the Main Build
Release Thread... */

AddStatus( INFORMATION , "Abort !" , "Compilation process
aborted by operator" );
}
else
{
/* Exit this thread, this is the compiler thread... */

AddStatus( FATAL , "Abort !" , "Compilation process
aborted by operator" );
}

bRtn = TRUE;
}

return bRtn;
}

I suspect that the only major problem you might have is if the code uses
OS/2 APIs and that these will have to be ported to use Windows' API calls.

Years ago I work on a 'thing' called WLO [pronounced /Willow/ - The
*W*indows *L*ibraries for *O*S/2] - ok, it went the other way, but the
/mapping layer/ might be of interest to you, e.g., the libraries would
re-direct OS/2 [actually GPI] APIs like gpiFullArc to the Windows' Elipse
function in GDI. The idea here was that one could port a Windows app to
OS/2 via simply linking to these replacement libraries. Of course, you'll
most likely not find something that does this in the other direction -
dunno, been away from this stuff for some time now. So, you'll have to
/port/ any API calls manually - most I suspect will now [2K, XP etc] move
easily - but that's what I always think!
 
A

Al Balmer

Chris Dollin said:
Or it's possible that the AB
compiler is written using them (Lex and Yacc, or Flex and Bison,
turn descriptions of languages into C code [well, tables for C code])
and migrating it will need to migrate the lexis and grammar.

In this case you will quite likely be able to generate the C code on
the old OS and just copy it over.
OK for the initial port, but not for maintenance. I'd port the highest
level source available.
 
K

Keith Thompson

jacob navia said:
(e-mail address removed) a écrit :

This is a mistake. Lex and Yacc are not needed at all.
What you have to do is

1) Find somebody that has a clue. If you think that lex/yacc
will port a C application from OS2 to Unix it means you
have no clue but really ABSOLUTELY NOTHING!

2) Pay him/her what he/she wants (you have no choice anyway)

Maybe. Since, as the OP said later, the C application is a compiler
for a custom language (called "AB"), lex and yacc might well be part
of the solution.

Using lex and yacc to port C code in general is absurd, but it could
make sense in this particular case. (No offense, jacob; I'm sure you
hadn't seen the OP's followup when you posted this.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,979
Members
47,579
Latest member
CharaS3188

Latest Threads

Top