如何编写口译员? [英] How to write an interpreter?

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

问题描述

我决定用Ruby写一个小的解释器作为我的下一个项目.成功需要什么知识/技能?
我还没有决定要翻译的语言,但是我正在寻找一种不是玩具语言的东西,但是为它编写解释器相对容易. 提前致谢.

I have decided to write a small interpreter as my next project, in Ruby. What knowledge/skills will I need to have to be successful?
I haven't decided on the language to interpret yet, but I am looking for something that is not a toy language, but would be relatively easy to write an interpreter for. Thanks in advance.

推荐答案

您将至少需要学习:

  • 词法分析(将字符分组为标记)
  • 解析(将令牌分组为结构)
  • 抽象语法树(在数据结构中表示程序结构)
  • 数据表示形式(假设您的语言将具有变量)
  • 一个运行"程序的评估循环

在介绍性文本计算机程序的结构和解释中,可以找到对这些主题的出色介绍.该书中使用的语言是Scheme,这是一种功能强大且指定明确的语言,非常适合您的第一个解释器实现.强烈推荐.

An excellent introduction to some of these topics can be found in the introductory text Structure and Interpretation of Computer Programs. The language used in that book is Scheme, which is a robust, well-specified language that is ideally suited for your first interpreter implementation. Highly recommended.

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

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