ArnoldC 是一种命令式编程语言,其基本的关键字均出自阿诺·斯瓦辛格的电影。该语言编写的程序可用 Parboiled 和 ASM 解析成 Java 字节码。
为宣城等地区用户提供了全套网页设计制作服务,及宣城网站建设行业解决方案。主营业务为做网站、成都网站制作、宣城网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
下面一起来看看如何使用这种(蛋疼)趣味语言。
Main 方法
每个 ArnoldC 程序必须有一个main 方法。如下:
- IT'S SHOWTIME
- [语句]
- YOU HAVE BEEN TERMINATED
最简单的 ArnoldC 程序如下:
- IT'S SHOWTIME
- YOU HAVE BEEN TERMINATED
语句
输出
TALK TO THE HAND 语句用于打印输出字符串或变量。打印字符串:
- TALK TO THE HAND "jobbole"
打印变量:
- TALK TO THE HAND myvar
ArnoldC 语言中唯一的变量类型是 16 位的有符号整数。必须在声明时赋值。
- HEY CHRISTMAS TREE variablename
- YOU SET US UP initialvalue
@I LIED 和 @NO PROBLEMO 这两个“宏” 对应的值是 0 和 1
声明两个变量,值分别是 0 和 1
- HEY CHRISTMAS TREE varFalse
- YOU SET US UP @I LIED
- HEY CHRISTMAS TREE varTrue
- YOU SET US UP @NO PROBLEMO
变量赋值语句用如下格式:
- GET TO THE CHOPPER myvar
- HERE IS MY INVITATION firstOperand
- [operations]
- ENOUGH TALK
HERE IS MY INVITATION 用来对栈顶的变量做赋值。经过其他操作,最终赋值给变量 myvar。
算术操作
加法
- GET UP operand
减法
- GET DOWN operand
乘法
- YOU'RE FIRED operand
除法
- HE HAD TO SPLIT operand
所有算术操作优先级同一样。比如: a = (4 + b) * 2
- GET TO THE CHOPPER a
- HERE IS MY INVITATION 4
- GET UP b
- YOU'RE FIRED 2
- ENOUGH TALK
#p#
逻辑操作
真语句的值为 1,假语句的值为 0。
等于
- YOU ARE NOT YOU YOU ARE ME operand
大于
- LET OFF SOME STEAM BENNET operand
或
- CONSIDER THAT A DIVORCE operand
与
- KNOCK KNOCK operand
比如: a = (b + 5) > c
- GET TO THE CHOPPER a
- HERE IS MY INVITATION b
- GET UP 5
- LET OFF SOME STEAM BENNET c
- ENOUGH TALK
比如 a = (b || c) && d
- GET TO THE CHOPPER a
- HERE IS MY INVITATION b
- CONSIDER THAT A DIVORCE c
- KNOCK KNOCK d
- ENOUGH TALK
条件语句
如果 value 非0,执行条件分支
If
- if (value) [statements]
- BECAUSE I'M GOING TO SAY PLEASE value
- [statements]
- YOU HAVE NO RESPECT FOR LOGIC
If Else
- if (value) [statements] else [statements]
- BECAUSE I'M GOING TO SAY PLEASE value
- [statements]
- BULLSHIT
- [statements]
- YOU HAVE NO RESPECT FOR LOGIC
例1
- if(a) print "a is true"
- else print "a is not true"
- BECAUSE I'M GOING TO SAY PLEASE a
- TALK TO THE HAND "a is true"
- BULLSHIT
- TALK TO THE HAND "a is not true"
- YOU HAVE NO RESPECT FOR LOGIC
例2 条件语句的值必须先计算 if(a > b) print “a is greater than b”
- GET TO THE CHOPPER result
- HERE IS MY INVITATION a
- LET OFF SOME STEAM BENNET b
- ENOUGH TALK
- BECAUSE I'M GOING TO SAY PLEASE result
- TALK TO THE HAND "a is greater b"
- YOU HAVE NO RESPECT FOR LOGIC
While
- STICK AROUND value
- [statements]
- CHILL
例子 打印 1 到 10
- IT'S SHOWTIME
- HEY CHRISTMAS TREE isLessThan10
- YOU SET US UP @NO PROBLEMO
- HEY CHRISTMAS TREE n
- YOU SET US UP 0
- STICK AROUND isLessThan10
- GET TO THE CHOPPER n
- HERE IS MY INVITATION n
- GET UP 1
- ENOUGH TALK
- TALK TO THE HAND n
- GET TO THE CHOPPER isLessThan10
- HERE IS MY INVITATION 10
- LET OFF SOME STEAM BENNET n
- ENOUGH TALK
- CHILL
- YOU HAVE BEEN TERMINATED
方法
方法必须在主函数外定义。方法参数用 I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE 定义。每个变量必须单独定义。GET YOUR ASS TO MARS 放在方法申明末尾,表明该方法是非空方法。I’LL BE BACK 就是 RETURN,根据方法是否为空,可以带一个变量。
空方法
- LISTEN TO ME VERY CAREFULLY methodName
- [Statements]
- HASTA LA VISTA, BABY
#p#
一个带两个参数的非空方法
- LISTEN TO ME VERY CAREFULLY methodName
- I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE arg1
- I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE arg2
- GET YOUR ASS TO MARS
- [Statements]
- HASTA LA VISTA, BABY
典型示例
更多例子可以在测试包中查看
Printing squares from 1 to 10
- IT'S SHOWTIME
- HEY CHRISTMAS TREE limit
- YOU SET US UP 10
- HEY CHRISTMAS TREE index
- YOU SET US UP 1
- HEY CHRISTMAS TREE squared
- YOU SET US UP 1
- HEY CHRISTMAS TREE loop
- YOU SET US UP @NO PROBLEMO
- STICK AROUND loop
- GET TO THE CHOPPER squared
- HERE IS MY INVITATION index
- YOU'RE FIRED index
- ENOUGH TALK
- TALK TO THE HAND squared
- GET TO THE CHOPPER loop
- HERE IS MY INVITATION limit
- LET OFF SOME STEAM BENNET index
- ENOUGH TALK
- GET TO THE CHOPPER index
- HERE IS MY INVITATION index
- GET UP 1
- ENOUGH TALK
- CHILL
- YOU HAVE BEEN TERMINATED
申明一个 modulo 函数,并在主函数调用它
- IT'S SHOWTIME
- HEY CHRISTMAS TREE result1
- YOU SET US UP 0
- HEY CHRISTMAS TREE result2
- YOU SET US UP 0
- HEY CHRISTMAS TREE result3
- YOU SET US UP 0
- HEY CHRISTMAS TREE result4
- YOU SET US UP 0
- GET YOUR ASS TO MARS result1
- DO IT NOW modulo 9 4
- TALK TO THE HAND result1
- GET YOUR ASS TO MARS result2
- DO IT NOW modulo 4795 87
- TALK TO THE HAND result2
- GET YOUR ASS TO MARS result3
- DO IT NOW modulo 3978 221
- TALK TO THE HAND result3
- GET YOUR ASS TO MARS result4
- DO IT NOW modulo 5559 345
- TALK TO THE HAND result4
- YOU HAVE BEEN TERMINATED
- LISTEN TO ME VERY CAREFULLY modulo
- I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE dividend
- I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE divisor
- GIVE THESE PEOPLE AIR
- HEY CHRISTMAS TREE quotient
- YOU SET US UP 0
- HEY CHRISTMAS TREE remainder
- YOU SET US UP 0
- HEY CHRISTMAS TREE product
- YOU SET US UP 0
- GET TO THE CHOPPER quotient
- HERE IS MY INVITATION dividend
- HE HAD TO SPLIT divisor
- ENOUGH TALK
- GET TO THE CHOPPER product
- HERE IS MY INVITATION divisor
- YOU'RE FIRED quotient
- ENOUGH TALK
- GET TO THE CHOPPER remainder
- HERE IS MY INVITATION dividend
- GET DOWN product
- ENOUGH TALK
- I'LL BE BACK remainder
- HASTA LA VISTA, BABY
网页标题:ArnoldC:关键字出自斯瓦辛格电影的趣味编程语言
文章网址:http://www.shufengxianlan.com/qtweb/news26/510576.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联