C#-非常简单的编译器? [英] C# - Very Simple Compiler?

查看:113
本文介绍了C#-非常简单的编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在学校,我需要一个非常简单的编译器来完成一个项目.您能否在C#中提供一些指向迷你编译器的链接来帮助我?

我没有以正确的方式表达自己.编译器需要用C#编写,但是需要编译汇编语言.对不起...

非常感谢!

Hi,

I need a very simple compiler for a project at school. Could you please help me out with some links to mini compilers in C#?

I didn''t express myself in the right way. The compiler needs to be written in C# but it needs to compile assembly language. Sorry...

Thanks a lot!

推荐答案

当我搜索"C#简单编译器"时,Google第一页的第三链接:

http://msdn.microsoft.com/en-us/magazine/cc136756.aspx [ ^ ]
Third link of the first page in Google when I search for "C# simple compiler":

http://msdn.microsoft.com/en-us/magazine/cc136756.aspx[^]


如果愿意,您可以对此票否决,因为我听起来有点苛刻.

首先,您的命名法是错误的.您无需编译"汇编代码,而是对其进行汇编",因此需要一个汇编器".除了术语...

其次-这听起来像是一项家庭作业-您必须使用C#编写汇编程序.我之所以称其为家庭作业,是因为企业界没有人会浪费时间重新发明MASM(微软的汇编程序).为什么?它是免费的,免费,如下载并使用.

第三,您要求输入代码来完成您的作业.如果您自己不做这项工作,您将如何学习任何东西?

第四,当懒惰无知的程序员进入工作队伍时,他们威胁着摆在他们面前的每个人的工作,并且将跟随他们进入该行业.

如果您可以证明我做错这件事,那么我将删除此答案.
You can down-vote this one if you like, because I''m about to sound kinda harsh.

First, your nomenclature is wrong. You don''t "compile" assembly code - you "assemble" it, and you therefore need an "assembler". Terminology aside...

Second - this sounds like a homework assignment - you have to write an assembler in C#. The reason I''m calling it homework is because nobody in the corporate world would waste their time reinventing the wheel that is MASM (Microsoft''s Assembler). Why? It''s freakin'' free , as in no charge, as in download it and use it.

Third, you''re asking for code to fulfill your homework assignment. How are you going to learn anything if you don''t do the work yourself?

Fourth, when lazy know-nothing programmers enter the workforce, they threaten EVERYBODY''S job that came before them, and that will follow them into the industry.

If you can prove me wrong about this being homework, I''ll delete this answer.


编译器实际上是最后一步.您首先从扫描输入(也检测语法错误)的扫描器开始.一个解析器,它创建相应的结构,通常是一棵树(并且还检测语法错误).当对应的结构(或树项目)是具有编译方法的类的对象时,它们是最简单的.解析完完整的输入后,您只需在根目录下调用compile(它将编译自身以及每个分支),然后以这种方式生成输出.您还可以选择实现一个execute方法而不是进行编译,并以此方式创建解释器.只需与Google查找如何构建自己的编译器/解释器",您就会得到很多结果.

在这里,您可以使用一些链接来入门:
http://msdn.microsoft.com/en-us/magazine/cc136756.aspx [ ^ ]

http://blogs.microsoft.co.il/blogs/sasha/archive/2010/10/06/writing-a-compiler-in-c-lexical-analysis.aspx [
The compiler is actually the last step. You first start with a scanner that scans the input (also detects syntax errors). A parser that creates corresponding structures, which is usually a tree (and also detects grammatical errors). The corresponding structures (or tree items) are the most easy when they are objects of a class that has a compile method. After parsing the complete input you simply call the compile at the root (that will compile itself and every branch) and that way produce the output. You can also choose to implement an execute method instead of compile and that way create an interpreter. Just look for "How to build your own compiler/interpreter" with google and you will get lots of results.

Here you have some links that might get you started:
http://msdn.microsoft.com/en-us/magazine/cc136756.aspx[^]

http://blogs.microsoft.co.il/blogs/sasha/archive/2010/10/06/writing-a-compiler-in-c-lexical-analysis.aspx[^]

Good luck!


这篇关于C#-非常简单的编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆