有谁知道一个PHP程序可以解释BASIC代码吗?我看过LOLCODE implementation,看起来这是一个很好的开始,但如果有人已经开发出类似的东西,我会很感激。寻找在PHP中实现的BASIC解释器
回答
在PHP中找不到一个,但在Javascript中有一个:http://stevehanov.ca/blog/index.php?id=92。如果您向下滚动该页面,作者会大力解释该事情的工作原理,哪个国际海事组织是一个开始的好地方。
其实,这正是我在几个月前写道:
http://pub.32kb.org/files/entry/pBasic/pBasic.zip
它是Java中的一个文件的基本实现,叫做端口jASIC在这里找到:
http://journal.stuffwithstuff.com/2010/07/18/jasic-a-complete-interpreter-in-one-java-file
用法如下:
$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
正如你所看到的,我扩大仍按原jASIC解释并添加函数调用和其他一些小的变化。
这看起来很有前途,但恐怕我无法实现。任何指针? – 2013-04-20 19:56:52
当然,我已经添加了上面的基本使用说明。随时与我联系,以获得进一步的问题。 – 2013-05-23 11:47:37
对不起,迟到的回应。我似乎无法得到它的工作:( – 2013-10-01 20:56:10
- 1. 寻找解释System.NotSupportedException
- 2. 在解释器中实现Brainfuck循环
- 3. 在PHP中寻找对exec的简单解释
- 4. 在C#中寻找后缀树实现?
- 5. 对.charAt()的OutOfBoundsException,寻找解释
- 6. 寻找WPF Grid GridSpan行为的解释
- 7. LLVM解释器在寻找外部函数(库?)
- 8. Python解释器可以用Python实现,但是哪个解释器会解释解释器本身?
- 9. 在Scala中寻找CSS解析器
- 10. 在Ruby中寻找CSS解析器
- 11. 在java中寻找CSS解析器
- 12. python字节码解释器实现
- 13. SQL Server舍入问题寻找解释
- 14. 在Scala中解释Y组合器的这个实现?
- 15. 在.Net中寻找“异步”字的解释?
- 16. 寻找在PHP
- 17. 在C#中为BASIC解释器编写Tokenizer类
- 18. 在Ruby/Python中是否有OpenSource BASIC解释器?
- 19. 如何在解释器中实现数组?
- 20. 寻找最佳的解决方案来实现AJAX TreeGrid
- 21. 寻找集群的LSH实现
- 22. 寻找SearchBlox REST API的.NET实现
- 23. 寻找IEnumerable/IEnumerator更快的实现
- 24. 寻求在PHP应用程序中实现Xmpp的基本理解 -
- 25. 寻找在现有的UITabBarController
- 26. 在C++中实现在无向图算法中寻找循环
- 27. 如何在Visual Basic中实现Tesseract OCR?
- 28. 在SOAP Web服务上寻找一个很好的解释
- 29. C中的位移和指针奇怪,寻找解释
- 30. C++中的现代解释器代码?
好吧,即使它不是我正在寻找的东西,它非常酷:)谢谢。 – 2010-01-18 11:28:11