简体   繁体   English

Coco / R可以将解析后的文件转换为字节码吗?

[英]Can Coco/R turn a parsed file into bytecode?

I want to write a simple compiler for educational purposes in Delphi. 我想在Delphi中为教育目的编写一个简单的编译器。 I have read about Coco/R and found this implementation for Delphi: http://code.google.com/p/dcocor/ . 我读过有关Coco / R的文章,并发现了Delphi的这个实现: http//code.google.com/p/dcocor/ From what I have read, this is a parser for the Delphi 2009 syntax. 根据我的阅读,这是Delphi 2009语法的解析器。

What would I have to do to turn the parsed file into a bytecode? 将解析后的文件转换为字节码需要做什么? Can Coco/R do this? Coco / R可以这样做吗?

I know about scripting languages like FastScript or DWS, but I'd like to try and write my own for my own purposes. 我知道像FastScript或DWS这样的脚本语言,但我想尝试为自己的目的编写自己的脚本。

Please give me some advice or clarify things a little. 请给我一些建议或澄清一点。

What would I have to do to turn the parsed file into a bytecode? 将解析后的文件转换为字节码需要做什么?

First, decide what kind of bytecode would you like to have: JVM? 首先,决定你想拥有什么样的字节码:JVM? LLVM? LLVM? MSIL? MSIL? Inventing your own? 发明自己的?

Can Coco/R do this? Coco / R可以这样做吗?

Coco/R is a parser generator framework, it only generates lexer-parser for a language you define and feed to the generator. Coco / R是一个解析器生成器框架,它只为您定义的语言生成lexer-parser并提供给生成器。 Steps after that is your responsibility. 之后的步骤是你的责任。 Though there might be projects out there that can help generating ast/target code (but I haven't found any for Coco/R ). 虽然可能有项目可以帮助生成ast /目标代码(但我没有找到任何Coco / R)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM