I know this should probably be in "Cutting Edge", but it is too late. Peter van Eerten, author of gtk-server, has written an amazing lexical parser/converter/compiler from basic to C in bash! He describes the program thus:

Quote:

BaCon is a free BASIC to C converter for Unix-based systems. The following design goals were followed:
Must run on each Unix/Linux/BSD platform, including MacOSX
Converted sourcecode must be compilable with GCC
Must resemble genuine BASIC with implicit variable delarations
Spoken language constructs are preferred
To use Bacon your system must have Korn Shell or Bourne Again Shell (BASH) available. If both Korn Shell nor Bash are available on your platform, download and install the free Public Domain Korn Shell which can execute BaCon also. Furthermore BaCon works with the traditional Korn Shell KSH88, but also with a newer Kornshell implementation like the MirBSD Korn Shell.

It supports gtk gui creation via glade and via calls to gtk libs. I have packaged the "compiled" compiler (yes, BaCon compiles itself!), the bash version and examples in the attached archive. The GTK apps I tried were about 20-30k in size after stripping.

BaCon presupposes a compiling environment, so if you don't have gcc, gtk headers etc. installed, you won't be able to do anything except to examine the source. I have also cleaned up a few examples. Documentation is included in the /doc dir.

Now, if we could only write a little lib (in Bacon - it supports includes) to understand gtkdialog syntax, we would have a nice little tool and very and small speedy apps - and the problems that Zigbert retularly experiences with widgets misbehaving or not recognizing one another's states would be solved.

With kind regards,
vovchik

BTW. BaCon - via functions and subroutines - is a "structured" variety of the language, which means no spaghetti. You can use it like Pascal and also make direct C calls. The sources are available at: http://www.basic-converter.org.

Ahem, before anyone responds that there is one, no there isn't. There is a public domain tool that embeds Bash source inside a binary executable. That offers no advantages except hides the Bash source.

There is actually a shell to C converter, a commercial product, but it is not for Bash, one of the other shells.

So the design of Basic/C and Bash programs use very different concepts.
Basic/C: inbuilt code
Bash: external utilities, the typical GNU idea to put utilities in a chain.

I think the modular approach of Bash, is also the potential drawback, that might make it much slower than the other languages.
Each utility is run in a subshell, and even worse: invoking another interpreter, if the utility is a script.

------------------------
Bacon looks interesting. Small executables, and by importing functions from shared libraries, the function calls are very close to the C syntax.
Like this existing C documentation can be used as programming reference.

I think we gain about 25% reduction by stripping (see the make-all script). It is instantaneous with such small binaries. The C stuff I changed in, for instance, gtkabout1.bac was pretty trivial - and I annotated my changes just to show how to create a button. Of course, we could write BaCon functions to wrap the gtk lib calls and make everything pretty and transparent - and more Basic-like.

I just got a nice email from Peter, the author, and he promises a working setenv, in addition to getenv, and a better system call (returning stdout and stderr) soon. I would also like to see CASE implemented, and he is considering it. We should send him bug reports or post them here, so that he gets feedback and continues to improve what I think is a very small, useful and CLEVER development tool.

If we have interesting libs or progs, we should also let him know so that he can post them on his site, too.

With kind regards,
vovchik

PS. I will look into the monkeymenu business. I think I first copied the Mr. Tech dir from FF into the appropriate Seamonkey dir, added a bit to the rdf (copied from a legitimate Seamonkey2 extension) and, after restarting Seamonkey2 and having fixed the rdf for monkeymenu in the same way, used Mr. Tech's local install feature to bring it in. It really works, although I haven't been able to adjust the size of the search box but did not try very hard. Since I was experimenting and not really counting on success, I didn't do a good job of recording my steps.

Although no great shakes here, I managed, as a test, to translate my bash mkbac into BaCon. My coding is exceptionally primitive, but I simply wanted to see how much time it would take to understand the syntax for basic procedures such as string handling, simple file i/o and parameter passing. The size of the BaCon binary is, obviously, much larger than the bash file, but that was to be expected, since the bash version doesn't really do that much and makes its own external calls (e.g date). I have attached the source and a binary.

I imagine MU and a few others on the forum could write a number of useful function libraries to simplify file, string handling, gtk calls and file i/o. What is amazing is that it works!

Thanks for the suggestion. I posted this at 99-bottles-of-beer.net. The team will have to examine the code first, but here it is, in all its inelegant glory. It does, however, demonstrate the new SELECT/CASE statement, which I wanted to try out. There are 1000 ways of doing this, at the very minimum. My approach was guided by the esteemed and widely accepted principle of "minimum thought".

We could always ask Peter whether he might consider implementing an OUT command directly. He is very forthcoming. But, you could also write your own function that would call a C routine and adjust your source accordingly. That is the nice thing about BaCon - it is "best friends" with C, so that if a routine is available in a C lib, you can generally call it - first having figured out the calling syntax and required var types. I am certain you could integrate your existing formulas pretty easily in an include lib. That lib might also interest some others (like the gmp include lib) in the first post.

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum