没前途 >> 程序员,四年结束了,可是还有另外的两年半,对我来说,我要如何面对呢?

声明:

鄙人不欢迎跟淘宝客有关的任何带链接式回复,不管回复什么内容,见链接即删!我不需要你的理解!

强悍的草泥马编程语言 (593)

0 Comments | This entry was posted on Nov 01,2009

此文章引自googlecode: http://code.google.com/p/grass-mud-horse/

世界之大 真是无奇不有!你相信这种语言能存活多久呢?》

序言

前略,天国的河蟹们,草泥马现在是超越阿姆骡的存在

发展中的草泥马语

Brief

This is a programing language based on stack & heap. The only tokens used are '草','泥','马' and "河蟹", other chars are ignored as comments.

简介

《草泥马语》是一个基于堆和栈的编程语言,该语言的最大特点在于:所有操作全部由“草”“泥”“马”“河蟹”这4个命令完成,文件内的其他字符都作为注释而不参与程序执行。
有人抱怨说不会用,这不是就凑合了一个简易草泥马语学习指南(好像差不多完了)

 

另外,由于草泥马语言形式过于震撼,所以为了调试,编写了草泥马语逆编译器:gmhd(但是没有正向编译,囧,谁贡献一个?)可以吧草泥马语言代码反编译成比较好懂的伪代码。
第二个工具是whitespace程序转换器:ws2gmh,简单的replace而已。

Example

The code of grass-mud-horse language looks like following, this program loops from 1 to 10:

示例

写出来大概就是这个样子,下面是一个从1到10的循环: 感谢(卡库尔 / Kakur)同学提供
草-草 草泥马 数字1压栈 Put a 1 on the stack
马-草草 草泥草草草草泥泥马 在这里设置一个循环开始的标识 Set a Label at this point
草-马草 复制栈顶元素 Duplicate the top stack item
泥马-草泥 输出当前值 Output the current value
草草 草泥草泥草马 换行(10)压栈 Put 10 (newline) on the stack...
泥马-草草 输出 ...and output the newline
草草 草泥马 1压栈 Put a 1 on the stack
泥草-草草 相加栈内两个元素 Addition. This increments our current value.
草-马草 复制栈顶以便比较 Duplicate that value so we can test it
草-草 草泥草泥泥马 11压栈 Push 11 onto the stack
泥草-草泥 相减,如果我们已经循环到11了应该会得到一个0到栈顶 Subtraction. So if we've reached the end, we have a zero on the stack.
马-泥草 草泥草草草泥草泥马 如果是0,跳到最后 If we have a zero, jump to the end
马-草马 草泥草草草草泥泥马 跳到开始 Jump to the start
马-草草 草泥草草草泥草泥马 设置一个标签标识循环结束 Set the end label
草-马马 清空堆栈,打扫卫生,整理整顿 Discard our accumulator, to be tidy
河蟹 正如其言 Just as it says.
Pages: 1/1 First page 1 Final page [ View by Articles | List ]