PHP uygulanan bir BASIC tercüman arıyor

2 Cevap php

Herkes TEMEL kodu yorumlamak bir PHP program biliyor mu? Ben başlamak için iyi bir yerdir, ama herkesin zaten böyle bir şey gelişti, ben minnettar olurdum gibi bir LOLCODE implementation olduğu görünüyor gördük.

2 Cevap

PHP birini bulmak ama Javascript biri var değil mi: http://stevehanov.ca/blog/index.php?id=92. Eğer bu sayfada aşağı doğru ilerleyin, yazar IMO başlamak için iyi bir yerdir ki, bir şey nasıl çalıştığını açıklayan çabaları bir sürü koyun.

Bu benim birkaç ay önce yazdı tam olarak ne aslında:

http://pub.32kb.org/files/entry/pBasic/pBasic.zip

Burada bulunmasını Jasic denilen JAVA bir dosya BASIC uygulama bir liman:

http://journal.stuffwithstuff.com/2010/07/18/jasic-a-complete-interpreter-in-one-java-file

Kullanımı şu şekildedir:

$pbas = new pBasic();
$basicScript = file_get_contents('test.bas');
// execute
$pbas->interpret($basicScript);

Ve bu benim bir oyun kavramı için kullanabileceğiniz bir örnek BASIC script:

' list all the files on the current server, by memmaker

println ""                                      ' used to produce a blank line in the        output, the "" is needed for the parser

if "bin" = arg1 then getbinaries                ' determine which directory to show

print "Listing of / on " + _ENV_CONNECTED_SERVER
allfiles = list_files()                         ' get list of files from the system

goto init

getbinaries:

print "Listing of /bin on " + _ENV_CONNECTED_SERVER
allfiles = list_files(1)                        ' get list of bin files from the system

init:

filecount = count(allfiles)                     ' get the length of the array

counter = 0                                     ' init the counter for the loop

println " - " + filecount + " files found"      ' print the file count, note the "" prefix is needed because pBasic infers the type from the left argument of a binary operator

println ""

beginloop:

println get_element(allfiles, counter)          ' output the current filename

counter = counter + 1                           ' increment the loop counter

if counter < filecount then beginloop           ' break the loop when all files are output

Gördüğünüz gibi, ben orijinal Jasic tercüman üzerine genişletilmiş ve fonksiyon çağrıları ve diğer bazı küçük değişiklikler eklendi.