IEC 61131-3 structured text translator [code offer]

  • Thread starter Campbell, David (Ex AS17)
  • Start date
C

Thread Starter

Campbell, David (Ex AS17)

I have thrown together a structured text translator which produces FORTRAN code (err... the task at hand required FORTRAN, please don't ask reason why).

I was thinking I might convert the internal routines to produce "C" code and then dump it into the LinuxPLC forum. The core of the current program is a medium sized Bison script (261 rules, 4162 lines long).

I will need to strip out some platform specific stuff of the core engine (specifically accessing physical IO, perhaps also MODBUS memory address referencing since this would not conform to the original standard).

The current code compiles under the following platforms:
Linux
VMS (again, don't ask why)
Cygwin (GCC tools for WinNT)
MS Visual C++ 6.0

Current limitations of the code is that "short" variants of INT and REAL variables are treated as "long" variants. This is to deal with the problem of FORTRAN not support function prototypes, this creates problems when passing constants or inline expressions (eg: is "3.14" a single or double precision floating point number?)

The handling of DATE/TIME variables needs some work. I have just laid my hands on the 1998 draft standard so hopefully I can clean this up (or with some assistance, I would prefer to release the code and then tidy up the rough edges later).

I have personally had a manic week so it might be Monday or Tuesday next week before I can complete the conversion of FORTRAN to "C" generation routines.

Comments anyone? Do I bother wasting my time or is there something similar in LinuxPLC already?

David Campbell


_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
Hello,

> I have thrown together a structured text translator which produces
> FORTRAN code (err... the task at hand required FORTRAN, please don't ask
> reason why).

> I was thinking I might convert the internal routines to produce "C" code
> and then dump it into the LinuxPLC forumn. The core of the current
> program is a medium sized Bison script (261 rules, 4162 lines long).
...

> Comments anyone? Do I bother wasting my time or is there something
> similar in LinuxPLC already?

There's currently a quick-and-dirty perl script (aren't they all?) which translates non-structured text (ie instead of brackets it uses the AND-block and OR-block instructions).

It has always been considered interim, and flex/bison sounds like exactly the right thing to replace it. If you look at it (logic/il/il2c.pl) and have any questions, I'm probably the best person to ask.


Jiri
--
Jiri Baum <[email protected]>
"Coffee machine out of paper" (error message missing from Coffee mini-HOWTO)

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
C

Curt Wuollet

Thanks Dave!

Yes, I hope you find this is very much worthwhile and we graciously accept your offer. Flex and Bison are indeed a good long term approach and the *nix way of doing it.

Please accept our warmest welcome and join our
rogues gallery. My next 2 weeks will be as you say, manic, but I'll try to look at what ever you post

Regards

cww
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
 
Top