batch to bash translation

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

batch to bash translation

Postby foundation » Thu Jan 14, 2010 11:08 am UTC

Hi

I wanted to share a project of mine here.

I was working on it as a part of compilers class exam.

It is a windows batch script to bash translator

you can see it here http://ea.github.com/batch2bash/

i know the project itself might be pointless , but since xkcd forums have wide range of users
with wide range of interests , it looked like a good idea to post it here :)
i had a great trouble finding something similar, there isn't anything

it's written in a combination of c and c++ , mostly c++
it's using bison and flex for parsing

the most valuable in this project could be the grammar of batch scripts , which i was unable to find anywhere , so i'm posting this topic so that anybody who needs it in the future could find it via google :)

of course , the grammar is incomplete, as is the translation, but it handles things pretty well

cheers , ea
foundation
 
Posts: 9
Joined: Mon Dec 17, 2007 11:59 am UTC

Re: batch to bash translation

Postby keeperofdakeys » Mon Jan 18, 2010 3:49 am UTC

looks good
Last edited by keeperofdakeys on Mon Jan 18, 2010 9:57 am UTC, edited 1 time in total.
GENERATION 2+i: The first time you see this, copy it into your sig on any forum. Divide by zero, and then add i to the generation.
Image
User avatar
keeperofdakeys
 
Posts: 658
Joined: Wed Oct 01, 2008 6:04 am UTC
Location: Adelaide Hills, Australia

Re: batch to bash translation

Postby TheChewanater » Mon Jan 18, 2010 5:01 am UTC

There are a few flaws ("@ECHO OFF" actually echos "off" and it has problems with absolute paths beginning with "C:/"), but it seems to work pretty well with the example batch files I looked up.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.
User avatar
TheChewanater
 
Posts: 1259
Joined: Sat Aug 08, 2009 5:24 am UTC

Re: batch to bash translation

Postby foundation » Thu Jan 21, 2010 6:42 am UTC

keeperofdakeys wrote:looks good

tnx

TheChewanater wrote:There are a few flaws ("@ECHO OFF" actually echos "off" and it has problems with absolute paths beginning with "C:/"), but it seems to work pretty well with the example batch files I looked up.


well, right now the grammar is pretty hacked up , it will probablly have some changes
when we get some time to work on it again
batch grammar is really tricky, no formal specification so we basically reverse engineered it
foundation
 
Posts: 9
Joined: Mon Dec 17, 2007 11:59 am UTC

Re: batch to bash translation

Postby metamorphosis » Fri Mar 23, 2012 11:36 am UTC

Just for those who accidentally stumble across this in google while searching on how to do this automatically...
it doesn't work.
TO save you some time compiling, it doesn't work. Okay? Errors out on every single script I've thrown at it.
Here's some links that will help you instead:

http://tldp.org/LDP/abs/html/dosbatch.html
http://www.dostips.com/DtTutoFunctions.php
http://stackoverflow.com/questions/2143 ... -dos-batch
http://forums.macrumors.com/showthread.php?t=627186
http://www.unix.com/shell-programming-s ... files.html
metamorphosis
 
Posts: 13
Joined: Sun Sep 26, 2010 8:56 am UTC


Return to Coding

Who is online

Users browsing this forum: hitechito, Slageammalymn and 9 guests