theBrianCui/ArnoldJS

语言: JavaScript

git: https://github.com/theBrianCui/ArnoldJS

受ArnoldC的启发,ArnoldJS为JavaScript添加了语法糖,因此您可以使用更多代码做更少的事情。
Inspired by ArnoldC, ArnoldJS adds syntactic sugar to JavaScript so you can do less with more code.
README.md (中文)

ArnoldJS

TALK TO THE HAND
    GIVE THESE PEOPLE AIR
        "Hello, World!"
    ENOUGH TALK
TERMINATED

受ArnoldC的启发,ArnoldJS为JavaScript添加了语法糖 这使得它不那么宽容,更加情绪化,甚至是痛苦的写作,让你做得更少 更多代码。

Arnold Schwarzenegger的行情充当了常见JavaScript关键字的直观替代品, 运营商等等。您可以继续在ArnoldJS和arnoldjs中使用原始JavaScript transpiler会将ArnoldJS代码转换为原始JavaScript。

安装

ArnoldJS需要Node.js和npm。

npm install -g arnoldjs

用法:

arnoldjs [input-file] [output-file]

[output-file]的内容将被[input-file]的转换内容替换。 输入文件通常使用.ajs扩展名,输出文件通常使用.js扩展名 可以提供任何文件扩展名。

作为可加载模块

ArnoldJS也可以用作代码中的模块,以编程方式调用:

npm install --save arnoldjs

用法:

var arnoldjs = require('arnoldjs');
var ajsProgram = "TERMINATED";
var jsProgram = arnoldjs.transpile(ajsProgram); //stores ";"

示例程序

使用混合的ArnoldJS语法和原始JavaScript实现FizzBu​​zz:

LET'S KICK SOME ICE
GIVE THESE PEOPLE AIR
    YOU SET US UP n STICK AROUND 1;
    n <= 100;
    n STICK AROUND n GET UP 1
ENOUGH TALK
IT'S SHOWTIME
YOU SET US UP out STICK AROUND "";
BECAUSE I'M GOING TO SAY PLEASE
    (I LIED (n I LET HIM GO 3))
    out STICK AROUND out GET UP "Fizz";
BECAUSE I'M GOING TO SAY PLEASE
    (I LIED (n I LET HIM GO 5))
    out STICK AROUND out GET UP "Buzz";
TALK TO THE HAND (out
    WHAT'S WRONG WITH YOUR EYES out
    I NOW KNOW WHY YOU CRY n);
HASTA LA VISTA BABY

该程序可以在samples / fizzbuzz.ajs中找到。它的转换版本可以在samples / fizzbuzz.js中找到。 其他示例可以在samples目录中找到。

用法

:左侧的以下短语(区分大小写)被右侧的值替换。

陈述和关键词

你设置了我们:var

休息:常数

不是:null

你的衣服送给我:新的

我在这:这个

和你在一起:删除

控制流程语句

非常仔细地听我说:功能

我会回来的:回来

因为我要说的是:如果

你没有对逻辑的尊重:否则

让我们开玩笑吧:因为

酷派:同时

ICEMAN COMETH:做

GET OUT:继续

你是什​​么:切换

KNOCK KNOCK:案例

去斩波器:休息

我将在下一次杀了你:默认

信任我:试试

这不是一个肿瘤:抓住

将COOKIE放下:最后

对象和对象属性

BULLSHIT:错误

他的生活:真的

跟手说话:console.log

你被终止了:process.exit

跟随数字:.length

把你的屁股带到MARS:.pop

这是我的邀请:.push

正在复制的主题:.bind

让我尝试矿:.call

这是ACRES的偶像:.apply

运营商

STICK AROUND:=

你不是你,你是:===

我需要你的靴子和你的摩托车的衣服:。

GET UP:+

下来 : -

你被开除了 : *

他必须分裂:/

我让他走了:%

我撒了谎 : !

你的眼睛出了什么问题:?

我现在知道你为什么哭:

常用字符

现在做 : ()

好戏开场了 : {

直到婴儿视图:}

给这些人提供空气:(

足够的谈话:)

终止:;

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

ArnoldJS

TALK TO THE HAND
    GIVE THESE PEOPLE AIR
        "Hello, World!"
    ENOUGH TALK
TERMINATED

Inspired by ArnoldC, ArnoldJS adds syntactic sugar to JavaScript
that makes it less forgiving, more emotional, and even painful to write, allowing you to do less
with more code.

Quotes by Arnold Schwarzenegger act as intuitive replacements for common JavaScript keywords,
operators, and more. You can continue to use raw JavaScript inside ArnoldJS, and the arnoldjs
transpiler will convert ArnoldJS code into raw JavaScript.

Installation

ArnoldJS requires Node.js and npm.

npm install -g arnoldjs

Usage:

arnoldjs [input-file] [output-file]

The contents of [output-file] will be replaced by the transpiled contents of [input-file].
Input files conventionally use the .ajs extension, and output files conventionally use the .js extension, though
any file extensions can be provided.

As a loadable module

ArnoldJS can also be used as a module in your code to be called programatically:

npm install --save arnoldjs

Usage:

var arnoldjs = require('arnoldjs');
var ajsProgram = "TERMINATED";
var jsProgram = arnoldjs.transpile(ajsProgram); //stores ";"

Example Program

An implementation of FizzBuzz using a mix of ArnoldJS syntax and raw JavaScript:

LET'S KICK SOME ICE
GIVE THESE PEOPLE AIR
    YOU SET US UP n STICK AROUND 1;
    n <= 100;
    n STICK AROUND n GET UP 1
ENOUGH TALK
IT'S SHOWTIME
YOU SET US UP out STICK AROUND "";
BECAUSE I'M GOING TO SAY PLEASE
    (I LIED (n I LET HIM GO 3))
    out STICK AROUND out GET UP "Fizz";
BECAUSE I'M GOING TO SAY PLEASE
    (I LIED (n I LET HIM GO 5))
    out STICK AROUND out GET UP "Buzz";
TALK TO THE HAND (out
    WHAT'S WRONG WITH YOUR EYES out
    I NOW KNOW WHY YOU CRY n);
HASTA LA VISTA BABY

This program can be found in samples/fizzbuzz.ajs. Its transpiled version can be found in samples/fizzbuzz.js.
Additional examples can be found in the samples directory.

Usage

The following phrases (case sensitive) on the left of the : are replaced by the value on the right.

Statements and Keywords

YOU SET US UP : var

CHILL OUT : const

NOT TO BE : null

YOUR CLOTHES GIVE THEM TO ME : new

I'M HERE : this

TO HELL WITH YOU : delete

Control Flow Statements

LISTEN TO ME VERY CAREFULLY : function

I'LL BE BACK : return

BECAUSE I'M GOING TO SAY PLEASE : if

YOU HAVE NO RESPECT FOR LOGIC : else

LET'S KICK SOME ICE : for

COOL PARTY : while

THE ICEMAN COMETH : do

GET OUT : continue

WHAT THE HELL ARE YOU : switch

KNOCK KNOCK : case

GET TO THE CHOPPER : break

I'LL KILL YOU NEXT TIME : default

TRUST ME : try

IT'S NOT A TUMOR : catch

PUT THE COOKIE DOWN : finally

Objects and object properties

BULLSHIT : false

HE'LL LIVE : true

TALK TO THE HAND : console.log

YOU ARE TERMINATED : process.exit

FOLLOW THE NUMBERS : .length

GET YOUR ASS TO MARS : .pop

HERE IS MY INVITATION : .push

THE SUBJECT BEING COPIED : .bind

LET ME TRY MINE : .call

HERE'S A COUPLE OF ACRES : .apply

Operators

STICK AROUND : =

YOU ARE NOT YOU YOU ARE ME : ===

I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE : .

GET UP : +

GET DOWN : -

YOU'RE FIRED : *

HE HAD TO SPLIT : /

I LET HIM GO : %

I LIED : !

WHAT'S WRONG WITH YOUR EYES : ?

I NOW KNOW WHY YOU CRY : :

Commonly used characters

DO IT NOW : ()

IT'S SHOWTIME : {

HASTA LA VISTA BABY : }

GIVE THESE PEOPLE AIR : (

ENOUGH TALK : )

TERMINATED : ;