From dbbd30cdab6ec31f79a7131759b9c89b49fb5e14 Mon Sep 17 00:00:00 2001 From: Thomas Cort Date: Sun, 22 Feb 2015 10:49:26 -0500 Subject: [PATCH] Prepare for release. --- AUTHORS | 1 + ChangeLog | 1 + Makefile.am | 5 ++++- README.md | 62 ++++++++++++++++++++++++++++++++++++----------------- TODO | 21 ++++++++++++++++-- sample.bas | 29 ++++++++++++++++++++----- 6 files changed, 91 insertions(+), 28 deletions(-) create mode 100644 AUTHORS create mode 100644 ChangeLog diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..b633c25 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +See https://github.com/tcort/tcb/graphs/contributors diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..d135aae --- /dev/null +++ b/ChangeLog @@ -0,0 +1 @@ +See https://github.com/tcort/tcb/commits/master diff --git a/Makefile.am b/Makefile.am index bab0a6d..1827df0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,7 +73,10 @@ CLEANFILES = $(BUILT_SOURCES) \ hello.out \ remainder.out -EXTRA_DIST = $(man_MANS) $(top_srcdir)/test-runner.sh \ +EXTRA_DIST = \ + $(man_MANS) \ + test-runner.sh \ + README.md \ abs.sh abs.bas abs.ex \ fib.sh fib.bas fib.ex \ hello.sh hello.bas hello.ex \ diff --git a/README.md b/README.md index 002bd5a..b2289b3 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,14 @@ # tcb -tcb is a small BASIC Interpreter written in C. +tcb is a small [BASIC](http://en.wikipedia.org/wiki/BASIC) Interpreter +written in C. ## Current Status -Under active development. - -## Road to v1.0.0 - -The following components are complete: - -* Scanner -* Parser -* Abstract Syntax Tree -* Man page - -The following components are in progress: - -* Unit Tests - -The following components remain: - -* i18n/l10n +The "basics" are done and working. The interpreter implements the +[Tiny BASIC](http://en.wikipedia.org/wiki/Tiny_BASIC) dialect of BASIC. +Development will continue with the goal of implementing successively more +complete dialects of BASIC. ## Requirements @@ -29,7 +16,9 @@ The following components remain: * [flex](http://www.gnu.org/software/flex/) - buildtime * [bison](http://www.gnu.org/software/bison/) - buildtime * [diff](http://www.gnu.org/software/diffutils/) - buildtime (running unit tests) -* [sed](https://www.gnu.org/software/sed/) - buildtime (running unit tests) +* [sed](http://www.gnu.org/software/sed/) - buildtime (running unit tests) +* [autoconf](http://gnu.org/software/autoconf) - development time +* [automake](http://gnu.org/software/makeconf) - development time ## Building @@ -38,6 +27,7 @@ Standard autotools build: $ autoreconf -i $ ./configure $ make + $ make check # make install ## Using @@ -50,6 +40,38 @@ Execute a program from a file in batch mode: $ tcb sample.bas +## Example Program + +The following program calculates +[Fibonacci numbers](http://en.wikipedia.org/wiki/Fibonacci_number) +and demonstrates all of the available statements. It's included +in the sources as `sample.bas`: + + 10 PRINT "How many fibonacci numbers should I calculate?" + 20 INPUT X + 30 IF X <= 2 THEN GOTO 10 + 40 PRINT "Calculating the first ",X," fibonacci numbers: " + 50 PRINT "fib[0] = 0" + 60 PRINT "fib[1] = 1" + 70 LET J = 1 + + 100 LET J = J + 1 + 110 LET A = 0 + 120 LET B = 1 + 130 LET I = 1 + 140 GOSUB 1000 + 150 PRINT "fib[",J,"] = ",C + 160 IF J < X-1 THEN GOTO 100 + 170 END + + 1000 LET C = B + A + 1010 LET T = B + 1020 LET B = C + 1030 LET A = T + 1040 LET I = I + 1 + 1050 IF I = J THEN RETURN + 1060 GOTO 1000 + ## Contributing 1. Fork it diff --git a/TODO b/TODO index 8c6e34a..3508d7d 100644 --- a/TODO +++ b/TODO @@ -1,2 +1,19 @@ -* Unit Tests -* i18n/l10n +Implement additional commands: + +* QUIT +* SAVE filename +* LOAD filename + +Implement additional statements: + +* FOR/NEXT + +Implement language fundamentals: + +* Strings +* Floating point + +Other changes: + +* Better error handling / reporting. +* Move away from flex and bison. diff --git a/sample.bas b/sample.bas index 44f0679..ac4e037 100644 --- a/sample.bas +++ b/sample.bas @@ -1,5 +1,24 @@ -10 LET A = 2 -20 LET B = 2 -30 LET C = A + B -40 PRINT A, "+", B, "=", C -50 END +10 PRINT "How many fibonacci numbers should I calculate?" +20 INPUT X +30 IF X <= 2 THEN GOTO 10 +40 PRINT "Calculating the first ",X," fibonacci numbers: " +50 PRINT "fib[0] = 0" +60 PRINT "fib[1] = 1" +70 LET J = 1 + +100 LET J = J + 1 +110 LET A = 0 +120 LET B = 1 +130 LET I = 1 +140 GOSUB 1000 +150 PRINT "fib[",J,"] = ",C +160 IF J < X-1 THEN GOTO 100 +170 END + +1000 LET C = B + A +1010 LET T = B +1020 LET B = C +1030 LET A = T +1040 LET I = I + 1 +1050 IF I = J THEN RETURN +1060 GOTO 1000