如何编写C ++编译器 [英] How to write a C++ compiler

查看:105
本文介绍了如何编写C ++编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在学习c ++,想写一个简单的C ++编译器。我应该怎么开始?b / b
请帮助。


Simon

Hi,

I am learning c++ and would like to write a simple C++ compiler. How should
I start?

Please help.

Simon

推荐答案

2004年3月4日星期四04:25:27 +0800,Simon Kwong < SK ** @ hotmail.com>写道:
On Thu, 4 Mar 2004 04:25:27 +0800, "Simon Kwong" <sk**@hotmail.com> wrote:


我正在学习c ++,想写一个简单的C ++编译器。我应该如何开始?

请帮忙。


首先写一个简单的<比C ++更简单的东西>编译器。我写的第一个

编译器(早在1978年)就是BASIC的一个子集,它生成了

中间代码然后解释它。当我在明年解决编写一个小型C编译器的时候,我能够蚕食一些这样的东西。


之后我发誓编写编译器我的余生;-)

-leor

Simon
Hi,

I am learning c++ and would like to write a simple C++ compiler. How should
I start?

Please help.
Start by writing a simple <something simpler than C++> compiler. The first
compiler I wrote (back in 1978) was for a subset of BASIC that generated
intermediate code and then interpreted it. I was able to cannibalize a few
pieces of that when I tackled writing a small C compiler the next year.

After that I swore off writing compilers for the rest of my life ;-)
-leor
Simon




Leor Zolman

BD软件
le**@bdsoft.com
www.bdsoft.com - 使用C / C ++,Java,Perl& Sons进行现场培训。 Unix

C ++用户:下载BD Software的免费STL错误消息

Decryptor at www.bdsoft.com/tools/stlfilt.html



Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software''s free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html


" Simon Kwong" < SK ** @ hotmail.com>在留言中写道

news:c2 ********** @ hfc.pacific.net.hk ...
"Simon Kwong" <sk**@hotmail.com> wrote in message
news:c2**********@hfc.pacific.net.hk...

<我正在学习c ++,并且想编写一个简单的C ++编译器。


没有这样的事情。

我应该如何开始?
Hi,

I am learning c++ and would like to write a simple C++ compiler.
No such thing.
How should
I start?




随着广泛的研究。查找术语''lexical''''analysis'',

''解析'',''语法'等等。


BTW为什么在你真正学会(非常好)如何使用*语言之前,你觉得你有能力写一个C ++

编译器吗?


另请注意,没有要求*使用* C ++(或任何其他

特定语言)来编写C ++编译器。 (虽然你会给b $ b几乎肯定需要学习平台的汇编语言

你打算瞄准目标。)


-Mike



With extensive research. Look up terms ''lexical'' ''analysis'',
''parsing'', ''grammar'', etc.

BTW why do you feel you''ll be capable of writing a C++
compiler before you''ve actually learned (very well) how to
*use* the language?

Also note that there''s no requirement to *use* C++ (or any other
particular language) to write a C++ compiler. (Although you''ll
almost certainly need to learn assembly language for the platform(s)
you intend to target.)

-Mike


*" Simon Kwong" < SK ** @ hotmail.com> schriebt:
* "Simon Kwong" <sk**@hotmail.com> schriebt:

我正在学习c ++,想写一个简单的C ++编译器。


C ++编译器绝对是一个非常重要的软件。


如果你正在学习C ++那么你没有机会用C ++创建一个C ++编译器




就像:我正在学习科学,想要制作月球火箭。 。

我该如何开始?

I am learning c++ and would like to write a simple C++ compiler.
A C++ compiler is definitely a non-trivial piece of software.

If you''re learning C++ then you have no chance of creating a C++ compiler
in C++.

It''s like: "I''m learning science and would like to make a moon rocket".
How should I start?




许多大学提供可以创建编译器的课程。


Dragon book,

< url:http://www.amazon.com/exec/obidos/tg/detail/-/0201100886/002-2510887-2360043 ?v =一瞥>

是开始学习编写编译器的好地方。


另一方面,对于学习C ++,它非常依赖你已经知道了什么?b $ b知道。如果你精通其他一些编程语言,那么

推荐的书就是Accelerated C ++。通过柯尼希,并且,记忆失败。 Moi?

否则请看看例如你可以做到!作者:Francis Glassborow。不是那个

我读过这本书,但弗朗西斯是一个非常称职的人,写得非常清楚

,说实话。见< url:http://www.spellen.org/youcandoit/>。



Many universities offer courses where you get to create a compiler.

The "Dragon book",
<url: http://www.amazon.com/exec/obidos/tg/detail/-/0201100886/002-2510887-2360043?v=glance>
is a good place to start for learning about writing compilers.

For learning C++, on the other hand, it very much depends on what you already
know. If you are proficient in some other programming language then the
recommended book is "Accelerated C++" by Koenig and, darn, memory failure. Moi?
Otherwise take a look at e.g. "You can do it!" by Francis Glassborow. Not that
I''ve read the book but Francis is a very competent person who writes very clearly
and honestly. See <url: http://www.spellen.org/youcandoit/>.


这篇关于如何编写C ++编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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