如何创建编程语言 [英] How to create a programming language

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

问题描述



我可以创建一种新的编程语言吗?

我知道我需要一个环境但我不知道哪一个?

Linux是一个用于为编程语言创建环境的操作系统吗?或者我可以用Windows 8做到这一点??



声明:我不想创建一个程序,而是一种编程语言,如:Python,Ruby,Java等..



谢谢!!

Hi,
Can I create a New programming language ?
I know I need an environmental but I don't know which one?
Is Linux an OS for Creating an environmental for programming language? Or I can do it with windows 8??

Claim: I don't want to create a program, but a programming language like: Python, Ruby, Java etc..

Thank You !!

推荐答案

我必须引起你​​注意以下事项:

- 您可以在纸上制作语言:语言首先是语法规范,而不是语义规范

- 有多种语言 [ ^ ]那里,但真的很少使用。你为什么要换一个新的?

- 还有几种非常奇怪的语言,请查看以下列表: http://net.tutsplus.com/articles/top-10-most-bizarre-programming-languages/ [ ^ ],我最喜欢的是空间。

- 定义语言语法,即使它的语义并不意味着你有一个工作语言,它只是一个规范,一个文件

- 要让它工作,你需要做一个< a href =http://www.parsifalsoft.com/examples/xidek/xidek/doc/fourways.htm>解释器 [ ^ ]或编译器 [ ^ ]基地d根据您的规格。后者更复杂。

- 当你拥有所有这些时,你仍然没有任何东西,因为要使它可用,你需要制作一桶库(或者那个喜欢拥有IO,GUI,netowrking,正则表达式等......

- Ant现在你必须推广,并收集信徒,支持者和用户。

我不想劝阻你,让我们假设你发明了有史以来最好的语言。不过,在进一步研究之前还有很多工作需要考虑。
I have to draw you attention on following things:
- You can make a language on paper: a language is first a syntactical specification, than a semantic one
- There are many languages[^] out there, but few are really used. Why do you want to make a new one?
- There are several really bizarre languages also, check this list: http://net.tutsplus.com/articles/top-10-most-bizarre-programming-languages/[^], my favorite is space.
- Defining a language syntax, even it's semantics does not mean that you have a working language, it is only a specification, a document
- To have it working, you need to make an interpreter[^] or a compiler[^] based on your specification. The later one is of yourse more complicated.
- And when you have all this, you still don't have anything, since to make it usable, you need to make a bucket of libraries (or that like) to have IO, GUI, netowrking, regular expressions, and so on...
- Ant now you will have to promote, and gather believers, supporters and users.
I don't want to discourage you, let's suppose you invented the best language ever. Still, there is lot of work you have to consider before going further.


现在似乎每天都会发明一种新语言。你可以付出一点努力来做到这一点。新语言的原因多种多样;最好的理由通常是运用一些新的范例或在限制域中定义某些东西(例如,在织机上移动彩色线程,与电子表格中的单元格交互,在数组上进行计算......)。



有几个程序可以帮助您解析和编译。我建议查看 lex [ ^ ]和 yacc [ ^ ]以获取示例。如果你研究这些链接,我想你会在这个问题上取得很好的进展。
Nowadays it seems that a new language is invented every day. You can do this with a little effort. Reasons for new languages are many and varied; the best reasons are usually to exercise some new paradigm or to define something in a restricted domain (eg. shifting colored threads on a loom, interacting with cells in a spreadsheet, doing calculations on arrays...).

There are several programs that will help you with parsing and compiling. I would suggest looking at lex[^] and yacc[^] for starting examples. If you research these links, I think you will make good progress on the problem.


构建一个编程语言很容易,但编写它很困难。您可以使用父语言轻松解释它。但是如果你想编译它,你将不得不首先创建一个内核,它将与硬件进行交互。第二,你将创建一个Lexer,你有没有看到代码有一些空格,注释和许多只对程序员而不是机器有用的东西。 Lexer会在将所有空格,注释和其他内容发送到编译器之前将其删除。最后和最重要的部分是制作编译器,编译器的工作是合并内核和Lexed代码,并将其编译为像EXE,DLL等程序集。

所以你是会有很多工作。

您可能在想什么是内核,

内核是操作系统的基础,它是操作系统的核心,

您可以使用COSMOS在c#中创建内核。

-Sids123
Building a Programming language is easy but making a compiler for it is difficult. You can easily interpret it using the parent language. But if you want to Compile it you will have to first make a Kernel, which will interact with the hardware. Second you will make a Lexer, Have you ever seen that the code has some whitespaces,comments and a lot of things that is only useful for the programmer and not the machine. The Lexer will remove all whitespaces,comments and other content before it's sent to the compiler. The last and the most important part is making the compiler, The job of the compiler is to merge the kernel and the Lexed code, and compile it to an assembly like EXE,DLL etc.
So you are going to have a lot of work.
You might be thinking what's a Kernel,
Well a kernel is the base of an OS, it's the CORE of the OS,
You can make a kernel in c# using COSMOS.
-Sids123


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

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