寻找用PHP实现的基本解释器
有人知道可以解释基本代码的PHP程序吗?我看到了一个很好的起点,但如果有人已经开发了类似的东西,我将不胜感激。在PHP中找不到,但在Javascript中有一个:。如果你向下滚动该页面,作者会花很多精力解释这个东西是如何工作的,哪个IMO是一个很好的起点。在PHP中找不到一个,但在Javascript中有一个:。如果你向下滚动那一页,作者花了很多精力解释这个东西是如何工作的,哪个IMO是一个很好的起点。这正是我几个月前写的: 它是JAVA中名为jASIC的单文件基本实现的一个端口,可在此处找到: 用法如下:寻找用PHP实现的基本解释器,php,interpreter,Php,Interpreter,有人知道可以解释基本代码的PHP程序吗?我看到了一个很好的起点,但如果有人已经开发了类似的东西,我将不胜感激。在PHP中找不到,但在Javascript中有一个:。如果你向下滚动该页面,作者会花很多精力解释这个东西是如何工作的,哪个IMO是一个很好的起点。在PHP中找不到一个,但在Javascript中有一个:。如果你向下滚动那一页,作者花了很多精力解释这个东西是如何工作的,哪个IMO是一个很好的起点。这正是我几个月前写的: 它是JAVA中名为jASIC的单文件基本实现的一个端口,可在此处找到
$pbas = new pBasic();
$basicScript = file_get_contents('test.bas');
// execute
$pbas->interpret($basicScript);
这是我在游戏概念中使用的基本脚本示例:
' 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
”按memmaker列出当前服务器上的所有文件
println“”用于在输出中生成空行,解析器需要“”
如果“bin”=arg1,则getbinaries确定要显示的目录
打印“+\u环境\u连接的\u服务器上的/列表”
allfiles=list_files()'从系统获取文件列表
转到初始化
GetBinary:
打印“+\环境\连接\服务器上的/bin列表”
allfiles=list_files(1)'从系统获取bin文件列表
初始化:
filecount=count(allfiles)'获取数组的长度
计数器=0'初始化循环的计数器
println“-“+filecount+”files found“”打印文件计数,请注意,“”前缀是必需的,因为pBasic从二进制运算符的左参数推断类型
println“”
beginloop:
println get_元素(所有文件,计数器)'输出当前文件名
计数器=计数器+1'递增循环计数器
如果计数器
如您所见,我在原来的jASIC解释器的基础上进行了扩展,添加了函数调用和其他一些小改动。这正是我几个月前写的: 它是JAVA中名为jASIC的单文件基本实现的一个端口,可在此处找到: 用法如下:
$pbas = new pBasic();
$basicScript = file_get_contents('test.bas');
// execute
$pbas->interpret($basicScript);
这是我在游戏概念中使用的基本脚本示例:
' 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
”按memmaker列出当前服务器上的所有文件
println“”用于在输出中生成空行,解析器需要“”
如果“bin”=arg1,则getbinaries确定要显示的目录
打印“+\u环境\u连接的\u服务器上的/列表”
allfiles=list_files()'从系统获取文件列表
转到初始化
GetBinary:
打印“+\环境\连接\服务器上的/bin列表”
allfiles=list_files(1)'从系统获取bin文件列表
初始化:
filecount=count(allfiles)'获取数组的长度
计数器=0'初始化循环的计数器
println“-“+filecount+”files found“”打印文件计数,请注意,“”前缀是必需的,因为pBasic从二进制运算符的左参数推断类型
println“”
beginloop:
println get_元素(所有文件,计数器)'输出当前文件名
计数器=计数器+1'递增循环计数器
如果计数器
正如您所见,我扩展了原来的jASIC解释器,添加了函数调用和其他一些小改动。好吧,即使它不是我要找的,也很酷:)谢谢。好吧,即使它不是我要找的,也很酷:)谢谢。这看起来很有希望,但恐怕我无法让它工作。有什么提示吗?当然,我已经在上面添加了基本的使用说明。如有任何问题,请随时与我联系。很抱歉,回复太晚。我似乎无法让它工作:(这看起来很有希望,但恐怕我无法让它工作。有什么建议吗?当然,我已经在上面添加了基本的使用说明。请随时与我联系以了解更多问题。很抱歉反应太晚。我似乎无法让它工作:(