Skip to content

Instantly share code, notes, and snippets.

@myzsyweb myzsyweb/test.sh
Created Jun 20, 2012

Embed
What would you like to do?
test
a simple interpreter for BASIC written in AWK
see url https://gist.github.com/2959816
########## GWBASIC ###############
#!./basic2.sh
print "start"
s = 0:i = 0
loop:
s = s + i:i = i + 1
print "s" , s
print "i" , i
print "test" & (i<10)
if i<=100 goto loop
print "end"
print s
#!./basic2.sh
10 print "start"
20 s = 0:i = 0
30 s = s + i:i = i + 1
40 print "s" , s
50 print "i" , i
60 print "test" & (i<10)
70 if i<=100 goto 30
80 print "end"
90 print s
#!./basic2.sh
print 0
print 1,2
print 0,"1 2 3 " & 1+2+3
print
input x
print x+1
#!./basic2.sh
print "start"
s = 0:i = 0
loop:
10 s = s + i:i = i + 1
print "s" & s
print "i" & i
if mod(i,2)=0 then print ">>>" & i:print "!!"
print "test" & (i<10)
if i<=100 then 10
print "end"
print s
#!./basic2.sh
x=1
gosub display
x=x+1
gosub display
end
display:
print ">>>>",x
return
#!./basic2.sh
print "start"
x[0]=1:x[1]=2
i=1:s=0
while i<=100
s=s+i
i=i+1
while 0<0
end
wend
#print "!!"
#end
wend:print s
print "end"
print x[0]+x[1]
#!./basic2.sh
print "hello"
cls
print 0,1,
print 2;
print 3
print 4
input "num",x
print x
##### EXTEND #####
#!./basic2.sh
print "begin!"
@if 0
print "see me!"
print "a!"
@else
print "b!"
@endif
print "end!"
print 0
print "eof"
#!./basic2.sh
print "begin!"
print 0,"true"
@if 1
print "a",1
@else
print "b",0
@endif
print "c",1
@if 0
print 1,"false"
@if 1
print 5,"false"
@else
print 6,"false"
@endif
@elseif 1
print 2,"true"
@if 1
print 3,"true"
@else
print 4,"false"
@endif
@endif
print 7,"true"
print "end!",-1
print 0
print "eof"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.