feat: Add command-line compilation

This is performed using the sunshine executable jar, which must be
  separately downloaded, and a bash script in this project, called
  hel2py. Although the process is a bit cumbersome, it
  meets the original goals of this repository, so this will likely
  be the last commit.
This commit is contained in:
Glen Whitney 2020-12-10 22:12:51 -08:00
parent cd5f02603b
commit 04ad85ee38
2 changed files with 32 additions and 1 deletions

29
hel2py Executable file
View file

@ -0,0 +1,29 @@
#!/bin/bash
while [[ $1 = -* ]]
do
case $1 in
-h|--help)
echo
echo "To use this script to 'compile' a helloworld program, you must set"
echo "environment variables:"
echo " SUNSHINE_JAR to the full path to the executable sunshine jar downloaded from Metaborg"
echo " ECLIPSE_INSTALL to the directory where your eclipse executable (with Spoofax plugin) resides"
echo " HELLOWORLD_PROJECT to the project directory of this project"
echo "(or of course you could make a copy of this script with those directories hardcoded)."
echo
echo "Usage:"
echo " hel2py [-q] FILE"
echo "You can specify -q to suppress standard error output."
echo "Writes the Python translation of FILE to standard out."
echo "So you can 'execute' the file with"
echo " hel2py -q FILE | python3 -"
exit
;;
-q)
shift
exec 2>/dev/null
;;
esac
done
java -jar $SUNSHINE_JAR transform -i $1 -n "Generate Python" -p $HELLOWORLD_PROJECT -l $HELLOWORLD_PROJECT -l "${ECLIPSE_INSTALL}/plugins"