Author Topic: BaCon 3.0 Released  (Read 5268 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
BaCon 3.0 Released
« on: April 30, 2014, 06:48:20 PM »
All,

The latest BaCon version 3.0 is ready for consumption and can be obtained from the BaCon website.

This is a major step towards an efficient transcompiler, containing huge changes and improvements in the overall design:

  • Previously, BaCon included its complete library with all functions in each program. Now, a new compile scheme has been implemented where only the functions actually being used in a program will be taken from a generic BaCon archive. This reduces compile speed and the size of the resulting binary.

  • The variable type detection mechanism has been re-implemented from scratch. Instead of a plain file search it is now based on in-memory detection. This also improves the overall conversion performance, which now is approx. 70% faster.


Next to this there are some other highlights:

  • CMDLINE function to conveniently parse command line parameters

  • correct detection and automatic casting in floating point assignments

  • copying of indexed arrays using COPY

  • lots of code cleaning and improvements


See the full list of changes for more details.

BaCon releases are made available after testing on several platforms, including Tru64Unix, Solaris, MacOSX and several flavors of Linux.

Thanks to the BaCon community for notifying issues, reporting bugs and suggesting improvements!

For long time users, please pay attention to the following remarks:


Installing BaCon 3.0

(1) To install BaCon on your system, start by running the configure
script:

# ./configure

(2) This script checks the requirements on your system and should
finish successfully. A Makefile will be generated.

Then start building the BaCon binary by executing:

# make

(3) This will create a static archive containing BaCon functions.
Also the BaCon console version and GUI version are created.

To install BaCon, simply execute:

# make install


Compatibility with earlier BaCon versions

Though the BASIC syntax and API has not changed, it occasionally may
happen that older programs cannot be converted. The following hints
should help to troubleshoot such problems.

(1) Starting from 3.0, BaCon uses a new and optimized variable detection
mechanism. This mechanism is faster and more precise. Now global variables
with a certain name cannot be used in combination with local variables
using the same name.

Solution: either change the name of the global variable, or consistently
declare variables using LOCAL.

(2) The IF/THEN/ELSE statement can be used in two ways. The first way
is an IF/THEN/ELSE which contains a body with statements, ending with an
ENDIF. The second way is an IF/THEN/ELSE containing one single statement
on the same line, where no ENDIF is needed.

The problem is that it cannot be detected which ELSE belongs to which IF
in case of nested IF/THEN/ELSE statements.

Solution: combinations of IF/THEN/ELSE with a body and without a body
are not allowed anymore. Such combinations of IF/THEN/ELSE have to be
rewritten. Either use IF/THEN/ELSE each with a body, or use IF/THEN/ELSE
each with a single line.


A note to beta testers

Before installing BaCon 3.0, please make sure that old beta versions of
the BaCon archive are removed from your system. This archive can have the
name 'bacon.a' or 'libbacon.a'.


Regards and happy converting!
Peter

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: BaCon 3.0 Released
« Reply #1 on: May 16, 2014, 08:04:36 PM »
Here is what the new BaCon (3.0.1) install looks like.

Code: [Select]
jrs@laptop:~/BaCon/V301$ ./configure --prefix=/usr
checking for a BSD-compatible install... /usr/bin/install -c
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing dlopen... -ldl
checking for library containing dlsym... none required
checking for library containing sin... -lm
checking for library containing cos... none required
checking for library containing tan... none required
checking for library containing asin... none required
checking for library containing acos... none required
checking for library containing atan... none required
checking for library containing log... none required
checking for library containing exp... none required
checking for library containing lrint... none required
checking for library containing floor... none required
checking for malloc... yes
checking for calloc... yes
checking for realloc... yes
checking for memset... yes
checking for random... yes
checking for fork... yes
checking for strcpy... yes
checking for strncpy... yes
checking for strcat... yes
checking for strncat... yes
checking for strlen... yes
checking for strstr... yes
checking for strcmp... yes
checking for strtok... yes
checking for strtok_r... yes
checking for strftime... yes
checking for fprintf... yes
checking for snprintf... yes
checking for usleep... yes
checking for socket... yes
checking for bind... yes
checking for connect... yes
checking for listen... yes
checking for accept... yes
checking for recv... yes
checking for send... yes
checking for setsockopt... yes
checking for select... yes
checking for gethostbyname... yes
checking for gethostbyaddr... yes
checking for inet_aton... yes
checking for inet_ntoa... yes
checking for inet_addr... yes
checking for htons... yes
checking for htonl... yes
checking for readdir... yes
checking for closedir... yes
checking for getpid... yes
checking for qsort... yes
checking for lfind... yes
checking for ftw... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking for stdlib.h... (cached) yes
checking stdarg.h usability... yes
checking stdarg.h presence... yes
checking for stdarg.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for sys/stat.h... (cached) yes
checking for sys/types.h... (cached) yes
checking sys/wait.h usability... yes
checking sys/wait.h presence... yes
checking for sys/wait.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/utsname.h usability... yes
checking sys/utsname.h presence... yes
checking for sys/utsname.h... yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking setjmp.h usability... yes
checking setjmp.h presence... yes
checking for setjmp.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking search.h usability... yes
checking search.h presence... yes
checking for search.h... yes
checking ftw.h usability... yes
checking ftw.h presence... yes
checking for ftw.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking for unistd.h... (cached) yes
checking for string.h... (cached) yes
checking ctype.h usability... yes
checking ctype.h presence... yes
checking for ctype.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking regex.h usability... yes
checking regex.h presence... yes
checking for regex.h... yes
checking for mksh... no
checking for bash... /bin/bash
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
configure: creating ./config.status
config.status: creating Makefile

Congratulations, all requirements are met!

- Makefile created.
- Using '/bin/bash' to compile BaCon.

Now run 'make' and 'make install' to build and install BaCon.

jrs@laptop:~/BaCon/V301$ make
/bin/bash ./bacon.sh -d build bacon.bac
Converting 'bacon.bac'... done.
New BaCon archive requested! Creating...
Compiling 'bacon.bac'... make[1]: Entering directory `/home/jrs/BaCon/V301/build'
cc  -O2 -c bacon.bac.c
cc  -O2 -fPIC -c bacon.chop.c
cc  -O2 -fPIC -c bacon.chr.c
cc  -O2 -fPIC -c bacon.cmdline.c
cc  -O2 -fPIC -c bacon.concat.c
cc  -O2 -fPIC -c bacon.count.c
cc  -O2 -fPIC -c bacon.curdir.c
cc  -O2 -fPIC -c bacon.datename.c
cc  -O2 -fPIC -c bacon.dec.c
cc  -O2 -fPIC -c bacon.epoch.c
cc  -O2 -fPIC -c bacon.error.c
cc  -O2 -fPIC -c bacon.exec.c
cc  -O2 -fPIC -c bacon.extract.c
cc  -O2 -fPIC -c bacon.fileexists.c
cc  -O2 -fPIC -c bacon.filelen.c
cc  -O2 -fPIC -c bacon.filetime.c
cc  -O2 -fPIC -c bacon.filetype.c
cc  -O2 -fPIC -c bacon.fill.c
cc  -O2 -fPIC -c bacon.getenviron.c
cc  -O2 -fPIC -c bacon.getkey.c
cc  -O2 -fPIC -c bacon.getpeer.c
cc  -O2 -fPIC -c bacon.getxy.c
cc  -O2 -fPIC -c bacon.hex.c
cc  -O2 -fPIC -c bacon.host.c
cc  -O2 -fPIC -c bacon.instr.c
cc  -O2 -fPIC -c bacon.instrrev.c
cc  -O2 -fPIC -c bacon.lcase.c
cc  -O2 -fPIC -c bacon.left.c
cc  -O2 -fPIC -c bacon.makedir.c
cc  -O2 -fPIC -c bacon.malloc.c
cc  -O2 -fPIC -c bacon.memcheck.c
cc  -O2 -fPIC -c bacon.memory.c
cc  -O2 -fPIC -c bacon.mid.c
cc  -O2 -fPIC -c bacon.os.c
cc  -O2 -fPIC -c bacon.peek.c
cc  -O2 -fPIC -c bacon.regex.c
cc  -O2 -fPIC -c bacon.remove.c
cc  -O2 -fPIC -c bacon.replace.c
cc  -O2 -fPIC -c bacon.reverse.c
cc  -O2 -fPIC -c bacon.right.c
cc  -O2 -fPIC -c bacon.screen.c
cc  -O2 -fPIC -c bacon.search.c
cc  -O2 -fPIC -c bacon.sort.c
cc  -O2 -fPIC -c bacon.spc.c
cc  -O2 -fPIC -c bacon.str.c
cc  -O2 -fPIC -c bacon.tab.c
cc  -O2 -fPIC -c bacon.time.c
cc  -O2 -fPIC -c bacon.timer.c
cc  -O2 -fPIC -c bacon.ucase.c
cc  -O2 -fPIC -c bacon.version.c
cc  -O2 -fPIC -c bacon.wait.c
ar -r libbacon.a  bacon.chop.o bacon.chr.o bacon.cmdline.o bacon.concat.o bacon.count.o bacon.curdir.o bacon.datename.o bacon.dec.o bacon.epoch.o bacon.error.o bacon.exec.o bacon.extract.o bacon.fileexists.o bacon.filelen.o bacon.filetime.o bacon.filetype.o bacon.fill.o bacon.getenviron.o bacon.getkey.o bacon.getpeer.o bacon.getxy.o bacon.hex.o bacon.host.o bacon.instr.o bacon.instrrev.o bacon.lcase.o bacon.left.o bacon.makedir.o bacon.malloc.o bacon.memcheck.o bacon.memory.o bacon.mid.o bacon.os.o bacon.peek.o bacon.regex.o bacon.remove.o bacon.replace.o bacon.reverse.o bacon.right.o bacon.screen.o bacon.search.o bacon.sort.o bacon.spc.o bacon.str.o bacon.tab.o bacon.time.o bacon.timer.o bacon.ucase.o bacon.version.o bacon.wait.o >/dev/null 2>&1
cc -o bacon bacon.bac.o -lbacon -L. -lm -ldl
make[1]: Leaving directory `/home/jrs/BaCon/V301/build'
Done, program 'bacon' ready.
strip build/bacon
build/bacon -d build bacongui.bac
Converting 'bacongui.bac'... done.
Compiling 'bacongui.bac'... make[1]: Entering directory `/home/jrs/BaCon/V301/build'
cc  -O2 -c bacongui.bac.c
cc -o bacongui bacongui.bac.o -lbacon -lm -ldl -L.
make[1]: Leaving directory `/home/jrs/BaCon/V301/build'
Done, program 'bacongui' ready.
strip build/bacongui
Run 'make install' to install BaCon on your system.
jrs@laptop:~/BaCon/V301$ sudo make install
sudo: unable to resolve host laptop
[sudo] password for jrs:
mkdir -p /usr/bin
/usr/bin/install -c build/bacon /usr/bin
/usr/bin/install -c build/bacongui /usr/bin
/usr/bin/install -c bacon.sh /usr/bin
mkdir -p /usr/lib
/usr/bin/install -c build/libbacon.a /usr/lib
mkdir -p /usr/share/man/man1
/usr/bin/install -c -m 644 bacon.1 /usr/share/man/man1
mkdir -p /usr/share/applications
/usr/bin/install -c bacongui.desktop /usr/share/applications
mkdir -p /usr/share/pixmaps
/usr/bin/install -c icons/BaCon.png /usr/share/pixmaps
jrs@laptop:~/BaCon/V301$

The following example embeds Script BASIC in BaCon.

Code: [Select]
' BaCon Command Line Interpreter

PRAGMA OPTIONS -I/home/jrs/sb/source
PRAGMA LDFLAGS scriba pthread
PRAGMA INCLUDE scriba.h getopt.h
PROTO scriba_destroy

DECLARE pProgram TYPE pSbProgram

cmdln$ = ARGUMENT$
SPLIT cmdln$ BY " " TO opts$ SIZE cnt

pProgram = scriba_new(malloc,free)
ok = scriba_LoadConfiguration(pProgram,"/home/jrs/sb/sb22/basic.conf")
ok = scriba_SetFileName(pProgram, opts$[1])
ok = scriba_LoadSourceProgram(pProgram)
ok = scriba_Run(pProgram,opts$[2])
scriba_destroy(pProgram)

test.sb
Code: [Select]
cmd = COMMAND()

PRINT "ARG = ",cmd,"\n"

FOR x = 1 TO 5
PRINT x,"\n"
NEXT

jrs@laptop:~/BaCon/V301/test$ ls -l
total 8
-rw-rw-r-- 1 jrs jrs 499 Mar  6 14:06 sb.bac
-rw-rw-r-- 1 jrs jrs  76 Mar  6 14:08 test.sb
jrs@laptop:~/BaCon/V301/test$ bacon sb.bac
Converting 'sb.bac'... done.
Compiling 'sb.bac'... cc  -I/home/jrs/sb/source -c sb.bac.c
cc -o sb sb.bac.o -lbacon -lm -ldl -lscriba -lpthread
Done, program 'sb' ready.
jrs@laptop:~/BaCon/V301/test$ ./sb test.sb BaCon
ARG = BaCon
1
2
3
4
5
jrs@laptop:~/BaCon/V301/test$
« Last Edit: May 16, 2014, 10:04:35 PM by John »