创造自己的语言 [英] Creating your own language

查看:78
本文介绍了创造自己的语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想创建自己的语言,有没有什么工具可以帮助我呢?我听说过yacc,但是我想知道如何用该语言实现我想要的功能.

If I were looking to create my own language are there any tools that would help me along? I have heard of yacc but I'm wondering how I would implement features that I want in the language.

推荐答案

我推荐的第一个工具是Dragon Book.这是构建编译器的参考.设计语言绝非易事,而实施它则更加困难.龙书在那儿有帮助.该书甚至引用了标准的UNIX工具lex和yacc.相当于gnu的工具称为flex和bison.它们都生成词法分析器和解析器.还存在用于生成词法分析器和解析器的更现代的工具,例如对于Java,有ANTLR(我也记得javacc和CUP,但我只使用了ANTLR). ANTLR结合了解析器和词法分析器以及eclipse插件的事实使它使用起来非常舒适.但是要比较它们,所需的解析器类型并了解所需的解析器,您应该阅读Dragon书籍.您还需要考虑其他事项,例如运行时环境,编程范例....

The first tool I would recommend is the Dragon Book. That is the reference for building compilers. Designing a language is no easy task, implementing it is even more difficult. The dragon book helps there. The book even reference to the standard unix tools lex and yacc. The gnu equivalent tools are called flex and bison. They both generate lexer and parser. There exist also more modern tools for generating lexer and parser, e.g. for java there are ANTLR (I also remember javacc and CUP, but I used myself only ANTLR). The fact that ANTLR combines parser and lexer and that eclipse plugin is availabe make it very comfortable to use. But to compare them, the type of parser you need, and know for what you need them, you should read the Dragon book. There are also other things you have to consider, like runtime environment, programming paradigm, ....

如果您已经有了某些设计思想,并且需要某个步骤或细节的帮助,则答案可能会更有用.

If you have already certain design ideas and need help for a certain step or detail the anwsers could be more helpful.

这篇关于创造自己的语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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