I am trying to translate my .spl
file into a C file (because there is no compiler). I have an example "Hello World" .spl file, and I have downloaded the Shakespeare Programming Language .tar
and extracted it, but I have no idea what to do next. I can't seem to find instructions in any documentation. Can anyone help?
Edit:
When I type make -f "Makefile"
, I get the following output:
bison --verbose -d grammar.y
gcc -O2 -Wall -c grammar.tab.c
gcc -O2 -Wall -c makescanner.c
gcc makescanner.o -O2 -Wall -o makescanner
./makescanner include > scanner.l
flex -Cem -t scanner.l > scanner.c
scanner.l:600: warning, rule cannot be matched
gcc -O2 -Wall -c scanner.c
<stdout>:5823: warning: ‘yyunput’ defined but not used
gcc -O2 -Wall -c strutils.c
gcc grammar.tab.o scanner.o strutils.o -O2 -Wall -lfl -o spl2c
ld: library not found for -lfl
collect2: ld returned 1 exit status
make: *** [spl2c] Error 1
The error:
means that you've missing the library which is part of flex library.
To check if you've already flex library installed, you can look after it using locate:
OSX
If you don't have it, you can install install flex (if you're using brew):
If you still having the problems, you may try to pass the following variables manually during make, e.g.:
or:
eventually by modifying
DYLD_FALLBACK_LIBRARY_PATH
environment.You can see which environment were passed by executing
brew --env
.Note: Make sure that you'll change the paths according to your environment.
Related:
Linux
On most popular Linux distributions, you can install it by:
Related:
OS X (Homebrew)
Alternatively use Homebrew to install Shakespeare:
Which should detect all your dependencies.
You want to run the file called "Makefile" with the command
make -f "Makefile"
, and if you have the commandsar
gcc
flex
ranlib
tar
bison
in your terminal, you should be fine.You can test if you have a command by typing its name and then
--help
into your terminal.Then you can use
spl2c
(which has now appeared in your SPL folder) with your code to make a .c file, which you can then put intogcc
with spl.h to make a .o file, which you can finally put intogcc
again with libspl.a to make a final, compiled program.Just in case, put the files into
gcc
like this:First pass:
gcc programname.c spl.h -o programname.o
Second pass:
gcc programname.o libspl.a -o compiledprogramname
You can comment if you want more info, hopefully this helps (or even works).
If you're using a Mac, apparently OSX doesn't include the necessary libraries for flex, and that is what is causing the error:
library not found for -lfl
However, there is supposed to be an equivalent replacement you can use, you'll just need to change a line in the Makefile. You should change this line:
to this:
After doing that, trying running make again and see if you get any better results.
Actually, I had the same problem on OS X Yosemite.
Solution
I was able to make the "Makefile" after changing:
to
In the meantime I installed the flex library, but I'm not sure whether it helped or not. In case my solution doesn't work without the flex library, you can simply install it using:
(Here is how to get the
brew
: http://brew.sh)The problem is that the Authors decided to link their program against the mostly useless libfl library, which is almost never needed, so not included in some flex distributions (in particlar, the one on MacOS).
It turns out that libfl only has two functions defined in it --
main
andyywrap
. Themain
in libfl is pretty much never used, and theyywrap
might as well not be, because all it does is return1
.It turns out you can fix the code easily enough:
edit the file
include/user_code_top.metaflex
and add the line%option noyywrap
to the end.edit the
Makefile
and remove the-lfl
from the link line (just search for the string-lfl
and remove those 4 characters wherever they appear)Now you should be able to build it (though you may need to delete the file
scanner.l
if you previously ran make and got the failure, as the Makefile fails to detect that it need to be rebuilt after editing the metaflex file).