如果我想了解编译器和编程语言是如何构建的,该从哪里开始

发布于 2024-11-15 17:38:39 字数 353 浏览 1 评论 0原文

可能的重复:
学习编写编译器

我知道这是一个广泛的问题,但哪里可以我开始学习编译器实际上是如何工作的,编程语言是如何创建的,我的意思不是你如何使用 Java 或 Ruby,而是人们实际上是如何创建它们的。我不会尝试以任何方式复制这些语言,但我想了解其背后的概念和理论。所以我需要的是关于我应该搜索什么的一些指导,或者更好、更合适的是书籍推荐。

问候,

乔纳森·纳什。

Possible Duplicate:
Learning to write a compiler

I know this is a broad question to ask, but where could I start learning how compilers actually work, how programming languages are made, I mean not how you use Java or Ruby but how people actually are making them. I will not try to replicate these languages in any ways but I want to understand the concepts and theory behind it. So what I need is either some directions on what I should search for, or even better and more appriciated are book recommendations.

Regards,

Jonathan Nash.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

音盲 2024-11-22 17:38:39

您可能会发现 Jack Crenshaw 的让我们构建一个编译器是一个有趣的介绍。

保持非常简单,专注于构建实际功能。

You might find Lets Build a Compiler by by Jack Crenshaw an interesting introduction.

Kept very simple and focussed on building actual functionality.

九厘米的零° 2024-11-22 17:38:39
  • Niklaus Wirth 的编译器构建非常好,可以从我提供的链接(是的,合法)。它有点旧,使用 Oberon 作为示例,但很容易理解。

  • Marc-André Cournoyer 的

    创建您自己的编程语言可在线购买,售价 40 美元,包含一本电子书(包括练习和解决方案)、两种示例语言的源代码(一种是 Ruby,一种是 Java)以及关于扩展基于 JVM 的语言的截屏视频。这可能是您能找到的关于该主题的最适合新手的介绍,之后您应该对所涉及的步骤(标记化、解析、词法分析等)有一个很好的了解,并且可以使用提供的链接继续您的研究。虽然有点贵,但恕我直言,这是值得的。

  • 虽然主要不是学习资源,CoffeeScript 网站有一个名为“注释”的部分Source”,这对于了解编程语言的工作原理非常有帮助。 CoffeeScript 的作者在阅读了我在上一个要点中提到的书后开始研究它。

  • Compiler Constrution by Niklaus Wirth is pretty good and available for free from the link I provided (yes, legally). It's a bit old and uses Oberon for the examples but is easy to follow.

  • Create Your Own Programming Language by Marc-André Cournoyer is available online for USD 40 and consists of an eBook (including exercises and solutions), source code for two example languages (one in Ruby and one in Java) and a screencast on extending the JVM based language. This is probably the most newbie-friendly introduction you can find on the topic and afterwards you should have a pretty good idea about the steps involved (tokenizing, parsing, lexing etc.) and can continue your research with the provided links. It's a bit expensive, but IMHO it's worth it.

  • While not primarily a learning resource, the CoffeeScript web site has a section called "Annotated Source", which is really helpful in seeing how a programming language works. CoffeeScript's author started working on it after he read the book I mentioned in the previous bullet point btw.

杀手六號 2024-11-22 17:38:39

你可以看看龙之书

You could take a look at the Dragon Book:

想挽留 2024-11-22 17:38:39

我非常喜欢语言实现模式并学到了很多东西。我希望几年前在尝试实现 DSL 之前就读过它。

I've greatly enjoyed Language Implementation Patterns and learned a bunch. I wish I had read it before trying to implement a DSL some years ago.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文