是否有一个更现代的OO版本的“Let's Build a Compiler”? [英] Is there a more modern, OO version of "Let's Build a Compiler"?

查看:143
本文介绍了是否有一个更现代的OO版本的“Let's Build a Compiler”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有更现代的,也许面向对象,相当于Jack Crenshaw的让我们构建一个编译器< a>系列?

Is there a more modern, maybe object-oriented, equivalent to Jack Crenshaw's "Let's Build a Compiler" series?

A在回来时,我偶然发现了让我们构建一个编译器,可能只是不能拒绝编写一些代码。我在C#中编写了一个递归 - 下降C编译器,用于输出.NET CIL。 写一次,泄漏到处都是我的口号。

A while back I stumbled across "Let's Build a Compiler" and could just not resist writing some code. I wrote a recursive-descent C compiler in C# that output .NET CIL. "Write once, leak everywhere" was my slogan.

太糟糕了,我没有意识到,太晚了解析C是一场噩梦。

Too bad I did not realize until too late that parsing C is a nightmare.

我现在有兴趣在Java中编写一个Java编译器,输出.NET CIL或程序集,目的是自引导。我希望可能有一些新的教程踢。

I am now interested in writing a Java compiler in Java that outputs .NET CIL or assemblies with the goal of being self-bootstrapping. I was hoping there might some newer tutorials kicking around.

另外,你会花更多的时间与前期设计,或者你只是写了一吨测试支持无情重构的能力。回想起来,我倾向于后者。编译器工作,但代码真的很糟糕。

As an aside, would you spend more time with up-front design or would you just write a ton of tests to support the ability to mercilessly refactor. Thinking back, I am leaning towards the latter. The compiler worked but the code was really awful.

推荐答案

听起来你完全错过了Crenshaw的教程。 LBC不是写漂亮,干净或高效的代码。这是所有关于把一些沉浸在形式理论中的东西降到一个水平,在那里,休闲编码器可以轻松快速地编译一个初步的(但工作!)编译器。

It sounds like you completely missed the point of Crenshaw's tutorials. LBC isn't about writing pretty, clean, or efficient code. It's all about bringing something that's steeped in formal theory down to a level where the casual coder can easily and rapidly hack out a rudimentary (but working!) compiler.

阅读通过LBC年前,我重写了在C#的例子。我确信类布局不是最好的,或任务正确分离,但它可以与他的帕斯卡。如果您愿意,我很乐意与您分享代码 - 让我知道,我可以在线发布,并分享链接。

When I read through LBC years back, I rewrote the examples in C#. I'm sure the class layout isn't the best, or tasks segregated properly, but it's comparable to his Pascal. I'd be happy to share the code with you if you like-- let me know and I can post it online and share the link.

在我的业余时间我为了将LBC的理念和编译器设计的基础结合在一起,我们已经扼杀了一些写作 - 在每个单元/章节结尾处使用实用的工作代码,并且在探索这些想法之后讨论一些理论内容所以读者理解为什么事情是这样的。但是Crenshaw多年来写的不完整的系列,所以我的管道梦...我使用C(正是因为它不是C ++或Java)。

In my spare time I've been hacking out some writing with the aim of unifying the philosophies of LBC and Basics of Compiler Design together-- walkling away with practical, working code at the end of each unit/chapter, with also discuss some theoretical stuff after exploring the ideas so the reader understands why things are the way they are. But it took Crenshaw years to write his incomplete series, so mine my be a pipe dream... and I use C (exactly because it's not C++ or Java).

这篇关于是否有一个更现代的OO版本的“Let's Build a Compiler”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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