forked from glen/fostr
Add OCaml code generation (#24)
Also start using nailgun to speed up code generation. Resolves #6. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: glen/fostr#24 Co-Authored-By: Glen Whitney <glen@nobody@nowhere.net> Co-Committed-By: Glen Whitney <glen@nobody@nowhere.net>
This commit is contained in:
parent
380177b274
commit
cc89ad1e93
11 changed files with 155 additions and 8 deletions
|
@ -19,6 +19,7 @@ EXP = 'expect'
|
|||
for path in TEST_LIST:
|
||||
destdir = pf"{DESTINATION}/{path.stem}"
|
||||
mkdir -p @(destdir)
|
||||
chmod ugo+rwx @(destdir)
|
||||
contents = path.read_text()
|
||||
tests = re.split(r'test\s*(.+?)\s*\[\[.*?\n', contents)[1:]
|
||||
testit = iter(tests)
|
||||
|
|
20
bin/fosgen
20
bin/fosgen
|
@ -5,6 +5,7 @@ erro() { printf "%s\n" "$*" >&2; }
|
|||
|
||||
##### Set defaults:
|
||||
SUPPRESS_ERR=YES
|
||||
USE_NAILGUN=YES
|
||||
LANGUAGE=Python
|
||||
|
||||
##### Extract command line options:
|
||||
|
@ -14,18 +15,23 @@ do
|
|||
-h|--help)
|
||||
echo
|
||||
echo "Usage:"
|
||||
echo " fosgen [-d] [-l LANGUAGE] FILE"
|
||||
echo " fosgen [-d] [-j] [-l LANGUAGE] FILE"
|
||||
echo
|
||||
echo "Writes to standard output the code generated from the fostr"
|
||||
echo "program in FILE, targeting the specified LANGUAGE (which"
|
||||
echo "defaults to Python)."
|
||||
echo
|
||||
echo "The -d option writes diagnostic output to standard error."
|
||||
echo "The -j option uses the Spoofax Sunshine JAR directly, rather"
|
||||
echo "than via nailgun."
|
||||
exit
|
||||
;;
|
||||
-d)
|
||||
SUPPRESS_ERR=''
|
||||
;;
|
||||
-j)
|
||||
USE_NAILGUN=''
|
||||
;;
|
||||
-l)
|
||||
shift
|
||||
LANGUAGE="$1"
|
||||
|
@ -67,5 +73,17 @@ then
|
|||
exec 2>/dev/null
|
||||
fi
|
||||
|
||||
if [[ $USE_NAILGUN ]]
|
||||
then
|
||||
if [[ $SUPPRESS_ERR ]]
|
||||
then
|
||||
$BINDIR/let_sun_shine
|
||||
else
|
||||
$BINDIR/let_sun_shine noisy
|
||||
fi
|
||||
$BINDIR/ng sunshine transform -p $PROJDIR -n $LANGUAGE -i $PROGRAM
|
||||
exit $?
|
||||
fi
|
||||
|
||||
java -jar $SUNJAR transform -p $PROJDIR -l $PROJDIR -l $MVN_REPO -n $LANGUAGE -i $PROGRAM
|
||||
exit $?
|
||||
|
|
|
@ -4,7 +4,7 @@ failed=0
|
|||
|
||||
for dir in tests/extracted/*; do
|
||||
for file in $dir/*.fos; do
|
||||
for language in Python Javascript Haskell; do
|
||||
for language in Python Javascript Haskell OCaml; do
|
||||
echo bin/fosgen -l ${language%.*} $file ...
|
||||
bin/fosgen -l $language $file
|
||||
if [[ $? -ne 0 ]]; then
|
||||
|
|
40
bin/let_sun_shine
Executable file
40
bin/let_sun_shine
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Helper for fosgen, not intended to be used directly
|
||||
# With an argument, print diagnostic output
|
||||
|
||||
BINDIR=$(dirname $BASH_SOURCE)
|
||||
|
||||
if $BINDIR/ng sunshine --help
|
||||
then
|
||||
if [[ $1 ]]
|
||||
then
|
||||
echo "sun already shining."
|
||||
fi
|
||||
else
|
||||
if [[ $1 ]]
|
||||
then
|
||||
echo "disperse the clouds."
|
||||
fi
|
||||
SUNJAR="$BINDIR/../lib/sunshine.jar"
|
||||
PROJDIR="$BINDIR/.."
|
||||
if [[ ! $MVN_REPO ]]; then
|
||||
MVN_REPO="$HOME/.m2/repository"
|
||||
fi
|
||||
if [[ ! -d $MVN_REPO ]]; then
|
||||
MVN_REPO="/root/.m2/repository"
|
||||
fi
|
||||
if [[ ! -d $MVN_REPO ]]; then
|
||||
echo "Cannot find your Maven repository. Please set environment variable"
|
||||
echo "MVN_REPO to its full path and re-run."
|
||||
exit 1
|
||||
fi
|
||||
if [[ $1 ]]
|
||||
then
|
||||
java -jar $SUNJAR server &
|
||||
else
|
||||
java -jar $SUNJAR server >/dev/null 2>&1 &
|
||||
fi
|
||||
sleep 5
|
||||
$BINDIR/ng sunshine load -l $PROJDIR -l $MVN_REPO
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue