My favorites | Sign in
Logo
                
Search
for
Updated May 04, 2009 by bearice
Labels: Featured, Phase-Design
A_Brife_To_GrassMudHorse_Language  
本文简要描述了马勒戈壁官方编程语言:《草泥马语(暂定名)》的语言规范,语法和技术规格

简介:什么是《草泥马语(暂定名)》

草泥马语是马勒戈壁第一款拥有自主知识产权的,以马勒戈壁上顽强生存的草泥马们为主体的编程语言:草泥马语(暂定名)与本日7时正式发行了。草泥马语语法生动丰富,内容健康活泼,是一门老少皆宜,人人适用的编程语言。它的出现弥补了我戈壁在国际编程语言届中的一项空白。

草泥马语是用了先进的JOT(Just Out of Time)编译引擎,并且运行于Java虚拟机中,运行速度大幅度降低同时,还使用了戈壁内外各种先进技术,使的草泥马语十分可靠。

《草泥马语(暂定名)》的语言规范

草泥马语是一款根据国外同类型语言“Whitespace”改编(替换关键字)而成的全新的编程语言,执行时使用“草泥马”的不同组合实现不同功能。
PS:在本文还没有完工之前(但是看起来已经完工了),可以先看Whitespace语言入门,然后吧其中的[Space]替换成[Tab]替换成[LF]替换成就可以了解草泥马语的大致用法了。
每个指令都有3部分组成,包括指令头,指令和可选的操作数

指令头

草泥马语的指令头说明了指令的类型,列表如下:

指令头说明鸟语说明
[草]栈操作Stack Manipulation
[泥][草]数学运算Arithmetic
[泥][泥]堆操作Heap access
[马]流程控制Flow Control
[泥][马]输入输出I/O

感谢`hyperbolica`同学指出错误

栈操作指令 [指令头:草]

栈用来存储指令调用的参数和结果,元素仅限整数,栈高度不限。

指令操作数说明鸟语说明
[草]Number 吧某个数压栈Push the number onto the stack
[马][草]-复制栈顶元素Duplicate the top item on the stack
[泥][草]Number复制第n个元素到栈顶Copy the nth item on the stack (given by the argument) onto the top of the stack
[马][泥]-交换栈顶两个元素的位置Swap the top two items on the stack
[马][马]-销毁栈顶元素Discard the top item on the stack
[泥][马]Number销毁栈顶的n个元素,但保持栈顶Slide n items off the stack, keeping the top item

数学运算指令[指令头:泥草]

注意,草泥马语没有浮点运算,但是整数运算的精度是无限的。

指令操作数说明鸟语说明
[草][草]-Addition
[草][泥]-Subtraction
[草][马]-Multiplication
[泥][草]-Integer Division
[泥][泥]-取模Modulo

堆操作[指令头:泥泥]

与栈一样,堆也只能存储整数,草泥马虚拟机(AlpacaVM)最多支持65536个堆元素(0-65535),但是堆元素的大小不限制。

指令操作数说明鸟语说明
[草]-存储栈顶元素x到堆空间y中,y是次栈顶元素Store
[泥]-获取堆空间y中的元素,y是次栈顶元素Retrieve

流程控制[指令头:马]

标记一个程序点可以用来进行跳转或者函数调用,标记是一个任意长度的无符号整数,每个草泥马文件中,标记应该是唯一的,并且所有调用的标记应当存在。

注意:河蟹这个指令仅仅在河蟹这两个字连在一起时有效,分开是没有效果的。(注意更正一个歧义表达,河蟹这个指令是没有指令头的。
指令操作数说明鸟语说明
[草][草]Label定义一个标记Mark a location in the program
[草][泥]Label调用函数Call a subroutine
[草][马]Label无条件跳转Jump unconditionally to a label
[泥][草]Label如果栈顶元素等于0则跳转Jump to a label if the top of the stack is zero
[泥][泥]Label如果栈顶元素小于0则跳转Jump to a label if the top of the stack is negative
[泥][马]-函数结束,返回调用方End a subroutine and transfer control back to the caller
[马][马]或者[河蟹]-无条件结束程序运行End the program

IO控制[指令头:泥马]

指令操作数说明鸟语说明
[草][草]-输出一个字符到标准输出Output the character at the top of the stack
[草][泥]-输出一个数字到标准输出Output the number at the top of the stack
[泥][草]-从标准输入内读取一个数字(回车结束)并且放到栈顶所对应的堆空间Read a character and place it in the location given by the top of the stack
[泥][泥]-从标准输入内读取一个字符并且放到栈顶所对应的堆空间Read a number and place it in the location given by the top of the stack

如何定义操作数

操作数的定义是二进制的整数,对于流程控制指令来说是无符号的,否则是有符号的,第一位为符号位。 定义方法是:草为0;泥为1;马代表定义结束。对于符号位,草为正,泥为负。

举个例子吧

看首页,有一个例子了。

Comment by zoidsEX, Mar 28, 2009

1

Comment by Fz258...@gmail.com, Mar 28, 2009

露过留名围观

Comment by mk124@163.com, Mar 28, 2009

路过 跟楼上一起留名围观|

Comment by noregret, Mar 28, 2009

一起围观一下

Comment by jiawei.ou, Mar 28, 2009

继续围观

Comment by tabris17.cn, Mar 28, 2009

不明真相的围观

Comment by LuooChaoo, Mar 28, 2009

围观!

Comment by zellux, Mar 29, 2009

留名

Comment by verydxz, Mar 29, 2009
Comment by u20024804, Mar 29, 2009

留名

Comment by lanhaiping, Mar 29, 2009

admire

Comment by xu.mathena, Mar 29, 2009

CHTML ( http://code.google.com/p/chtml/ ) 今天正式和草你马语达成谅解备忘路, 草你妈语 (http://code.google.com/p/grass-mud-horse/wiki/A_Brife_To_GrassMudHorse_Language) 取代汉编, 成为CHTML推荐的脚本语言. CHTML也成为业界第一个支持浏览器中草尼马语的语言

Comment by peterguo1983, Mar 29, 2009

太牛了,留下脚印

Comment by wileishn, Mar 29, 2009

凡成年的路过者都有资格获取一匹狂艹氵马, 先来先得后来面mlg壁。

Comment by ericjames17, Mar 29, 2009

20年后谭浩强开始写《草|泥|马程序设计》

Comment by borderj, Mar 29, 2009

来此观光。。。

Comment by keakon, Mar 29, 2009

围观中

Comment by zhangchunlin, Mar 29, 2009

慕名前来围观...

Comment by zhangdehai, Mar 29, 2009

慕名前来围观...

Comment by moses.ma...@gmail.com, Mar 29, 2009

.................

Comment by liuyuan...@gmail.com, Mar 29, 2009

希望你要搞这个就自己买空间、域名,不要害得整个China不能访问google code

Comment by mailliuwenyong, Mar 29, 2009

实在是...

Comment by hftx1986, Mar 29, 2009

观光团路过···

Comment by bearice, Mar 29, 2009

@liuyuanzhi

  • 当初没有想到这一点,如果给您或者其他人带来不便,请谅解。
  • Google 上的河蟹项目好像不只这个,比如Gladder之类的。而且就算没有河蟹项目,根据GFW3定律,被GOV盯上的网站迟早要被HX。

Comment by yzhrain, Mar 29, 2009

慕名过来围观...

Comment by e.guokb, Mar 30, 2009

大師啊,最偉大的語言!!

Comment by Garfilone, Mar 30, 2009

观光。。。

Comment by chen3feng, Mar 30, 2009

的Space?替换成草;Tab?替换成草; Tab? 是泥吧?

Comment by bearice, Mar 30, 2009

感谢楼上chen3feng同学指出错误,已经改正。

Comment by lipeng.net, Mar 30, 2009

@liuyuanzhi: 貌似在谁害的中国不能访问google code这个问题上,你搞反了。。

Comment by iveney, Mar 30, 2009

路過,大家要好好學習草泥馬語,為國爭光

Comment by skatou, Mar 31, 2009

有人做i18n吗?

Comment by fwtzzl, Mar 31, 2009

潜力,围观,留名

Comment by shishanshi, Mar 31, 2009

围观之

Comment by snquentin, Mar 31, 2009

咋这么多人围观!我也围一个!

Comment by qquchn, Apr 03, 2009

囧,围观之

Comment by overboming, Apr 04, 2009

千万别把google code河蟹了

Comment by lkunable, Apr 06, 2009

mark~

Comment by hubdog, Apr 10, 2009

围观的群众情绪很稳定

Comment by auspanda, Apr 26, 2009

passing by. keep up your good work.

Comment by rookiej...@163.com, May 01, 2009

观光团

Comment by hyperbol...@163.com, May 02, 2009

指令头 说明 鸟语说明 [草] 栈操作 Stack Manipulation [泥][草] 数学运算 Arithmetic [泥][泥] 堆操作 Heap access [马] 流程控制 Flow Control [草][马] 输入输出 I/O

是[泥][马]........

Comment by hyperbol...@163.com, May 02, 2009

输入输出 I/O 是[泥][马]........

Comment by fly2never, May 07, 2009

围观....

Comment by zhong.simon, May 13, 2009

豆瓣观光团面前,一切都是尘埃!

Comment by joyjoke2001, May 24, 2009

豆瓣观光团到此围观并帮顶。

专业课程,NB!

Comment by kenpus...@gmail.com, May 27, 2009

很好.... 草泥马... CHTML...

Comment by smart.wolfer, Jun 12, 2009

围观,却不知——为什么呢? 溜掉~~~

Comment by lizhang0602, Jul 12, 2009

路过。。。

Comment by wx2020, Jul 13, 2009

慕名前来围观..

Comment by cove.wen, Jul 14, 2009

围观中..

Comment by xieyanwei51, Jul 16, 2009

慕名而来。<

Comment by TheGreenChina, Jul 23, 2009

<汗>瀑布汗~~~</汗>

Comment by KyllYang, Jul 28, 2009

期待未来的发展

Comment by flc945, Sep 20, 2009

路过好奇者围观

Comment by dannyxcz, Sep 21, 2009

强力围观!

Comment by tangxiucai2, Sep 22, 2009

强了插入。

Comment by lur...@163.com, Oct 21, 2009

<b>粗</b>

Comment by mckeyu2009, Oct 23, 2009

Comment by gtrgtl, Nov 02, 2009

无语了

Comment by jcj1988, Nov 02, 2009

从matrix67博客上一路杀过来……最终我决定,参与此项目……

Comment by lavaxin, Nov 19 (3 days ago)

nb死了

Comment by pj.hades, Nov 19 (3 days ago)

.................... brainfuck

Comment by pj.hades, Nov 19 (3 days ago)

围观一下……


Sign in to add a comment
Hosted by Google Code