Skip to content

Commit 64dbd78

Browse files
committed
Version 1.41.1 prepared
1 parent 7038119 commit 64dbd78

18 files changed

+4088
-1
lines changed

bfbasic/HOW TO RELEASE.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
1. Make sure your Eclipse project is synchronized with GitHub.
2+
3+
2. Within Eclipse, go to File > Export > Java Runnable JAR File
4+
5+
Select run configuration bfbasic - bfbasic and a destination folder for the .jar file.
6+
Name the .jar file bfbasic.jar.
7+
8+
2. Zip together:
9+
10+
a. the newly created bfbasic.jar
11+
b. Following files that can be found inside the main folder of the Java project:
12+
13+
bfbasic.bat
14+
bfbasic.sh
15+
LICENSE
16+
README
17+
18+
3. Create a new release in GitHub and upload the newly created .zip file as binaries for the release.
19+

bfbasic/LICENSE

+340
Large diffs are not rendered by default.

bfbasic/README

+291
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
BFBASIC -- Basic to BrainF*** Compiler
2+
Copyright (c) 2001-2005 Jeffry Johnston, with contributions by others
3+
WWW: http://kidsquid.com/compilers/bfbasic
4+
5+
6+
Contributors (thanks!)
7+
------------
8+
[Jeff] Jeffry Johnston (bfbasic@kidsquid.com)
9+
[Jon] Jon Ripley (jon@jonripley.com)
10+
11+
12+
License
13+
-------
14+
This program is free software; you can redistribute it and/or modify
15+
it under the terms of the GNU General Public License as published by
16+
the Free Software Foundation. See the file LICENSE for more details.
17+
18+
19+
Usage
20+
-----
21+
bfbasic [-c] [-d | -D] [-O#] [-w [#]] FILE[.bas] [[-o] FILE] [-?]
22+
23+
Where:
24+
-c Treat newline as CR LF. The default is LF
25+
-d Add additional debug output
26+
-D Verbose debug output
27+
-Olevel Optimization level. The default is 2
28+
-w [column] Wraps output at the given column, default: 72
29+
FILE Input filename. The ".bas" extension may be omitted
30+
-o outfile Specify output filename. The default filename is FILE.bf
31+
-? Display usage information
32+
33+
34+
Introduction
35+
------------
36+
BFBASIC is a Basic to BF compiler written using the Java programming
37+
language. An understanding of the Basic language is assumed.
38+
39+
Variables and arrays do not need to be dimensioned before use,
40+
however, certain orderings of variables produce smaller code than
41+
others. If -O2 (default) or greater is used, an attempt will be made
42+
to find the best arrangement (this is what "Optimizing..."
43+
represents). Optimization level 3 exists, but it is experimental and
44+
currently breaks some programs.
45+
46+
Variable names must contain only letters and numbers and must start
47+
with a letter. Arrays and variables can share the same name, but the
48+
practice is not recommended. V1, V2, and V3 are examples of variable
49+
names. Variables can hold unsigned byte values from 0 to 255 (or more
50+
depending on the particular BF implementation used, although some
51+
functions require 8-bit cells for proper functioning).
52+
53+
Arrays can be dimensioned to hold up to 256 elements each. Each
54+
element can store an unsigned byte value from 0 to 255. The array
55+
element numbers are 0 based (i.e. they start with 0). Any
56+
undimensioned arrays will receive 10 elements by default (so the
57+
valid elements number 0 to 9).
58+
59+
Line labels can use alphanumeric characters and the underscore symbol,
60+
but cannot start with a number. Labels must end with a colon. When
61+
referring to a line label, the colon may be omitted. If a GOTO is
62+
made to a label that does not exist, the program will compile, but at
63+
runtime if the GOTO is encountered then the program will enter an
64+
endless loop searching for the missing label. There is no limit on
65+
the number of labels, but each one uses one BF memory cell. Certain
66+
statements (for example, "WHILE") will automatically create and use
67+
labels.
68+
69+
With an 8-bit interpreter there can be a maximum of 256 GOSUB
70+
statements. A compile warning will be generated if this number is
71+
exceeded.
72+
73+
Numbers can be given in decimal (0 to 255) or hexadecimal (&H0 to
74+
&HFF).
75+
76+
Expressions are made up of exprerssion elements and are evaluated
77+
using standard algebraic precedence rules.
78+
79+
80+
Command Details
81+
------- ----------
82+
blank line
83+
'comment comment
84+
: command separator
85+
label: label
86+
? [list] PRINT shorthand, see Print List Elements below
87+
var=expr variable assign
88+
array(expr)=expr array element assign
89+
BEEP prints ASCII character 7 (BEL)
90+
BF raw BF commands, @var for auto var. position
91+
CLS clear the screen (ANSI)
92+
COLOR expr 0:reset to normal, 1:bold, 5:blink,
93+
30-37:foreground, 40-47:background (ANSI)
94+
DIM var no longer necessary with the -O2 option
95+
DIM array(elements)
96+
DO
97+
DO UNTIL expr
98+
DO WHILE expr
99+
ELSE
100+
END exit program
101+
END IF
102+
EXIT DO
103+
EXIT FOR
104+
FOR var=expr TO expr2
105+
FOR array(expr)=expr TO expr2
106+
GOSUB label
107+
GOTO label
108+
IF expr THEN
109+
IF expr THEN EXIT DO
110+
IF expr THEN EXIT FOR
111+
IF expr THEN GOTO label
112+
INPUT var decimal input to variable
113+
INPUT array(expr) decimal input to array element
114+
LET var=expr old style variable assign
115+
LET array(expr)=expr old style array element assign
116+
LOCATE expr,expr row (1-24), column (1-80) (ANSI)
117+
LOOP
118+
LOOP UNTIL expr
119+
LOOP WHILE expr
120+
NEXT expr
121+
PRINT [list] see Print List Elements below
122+
RANDOMIZE KEY select random number seed from keyboard
123+
REM comment old style comment
124+
RETURN
125+
STOP exit program
126+
SWAP var1,var2
127+
SYSTEM exit program
128+
WEND LOOP
129+
WHILE expr DO WHILE expr
130+
131+
132+
Expression Elements
133+
-------------------
134+
#, &H# number
135+
( ) parenthesis
136+
var variable
137+
INKEY returns ASC(INPUT$(1,1))
138+
RND returns pseudorandom # 0-255 (period 65536)
139+
array(expr) array element
140+
NOT(expr) returns 255-expr
141+
expr1+expr2 addition
142+
expr1-expr2
143+
expr1*expr2
144+
expr1/expr2 division by 0 will result in an infinite loop
145+
expr1=expr2 if expr1 = expr2 then 255 else 0
146+
expr1<>expr2 if expr1 <> expr2 then 255 else 0
147+
expr1<expr2 if expr1 < expr2 then 255 else 0
148+
expr1<=expr2 if expr1 <= expr2 then 255 else 0
149+
expr1>expr2 if expr1 > expr2 then 255 else 0
150+
expr1>=expr2 if expr1 >= expr2 then 255 else 0
151+
expr1 AND expr2 if expr1<>0 and expr2<>0 then 255 else 0
152+
expr1 OR expr2 if expr1<>0 or expr2<>0 then 255 else 0
153+
154+
155+
Print List Elements
156+
-------------------
157+
; print or join strings without a newline
158+
expr decimal value
159+
"text" string literal: only uses ASCII 15-126
160+
CHR$(expr) ASCII character
161+
SPACE$(expr) print expr number of spaces
162+
STRING$(expr1, expr2) print expr1 number of ASCII expr2
163+
164+
165+
Future Commands?
166+
----------------
167+
better GOSUB/RETURN?
168+
IF expr THEN command
169+
FOR...STEP expr
170+
RANDOMIZE #
171+
SELECT CASE expr
172+
CASE expr
173+
CASE ELSE
174+
END SELECT
175+
EXIT SELECT
176+
DATA #
177+
READ var|array
178+
RESTORE
179+
180+
181+
Future Expression Elements?
182+
---------------------------
183+
-expr
184+
185+
186+
Future Print List Elements?
187+
---------------------------
188+
STRING$(expr,"a")
189+
190+
191+
Memory layout Used for
192+
------------- --------
193+
Q 1 byte Quit? (0=yes, 1=no)
194+
G 1 byte Goto mode? (0=yes, 1=no)
195+
T 1 byte Goto temp
196+
0-6 7 bytes Misc temp
197+
198+
199+
Known Problems
200+
--------------
201+
* INPUT acts strangely on *nix systems
202+
* "PRINT var" only works with 8-bit cells
203+
* -O3 causes problems (still debugging this)
204+
* GOSUB/RETURN is very slow
205+
206+
207+
Version History
208+
---------------
209+
1.41 29 Jun 2005
210+
* FOR...NEXT code rewritten, speed/size improvements and
211+
"FOR var = 0 TO 255" now works! [Jon]
212+
* Instances of "#" changed to "(hash)" in debug output to
213+
prevent accidental breakpoints [Jon]
214+
215+
1.40 21 Mar 2005
216+
* Added -w option [Jon]
217+
* REM comments show up in debug mode [Jon]
218+
* Modified -o option so that the "-o" is optional [Jon]
219+
* STOP statement now prints "Stopped" [Jon]
220+
* Reworked labels for more speed [Jeff]
221+
* The number of labels is now limited only by available memory [Jeff]
222+
* ONGOTO removed, it is not supported by the new labels [Jeff]
223+
* Code cleanup and fixes [Jeff]
224+
* Changed -w to wrap debug output too [Jeff]
225+
* Fixed bug that allowed SYSTEM to be misused (ex: SYSTEM IF) [Jeff]
226+
* Ported over the better BFASM array code [Jeff]
227+
* Added optimization levels. -O2=default
228+
* Added -O2, rearranges variables for smaller and more efficient code [Jeff]
229+
* Replaced high/low add-to loops with straight +/-. Smaller! [Jeff]
230+
* Numerical constants in expressions can now be optimized [Jeff]
231+
* Added "+" and "-" numerical constant optimizations [Jeff]
232+
* Fixed bug that allowed statements such as "A=()" [Jeff]
233+
* Added -O3, assignments skip a temp variable. Code is larger,
234+
but should be slightly faster on optimizing interpreters (BROKEN!) [Jeff]
235+
* Implemented new GOSUB and RETURN, very slow :( [Jeff]
236+
237+
1.30 30 Oct 2003
238+
* Added -c option for CR LF = newline (LF now the default)
239+
* New commands: RANDOMIZE KEY
240+
* Modified commands: INPUT (as decimal), BF
241+
* New expressions: INKEY, RND (uses N=(31821*N+13849)%65536)
242+
243+
1.20 23 Oct 2003
244+
* New commands: BF (for raw BF commands), ?, WHILE, WEND, SYSTEM, LET,
245+
STOP, FOR, NEXT, EXIT FOR, IF...EXIT FOR
246+
* Upgraded L# labels to free text labels
247+
* Rewrote expr1<expr2 to fix multiple bugs
248+
* New expressions: expr1<>expr2, expr1>expr2, expr1>=expr2,
249+
expr1<=expr2, expr1/expr2
250+
* PRINT now supports ; and multiple expressions per line
251+
* Updated CLS, COLOR, and LOCATE to use the new ; syntax
252+
* Only outputs pre() and post() code when needed
253+
254+
1.10 16 Oct 2003
255+
* New commands: IF...THEN, ELSE, END IF
256+
* New expressions: expr1 OR expr2, expr1 AND expr2
257+
258+
1.00 15 Oct 2003
259+
* Ported compiler from Basic to Java, major rewrite of some parts
260+
* Added algebraic expression parser
261+
* Updated commands to use the expression parser
262+
* New commands: DO [WHILE | UNTIL], EXIT DO, LOOP [WHILE | UNTIL],
263+
IF...EXIT DO, GOSUB, RETURN, PRINT CHR$, PRINT num, COLOR, LOCATE
264+
INPUT array
265+
* New expression: expr1*expr2
266+
* Improved debug output line wrapping
267+
* Removed V1="a" expression
268+
269+
0.90 23 Sep 2003
270+
* Fixed label bug affecting PRINT
271+
* Fixed PRINT parsing bug
272+
* Fixed calculation parsing bug that ignored certain illegal
273+
operators
274+
* IP starts at 1 (instead of 255) for faster exit
275+
* Not released
276+
277+
0.80 20 Sep 2003
278+
* Fixed label bug that affected GOTO and IF ... THEN GOTO
279+
* Added optional debug output
280+
281+
0.70 14 Mar 2003
282+
* Major rewrite, no longer forced to use certain variables
283+
* New commands: BEEP, CLS, DIM, ONGOTO, PRINT, PRINT #, SWAP
284+
* New calculations: Almost everything is new or improved upon.
285+
286+
0.60 12 Mar 2003
287+
* Not released
288+
289+
0.50 11 Mar 2003
290+
* Initial release
291+
* Programmed using QuickBasic Extended 7.0

bfbasic/bfbasic.bat

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
java -jar bfbasic.jar %1 %2 %3 %4 %5 %6 %7 %8
3+

bfbasic/bfbasic.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#! /bin/sh
2+
java -jar bfbasic.jar $*

bfbasic/examples/99bob.bas

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'99 bottles of beer
2+
N = 99
3+
DO
4+
GOSUB LYRIC1: GOSUB LYRIC2
5+
GOSUB LYRIC1: PRINT
6+
PRINT "Take one down and pass it around"
7+
N = N - 1
8+
GOSUB LYRIC1: GOSUB LYRIC2: PRINT
9+
LOOP UNTIL N = 0
10+
END
11+
12+
LYRIC1:
13+
IF N <> 0 THEN
14+
PRINT N;
15+
ELSE
16+
PRINT "No more";
17+
END IF
18+
PRINT " bottle";
19+
IF N <> 1 THEN
20+
PRINT "s";
21+
END IF
22+
PRINT " of beer";
23+
RETURN
24+
25+
LYRIC2:
26+
PRINT " on the wall"
27+
RETURN

0 commit comments

Comments
 (0)